Browse Source

Guard null my-account node in Howdy replacement

get_node('my-account') can return null in some admin-bar render
contexts; reading ->title on it emitted a warning on PHP 8.3 (silent
on the server's 7.4). Bail out when the node is absent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
David Windham 3 weeks ago
parent
commit
1662dda49b
1 changed files with 3 additions and 0 deletions
  1. 3 0
      functions.php

+ 3 - 0
functions.php

@@ -236,6 +236,9 @@ function gwp24_remove_adminbar( $wp_admin_bar ) {
 add_filter( 'admin_bar_menu', 'gwp24_replace_wordpress_howdy', 25 );
 function gwp24_replace_wordpress_howdy( $wp_admin_bar ) {
   $account = $wp_admin_bar->get_node('my-account');
+  if ( ! $account ) {
+    return;
+  }
   $newtext = str_replace( 'Howdy,', '', $account->title );
   $wp_admin_bar->add_node( array(
     'id' => 'my-account',