将“WooCommerce”仪表板菜单选项名称更改为“商店”
Posted
技术标签:
【中文标题】将“WooCommerce”仪表板菜单选项名称更改为“商店”【英文标题】:Change the "WooCommerce" Dashboard Menu option name into "Store" 【发布时间】:2021-02-13 13:43:06 【问题描述】:根据 7uc13r 的Change WooCommerce products menu title in WordPress admin dashboard 回答,我试图了解如何将WooCommerce
变为 Store
。
我尝试了以下方法,但没有成功:
#1:调试,在仪表板上显示菜单数组
function debug_admin_menus()
global $menu, $submenu, $pagenow;
if ( current_user_can('manage_options') )
if( $pagenow == 'index.php' ) // print on dashboard
echo '<pre>', print_r( $menu, 1 ), '</pre>'; // top level menus
echo '<pre>', print_r( $submenu, 1 ), '</pre>'; // submenus
add_action( 'admin_notices', 'debug_admin_menus' );
#2:更改名称和子菜单名称(WooCommerce 不会更改,“所有产品”会更改)
function custom_change_admin_label()
global $menu, $submenu;
$menu[70][0] = 'Store';
$submenu['edit.php?post_type=product'][5][0] = 'All Plugins';
add_action( 'admin_menu', 'custom_change_admin_label' );
【问题讨论】:
【参考方案1】:这足以将WooCommerce
更改为Store
function custom_change_admin_label()
global $menu, $submenu;
// Change WooCommerce to Store
$menu['55.5'][0] = 'Store';
add_action( 'admin_menu', 'custom_change_admin_label' );
结合您的previous question,您将获得:
function custom_change_admin_label()
global $menu, $submenu;
// Change 'WooCommerce' to 'Store'
$menu['55.5'][0] = 'Store';
// Change 'All Products' to 'All Plugins'
$submenu['edit.php?post_type=product'][5][0] = 'All Plugins';
// Contains the URI of the current page.
$current_url = $_SERVER['REQUEST_URI'];
// Make sure wc-admin / customers page will still work
if ( strpos( $current_url, 'customers' ) == false)
// Remove 'Home' from WooCommerce menu
remove_submenu_page( 'woocommerce', 'wc-admin' );
add_action( 'admin_menu', 'custom_change_admin_label', 99, 0 );
【讨论】:
确实如此。但是与子菜单结合使用时,子菜单的变化不会改变。代码:function custom_change_admin_label() global $menu, $submenu; $menu['55.5'][0] = 'Store'; $submenu['edit.php?post_type=product'][5][0] = 'All Plugins'; add_action( 'admin_menu', 'custom_change_admin_label' );
查看更新的答案,代码确实可以相互结合
抱歉,我在想“产品”菜单名称。无论哪种方式;感谢您花时间回复和修复。我真的很感激。现在全部完成!以上是关于将“WooCommerce”仪表板菜单选项名称更改为“商店”的主要内容,如果未能解决你的问题,请参考以下文章
如何从 WooCommerce 订单中更改 Paypal 项目名称?