diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php
index 0cd2359d56..7223a262ba 100644
|
|
final class WP_Customize_Widgets { |
115 | 115 | |
116 | 116 | add_action( 'dynamic_sidebar', array( $this, 'tally_rendered_widgets' ) ); |
117 | 117 | add_filter( 'is_active_sidebar', array( $this, 'tally_sidebars_via_is_active_sidebar_calls' ), 10, 2 ); |
| 118 | add_filter( 'body_class', array( $this, 'flag_did_filter_body_classes' ), 1000 ); |
118 | 119 | add_filter( 'dynamic_sidebar_has_widgets', array( $this, 'tally_sidebars_via_dynamic_sidebar_calls' ), 10, 2 ); |
119 | 120 | |
120 | 121 | // Selective Refresh. |
… |
… |
final class WP_Customize_Widgets { |
122 | 123 | add_action( 'customize_preview_init', array( $this, 'selective_refresh_init' ) ); |
123 | 124 | } |
124 | 125 | |
| 126 | protected $did_filter_body_classes = false; |
| 127 | |
| 128 | /** |
| 129 | * Capture the "action" for when the body classes have already been computed and thus the last time that is_active_sidebar is likely to be called until dynamic_sidebar() calls. |
| 130 | * |
| 131 | * @param array $classes Body classes. |
| 132 | * @return array Body classes/ |
| 133 | */ |
| 134 | function flag_did_filter_body_classes( $classes ) { |
| 135 | $this->did_filter_body_classes = true; |
| 136 | return $classes; |
| 137 | } |
| 138 | |
125 | 139 | /** |
126 | 140 | * List whether each registered widget can be use selective refresh. |
127 | 141 | * |
… |
… |
final class WP_Customize_Widgets { |
1203 | 1217 | * @return bool Whether the sidebar is active. |
1204 | 1218 | */ |
1205 | 1219 | public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar_id ) { |
1206 | | if ( is_registered_sidebar( $sidebar_id ) ) { |
| 1220 | if ( $this->did_filter_body_classes && is_registered_sidebar( $sidebar_id ) ) { |
1207 | 1221 | $this->rendered_sidebars[] = $sidebar_id; |
1208 | 1222 | } |
1209 | 1223 | /* |