Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

103 righe
2.9 KiB

  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. * @access public
  20. * @var string
  21. */
  22. public $type = 'nav_menu';
  23. /**
  24. * The nav menu setting.
  25. *
  26. * @since 4.3.0
  27. * @access public
  28. * @var WP_Customize_Nav_Menu_Setting
  29. */
  30. public $setting;
  31. /**
  32. * Don't render the control's content - it uses a JS template instead.
  33. *
  34. * @since 4.3.0
  35. * @access public
  36. */
  37. public function render_content() {}
  38. /**
  39. * JS/Underscore template for the control UI.
  40. *
  41. * @since 4.3.0
  42. * @access public
  43. */
  44. public function content_template() {
  45. ?>
  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 _e( '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 _ex( 'Reorder', 'Reorder menu items in Customizer' ); ?></span>
  51. <span class="reorder-done"><?php _ex( 'Done', 'Cancel reordering menu items in Customizer' ); ?></span>
  52. </button>
  53. <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>
  54. <span class="menu-delete-item">
  55. <button type="button" class="button-link menu-delete">
  56. <?php _e( 'Delete Menu' ); ?>
  57. </button>
  58. </span>
  59. <?php if ( current_theme_supports( 'menus' ) ) : ?>
  60. <ul class="menu-settings">
  61. <li class="customize-control">
  62. <span class="customize-control-title"><?php _e( 'Display Location' ); ?></span>
  63. </li>
  64. <?php foreach ( get_registered_nav_menus() as $location => $description ) : ?>
  65. <li class="customize-control customize-control-checkbox assigned-menu-location">
  66. <label>
  67. <input type="checkbox" data-menu-id="{{ data.menu_id }}" data-location-id="<?php echo esc_attr( $location ); ?>" class="menu-location" /> <?php echo $description; ?>
  68. <span class="theme-location-set"><?php
  69. /* translators: %s: menu name */
  70. printf( _x( '(Current: %s)', 'menu location' ),
  71. '<span class="current-menu-location-name-' . esc_attr( $location ) . '"></span>'
  72. );
  73. ?></span>
  74. </label>
  75. </li>
  76. <?php endforeach; ?>
  77. </ul>
  78. <?php endif;
  79. }
  80. /**
  81. * Return parameters for this control.
  82. *
  83. * @since 4.3.0
  84. * @access public
  85. *
  86. * @return array Exported parameters.
  87. */
  88. public function json() {
  89. $exported = parent::json();
  90. $exported['menu_id'] = $this->setting->term_id;
  91. return $exported;
  92. }
  93. }