Search code examples
phpwordpresswoocommercebackenddashboard

Change the "WooCommerce" Dashboard Menu option name into "Store"


Based on Change WooCommerce products menu title in WordPress admin dashboard answer by 7uc13r, I am trying to understand how to change WooCommerce into Store.

I've tried with the following, without success:

#1: Debug, show the menu array on dashboard

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: change the name and submenu name (WooCommerce won't change, "All products" does)

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' );

Solution

  • This should suffice to change WooCommerce into 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' );
    


    In conjunction with your previous question you will get:

    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 );
    

    enter image description here