Customizer: Introduce WP_Customize_Control::active() method to determine whether the control is relevant to the current context (i.e. to the current URL being previewed).
Control can indicate its active state by a subclass overriding the 'active_callback' method, by supplying a callable 'active_callback' argument into the control's constructor, or by filtering 'customize_control_active'. props westonruter. see #27993. Built from https://develop.svn.wordpress.org/trunk@29051 git-svn-id: http://core.svn.wordpress.org/trunk@28839 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1068,7 +1068,33 @@ final class WP_Customize_Widgets {
|
||||
* @param array $widget Rendered widget to tally.
|
||||
*/
|
||||
public function tally_rendered_widgets( $widget ) {
|
||||
$this->rendered_widgets[$widget['id']] = true;
|
||||
$this->rendered_widgets[ $widget['id'] ] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a widget is rendered on the page.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $widget_id
|
||||
* @return bool
|
||||
*/
|
||||
public function is_widget_rendered( $widget_id ) {
|
||||
return in_array( $widget_id, $this->rendered_widgets );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a sidebar is rendered on the page.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $sidebar_id
|
||||
* @return bool
|
||||
*/
|
||||
public function is_sidebar_rendered( $sidebar_id ) {
|
||||
return in_array( $sidebar_id, $this->rendered_sidebars );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user