On this page
WP_Customize_Manager::add_control( WP_Customize_Control|string $id, array $args = array() ): WP_Customize_Control
Adds a customize control.
Description
See also
Parameters
$idWP_Customize_Control|string Required-
Customize Control object, or ID.
$argsarray Optional-
Array of properties for the new Control object.
See WP_Customize_Control::__construct() for information on accepted arguments.More Arguments from WP_Customize_Control::__construct( ... $args )
Array of properties for the new Control object.
instance_numberintOrder in which this instance was created in relation to other instances.managerWP_Customize_ManagerCustomizer bootstrap instance.idstringControl ID.settingsarrayAll settings tied to the control. If undefined,$idwill be used.settingstringThe primary setting for the control (if there is one).
Default'default'.capabilitystringCapability required to use this control. Normally this is empty and the capability is derived from$settings.priorityintOrder priority to load the control. Default 10.sectionstringSection the control belongs to.labelstringLabel for the control.descriptionstringDescription for the control.choicesarrayList of choices for'radio'or'select'type controls, where values are the keys, and labels are the values.
input_attrsarrayList of custom input attributes for control output, where attribute names are the keys and values are the values. Not used for'checkbox','radio','select','textarea', or'dropdown-pages'control types.allow_additionboolShow UI for adding new content, currently only used for the dropdown-pages control. Default false.jsonarrayDeprecated. Use WP_Customize_Control::json() instead.typestringControl type. Core controls include'text','checkbox','textarea','radio','select', and'dropdown-pages'. Additional input types such as'email','url','number','hidden', and'date'are supported implicitly. Default'text'.active_callbackcallableActive callback.
Default:
array()
Return
WP_Customize_Control The instance of the control that was added.
Source
File: wp-includes/class-wp-customize-manager.php. View all references
public function add_control( $id, $args = array() ) {
if ( $id instanceof WP_Customize_Control ) {
$control = $id;
} else {
$control = new WP_Customize_Control( $this, $id, $args );
}
$this->controls[ $control->id ] = $control;
return $control;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Customize_Control::__construct() wp-includes/class-wp-customize-control.php | Constructor. |
Used By
| Used By | Description |
|---|---|
| WP_Customize_Manager::register_controls() wp-includes/class-wp-customize-manager.php | Registers some default controls. |
Changelog
| Version | Description |
|---|---|
| 4.5.0 | Return added WP_Customize_Control instance. |
| 3.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_customize_manager/add_control