WP_Customize_Control::__construct( WP_Customize_Manager $manager, string $id, array $args = array() )
- Since
- 3.4.0
- Source
wp-includes/class-wp-customize-control.php:211
Constructor.
Description
Supplied
$args override class property defaults. If $args['settings'] is not defined, use the $id as the setting ID.Parameters
$managerWP_Customize_Manager- Customizer bootstrap instance.
$idstring- Control ID.
$argsarrayoptional- Array of properties for the new Control object. Default empty array.Default:
array()$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.$settingstringdefault: 'default'The primary setting for the control (if there is one).$capabilitystringCapability required to use this control. Normally this is empty and the capability is derived from$settings.$priorityintdefault: 10Order priority to load the control.$sectionstringdefault: emptySection the control belongs to.$labelstringdefault: emptyLabel for the control.$descriptionstringdefault: emptyDescription for the control.$choicesarraydefault: empty arrayList of choices for 'radio' or 'select' type controls, where values are the keys, and labels are the values.$input_attrsarraydefault: empty arrayList 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_additionbooldefault: falseShow UI for adding new content, currently only used for the dropdown-pages control.$jsonarrayDeprecated. Use WP_Customize_Control::json() instead.$typestringdefault: 'text'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.$active_callbackcallableActive callback.
Used by · 5
- WP_Customize_Color_Control::__construct()Constructor.
- WP_Customize_Manager::add_control()Adds a customize control.
- WP_Customize_Media_Control::__construct()Constructor.
- WP_Customize_Nav_Menu_Item_Control::__construct()Constructor.
- WP_Customize_New_Menu_Control::__construct()Constructor.
Source
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; }History
Introduced in 3.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/class-wp-customize-control.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.