Rename plugin title> Wordpress> Dashboard

Please help me? I need to change the name of the plugin installed in my wordpress (only the name in the admin panel is ok;). Thanks!

Preview:

enter image description here

+4
source share
3 answers

Here's the process of changing labels (I changed WooCommerce to "Stall" in my example). You can try this using the gettext filterfollowing.

Use this in 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 );

You can also 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

+7
source

-, . , function.php

add_action( 'admin_menu', 'myRenamedPlugin' );

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

, , :

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

, . , " Wordpress"

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

, 2 "pgl_wp_files". , . , .

. ( 0) , .

: function.php :

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
}
+2

, , ! , , .

(.. - ), (wp-content/plugins/whatever-plugin-name) add_menu_page. - " ", , .

: https://codex.wordpress.org/Function_Reference/add_menu_page

, add_submenu_page. , .

add_submenu_page, add_plugins_page add_theme_page : https://codex.wordpress.org/Function_Reference/add_submenu_page , .

: "", SECOND.

0

Source: https://habr.com/ru/post/1618317/


All Articles