3 * Customize API: WP_Customize_Nav_Menu_Item_Control class
6 * @subpackage Customize
11 * Customize control to represent the name field for a given menu.
15 class WP_Customize_Nav_Menu_Item_Control extends WP_Customize_Control {
24 public $type = 'nav_menu_item';
27 * The nav menu item setting.
31 * @var WP_Customize_Nav_Menu_Item_Setting
41 * @see WP_Customize_Control::__construct()
43 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
44 * @param string $id The control ID.
45 * @param array $args Optional. Overrides class property defaults.
47 public function __construct( $manager, $id, $args = array() ) {
48 parent::__construct( $manager, $id, $args );
52 * Don't render the control's content - it's rendered with a JS template.
57 public function render_content() {}
60 * JS/Underscore template for the control UI.
65 public function content_template() {
67 <div class="menu-item-bar">
68 <div class="menu-item-handle">
69 <span class="item-type" aria-hidden="true">{{ data.item_type_label }}</span>
70 <span class="item-title" aria-hidden="true">
71 <span class="spinner"></span>
72 <span class="menu-item-title<# if ( ! data.title ) { #> no-title<# } #>">{{ data.title || wp.customize.Menus.data.l10n.untitled }}</span>
74 <span class="item-controls">
75 <button type="button" class="button-link item-edit" aria-expanded="false"><span class="screen-reader-text"><?php
76 /* translators: 1: Title of a menu item, 2: Type of a menu item */
77 printf( __( 'Edit menu item: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.item_type_label }}' );
78 ?></span><span class="toggle-indicator" aria-hidden="true"></span></button>
79 <button type="button" class="button-link item-delete submitdelete deletion"><span class="screen-reader-text"><?php
80 /* translators: 1: Title of a menu item, 2: Type of a menu item */
81 printf( __( 'Remove Menu Item: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.item_type_label }}' );
87 <div class="menu-item-settings" id="menu-item-settings-{{ data.menu_item_id }}">
88 <# if ( 'custom' === data.item_type ) { #>
89 <p class="field-url description description-thin">
90 <label for="edit-menu-item-url-{{ data.menu_item_id }}">
91 <?php _e( 'URL' ); ?><br />
92 <input class="widefat code edit-menu-item-url" type="text" id="edit-menu-item-url-{{ data.menu_item_id }}" name="menu-item-url" />
96 <p class="description description-thin">
97 <label for="edit-menu-item-title-{{ data.menu_item_id }}">
98 <?php _e( 'Navigation Label' ); ?><br />
99 <input type="text" id="edit-menu-item-title-{{ data.menu_item_id }}" class="widefat edit-menu-item-title" name="menu-item-title" />
102 <p class="field-link-target description description-thin">
103 <label for="edit-menu-item-target-{{ data.menu_item_id }}">
104 <input type="checkbox" id="edit-menu-item-target-{{ data.menu_item_id }}" class="edit-menu-item-target" value="_blank" name="menu-item-target" />
105 <?php _e( 'Open link in a new tab' ); ?>
108 <p class="field-title-attribute field-attr-title description description-thin">
109 <label for="edit-menu-item-attr-title-{{ data.menu_item_id }}">
110 <?php _e( 'Title Attribute' ); ?><br />
111 <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" />
114 <p class="field-css-classes description description-thin">
115 <label for="edit-menu-item-classes-{{ data.menu_item_id }}">
116 <?php _e( 'CSS Classes' ); ?><br />
117 <input type="text" id="edit-menu-item-classes-{{ data.menu_item_id }}" class="widefat code edit-menu-item-classes" name="menu-item-classes" />
120 <p class="field-xfn description description-thin">
121 <label for="edit-menu-item-xfn-{{ data.menu_item_id }}">
122 <?php _e( 'Link Relationship (XFN)' ); ?><br />
123 <input type="text" id="edit-menu-item-xfn-{{ data.menu_item_id }}" class="widefat code edit-menu-item-xfn" name="menu-item-xfn" />
126 <p class="field-description description description-thin">
127 <label for="edit-menu-item-description-{{ data.menu_item_id }}">
128 <?php _e( 'Description' ); ?><br />
129 <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>
130 <span class="description"><?php _e( 'The description will be displayed in the menu if the current theme supports it.' ); ?></span>
134 <div class="menu-item-actions description-thin submitbox">
135 <# if ( ( 'post_type' === data.item_type || 'taxonomy' === data.item_type ) && '' !== data.original_title ) { #>
136 <p class="link-to-original">
137 <?php printf( __( 'Original: %s' ), '<a class="original-link" href="{{ data.url }}">{{ data.original_title }}</a>' ); ?>
141 <button type="button" class="button-link item-delete submitdelete deletion"><?php _e( 'Remove' ); ?></button>
142 <span class="spinner"></span>
144 <input type="hidden" name="menu-item-db-id[{{ data.menu_item_id }}]" class="menu-item-data-db-id" value="{{ data.menu_item_id }}" />
145 <input type="hidden" name="menu-item-parent-id[{{ data.menu_item_id }}]" class="menu-item-data-parent-id" value="{{ data.parent }}" />
146 </div><!-- .menu-item-settings-->
147 <ul class="menu-item-transport"></ul>
152 * Return parameters for this control.
157 * @return array Exported parameters.
159 public function json() {
160 $exported = parent::json();
161 $exported['menu_item_id'] = $this->setting->post_id;