[英]Change WooCommerce products menu title in WordPress admin dashboard
[英]Change the "WooCommerce" Dashboard Menu option name into "Store"
根據 7uc13r 在 WordPress 管理儀表板回答中更改 WooCommerce 產品菜單標題,我試圖了解如何將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' );
這應該足以將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' );
結合您之前的問題,您將獲得:
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 );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.