WP_Customize_Nav_Menu_Item_Control

Customize control to represent the name field for a given menu.

Defined (1)

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

/wp-includes/customize/class-wp-customize-nav-menu-item-control.php  
  1. class WP_Customize_Nav_Menu_Item_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_item'; 
  10.  
  11. /** 
  12. * The nav menu item setting. 
  13. * @since 4.3.0 
  14. * @access public 
  15. * @var WP_Customize_Nav_Menu_Item_Setting 
  16. */ 
  17. public $setting; 
  18.  
  19. /** 
  20. * Constructor. 
  21. * @since 4.3.0 
  22. * @access public 
  23. * @see WP_Customize_Control::__construct() 
  24. * @param WP_Customize_Manager $manager Customizer bootstrap instance. 
  25. * @param string $id The control ID. 
  26. * @param array $args Optional. Overrides class property defaults. 
  27. */ 
  28. public function __construct( $manager, $id, $args = array() ) { 
  29. parent::__construct( $manager, $id, $args ); 
  30.  
  31. /** 
  32. * Don't render the control's content - it's rendered with a JS template. 
  33. * @since 4.3.0 
  34. * @access public 
  35. */ 
  36. public function render_content() {} 
  37.  
  38. /** 
  39. * JS/Underscore template for the control UI. 
  40. * @since 4.3.0 
  41. * @access public 
  42. */ 
  43. public function content_template() { 
  44. ?> 
  45. <div class="menu-item-bar"> 
  46. <div class="menu-item-handle"> 
  47. <span class="item-type" aria-hidden="true">{{ data.item_type_label }}</span> 
  48. <span class="item-title" aria-hidden="true"> 
  49. <span class="spinner"></span> 
  50. <span class="menu-item-title<# if ( ! data.title && ! data.original_title ) { #> no-title<# } #>">{{ data.title || data.original_title || wp.customize.Menus.data.l10n.untitled }}</span> 
  51. </span> 
  52. <span class="item-controls"> 
  53. <button type="button" class="button-link item-edit" aria-expanded="false"><span class="screen-reader-text"><?php 
  54. /** translators: 1: Title of a menu item, 2: Type of a menu item */ 
  55. printf( __( 'Edit menu item: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.item_type_label }}' ); 
  56. ?></span><span class="toggle-indicator" aria-hidden="true"></span></button> 
  57. <button type="button" class="button-link item-delete submitdelete deletion"><span class="screen-reader-text"><?php 
  58. /** translators: 1: Title of a menu item, 2: Type of a menu item */ 
  59. printf( __( 'Remove Menu Item: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.item_type_label }}' ); 
  60. ?></span></button> 
  61. </span> 
  62. </div> 
  63. </div> 
  64.  
  65. <div class="menu-item-settings" id="menu-item-settings-{{ data.menu_item_id }}"> 
  66. <# if ( 'custom' === data.item_type ) { #> 
  67. <p class="field-url description description-thin"> 
  68. <label for="edit-menu-item-url-{{ data.menu_item_id }}"> 
  69. <?php _e( 'URL' ); ?><br /> 
  70. <input class="widefat code edit-menu-item-url" type="text" id="edit-menu-item-url-{{ data.menu_item_id }}" name="menu-item-url" /> 
  71. </label> 
  72. </p> 
  73. <# } #> 
  74. <p class="description description-thin"> 
  75. <label for="edit-menu-item-title-{{ data.menu_item_id }}"> 
  76. <?php _e( 'Navigation Label' ); ?><br /> 
  77. <input type="text" id="edit-menu-item-title-{{ data.menu_item_id }}" placeholder="{{ data.original_title }}" class="widefat edit-menu-item-title" name="menu-item-title" /> 
  78. </label> 
  79. </p> 
  80. <p class="field-link-target description description-thin"> 
  81. <label for="edit-menu-item-target-{{ data.menu_item_id }}"> 
  82. <input type="checkbox" id="edit-menu-item-target-{{ data.menu_item_id }}" class="edit-menu-item-target" value="_blank" name="menu-item-target" /> 
  83. <?php _e( 'Open link in a new tab' ); ?> 
  84. </label> 
  85. </p> 
  86. <p class="field-title-attribute field-attr-title description description-thin"> 
  87. <label for="edit-menu-item-attr-title-{{ data.menu_item_id }}"> 
  88. <?php _e( 'Title Attribute' ); ?><br /> 
  89. <input type="text" id="edit-menu-item-attr-title-{{ data.menu_item_id }}" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title" /> 
  90. </label> 
  91. </p> 
  92. <p class="field-css-classes description description-thin"> 
  93. <label for="edit-menu-item-classes-{{ data.menu_item_id }}"> 
  94. <?php _e( 'CSS Classes' ); ?><br /> 
  95. <input type="text" id="edit-menu-item-classes-{{ data.menu_item_id }}" class="widefat code edit-menu-item-classes" name="menu-item-classes" /> 
  96. </label> 
  97. </p> 
  98. <p class="field-xfn description description-thin"> 
  99. <label for="edit-menu-item-xfn-{{ data.menu_item_id }}"> 
  100. <?php _e( 'Link Relationship (XFN)' ); ?><br /> 
  101. <input type="text" id="edit-menu-item-xfn-{{ data.menu_item_id }}" class="widefat code edit-menu-item-xfn" name="menu-item-xfn" /> 
  102. </label> 
  103. </p> 
  104. <p class="field-description description description-thin"> 
  105. <label for="edit-menu-item-description-{{ data.menu_item_id }}"> 
  106. <?php _e( 'Description' ); ?><br /> 
  107. <textarea id="edit-menu-item-description-{{ data.menu_item_id }}" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description">{{ data.description }}</textarea> 
  108. <span class="description"><?php _e( 'The description will be displayed in the menu if the current theme supports it.' ); ?></span> 
  109. </label> 
  110. </p> 
  111.  
  112. <div class="menu-item-actions description-thin submitbox"> 
  113. <# if ( ( 'post_type' === data.item_type || 'taxonomy' === data.item_type ) && '' !== data.original_title ) { #> 
  114. <p class="link-to-original"> 
  115. <?php 
  116. /** translators: Nav menu item original title. 1: Original title */ 
  117. printf( __( 'Original: %s' ), '<a class="original-link" href="{{ data.url }}">{{ data.original_title }}</a>' ); 
  118. ?> 
  119. </p> 
  120. <# } #> 
  121.  
  122. <button type="button" class="button-link item-delete submitdelete deletion"><?php _e( 'Remove' ); ?></button> 
  123. <span class="spinner"></span> 
  124. </div> 
  125. <input type="hidden" name="menu-item-db-id[{{ data.menu_item_id }}]" class="menu-item-data-db-id" value="{{ data.menu_item_id }}" /> 
  126. <input type="hidden" name="menu-item-parent-id[{{ data.menu_item_id }}]" class="menu-item-data-parent-id" value="{{ data.parent }}" /> 
  127. </div><!-- .menu-item-settings--> 
  128. <ul class="menu-item-transport"></ul> 
  129. <?php 
  130.  
  131. /** 
  132. * Return parameters for this control. 
  133. * @since 4.3.0 
  134. * @access public 
  135. * @return array Exported parameters. 
  136. */ 
  137. public function json() { 
  138. $exported = parent::json(); 
  139. $exported['menu_item_id'] = $this->setting->post_id; 
  140.  
  141. return $exported;