Wordpress garbled text

Discussion in 'Web Design and Development' started by AppleDApp, Jan 21, 2016.

  1. AppleDApp, Jan 21, 2016
    Last edited: Jan 22, 2016

    AppleDApp macrumors 68020

    AppleDApp

    Joined:
    Jun 21, 2011
    #1
    I tried following this posts tutorial HOW TO CHANGE THE WORDPRESS “HOWDY” MESSAGE TO A CUSTOM WELCOME

    I created a functions.php file inserted the code and saved. Once I did that I got a strange message on my page and the Howdy message remained. I have since deleted my functions.php file in the hope of removing the text but it is not working.

    Code:
    add_filter('gettext', 'change_howdy', 10, 3);
    
    function change_howdy($translated, $text, $domain) {
    
        if (!is_admin() || 'default' != $domain)
            return $translated;
    
        if (false !== strpos($translated, 'Howdy'))
            return str_replace('Howdy', 'Welcome', $translated);
    
        return $translated;
    }
    Fixed The functions file was not properly deleted.

    This thread may be archived or sent to the wasteland.
     

    Attached Files:

  2. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #2
    Did you remember the opening <?php at the beginning of your functions.php file?
     
  3. AppleDApp thread starter macrumors 68020

    AppleDApp

    Joined:
    Jun 21, 2011
    #3
    I forgot to add that just corrected it and I still get the howdy message in my dashboard.
     
  4. ocabj macrumors 6502a

    ocabj

    Joined:
    Jul 2, 2009
    #4
    I think the problem with the method you tried is that it filters using gettext, which I believe is called by WP for every text render context, not just the admin bar, but also menus, post contents, etc.

    Just modify the $wp_admin_bar object itself (ref: https://codex.wordpress.org/Class_Reference/WP_Admin_Bar).

    Here's one example from the web:

    Code:
    add_filter('admin_bar_menu','change_howdy_text_toolbar');
    function change_howdy_text_toolbar($wp_admin_bar)
    {
        $getgreetings = $wp_admin_bar->get_node('my-account');
        $rpctitle = str_replace('Howdy,','',$getgreetings->title);
        $wp_admin_bar->add_node(array("id"=>"my-account","title"=>$rpctitle));
    }
    Note: I have no idea where the built in WP_Admin_Bar menus are defined, but apparently, 'my-account' is a menu item pre-defined and the node that needs to be altered.
     
  5. AppleDApp thread starter macrumors 68020

    AppleDApp

    Joined:
    Jun 21, 2011
    #5
    Ocabj thanks for the reply I will look into this when I get my Wordpress from my other thread.
     

Share This Page