WP_Customize_Control::active_callback() WordPress Method
The WP_Customize_Control::active_callback() method is used to determine whether a Customizer control is active. This method is called when the Customizer is first loaded, and whenever a setting is changed that could affect the control. The control is considered active if the active_callback() method returns true. The active_callback() method can be used to hide or show a control based on the value of another setting. For example, you could use the active_callback() method to show a control only when the 'show_on_front' setting is set to 'posts'. You can also use the active_callback() method to show or hide a control based on the capabilities of the current user. For example, you could use the active_callback() method to show a control only to users who have the 'manage_options' capability. The active_callback() method accepts two arguments: $control and $value. The $control argument is a WP_Customize_Control object. The $value argument is the value of the setting that the control is tied to. The active_callback() method should return a boolean value. If the method returns true, the control will be shown. If the method returns false, the control will be hidden.
WP_Customize_Control::active_callback() #
Default callback used when invoking WP_Customize_Control::active().
Contents
Description
Subclasses can override this with their specific logic, or they may provide an ‘active_callback’ argument to the constructor.
Return
(true) Always true.
Source
File: wp-includes/class-wp-customize-control.php
public function active_callback() { return true; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.0.0 | Introduced. |