I am trying to change the Admin Menu name for “WooCommerce” to “Store Settings”.
I tried the other code rename posts to articles, etc. but it did not work for WooCommerce.
WooCommerce’s Admin Menu function is as below:
function woocommerce_admin_menu() {
global $menu, $woocommerce;
if ( current_user_can( 'manage_woocommerce' ) )
$menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator woocommerce' );
$main_page = add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'manage_woocommerce', 'woocommerce' , 'woocommerce_settings_page', null, '55.5' );
$reports_page = add_submenu_page( 'woocommerce', __( 'Reports', 'woocommerce' ), __( 'Reports', 'woocommerce' ) , 'view_woocommerce_reports', 'woocommerce_reports', 'woocommerce_reports_page' );
add_submenu_page( 'edit.php?post_type=product', __( 'Attributes', 'woocommerce' ), __( 'Attributes', 'woocommerce' ), 'manage_product_terms', 'woocommerce_attributes', 'woocommerce_attributes_page');
add_action( 'load-' . $main_page, 'woocommerce_admin_help_tab' );
add_action( 'load-' . $reports_page, 'woocommerce_admin_help_tab' );
$wc_screen_id = strtolower( __( 'WooCommerce', 'woocommerce' ) );
$print_css_on = apply_filters( 'woocommerce_screen_ids', array( 'toplevel_page_' . $wc_screen_id, $wc_screen_id . '_page_woocommerce_settings', $wc_screen_id . '_page_woocommerce_reports', 'toplevel_page_woocommerce', 'woocommerce_page_woocommerce_settings', 'woocommerce_page_woocommerce_reports', 'woocommerce_page_woocommerce_status', 'product_page_woocommerce_attributes', 'edit-tags.php', 'edit.php', 'index.php', 'post-new.php', 'post.php' ) );
foreach ( $print_css_on as $page )
add_action( 'admin_print_styles-'. $page, 'woocommerce_admin_css' );
}
add_action('admin_menu', 'woocommerce_admin_menu', 9);
Below code helps to change the Menu Name, but it causes the CSS files to not properly load on Settings page.
function change_woocommerce_menu_title( $translated )
{
$translated = str_replace( 'WooCommerce', 'Store', $translated );
$translated = str_replace( 'WooCommerce', 'Store', $translated );
return $translated;
}
add_filter( 'gettext', 'change_woocommerce_menu_title' );
add_filter( 'ngettext', 'change_woocommerce_menu_title' );
This is what I do to rename menu items: in the action hook
admin_menu
, use a recursive array search to pinpoint the key position of the desired menu and then modify the global$menu
array.