Constructor.
Supplied $args override class property defaults.
If $args['settings'] is not defined, use the $id as the setting ID.
$managerWP_Customize_Managerrequired
$idstringrequired
$argsarrayoptional
instance_number intmanager WP_Customize_Managerid stringsettings array$id will be used.setting string'default'.capability string$settings.priority intsection stringlabel stringdescription stringchoices array'radio' or 'select' type controls, where values are the keys, and labels are the values.input_attrs array'checkbox', 'radio', 'select', 'textarea', or 'dropdown-pages' control types. allow_addition booljson arraytype string'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_callback callableDefault:array()
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 );
}
} elseif ( is_string( $this->settings ) ) {
$this->setting = $this->manager->get_setting( $this->settings );
$settings['default'] = $this->setting;
}
$this->settings = $settings;
}
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_customize_control/__construct