je crée un extrait pour le point de terminaison personnalisé ajouté et cela mon 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' );
Cet extrait montrant l’onglet My Subscriptions
avec le noeud final my-subscriptions
avec l’icône engrenage, ma question est de savoir comment changer d’icône?
vous pouvez changer l'icône avec CSS et en utilisant FontAwesome http://fontawesome.io/
par exemple. mettre un calendrier
.woocommerce-MyAccount-navigation ul li.woocommerce-MyAccount-navigation-link--my-subscriptions a::before
{
content : "\f073";
}