WP_Customize_Control::active() WordPress Method
The WP_Customize_Control::active() method is used to determine whether a Customizer control is currently active. This is useful when you want to know whether a particular setting is currently being previewed in the Customizer. For example, if you have a theme with a light and dark color scheme, you could use this method to switch between the two schemes based on the active setting. To use this method, simply pass in the name of the setting you want to check. The method will return true if the setting is currently active, or false if it is not. This method is particularly useful for Customizer controls that have multiple settings. For example, if you have a control with a light and dark color scheme, you could use this method to determine which scheme is currently active.
WP_Customize_Control::active() #
Check whether control is active to current Customizer preview.
Return
(bool) Whether the control is active to the current preview.
Source
File: wp-includes/class-wp-customize-control.php
final public function active() { $control = $this; $active = call_user_func( $this->active_callback, $this ); /** * Filters response of WP_Customize_Control::active(). * * @since 4.0.0 * * @param bool $active Whether the Customizer control is active. * @param WP_Customize_Control $control WP_Customize_Control instance. */ $active = apply_filters( 'customize_control_active', $active, $control ); return $active; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.0.0 | Introduced. |