WP_Customize_Nav_Menu_Control

Customize Nav Menu Control Class.

Defined (1)

The class is defined in the following location(s).

/wp-includes/customize/class-wp-customize-nav-menu-control.php  
  1. class WP_Customize_Nav_Menu_Control extends WP_Customize_Control { 
  2.  
  3. /** 
  4. * Control type. 
  5. * @since 4.3.0 
  6. * @access public 
  7. * @var string 
  8. */ 
  9. public $type = 'nav_menu'; 
  10.  
  11. /** 
  12. * The nav menu setting. 
  13. * @since 4.3.0 
  14. * @access public 
  15. * @var WP_Customize_Nav_Menu_Setting 
  16. */ 
  17. public $setting; 
  18.  
  19. /** 
  20. * Don't render the control's content - it uses a JS template instead. 
  21. * @since 4.3.0 
  22. * @access public 
  23. */ 
  24. public function render_content() {} 
  25.  
  26. /** 
  27. * JS/Underscore template for the control UI. 
  28. * @since 4.3.0 
  29. * @access public 
  30. */ 
  31. public function content_template() { 
  32. ?> 
  33. <button type="button" class="button-secondary add-new-menu-item" aria-label="<?php esc_attr_e( 'Add or remove menu items' ); ?>" aria-expanded="false" aria-controls="available-menu-items"> 
  34. <?php _e( 'Add Items' ); ?> 
  35. </button> 
  36. <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 }}"> 
  37. <span class="reorder"><?php _ex( 'Reorder', 'Reorder menu items in Customizer' ); ?></span> 
  38. <span class="reorder-done"><?php _ex( 'Done', 'Cancel reordering menu items in Customizer' ); ?></span> 
  39. </button> 
  40. <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> 
  41. <span class="menu-delete-item"> 
  42. <button type="button" class="button-link menu-delete"> 
  43. <?php _e( 'Delete Menu' ); ?> 
  44. </button> 
  45. </span> 
  46. <?php if ( current_theme_supports( 'menus' ) ) : ?> 
  47. <ul class="menu-settings"> 
  48. <li class="customize-control"> 
  49. <span class="customize-control-title"><?php _e( 'Menu Locations' ); ?></span> 
  50. </li> 
  51.  
  52. <?php foreach ( get_registered_nav_menus() as $location => $description ) : ?> 
  53. <li class="customize-control customize-control-checkbox assigned-menu-location"> 
  54. <label> 
  55. <input type="checkbox" data-menu-id="{{ data.menu_id }}" data-location-id="<?php echo esc_attr( $location ); ?>" class="menu-location" /> <?php echo $description; ?> 
  56. <span class="theme-location-set"><?php 
  57. /** translators: %s: menu name */ 
  58. printf( _x( '(Current: %s)', 'menu location' ),  
  59. '<span class="current-menu-location-name-' . esc_attr( $location ) . '"></span>' 
  60. ); 
  61. ?></span> 
  62. </label> 
  63. </li> 
  64. <?php endforeach; ?> 
  65.  
  66. </ul> 
  67. <?php endif; 
  68.  
  69. /** 
  70. * Return parameters for this control. 
  71. * @since 4.3.0 
  72. * @access public 
  73. * @return array Exported parameters. 
  74. */ 
  75. public function json() { 
  76. $exported = parent::json(); 
  77. $exported['menu_id'] = $this->setting->term_id; 
  78.  
  79. return $exported;