class-wp-customize-nav-menu-control.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Customize API: WP_Customize_Nav_Menu_Control class
  4. *
  5. * @package WordPress
  6. * @subpackage Customize
  7. * @since 4.4.0
  8. */
  9. /**
  10. * Customize Nav Menu Control Class.
  11. *
  12. * @since 4.3.0
  13. */
  14. class WP_Customize_Nav_Menu_Control extends WP_Customize_Control {
  15. /**
  16. * Control type.
  17. *
  18. * @since 4.3.0
  19. * @var string
  20. */
  21. public $type = 'nav_menu';
  22. /**
  23. * Don't render the control's content - it uses a JS template instead.
  24. *
  25. * @since 4.3.0
  26. */
  27. public function render_content() {}
  28. /**
  29. * JS/Underscore template for the control UI.
  30. *
  31. * @since 4.3.0
  32. */
  33. public function content_template() {
  34. $add_items = __( 'Add Items' );
  35. ?>
  36. <p class="new-menu-item-invitation">
  37. <?php
  38. printf(
  39. /* translators: %s: "Add Items" button text */
  40. __( 'Time to add some links! Click &#8220;%s&#8221; to start putting pages, categories, and custom links in your menu. Add as many things as you&#8217;d like.' ),
  41. $add_items
  42. );
  43. ?>
  44. </p>
  45. <div class="customize-control-nav_menu-buttons">
  46. <button type="button" class="button add-new-menu-item" aria-label="<?php esc_attr_e( 'Add or remove menu items' ); ?>" aria-expanded="false" aria-controls="available-menu-items">
  47. <?php echo $add_items; ?>
  48. </button>
  49. <button type="button" class="button-link reorder-toggle" aria-label="<?php esc_attr_e( 'Reorder menu items' ); ?>" aria-describedby="reorder-items-desc-{{ data.menu_id }}">
  50. <span class="reorder"><?php _e( 'Reorder' ); ?></span>
  51. <span class="reorder-done"><?php _e( 'Done' ); ?></span>
  52. </button>
  53. </div>
  54. <p class="screen-reader-text" id="reorder-items-desc-{{ data.menu_id }}"><?php _e( 'When in reorder mode, additional controls to reorder menu items will be available in the items list above.' ); ?></p>
  55. <?php
  56. }
  57. /**
  58. * Return parameters for this control.
  59. *
  60. * @since 4.3.0
  61. *
  62. * @return array Exported parameters.
  63. */
  64. public function json() {
  65. $exported = parent::json();
  66. $exported['menu_id'] = $this->setting->term_id;
  67. return $exported;
  68. }
  69. }