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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. * @see WP_Customize_Control
  15. */
  16. class WP_Customize_Nav_Menu_Control extends WP_Customize_Control {
  17. /**
  18. * Control type.
  19. *
  20. * @since 4.3.0
  21. * @var string
  22. */
  23. public $type = 'nav_menu';
  24. /**
  25. * Don't render the control's content - it uses a JS template instead.
  26. *
  27. * @since 4.3.0
  28. */
  29. public function render_content() {}
  30. /**
  31. * JS/Underscore template for the control UI.
  32. *
  33. * @since 4.3.0
  34. */
  35. public function content_template() {
  36. $add_items = __( 'Add Items' );
  37. ?>
  38. <p class="new-menu-item-invitation">
  39. <?php
  40. printf(
  41. /* translators: %s: "Add Items" button text. */
  42. __( '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 would like.' ),
  43. $add_items
  44. );
  45. ?>
  46. </p>
  47. <div class="customize-control-nav_menu-buttons">
  48. <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">
  49. <?php echo $add_items; ?>
  50. </button>
  51. <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 }}">
  52. <span class="reorder"><?php _e( 'Reorder' ); ?></span>
  53. <span class="reorder-done"><?php _e( 'Done' ); ?></span>
  54. </button>
  55. </div>
  56. <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>
  57. <?php
  58. }
  59. /**
  60. * Return parameters for this control.
  61. *
  62. * @since 4.3.0
  63. *
  64. * @return array Exported parameters.
  65. */
  66. public function json() {
  67. $exported = parent::json();
  68. $exported['menu_id'] = $this->setting->term_id;
  69. return $exported;
  70. }
  71. }