我为添加的自定义端点创建代码段,下面是我的代码:
/**
* 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\' );
此代码段显示
My Subscriptions
带端点的选项卡
my-subscriptions
对于gear图标,我的问题是如何更改图标?