How to rename a menu tab under WooCommerce tab on WordPress admin dashboard

大城市里の小女人 提交于 2021-01-01 07:12:43

问题


I need help in renaming a tab menu item under woocommerce tab on wordpress admin. We installed a plugin that appears as a submenu on woocommerce tab. Can anyone please help me on this?

I found this code below to rename a tab menu, but I dont know what is the tabmenu key of it. Or anyone here how to check tab menu key on my current tab menu items?

add_action( 'admin_menu', 'custom_change_admin_label', 99);
function custom_change_admin_label() {
    global $menu;
    //global $submenu;
    $menu[5][0] = 'Articles';
}

Thank you


回答1:


The first part of the code is to debug, this will show you the menu in detail on the dashboard. (you can remove this afterwards)

The 2nd part in this example changes the 'coupons' label to 'voucher'

It is therefore a matter of adjusting based on the detail

// DEBUG: This displays the complete wordpress admin menu on your dashboard for admin only.
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' );

// Change label, in this example changes the 'coupons' label to 'voucher'
function custom_change_admin_label() {
    global $menu, $submenu;

    $submenu['woocommerce'][2][0] = 'Voucher'; // rename 'coupons' label
}
add_action( 'admin_menu', 'custom_change_admin_label' );


来源:https://stackoverflow.com/questions/60445980/how-to-rename-a-menu-tab-under-woocommerce-tab-on-wordpress-admin-dashboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!