Make WordPress Core

Ticket #33602: 33602.diff

File 33602.diff, 1.4 KB (added by welcher, 9 years ago)
  • wp-includes/widget-functions.php

     
    739739 * @return bool true if the sidebar is in use, false otherwise.
    740740 */
    741741function is_active_sidebar( $index ) {
    742         $index = ( is_int($index) ) ? "sidebar-$index" : sanitize_title($index);
    743         $sidebars_widgets = wp_get_sidebars_widgets();
    744         $is_active_sidebar = ! empty( $sidebars_widgets[$index] );
     742        $index             = ( is_int( $index ) ) ? "sidebar-$index" : sanitize_title( $index );
     743        $sidebars_widgets  = wp_get_sidebars_widgets();
     744        $is_active_sidebar = ! empty( $sidebars_widgets[ $index ] );
    745745
    746746        /**
     747         * Addresses case where a widget instance is still in sidebars_widgets but
     748         * is not actually registered.
     749         *
     750         * @ticket 33602
     751         */
     752        if ( true === $is_active_sidebar ) {
     753
     754                global $wp_registered_widgets;
     755                $widget_area_contents = $sidebars_widgets[ $index ];
     756                $active_widget_count  = count( $widget_area_contents );
     757
     758                foreach ( $widget_area_contents as $widget_instance ) {
     759
     760                        if ( ! array_key_exists( $widget_instance, $wp_registered_widgets ) ) {
     761                                $active_widget_count--;
     762                        }
     763                }
     764                $is_active_sidebar = ( 0 < $active_widget_count );
     765        }
     766
     767        /**
    747768         * Filter whether a dynamic sidebar is considered "active".
    748769         *
    749770         * @since 3.9.0