How rename a plugin title > Wordpress > Dashboard

Here's the process to change the labels (I changed WooCommerce to "Stall" in my example). You could try that with the gettext filter in the following manner.

Use this in your functions.php file

function rename_header_to_logo( $translated, $original, $domain ) {

$strings = array(
    'WooCommerce' => 'Stall',
    'Custom Header' => 'Custom Stall'
);

if ( isset( $strings[$original] ) && is_admin() ) {
    $translations = &get_translations_for_domain( $domain );
    $translated = $translations->translate( $strings[$original] );
}

  return $translated;
}

add_filter( 'gettext', 'rename_header_to_logo', 10, 3 );

Also you can apply below code

function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
    case 'WooCommerce' :
        $translated_text = __( 'Stall', 'woocommerce' );
        break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );

enter image description here


First, have a look at your current admin menu. I usually do that with a temporary code, which I insert into my theme's function.php

add_action( 'admin_menu', 'myRenamedPlugin' );

function myRenamedPlugin() {
    global $menu;
    print_r($menu);
}

Now, when you are logged in, the complete tree of your admin menu is visible in the source code and will look something like this:

Array
(
    [2] => Array
        (
            [0] => Dashboard
            [1] => read
            [2] => index.php
            [3] =>
            [4] => menu-top menu-top-first menu-icon-dashboard menu-top-last
            [5] => menu-dashboard
            [6] => div
        )

    [4] => Array
        (
            [0] =>
            [1] => read
            [2] => separator1
            [3] =>
            [4] => wp-menu-separator
        )
...

In this array, find the plugin that you want to rename. For example the Plugin "Wordpress Files"

[101] => Array
    (
        [0] => Wordpress Files
        [1] => read
        [2] => pgl_wp_files
        [3] => WP Files
        [4] => menu-top menu-icon-generic
        [5] => toplevel_page_pgl_wp_files
        [6] => dashicons-admin-generic
    )

You see, at position 2 is the plugin's unique name "pgl_wp_files". By using the plugin's unique name, we avoid that other plugins with a similar name are going to be renamed. Hence, this extra step was important.

Now, we use this value in our function as a search needle. Once found, it can replace the plugin's name (position 0) with whatever name we like to have.

To make it short: Replace the above function in your theme's function.php with the following:

add_action( 'admin_menu', 'myRenamedPlugin' );

function myRenamedPlugin() {

    global $menu;
    $searchPlugin = "pgl_wp_files"; // Use the unique plugin name
    $replaceName = "New Name for Plugin";

    $menuItem = "";
    foreach($menu as $key => $item){
        if ( $item[2] === $searchPlugin ){
            $menuItem = $key;
        }
    }
    $menu[$menuItem][0] = $replaceName; // Position 0 stores the menu title
}

Tags:

Wordpress