WordPress.org

Make WordPress Core

Ticket #9393: 9393-widgets-var-notice.diff

File 9393-widgets-var-notice.diff, 724 bytes (added by sivel, 6 years ago)

If there are no widgets don't try looping through them

  • wp-includes/widgets.php

     
    821821                if ( 'wp_inactive_widgets' == $sidebar ) 
    822822                        continue; 
    823823 
    824                 if ( is_array($widgets) ) foreach ( $widgets as $widget ) 
     824                if ( isset($widgets) && is_array($widgets) ) foreach ( $widgets as $widget ) 
    825825                        if ( ( $callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback ) || ( $id_base && preg_replace( '/-[0-9]+$/', '', $widget ) == $id_base ) ) { 
    826826                                if ( !$widget_id || $widget_id == $wp_registered_widgets[$widget]['id'] ) 
    827827                                        return $sidebar;