3

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' );
7uc1f3r
  • 28,449
  • 17
  • 32
  • 50
Tina York
  • 63
  • 4

1 Answers1

4

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

7uc1f3r
  • 28,449
  • 17
  • 32
  • 50
  • It does. But when using it in combination with the submenu, the submenu change does not change. Code: `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' );` – Tina York Oct 31 '20 at 08:21
  • see updated answer, the code can indeed be combined with each other – 7uc1f3r Oct 31 '20 at 08:36
  • My apologize, I was thinking of the "Products" menu name. Either way; thank you for taking the time to respond and fix. I truly appreciate it. All done now! – Tina York Oct 31 '20 at 08:47