[wp-trac] [WordPress Trac] #61738: admin_bar_menu node my-account returns null

WordPress Trac noreply at wordpress.org
Wed Jul 24 13:09:43 UTC 2024


#61738: admin_bar_menu node my-account returns null
--------------------------+---------------------
 Reporter:  michaelwp85   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  6.6.2
Component:  Toolbar       |     Version:  6.6.1
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+---------------------

Comment (by hellofromTonya):

 This is a copy of @rabmalin
 [https://core.trac.wordpress.org/ticket/61615#comment:17 issue report from
 the original ticket]

 I have this in my theme:


 {{{
 function theme_slug_replace_howdy( $wp_admin_bar ) {
         $my_account = $wp_admin_bar->get_node( 'my-account' );
         $wp_admin_bar->add_node(
                 array(
                         'id'    => 'my-account',
                         'title' => str_replace( 'Howdy,', 'Hello,',
 $my_account->title ),
                 )
         );
 }

 add_action( 'admin_bar_menu', 'theme_slug_replace_howdy', 25 );
 }}}

 After 6.6.1 release I am getting following PHP warnings.
 {{{
 PHP Warning:  Attempt to read property "title" on null in
 /Users/nilambarsharma/Sites/staging/app/public/wp-
 content/themes/khai/functions.php on line 45
 PHP Deprecated:  str_replace(): Passing null to parameter #3 ($subject) of
 type array|string is deprecated in
 /Users/nilambarsharma/Sites/staging/app/public/wp-
 content/themes/khai/functions.php on line 45
 }}}

 I noticed priority of this hook has been changed in the above commit. PHP
 notice is fixed when I keep priority `9999` for my custom hook in my
 theme. Just reporting here because I am not sure whether this issue should
 be fixed in core or in my theme.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61738#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list