[wp-trac] [WordPress Trac] #42603: Widgets Warning after activating theme and on dashboard widgets page

WordPress Trac noreply at wordpress.org
Fri Nov 17 15:41:13 UTC 2017


#42603: Widgets Warning after activating theme and on dashboard widgets page
----------------------------+-----------------------------
 Reporter:  ionvv           |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Widgets         |    Version:  4.9
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 This happens only on websites that were updated from 4.8.x to 4.9
 This happens to custom widget areas (in my case, sidebar-3, sidebar-4,
 sidebar-5)

 Recorded issue here: https://www.youtube.com/watch?v=Dg3JPGWaCwU

 To replicate:
 1. Install WP 4.8.x
 2. Install a theme that has custom widget areas
 3. Activate theme, don't add any widgets
 4. Update WP to 4.9
 5. Activate another theme
 6. Activate again the theme that has custom widgets - the warning will be
 displayed
 7. Go to dashboard, widgets. Warnings will be displayed ->
 https://i.imgur.com/v7qU1M0.png

 This happens because of the "_wp_remove_unregistered_widgets" function
 added to 4.9 version. It returns null value instead of empty array (
 https://i.imgur.com/dfNhQKS.png last 3 items in array ).

 To fix the issue, the function "_wp_remove_unregistered_widgets" should be
 changed from

 {{{
 foreach ( $sidebars_widgets as $sidebar => $widgets ) {
     if ( is_array( $widgets ) ) {
         $sidebars_widgets[ $sidebar ] = array_intersect( $widgets,
 $whitelist );
     }
 }
 }}}

 to

 {{{
 foreach ( $sidebars_widgets as $sidebar => $widgets ) {
     if ( is_array( $widgets ) ) {
         $sidebars_widgets[ $sidebar ] = array_intersect( $widgets,
 $whitelist );
     } else {
         $sidebars_widgets[ $sidebar ] = array();
     }
 }
 }}}

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


More information about the wp-trac mailing list