webentwicklung-frage-antwort-db.com.de

Woocommerce Customs Endpoint

ich erstelle ein Snippet für den hinzugefügten benutzerdefinierten Endpunkt und diesen meinen Code:

/**
 * Register new endpoint to use inside My Account page.
 *
 * @see https://developer.wordpress.org/reference/functions/add_rewrite_endpoint/
 */
function my_subscriptions_endpoints() {
    add_rewrite_endpoint( 'my-subscriptions', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_subscriptions_endpoints' );

/**
 * Add new query var.
 *
 * @param array $vars
 * @return array
 */
function my_subscriptions_query_vars( $vars ) {
    $vars[] = 'my-subscriptions';

    return $vars;
}
add_filter( 'query_vars', 'my_subscriptions_query_vars', 0 );


/**
 * Flush rewrite rules on theme activation.
 */
function my_subscriptions_flush_rewrite_rules() {
    add_rewrite_endpoint( 'my-subscriptions', EP_ROOT | EP_PAGES );
    flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_subscriptions_flush_rewrite_rules' );

/**
 * Custom help to add new items into an array after a selected item.
 *
 * @param array $items
 * @param array $new_items
 * @param string $after
 * @return array
 */
function my_subscriptions_insert_after_helper( $items, $new_items, $after ) {
    // Search for the item position and +1 since is after the selected item key.
    $position = array_search( $after, array_keys( $items ) ) + 1;

    // Insert the new item.
    $array = array_slice( $items, 0, $position, true );
    $array += $new_items;
    $array += array_slice( $items, $position, count( $items ) - $position, true );

    return $array;
}

/**
 * Insert the new endpoint into the My Account menu.
 *
 * @param array $items
 * @return array
 */
function my_subscriptions_my_account_menu_items( $items ) {
    $new_items = array();
    $new_items['my-subscriptions'] = __( 'My Subscriptions', 'woocommerce' );

    // Add the new item after `orders`.
    return my_subscriptions_insert_after_helper( $items, $new_items, 'orders' );
}
add_filter( 'woocommerce_account_menu_items', 'my_subscriptions_my_account_menu_items' );

/**
 * Custom Endpoint content
 */
function gc_custom_endpoint_content() {
    echo do_shortcode('[ywsbs_my_account_subscriptions]');
}
add_action( 'woocommerce_account_my-subscriptions_endpoint', 'gc_custom_endpoint_content' );

Dieses Snippet zeigt die Registerkarte My Subscriptions mit dem Endpunkt my-subscriptions mit dem Zahnradsymbol. Meine Frage: Wie ändere ich das Symbol?

1

sie können das Symbol mit CSS und mit FontAwesome http://fontawesome.io/ ändern.

z.B. einen Kalender setzen

.woocommerce-MyAccount-navigation ul li.woocommerce-MyAccount-navigation-link--my-subscriptions a::before
{
    content : "\f073";
}
1
mmm