balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-wp-customize-control.php (25669B)


      1 <?php
      2 /**
      3  * WordPress Customize Control classes
      4  *
      5  * @package WordPress
      6  * @subpackage Customize
      7  * @since 3.4.0
      8  */
      9 
     10 /**
     11  * Customize Control class.
     12  *
     13  * @since 3.4.0
     14  */
     15 class WP_Customize_Control {
     16 
     17 	/**
     18 	 * Incremented with each new class instantiation, then stored in $instance_number.
     19 	 *
     20 	 * Used when sorting two instances whose priorities are equal.
     21 	 *
     22 	 * @since 4.1.0
     23 	 * @var int
     24 	 */
     25 	protected static $instance_count = 0;
     26 
     27 	/**
     28 	 * Order in which this instance was created in relation to other instances.
     29 	 *
     30 	 * @since 4.1.0
     31 	 * @var int
     32 	 */
     33 	public $instance_number;
     34 
     35 	/**
     36 	 * Customizer manager.
     37 	 *
     38 	 * @since 3.4.0
     39 	 * @var WP_Customize_Manager
     40 	 */
     41 	public $manager;
     42 
     43 	/**
     44 	 * Control ID.
     45 	 *
     46 	 * @since 3.4.0
     47 	 * @var string
     48 	 */
     49 	public $id;
     50 
     51 	/**
     52 	 * All settings tied to the control.
     53 	 *
     54 	 * @since 3.4.0
     55 	 * @var array
     56 	 */
     57 	public $settings;
     58 
     59 	/**
     60 	 * The primary setting for the control (if there is one).
     61 	 *
     62 	 * @since 3.4.0
     63 	 * @var string|WP_Customize_Setting|null
     64 	 */
     65 	public $setting = 'default';
     66 
     67 	/**
     68 	 * Capability required to use this control.
     69 	 *
     70 	 * Normally this is empty and the capability is derived from the capabilities
     71 	 * of the associated `$settings`.
     72 	 *
     73 	 * @since 4.5.0
     74 	 * @var string
     75 	 */
     76 	public $capability;
     77 
     78 	/**
     79 	 * Order priority to load the control in Customizer.
     80 	 *
     81 	 * @since 3.4.0
     82 	 * @var int
     83 	 */
     84 	public $priority = 10;
     85 
     86 	/**
     87 	 * Section the control belongs to.
     88 	 *
     89 	 * @since 3.4.0
     90 	 * @var string
     91 	 */
     92 	public $section = '';
     93 
     94 	/**
     95 	 * Label for the control.
     96 	 *
     97 	 * @since 3.4.0
     98 	 * @var string
     99 	 */
    100 	public $label = '';
    101 
    102 	/**
    103 	 * Description for the control.
    104 	 *
    105 	 * @since 4.0.0
    106 	 * @var string
    107 	 */
    108 	public $description = '';
    109 
    110 	/**
    111 	 * List of choices for 'radio' or 'select' type controls, where values are the keys, and labels are the values.
    112 	 *
    113 	 * @since 3.4.0
    114 	 * @var array
    115 	 */
    116 	public $choices = array();
    117 
    118 	/**
    119 	 * List of custom input attributes for control output, where attribute names are the keys and values are the values.
    120 	 *
    121 	 * Not used for 'checkbox', 'radio', 'select', 'textarea', or 'dropdown-pages' control types.
    122 	 *
    123 	 * @since 4.0.0
    124 	 * @var array
    125 	 */
    126 	public $input_attrs = array();
    127 
    128 	/**
    129 	 * Show UI for adding new content, currently only used for the dropdown-pages control.
    130 	 *
    131 	 * @since 4.7.0
    132 	 * @var bool
    133 	 */
    134 	public $allow_addition = false;
    135 
    136 	/**
    137 	 * @deprecated It is better to just call the json() method
    138 	 * @since 3.4.0
    139 	 * @var array
    140 	 */
    141 	public $json = array();
    142 
    143 	/**
    144 	 * Control's Type.
    145 	 *
    146 	 * @since 3.4.0
    147 	 * @var string
    148 	 */
    149 	public $type = 'text';
    150 
    151 	/**
    152 	 * Callback.
    153 	 *
    154 	 * @since 4.0.0
    155 	 *
    156 	 * @see WP_Customize_Control::active()
    157 	 *
    158 	 * @var callable Callback is called with one argument, the instance of
    159 	 *               WP_Customize_Control, and returns bool to indicate whether
    160 	 *               the control is active (such as it relates to the URL
    161 	 *               currently being previewed).
    162 	 */
    163 	public $active_callback = '';
    164 
    165 	/**
    166 	 * Constructor.
    167 	 *
    168 	 * Supplied `$args` override class property defaults.
    169 	 *
    170 	 * If `$args['settings']` is not defined, use the $id as the setting ID.
    171 	 *
    172 	 * @since 3.4.0
    173 	 *
    174 	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
    175 	 * @param string               $id      Control ID.
    176 	 * @param array                $args    {
    177 	 *     Optional. Array of properties for the new Control object. Default empty array.
    178 	 *
    179 	 *     @type int                  $instance_number Order in which this instance was created in relation
    180 	 *                                                 to other instances.
    181 	 *     @type WP_Customize_Manager $manager         Customizer bootstrap instance.
    182 	 *     @type string               $id              Control ID.
    183 	 *     @type array                $settings        All settings tied to the control. If undefined, `$id` will
    184 	 *                                                 be used.
    185 	 *     @type string               $setting         The primary setting for the control (if there is one).
    186 	 *                                                 Default 'default'.
    187 	 *     @type string               $capability      Capability required to use this control. Normally this is empty
    188 	 *                                                 and the capability is derived from `$settings`.
    189 	 *     @type int                  $priority        Order priority to load the control. Default 10.
    190 	 *     @type string               $section         Section the control belongs to. Default empty.
    191 	 *     @type string               $label           Label for the control. Default empty.
    192 	 *     @type string               $description     Description for the control. Default empty.
    193 	 *     @type array                $choices         List of choices for 'radio' or 'select' type controls, where
    194 	 *                                                 values are the keys, and labels are the values.
    195 	 *                                                 Default empty array.
    196 	 *     @type array                $input_attrs     List of custom input attributes for control output, where
    197 	 *                                                 attribute names are the keys and values are the values. Not
    198 	 *                                                 used for 'checkbox', 'radio', 'select', 'textarea', or
    199 	 *                                                 'dropdown-pages' control types. Default empty array.
    200 	 *     @type bool                 $allow_addition  Show UI for adding new content, currently only used for the
    201 	 *                                                 dropdown-pages control. Default false.
    202 	 *     @type array                $json            Deprecated. Use WP_Customize_Control::json() instead.
    203 	 *     @type string               $type            Control type. Core controls include 'text', 'checkbox',
    204 	 *                                                 'textarea', 'radio', 'select', and 'dropdown-pages'. Additional
    205 	 *                                                 input types such as 'email', 'url', 'number', 'hidden', and
    206 	 *                                                 'date' are supported implicitly. Default 'text'.
    207 	 *     @type callable             $active_callback Active callback.
    208 	 * }
    209 	 */
    210 	public function __construct( $manager, $id, $args = array() ) {
    211 		$keys = array_keys( get_object_vars( $this ) );
    212 		foreach ( $keys as $key ) {
    213 			if ( isset( $args[ $key ] ) ) {
    214 				$this->$key = $args[ $key ];
    215 			}
    216 		}
    217 
    218 		$this->manager = $manager;
    219 		$this->id      = $id;
    220 		if ( empty( $this->active_callback ) ) {
    221 			$this->active_callback = array( $this, 'active_callback' );
    222 		}
    223 		self::$instance_count += 1;
    224 		$this->instance_number = self::$instance_count;
    225 
    226 		// Process settings.
    227 		if ( ! isset( $this->settings ) ) {
    228 			$this->settings = $id;
    229 		}
    230 
    231 		$settings = array();
    232 		if ( is_array( $this->settings ) ) {
    233 			foreach ( $this->settings as $key => $setting ) {
    234 				$settings[ $key ] = $this->manager->get_setting( $setting );
    235 			}
    236 		} elseif ( is_string( $this->settings ) ) {
    237 			$this->setting       = $this->manager->get_setting( $this->settings );
    238 			$settings['default'] = $this->setting;
    239 		}
    240 		$this->settings = $settings;
    241 	}
    242 
    243 	/**
    244 	 * Enqueue control related scripts/styles.
    245 	 *
    246 	 * @since 3.4.0
    247 	 */
    248 	public function enqueue() {}
    249 
    250 	/**
    251 	 * Check whether control is active to current Customizer preview.
    252 	 *
    253 	 * @since 4.0.0
    254 	 *
    255 	 * @return bool Whether the control is active to the current preview.
    256 	 */
    257 	final public function active() {
    258 		$control = $this;
    259 		$active  = call_user_func( $this->active_callback, $this );
    260 
    261 		/**
    262 		 * Filters response of WP_Customize_Control::active().
    263 		 *
    264 		 * @since 4.0.0
    265 		 *
    266 		 * @param bool                 $active  Whether the Customizer control is active.
    267 		 * @param WP_Customize_Control $control WP_Customize_Control instance.
    268 		 */
    269 		$active = apply_filters( 'customize_control_active', $active, $control );
    270 
    271 		return $active;
    272 	}
    273 
    274 	/**
    275 	 * Default callback used when invoking WP_Customize_Control::active().
    276 	 *
    277 	 * Subclasses can override this with their specific logic, or they may
    278 	 * provide an 'active_callback' argument to the constructor.
    279 	 *
    280 	 * @since 4.0.0
    281 	 *
    282 	 * @return true Always true.
    283 	 */
    284 	public function active_callback() {
    285 		return true;
    286 	}
    287 
    288 	/**
    289 	 * Fetch a setting's value.
    290 	 * Grabs the main setting by default.
    291 	 *
    292 	 * @since 3.4.0
    293 	 *
    294 	 * @param string $setting_key
    295 	 * @return mixed The requested setting's value, if the setting exists.
    296 	 */
    297 	final public function value( $setting_key = 'default' ) {
    298 		if ( isset( $this->settings[ $setting_key ] ) ) {
    299 			return $this->settings[ $setting_key ]->value();
    300 		}
    301 	}
    302 
    303 	/**
    304 	 * Refresh the parameters passed to the JavaScript via JSON.
    305 	 *
    306 	 * @since 3.4.0
    307 	 */
    308 	public function to_json() {
    309 		$this->json['settings'] = array();
    310 		foreach ( $this->settings as $key => $setting ) {
    311 			$this->json['settings'][ $key ] = $setting->id;
    312 		}
    313 
    314 		$this->json['type']           = $this->type;
    315 		$this->json['priority']       = $this->priority;
    316 		$this->json['active']         = $this->active();
    317 		$this->json['section']        = $this->section;
    318 		$this->json['content']        = $this->get_content();
    319 		$this->json['label']          = $this->label;
    320 		$this->json['description']    = $this->description;
    321 		$this->json['instanceNumber'] = $this->instance_number;
    322 
    323 		if ( 'dropdown-pages' === $this->type ) {
    324 			$this->json['allow_addition'] = $this->allow_addition;
    325 		}
    326 	}
    327 
    328 	/**
    329 	 * Get the data to export to the client via JSON.
    330 	 *
    331 	 * @since 4.1.0
    332 	 *
    333 	 * @return array Array of parameters passed to the JavaScript.
    334 	 */
    335 	public function json() {
    336 		$this->to_json();
    337 		return $this->json;
    338 	}
    339 
    340 	/**
    341 	 * Checks if the user can use this control.
    342 	 *
    343 	 * Returns false if the user cannot manipulate one of the associated settings,
    344 	 * or if one of the associated settings does not exist. Also returns false if
    345 	 * the associated section does not exist or if its capability check returns
    346 	 * false.
    347 	 *
    348 	 * @since 3.4.0
    349 	 *
    350 	 * @return bool False if theme doesn't support the control or user doesn't have the required permissions, otherwise true.
    351 	 */
    352 	final public function check_capabilities() {
    353 		if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) {
    354 			return false;
    355 		}
    356 
    357 		foreach ( $this->settings as $setting ) {
    358 			if ( ! $setting || ! $setting->check_capabilities() ) {
    359 				return false;
    360 			}
    361 		}
    362 
    363 		$section = $this->manager->get_section( $this->section );
    364 		if ( isset( $section ) && ! $section->check_capabilities() ) {
    365 			return false;
    366 		}
    367 
    368 		return true;
    369 	}
    370 
    371 	/**
    372 	 * Get the control's content for insertion into the Customizer pane.
    373 	 *
    374 	 * @since 4.1.0
    375 	 *
    376 	 * @return string Contents of the control.
    377 	 */
    378 	final public function get_content() {
    379 		ob_start();
    380 		$this->maybe_render();
    381 		return trim( ob_get_clean() );
    382 	}
    383 
    384 	/**
    385 	 * Check capabilities and render the control.
    386 	 *
    387 	 * @since 3.4.0
    388 	 * @uses WP_Customize_Control::render()
    389 	 */
    390 	final public function maybe_render() {
    391 		if ( ! $this->check_capabilities() ) {
    392 			return;
    393 		}
    394 
    395 		/**
    396 		 * Fires just before the current Customizer control is rendered.
    397 		 *
    398 		 * @since 3.4.0
    399 		 *
    400 		 * @param WP_Customize_Control $this WP_Customize_Control instance.
    401 		 */
    402 		do_action( 'customize_render_control', $this );
    403 
    404 		/**
    405 		 * Fires just before a specific Customizer control is rendered.
    406 		 *
    407 		 * The dynamic portion of the hook name, `$this->id`, refers to
    408 		 * the control ID.
    409 		 *
    410 		 * @since 3.4.0
    411 		 *
    412 		 * @param WP_Customize_Control $this WP_Customize_Control instance.
    413 		 */
    414 		do_action( "customize_render_control_{$this->id}", $this );
    415 
    416 		$this->render();
    417 	}
    418 
    419 	/**
    420 	 * Renders the control wrapper and calls $this->render_content() for the internals.
    421 	 *
    422 	 * @since 3.4.0
    423 	 */
    424 	protected function render() {
    425 		$id    = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
    426 		$class = 'customize-control customize-control-' . $this->type;
    427 
    428 		printf( '<li id="%s" class="%s">', esc_attr( $id ), esc_attr( $class ) );
    429 		$this->render_content();
    430 		echo '</li>';
    431 	}
    432 
    433 	/**
    434 	 * Get the data link attribute for a setting.
    435 	 *
    436 	 * @since 3.4.0
    437 	 * @since 4.9.0 Return a `data-customize-setting-key-link` attribute if a setting is not registered for the supplied setting key.
    438 	 *
    439 	 * @param string $setting_key
    440 	 * @return string Data link parameter, a `data-customize-setting-link` attribute if the `$setting_key` refers to a pre-registered setting,
    441 	 *                and a `data-customize-setting-key-link` attribute if the setting is not yet registered.
    442 	 */
    443 	public function get_link( $setting_key = 'default' ) {
    444 		if ( isset( $this->settings[ $setting_key ] ) && $this->settings[ $setting_key ] instanceof WP_Customize_Setting ) {
    445 			return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"';
    446 		} else {
    447 			return 'data-customize-setting-key-link="' . esc_attr( $setting_key ) . '"';
    448 		}
    449 	}
    450 
    451 	/**
    452 	 * Render the data link attribute for the control's input element.
    453 	 *
    454 	 * @since 3.4.0
    455 	 * @uses WP_Customize_Control::get_link()
    456 	 *
    457 	 * @param string $setting_key
    458 	 */
    459 	public function link( $setting_key = 'default' ) {
    460 		echo $this->get_link( $setting_key );
    461 	}
    462 
    463 	/**
    464 	 * Render the custom attributes for the control's input element.
    465 	 *
    466 	 * @since 4.0.0
    467 	 */
    468 	public function input_attrs() {
    469 		foreach ( $this->input_attrs as $attr => $value ) {
    470 			echo $attr . '="' . esc_attr( $value ) . '" ';
    471 		}
    472 	}
    473 
    474 	/**
    475 	 * Render the control's content.
    476 	 *
    477 	 * Allows the content to be overridden without having to rewrite the wrapper in `$this::render()`.
    478 	 *
    479 	 * Supports basic input types `text`, `checkbox`, `textarea`, `radio`, `select` and `dropdown-pages`.
    480 	 * Additional input types such as `email`, `url`, `number`, `hidden` and `date` are supported implicitly.
    481 	 *
    482 	 * Control content can alternately be rendered in JS. See WP_Customize_Control::print_template().
    483 	 *
    484 	 * @since 3.4.0
    485 	 */
    486 	protected function render_content() {
    487 		$input_id         = '_customize-input-' . $this->id;
    488 		$description_id   = '_customize-description-' . $this->id;
    489 		$describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : '';
    490 		switch ( $this->type ) {
    491 			case 'checkbox':
    492 				?>
    493 				<span class="customize-inside-control-row">
    494 					<input
    495 						id="<?php echo esc_attr( $input_id ); ?>"
    496 						<?php echo $describedby_attr; ?>
    497 						type="checkbox"
    498 						value="<?php echo esc_attr( $this->value() ); ?>"
    499 						<?php $this->link(); ?>
    500 						<?php checked( $this->value() ); ?>
    501 					/>
    502 					<label for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $this->label ); ?></label>
    503 					<?php if ( ! empty( $this->description ) ) : ?>
    504 						<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    505 					<?php endif; ?>
    506 				</span>
    507 				<?php
    508 				break;
    509 			case 'radio':
    510 				if ( empty( $this->choices ) ) {
    511 					return;
    512 				}
    513 
    514 				$name = '_customize-radio-' . $this->id;
    515 				?>
    516 				<?php if ( ! empty( $this->label ) ) : ?>
    517 					<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
    518 				<?php endif; ?>
    519 				<?php if ( ! empty( $this->description ) ) : ?>
    520 					<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    521 				<?php endif; ?>
    522 
    523 				<?php foreach ( $this->choices as $value => $label ) : ?>
    524 					<span class="customize-inside-control-row">
    525 						<input
    526 							id="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>"
    527 							type="radio"
    528 							<?php echo $describedby_attr; ?>
    529 							value="<?php echo esc_attr( $value ); ?>"
    530 							name="<?php echo esc_attr( $name ); ?>"
    531 							<?php $this->link(); ?>
    532 							<?php checked( $this->value(), $value ); ?>
    533 							/>
    534 						<label for="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>"><?php echo esc_html( $label ); ?></label>
    535 					</span>
    536 				<?php endforeach; ?>
    537 				<?php
    538 				break;
    539 			case 'select':
    540 				if ( empty( $this->choices ) ) {
    541 					return;
    542 				}
    543 
    544 				?>
    545 				<?php if ( ! empty( $this->label ) ) : ?>
    546 					<label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
    547 				<?php endif; ?>
    548 				<?php if ( ! empty( $this->description ) ) : ?>
    549 					<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    550 				<?php endif; ?>
    551 
    552 				<select id="<?php echo esc_attr( $input_id ); ?>" <?php echo $describedby_attr; ?> <?php $this->link(); ?>>
    553 					<?php
    554 					foreach ( $this->choices as $value => $label ) {
    555 						echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>';
    556 					}
    557 					?>
    558 				</select>
    559 				<?php
    560 				break;
    561 			case 'textarea':
    562 				?>
    563 				<?php if ( ! empty( $this->label ) ) : ?>
    564 					<label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
    565 				<?php endif; ?>
    566 				<?php if ( ! empty( $this->description ) ) : ?>
    567 					<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    568 				<?php endif; ?>
    569 				<textarea
    570 					id="<?php echo esc_attr( $input_id ); ?>"
    571 					rows="5"
    572 					<?php echo $describedby_attr; ?>
    573 					<?php $this->input_attrs(); ?>
    574 					<?php $this->link(); ?>
    575 				><?php echo esc_textarea( $this->value() ); ?></textarea>
    576 				<?php
    577 				break;
    578 			case 'dropdown-pages':
    579 				?>
    580 				<?php if ( ! empty( $this->label ) ) : ?>
    581 					<label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
    582 				<?php endif; ?>
    583 				<?php if ( ! empty( $this->description ) ) : ?>
    584 					<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    585 				<?php endif; ?>
    586 
    587 				<?php
    588 				$dropdown_name     = '_customize-dropdown-pages-' . $this->id;
    589 				$show_option_none  = __( '&mdash; Select &mdash;' );
    590 				$option_none_value = '0';
    591 				$dropdown          = wp_dropdown_pages(
    592 					array(
    593 						'name'              => $dropdown_name,
    594 						'echo'              => 0,
    595 						'show_option_none'  => $show_option_none,
    596 						'option_none_value' => $option_none_value,
    597 						'selected'          => $this->value(),
    598 					)
    599 				);
    600 				if ( empty( $dropdown ) ) {
    601 					$dropdown  = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $dropdown_name ) );
    602 					$dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) );
    603 					$dropdown .= '</select>';
    604 				}
    605 
    606 				// Hackily add in the data link parameter.
    607 				$dropdown = str_replace( '<select', '<select ' . $this->get_link() . ' id="' . esc_attr( $input_id ) . '" ' . $describedby_attr, $dropdown );
    608 
    609 				// Even more hacikly add auto-draft page stubs.
    610 				// @todo Eventually this should be removed in favor of the pages being injected into the underlying get_pages() call. See <https://github.com/xwp/wp-customize-posts/pull/250>.
    611 				$nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' );
    612 				if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) {
    613 					$auto_draft_page_options = '';
    614 					foreach ( $nav_menus_created_posts_setting->value() as $auto_draft_page_id ) {
    615 						$post = get_post( $auto_draft_page_id );
    616 						if ( $post && 'page' === $post->post_type ) {
    617 							$auto_draft_page_options .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $post->ID ), esc_html( $post->post_title ) );
    618 						}
    619 					}
    620 					if ( $auto_draft_page_options ) {
    621 						$dropdown = str_replace( '</select>', $auto_draft_page_options . '</select>', $dropdown );
    622 					}
    623 				}
    624 
    625 				echo $dropdown;
    626 				?>
    627 				<?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?>
    628 					<button type="button" class="button-link add-new-toggle">
    629 						<?php
    630 						/* translators: %s: Add New Page label. */
    631 						printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item );
    632 						?>
    633 					</button>
    634 					<div class="new-content-item">
    635 						<label for="create-input-<?php echo $this->id; ?>"><span class="screen-reader-text"><?php _e( 'New page title' ); ?></span></label>
    636 						<input type="text" id="create-input-<?php echo $this->id; ?>" class="create-item-input" placeholder="<?php esc_attr_e( 'New page title&hellip;' ); ?>">
    637 						<button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
    638 					</div>
    639 				<?php endif; ?>
    640 				<?php
    641 				break;
    642 			default:
    643 				?>
    644 				<?php if ( ! empty( $this->label ) ) : ?>
    645 					<label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label>
    646 				<?php endif; ?>
    647 				<?php if ( ! empty( $this->description ) ) : ?>
    648 					<span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span>
    649 				<?php endif; ?>
    650 				<input
    651 					id="<?php echo esc_attr( $input_id ); ?>"
    652 					type="<?php echo esc_attr( $this->type ); ?>"
    653 					<?php echo $describedby_attr; ?>
    654 					<?php $this->input_attrs(); ?>
    655 					<?php if ( ! isset( $this->input_attrs['value'] ) ) : ?>
    656 						value="<?php echo esc_attr( $this->value() ); ?>"
    657 					<?php endif; ?>
    658 					<?php $this->link(); ?>
    659 					/>
    660 				<?php
    661 				break;
    662 		}
    663 	}
    664 
    665 	/**
    666 	 * Render the control's JS template.
    667 	 *
    668 	 * This function is only run for control types that have been registered with
    669 	 * WP_Customize_Manager::register_control_type().
    670 	 *
    671 	 * In the future, this will also print the template for the control's container
    672 	 * element and be override-able.
    673 	 *
    674 	 * @since 4.1.0
    675 	 */
    676 	final public function print_template() {
    677 		?>
    678 		<script type="text/html" id="tmpl-customize-control-<?php echo $this->type; ?>-content">
    679 			<?php $this->content_template(); ?>
    680 		</script>
    681 		<?php
    682 	}
    683 
    684 	/**
    685 	 * An Underscore (JS) template for this control's content (but not its container).
    686 	 *
    687 	 * Class variables for this control class are available in the `data` JS object;
    688 	 * export custom variables by overriding WP_Customize_Control::to_json().
    689 	 *
    690 	 * @see WP_Customize_Control::print_template()
    691 	 *
    692 	 * @since 4.1.0
    693 	 */
    694 	protected function content_template() {}
    695 
    696 }
    697 
    698 /**
    699  * WP_Customize_Color_Control class.
    700  */
    701 require_once ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php';
    702 
    703 /**
    704  * WP_Customize_Media_Control class.
    705  */
    706 require_once ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php';
    707 
    708 /**
    709  * WP_Customize_Upload_Control class.
    710  */
    711 require_once ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php';
    712 
    713 /**
    714  * WP_Customize_Image_Control class.
    715  */
    716 require_once ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php';
    717 
    718 /**
    719  * WP_Customize_Background_Image_Control class.
    720  */
    721 require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php';
    722 
    723 /**
    724  * WP_Customize_Background_Position_Control class.
    725  */
    726 require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php';
    727 
    728 /**
    729  * WP_Customize_Cropped_Image_Control class.
    730  */
    731 require_once ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php';
    732 
    733 /**
    734  * WP_Customize_Site_Icon_Control class.
    735  */
    736 require_once ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php';
    737 
    738 /**
    739  * WP_Customize_Header_Image_Control class.
    740  */
    741 require_once ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php';
    742 
    743 /**
    744  * WP_Customize_Theme_Control class.
    745  */
    746 require_once ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php';
    747 
    748 /**
    749  * WP_Widget_Area_Customize_Control class.
    750  */
    751 require_once ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php';
    752 
    753 /**
    754  * WP_Widget_Form_Customize_Control class.
    755  */
    756 require_once ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php';
    757 
    758 /**
    759  * WP_Customize_Nav_Menu_Control class.
    760  */
    761 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php';
    762 
    763 /**
    764  * WP_Customize_Nav_Menu_Item_Control class.
    765  */
    766 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php';
    767 
    768 /**
    769  * WP_Customize_Nav_Menu_Location_Control class.
    770  */
    771 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php';
    772 
    773 /**
    774  * WP_Customize_Nav_Menu_Name_Control class.
    775  *
    776  * As this file is deprecated, it will trigger a deprecation notice if instantiated. In a subsequent
    777  * release, the require_once here will be removed and _deprecated_file() will be called if file is
    778  * required at all.
    779  *
    780  * @deprecated 4.9.0 This file is no longer used due to new menu creation UX.
    781  */
    782 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php';
    783 
    784 /**
    785  * WP_Customize_Nav_Menu_Locations_Control class.
    786  */
    787 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-locations-control.php';
    788 
    789 /**
    790  * WP_Customize_Nav_Menu_Auto_Add_Control class.
    791  */
    792 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php';
    793 
    794 /**
    795  * WP_Customize_Date_Time_Control class.
    796  */
    797 require_once ABSPATH . WPINC . '/customize/class-wp-customize-date-time-control.php';
    798 
    799 /**
    800  * WP_Sidebar_Block_Editor_Control class.
    801  */
    802 require_once ABSPATH . WPINC . '/customize/class-wp-sidebar-block-editor-control.php';