WP_Customize_Manager::add_control( WP_Customize_Control|string $id, array $args = array() )
Add a customize control.
Description Description
Parameters Parameters
- $id
-
(WP_Customize_Control|string) (Required) Customize Control object, or ID.
- $args
-
(array) (Optional) Array of properties for the new Control object.
- 'settings'
(array) All settings tied to the control. If undefined, defaults to$setting
. IDs in the array correspond to the ID of a registeredWP_Customize_Setting
. - 'setting'
(string) The primary setting for the control (if there is one). Default is 'default'. - 'capability'
(string) Capability required to use this control. Normally derived from$settings
. - 'priority'
(int) Order priority to load the control. Default 10. - 'section'
(string) The section this control belongs to. - 'label'
(string) Label for the control. - 'description'
(string) Description for the control. - 'choices'
(array) List of choices for 'radio' or 'select' type controls, where values are the keys, and labels are the values. - 'input_attrs'
(array) List of custom input attributes for control output, where attribute names are the keys and values are the values. - 'allow_addition'
(bool) Show UI for adding new content, currently only used for the dropdown-pages control. Default false. - 'type'
(string) The type of the control. Default 'text'. - 'active_callback'
(callback) Active callback.
Default value: array()
- 'settings'
Return Return
(WP_Customize_Control) The instance of the control that was added.
Source Source
File: wp-includes/class-wp-customize-manager.php
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; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
4.5.0 | Return added WP_Customize_Control instance. |
3.4.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
basic use
Expand full source codeCollapse full source code