我正在尝试将“WooCommerce”的管理菜单名称更改为“Store Settings”。
我尝试了其他代码,将帖子重命名为文章等,但对WooCommerce不起作用。
WooCommerce的管理菜单功能如下:
function woocommerce_admin_menu() {
global $menu, $woocommerce;
if ( current_user_can( \'manage_woocommerce\' ) )
$menu[] = array( \'\', \'read\', \'separator-woocommerce\', \'\', \'wp-menu-separator woocommerce\' );
$main_page = add_menu_page( __( \'WooCommerce\', \'woocommerce\' ), __( \'WooCommerce\', \'woocommerce\' ), \'manage_woocommerce\', \'woocommerce\' , \'woocommerce_settings_page\', null, \'55.5\' );
$reports_page = add_submenu_page( \'woocommerce\', __( \'Reports\', \'woocommerce\' ), __( \'Reports\', \'woocommerce\' ) , \'view_woocommerce_reports\', \'woocommerce_reports\', \'woocommerce_reports_page\' );
add_submenu_page( \'edit.php?post_type=product\', __( \'Attributes\', \'woocommerce\' ), __( \'Attributes\', \'woocommerce\' ), \'manage_product_terms\', \'woocommerce_attributes\', \'woocommerce_attributes_page\');
add_action( \'load-\' . $main_page, \'woocommerce_admin_help_tab\' );
add_action( \'load-\' . $reports_page, \'woocommerce_admin_help_tab\' );
$wc_screen_id = strtolower( __( \'WooCommerce\', \'woocommerce\' ) );
$print_css_on = apply_filters( \'woocommerce_screen_ids\', array( \'toplevel_page_\' . $wc_screen_id, $wc_screen_id . \'_page_woocommerce_settings\', $wc_screen_id . \'_page_woocommerce_reports\', \'toplevel_page_woocommerce\', \'woocommerce_page_woocommerce_settings\', \'woocommerce_page_woocommerce_reports\', \'woocommerce_page_woocommerce_status\', \'product_page_woocommerce_attributes\', \'edit-tags.php\', \'edit.php\', \'index.php\', \'post-new.php\', \'post.php\' ) );
foreach ( $print_css_on as $page )
add_action( \'admin_print_styles-\'. $page, \'woocommerce_admin_css\' );
}
add_action(\'admin_menu\', \'woocommerce_admin_menu\', 9);
下面的代码有助于更改菜单名称,但它会导致CSS文件无法正确加载到设置页面。
function change_woocommerce_menu_title( $translated )
{
$translated = str_replace( \'WooCommerce\', \'Store\', $translated );
$translated = str_replace( \'WooCommerce\', \'Store\', $translated );
return $translated;
}
add_filter( \'gettext\', \'change_woocommerce_menu_title\' );
add_filter( \'ngettext\', \'change_woocommerce_menu_title\' );