Make WordPress Core

Ticket #50508: 50508.3.diff

File 50508.3.diff, 2.6 KB (added by dlh, 6 years ago)
  • src/wp-includes/class-wp-customize-widgets.php

    diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php
    index 0aa75168a4..8c6856bf10 100644
    final class WP_Customize_Widgets {  
    11791179
    11801180                // Prepare Customizer settings to pass to JavaScript.
    11811181                $settings = array(
    1182                         'renderedSidebars'            => array_fill_keys( array_unique( $this->rendered_sidebars ), true ),
    1183                         'renderedWidgets'             => array_fill_keys( array_keys( $this->rendered_widgets ), true ),
     1182                        'renderedSidebars'            => array_fill_keys( array_keys( array_filter( $this->rendered_sidebars ) ), true ),
     1183                        'renderedWidgets'             => array_fill_keys( array_keys( array_filter( $this->rendered_widgets ) ), true ),
    11841184                        'registeredSidebars'          => array_values( $wp_registered_sidebars ),
    11851185                        'registeredWidgets'           => $wp_registered_widgets,
    11861186                        'l10n'                        => $l10n,
    11871187                        'selectiveRefreshableWidgets' => $this->get_selective_refreshable_widgets(),
    11881188                );
     1189
    11891190                foreach ( $settings['registeredWidgets'] as &$registered_widget ) {
    11901191                        unset( $registered_widget['callback'] ); // May not be JSON-serializeable.
    11911192                }
    final class WP_Customize_Widgets {  
    12171218         * @return bool Whether the widget is rendered.
    12181219         */
    12191220        public function is_widget_rendered( $widget_id ) {
    1220                 return in_array( $widget_id, $this->rendered_widgets, true );
     1221                return ! empty( $this->rendered_widgets[ $widget_id ] );
    12211222        }
    12221223
    12231224        /**
    final class WP_Customize_Widgets {  
    12291230         * @return bool Whether the sidebar is rendered.
    12301231         */
    12311232        public function is_sidebar_rendered( $sidebar_id ) {
    1232                 return in_array( $sidebar_id, $this->rendered_sidebars, true );
     1233                return ! empty( $this->rendered_sidebars[ $sidebar_id ] );
    12331234        }
    12341235
    12351236        /**
    final class WP_Customize_Widgets {  
    12471248         */
    12481249        public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar_id ) {
    12491250                if ( is_registered_sidebar( $sidebar_id ) ) {
    1250                         $this->rendered_sidebars[] = $sidebar_id;
     1251                        $this->rendered_sidebars[ $sidebar_id ] = true;
    12511252                }
     1253
    12521254                /*
    12531255                 * We may need to force this to true, and also force-true the value
    12541256                 * for 'dynamic_sidebar_has_widgets' if we want to ensure that there
    final class WP_Customize_Widgets {  
    12721274         */
    12731275        public function tally_sidebars_via_dynamic_sidebar_calls( $has_widgets, $sidebar_id ) {
    12741276                if ( is_registered_sidebar( $sidebar_id ) ) {
    1275                         $this->rendered_sidebars[] = $sidebar_id;
     1277                        $this->rendered_sidebars[ $sidebar_id ] = true;
    12761278                }
    12771279
    12781280                /*