[wp-trac] [WordPress Trac] #56142: Warnings from Customizer when choosing Site icon settings link for FSE theme(s)

WordPress Trac noreply at wordpress.org
Tue Jul 5 09:16:33 UTC 2022


#56142: Warnings from Customizer when choosing Site icon settings link for FSE
theme(s)
--------------------------+-----------------------------
 Reporter:  bobbingwide   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Customize     |    Version:  5.9
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The Site Logo block contains a Site Icon settings link to the customizer.
 This is to allow you to define a different site icon from the site logo.
 When you click on this link, for a Full Site Editing (FSE) theme, such as
 Twenty Twenty Two, there are a number of Warnings generated. Some of these
 are obvious to the end user, the others can be seen in the HTML output or
 the PHP Error log.


 Warning:  Attempt to read property "title" on null in \wp-includes\class-
 wp-customize-nav-menus.php on line 523
 Warning:  Attempt to read property "title" on null in \wp-includes\class-
 wp-customize-widgets.php on line 899
 Warning:  Attempt to read property "title" on null in \wp-includes\class-
 wp-customize-nav-menus.php on line 1152

 These messages are issued from code which is attempting to set a title for
 the panel.
 eg.
 ```
 customizingMenus'       => sprintf( __( 'Customizing ▸ %s' ),
 esc_html( $this->manager->get_panel( 'nav_menus' )->title ) ),
 ```

 Since FSE themes do not call `register_nav_menus()` or
 `register_sidebar()` no calls to `add_theme_support( 'menus' )` or
 `add_theme_support( 'widgets' )` have been made.

 The result of the `$this->manager->get_panel()` call(s) is null, leading
 to the Warning messages when attempting to access the title property.

 The solution is to check the result before attempting to obtain the
 property. eg
 ```
 $panel = $this->manager->get_panel( 'menus' );
 $section_title = ( null !== $panel ) ? $panel->title : __( 'Menus');
 /* translators: ▸ is the unicode right-pointing triangle. %s:
 Section title in the Customizer. */
 printf( __( 'Customizing ▸ %s' ), esc_html( $section_title ) );
 ```

 Similar code needed for the other two message.

 I originally reported this issue at
 https://github.com/bobbingwide/bobbingwide/issues/47
 It's received a number of comments from other people experiencing the
 problem.

 The workaround to call `add_theme_support()` is unsatisfactory, hence this
 error report.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56142>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list