WP_Customize_Control::__construct( WP_Customize_Manager $manager, string $id, array $args = array() )
Constructor.
Description
Supplied $args
override class property defaults.
If $args['settings']
is not defined, use the $id as the setting ID.
Parameters
- $manager
-
(Required) Customizer bootstrap instance.
- $id
-
(Required) Control ID.
- $args
-
(Optional) Arguments to override class property defaults.
- 'instance_number'
(int) Order in which this instance was created in relation to other instances. - 'manager'
(WP_Customize_Manager) Customizer bootstrap instance. - 'id'
(string) Control ID. - 'settings'
(array) All settings tied to the control. If undefined,$id
will be used. - 'setting'
(string) The primary setting for the control (if there is one). Default 'default'. - 'priority'
(int) Order priority to load the control. Default 10. - 'section'
(string) Section the 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. Not used for 'checkbox', 'radio', 'select', 'textarea', or 'dropdown-pages' control types. - 'json'
(array) Deprecated. Use WP_Customize_Control::json() instead. - 'type'
(string) Control 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'.
Default value: array()
- 'instance_number'
Source
File: wp-includes/class-wp-customize-control.php
public function __construct( $manager, $id, $args = array() ) {
$keys = array_keys( get_object_vars( $this ) );
foreach ( $keys as $key ) {
if ( isset( $args[ $key ] ) ) {
$this->$key = $args[ $key ];
}
}
$this->manager = $manager;
$this->id = $id;
if ( empty( $this->active_callback ) ) {
$this->active_callback = array( $this, 'active_callback' );
}
self::$instance_count += 1;
$this->instance_number = self::$instance_count;
// Process settings.
if ( ! isset( $this->settings ) ) {
$this->settings = $id;
}
$settings = array();
if ( is_array( $this->settings ) ) {
foreach ( $this->settings as $key => $setting ) {
$settings[ $key ] = $this->manager->get_setting( $setting );
}
} else if ( is_string( $this->settings ) ) {
$this->setting = $this->manager->get_setting( $this->settings );
$settings['default'] = $this->setting;
}
$this->settings = $settings;
}
Changelog
Version | Description |
---|---|
WP-3.4.0 | Introduced. |