Rename W3 Total Cache admin menu

I’m developing a plugin that I’ll install for all my clients to make WordPress slightly easier to use for them. One of the things it will change is name of the W3 Total Cache Admin menu from “Performance” to “Ytelse (avansert)”.

I know how to rename the default admin menus. The code below changes “Posts” to “Nyheter”(News in Norwegian).

function change_post_menu_label_news() {
global $menu;
$menu[5][0] = 'Nyheter';
echo '';
}

add_action( 'admin_menu', 'change_post_menu_label_news' );

I find the ID to change by temporarily using this code:

add_action('admin_init','dump_admin_menu');
function dump_admin_menu() {
 if (is_admin()) {
header('Content-Type:text/plain');
var_dump($GLOBALS['menu']);
exit;
}
}

However, it’s harder to rename the Performance menu since the ID increments by one when I try to rename it!. W3 Total Cache probably thinks that the ID is taken and tries a higher one.

How can I change the name of the W3 Total Cache admin Menu while avoiding this issue and without editing anything related to the plugin?

3 Answers
3

You may be able to use the WordPress filter ‘gettext’:

http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

add_filter( 'gettext', 'rename_menu_item' );
function rename_menu_item( $translated ) 
{
    $translated = str_replace( 'Performance', 'Ytelse', $translated );
    return $translated;
}

Leave a Comment