[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-customize-control.php (source)

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


Generated : Sat Dec 5 08:20:02 2026 Cross-referenced by PHPXref