Kirki_Customize_Control::__construct PHP Méthode

__construct() public méthode

Supplied $args override class property defaults. If $args['settings'] is not defined, use the $id as the setting ID.
Since: 2.3.5
public __construct ( WP_Customize_Manager $manager, string $id, array $args = [] )
$manager WP_Customize_Manager Customizer bootstrap instance.
$id string Control ID.
$args array { Optional. Arguments to override class property defaults. @type int $instance_number Order in which this instance was created in relation to other instances. @type WP_Customize_Manager $manager Customizer bootstrap instance. @type string $id Control ID. @type array $settings All settings tied to the control. If undefined, `$id` will be used. @type string $setting The primary setting for the control (if there is one). Default 'default'. @type int $priority Order priority to load the control. Default 10. @type string $section Section the control belongs to. Default empty. @type string $label Label for the control. Default empty. @type string $description Description for the control. Default empty. @type array $choices List of choices for 'radio' or 'select' type controls, where values are the keys, and labels are the values. Default empty array. @type array $input_attrs 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. Default empty array. @type array $json Deprecated. Use WP_Customize_Control::json() instead. @type string $type 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'. }
        public function __construct($manager, $id, $args = array())
        {
            // Call the constructor from the parent class.
            parent::__construct($manager, $id, $args);
            // Add translation strings.
            $this->l10n = Kirki_l10n::get_strings($this->kirki_config);
        }

Usage Example

 public function __construct($manager, $id, $args = array())
 {
     parent::__construct($manager, $id, $args);
     if (empty($this->button_label)) {
         $this->button_label = esc_attr__('Add new row', 'Kirki');
     }
     if (empty($args['fields']) || !is_array($args['fields'])) {
         $args['fields'] = array();
     }
     foreach ($args['fields'] as $key => $value) {
         if (!isset($value['default'])) {
             $args['fields'][$key]['default'] = '';
         }
         if (!isset($value['label'])) {
             $args['fields'][$key]['label'] = '';
         }
         $args['fields'][$key]['id'] = $key;
     }
     $this->fields = $args['fields'];
 }
All Usage Examples Of Kirki_Customize_Control::__construct