class-wp-customize-control.php 24 KB

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