Umbenennen eines WordPress-Admin-Menüs

Ich versuche, den Namen des AdminMenüs für “WooCommerce” in “Store-Einstellungen” zu ändern.

Ich habe den anderen Code versucht, Posts in Artikel umzubenennen, etc., aber es funktionierte nicht für WooCommerce.

WooCommerce Admin-Menü-function ist wie folgt:

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

Der folgende Code hilft, den Menünamen zu ändern, führt jedoch dazu, dass die CSS-Dateien nicht ordnungsgemäß auf der Einstellungsseite geladen werden.

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

Solutions Collecting From Web of "Umbenennen eines WordPress-Admin-Menüs"

Das ist, was ich mache, um Menüeinträge umzubenennen: admin_menu im Aktions-Hook admin_menu eine rekursive Array-Suche, um die Schlüsselposition des gewünschten Menüs zu admin_menu , und modifizieren Sie dann das globale $menu Array.

 add_action( 'admin_menu', 'rename_woocoomerce_wpse_100758', 999 ); function rename_woocoomerce_wpse_100758() { global $menu; // Pinpoint menu item $woo = recursive_array_search_php_91365( 'WooCommerce', $menu ); // Validate if( !$woo ) return; $menu[$woo][0] = 'Store Settings'; } // http://www.php.net/manual/en/function.array-search.php#91365 function recursive_array_search_php_91365( $needle, $haystack ) { foreach( $haystack as $key => $value ) { $current_key = $key; if( $needle === $value OR ( is_array( $value ) && recursive_array_search_php_91365( $needle, $value ) !== false ) ) { return $current_key; } } return false; }