author | ymh <ymh.work@gmail.com> |
Tue, 15 Dec 2020 13:49:49 +0100 | |
changeset 16 | a86126ab1dd4 |
parent 9 | 177826044cd9 |
child 18 | be944660c56a |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* WordPress Administration for Navigation Menus |
|
4 |
* Interface functions |
|
5 |
* |
|
6 |
* @version 2.0.0 |
|
7 |
* |
|
8 |
* @package WordPress |
|
9 |
* @subpackage Administration |
|
10 |
*/ |
|
11 |
||
12 |
/** Load WordPress Administration Bootstrap */ |
|
16 | 13 |
require_once __DIR__ . '/admin.php'; |
0 | 14 |
|
16 | 15 |
// Load all the nav menu interface functions. |
16 |
require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; |
|
0 | 17 |
|
9 | 18 |
if ( ! current_theme_supports( 'menus' ) && ! current_theme_supports( 'widgets' ) ) { |
0 | 19 |
wp_die( __( 'Your theme does not support navigation menus or widgets.' ) ); |
9 | 20 |
} |
0 | 21 |
|
16 | 22 |
// Permissions check. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
if ( ! current_user_can( 'edit_theme_options' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
24 |
wp_die( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
'<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
403 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
} |
0 | 30 |
|
31 |
wp_enqueue_script( 'nav-menu' ); |
|
32 |
||
9 | 33 |
if ( wp_is_mobile() ) { |
0 | 34 |
wp_enqueue_script( 'jquery-touch-punch' ); |
9 | 35 |
} |
0 | 36 |
|
16 | 37 |
// Container for any messages displayed to the user. |
0 | 38 |
$messages = array(); |
39 |
||
16 | 40 |
// Container that stores the name of the active menu. |
0 | 41 |
$nav_menu_selected_title = ''; |
42 |
||
16 | 43 |
// The menu id of the current menu being edited. |
0 | 44 |
$nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0; |
45 |
||
16 | 46 |
// Get existing menu locations assignments. |
9 | 47 |
$locations = get_registered_nav_menus(); |
0 | 48 |
$menu_locations = get_nav_menu_locations(); |
9 | 49 |
$num_locations = count( array_keys( $locations ) ); |
0 | 50 |
|
16 | 51 |
// Allowed actions: add, update, delete. |
0 | 52 |
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit'; |
53 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
* If a JSON blob of navigation menu data is found, expand it and inject it |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
* into `$_POST` to avoid PHP `max_input_vars` limitations. See #14134. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
_wp_expand_nav_menu_post_data(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
|
0 | 60 |
switch ( $action ) { |
61 |
case 'add-menu-item': |
|
62 |
check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' ); |
|
16 | 63 |
|
9 | 64 |
if ( isset( $_REQUEST['nav-menu-locations'] ) ) { |
0 | 65 |
set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_REQUEST['menu-locations'] ) ); |
9 | 66 |
} elseif ( isset( $_REQUEST['menu-item'] ) ) { |
0 | 67 |
wp_save_nav_menu_items( $nav_menu_selected_id, $_REQUEST['menu-item'] ); |
9 | 68 |
} |
16 | 69 |
|
0 | 70 |
break; |
16 | 71 |
|
9 | 72 |
case 'move-down-menu-item': |
5 | 73 |
// Moving down a menu item is the same as moving up the next in order. |
0 | 74 |
check_admin_referer( 'move-menu_item' ); |
16 | 75 |
|
0 | 76 |
$menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0; |
16 | 77 |
|
0 | 78 |
if ( is_nav_menu_item( $menu_item_id ) ) { |
79 |
$menus = isset( $_REQUEST['menu'] ) ? array( (int) $_REQUEST['menu'] ) : wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) ); |
|
16 | 80 |
|
0 | 81 |
if ( ! is_wp_error( $menus ) && ! empty( $menus[0] ) ) { |
9 | 82 |
$menu_id = (int) $menus[0]; |
0 | 83 |
$ordered_menu_items = wp_get_nav_menu_items( $menu_id ); |
9 | 84 |
$menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) ); |
0 | 85 |
|
5 | 86 |
// Set up the data we need in one pass through the array of menu items. |
0 | 87 |
$dbids_to_orders = array(); |
88 |
$orders_to_dbids = array(); |
|
16 | 89 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
foreach ( (array) $ordered_menu_items as $ordered_menu_item_object ) { |
0 | 91 |
if ( isset( $ordered_menu_item_object->ID ) ) { |
92 |
if ( isset( $ordered_menu_item_object->menu_order ) ) { |
|
9 | 93 |
$dbids_to_orders[ $ordered_menu_item_object->ID ] = $ordered_menu_item_object->menu_order; |
94 |
$orders_to_dbids[ $ordered_menu_item_object->menu_order ] = $ordered_menu_item_object->ID; |
|
0 | 95 |
} |
96 |
} |
|
97 |
} |
|
98 |
||
5 | 99 |
// Get next in order. |
16 | 100 |
if ( isset( $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] + 1 ] ) ) { |
9 | 101 |
$next_item_id = $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] + 1 ]; |
0 | 102 |
$next_item_data = (array) wp_setup_nav_menu_item( get_post( $next_item_id ) ); |
103 |
||
5 | 104 |
// If not siblings of same parent, bubble menu item up but keep order. |
16 | 105 |
if ( ! empty( $menu_item_data['menu_item_parent'] ) |
106 |
&& ( empty( $next_item_data['menu_item_parent'] ) |
|
107 |
|| (int) $next_item_data['menu_item_parent'] !== (int) $menu_item_data['menu_item_parent'] ) |
|
0 | 108 |
) { |
16 | 109 |
if ( in_array( (int) $menu_item_data['menu_item_parent'], $orders_to_dbids, true ) ) { |
110 |
$parent_db_id = (int) $menu_item_data['menu_item_parent']; |
|
111 |
} else { |
|
112 |
$parent_db_id = 0; |
|
113 |
} |
|
0 | 114 |
|
115 |
$parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) ); |
|
116 |
||
117 |
if ( ! is_wp_error( $parent_object ) ) { |
|
9 | 118 |
$parent_data = (array) $parent_object; |
0 | 119 |
$menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent']; |
120 |
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
|
121 |
} |
|
122 |
||
9 | 123 |
// Make menu item a child of its next sibling. |
0 | 124 |
} else { |
125 |
$next_item_data['menu_order'] = $next_item_data['menu_order'] - 1; |
|
126 |
$menu_item_data['menu_order'] = $menu_item_data['menu_order'] + 1; |
|
127 |
||
128 |
$menu_item_data['menu_item_parent'] = $next_item_data['ID']; |
|
129 |
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
|
130 |
||
9 | 131 |
wp_update_post( $menu_item_data ); |
132 |
wp_update_post( $next_item_data ); |
|
0 | 133 |
} |
134 |
||
9 | 135 |
// The item is last but still has a parent, so bubble up. |
16 | 136 |
} elseif ( ! empty( $menu_item_data['menu_item_parent'] ) |
137 |
&& in_array( (int) $menu_item_data['menu_item_parent'], $orders_to_dbids, true ) |
|
0 | 138 |
) { |
9 | 139 |
$menu_item_data['menu_item_parent'] = (int) get_post_meta( $menu_item_data['menu_item_parent'], '_menu_item_menu_item_parent', true ); |
0 | 140 |
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
141 |
} |
|
142 |
} |
|
143 |
} |
|
144 |
||
145 |
break; |
|
16 | 146 |
|
9 | 147 |
case 'move-up-menu-item': |
0 | 148 |
check_admin_referer( 'move-menu_item' ); |
16 | 149 |
|
0 | 150 |
$menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0; |
16 | 151 |
|
0 | 152 |
if ( is_nav_menu_item( $menu_item_id ) ) { |
16 | 153 |
if ( isset( $_REQUEST['menu'] ) ) { |
154 |
$menus = array( (int) $_REQUEST['menu'] ); |
|
155 |
} else { |
|
156 |
$menus = wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) ); |
|
157 |
} |
|
158 |
||
0 | 159 |
if ( ! is_wp_error( $menus ) && ! empty( $menus[0] ) ) { |
9 | 160 |
$menu_id = (int) $menus[0]; |
0 | 161 |
$ordered_menu_items = wp_get_nav_menu_items( $menu_id ); |
9 | 162 |
$menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) ); |
0 | 163 |
|
5 | 164 |
// Set up the data we need in one pass through the array of menu items. |
0 | 165 |
$dbids_to_orders = array(); |
166 |
$orders_to_dbids = array(); |
|
16 | 167 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
foreach ( (array) $ordered_menu_items as $ordered_menu_item_object ) { |
0 | 169 |
if ( isset( $ordered_menu_item_object->ID ) ) { |
170 |
if ( isset( $ordered_menu_item_object->menu_order ) ) { |
|
9 | 171 |
$dbids_to_orders[ $ordered_menu_item_object->ID ] = $ordered_menu_item_object->menu_order; |
172 |
$orders_to_dbids[ $ordered_menu_item_object->menu_order ] = $ordered_menu_item_object->ID; |
|
0 | 173 |
} |
174 |
} |
|
175 |
} |
|
176 |
||
5 | 177 |
// If this menu item is not first. |
16 | 178 |
if ( ! empty( $dbids_to_orders[ $menu_item_id ] ) |
179 |
&& ! empty( $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) |
|
180 |
) { |
|
0 | 181 |
|
5 | 182 |
// If this menu item is a child of the previous. |
16 | 183 |
if ( ! empty( $menu_item_data['menu_item_parent'] ) |
184 |
&& in_array( (int) $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ), true ) |
|
185 |
&& isset( $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) |
|
186 |
&& ( (int) $menu_item_data['menu_item_parent'] === $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) |
|
0 | 187 |
) { |
16 | 188 |
if ( in_array( (int) $menu_item_data['menu_item_parent'], $orders_to_dbids, true ) ) { |
189 |
$parent_db_id = (int) $menu_item_data['menu_item_parent']; |
|
190 |
} else { |
|
191 |
$parent_db_id = 0; |
|
192 |
} |
|
193 |
||
0 | 194 |
$parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) ); |
195 |
||
196 |
if ( ! is_wp_error( $parent_object ) ) { |
|
197 |
$parent_data = (array) $parent_object; |
|
198 |
||
5 | 199 |
/* |
200 |
* If there is something before the parent and parent a child of it, |
|
201 |
* make menu item a child also of it. |
|
202 |
*/ |
|
16 | 203 |
if ( ! empty( $dbids_to_orders[ $parent_db_id ] ) |
204 |
&& ! empty( $orders_to_dbids[ $dbids_to_orders[ $parent_db_id ] - 1 ] ) |
|
205 |
&& ! empty( $parent_data['menu_item_parent'] ) |
|
0 | 206 |
) { |
207 |
$menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent']; |
|
208 |
||
9 | 209 |
/* |
210 |
* Else if there is something before parent and parent not a child of it, |
|
211 |
* make menu item a child of that something's parent |
|
212 |
*/ |
|
16 | 213 |
} elseif ( ! empty( $dbids_to_orders[ $parent_db_id ] ) |
214 |
&& ! empty( $orders_to_dbids[ $dbids_to_orders[ $parent_db_id ] - 1 ] ) |
|
0 | 215 |
) { |
9 | 216 |
$_possible_parent_id = (int) get_post_meta( $orders_to_dbids[ $dbids_to_orders[ $parent_db_id ] - 1 ], '_menu_item_menu_item_parent', true ); |
16 | 217 |
|
218 |
if ( in_array( $_possible_parent_id, array_keys( $dbids_to_orders ), true ) ) { |
|
0 | 219 |
$menu_item_data['menu_item_parent'] = $_possible_parent_id; |
9 | 220 |
} else { |
0 | 221 |
$menu_item_data['menu_item_parent'] = 0; |
9 | 222 |
} |
0 | 223 |
|
9 | 224 |
// Else there isn't something before the parent. |
0 | 225 |
} else { |
226 |
$menu_item_data['menu_item_parent'] = 0; |
|
227 |
} |
|
228 |
||
5 | 229 |
// Set former parent's [menu_order] to that of menu-item's. |
0 | 230 |
$parent_data['menu_order'] = $parent_data['menu_order'] + 1; |
231 |
||
5 | 232 |
// Set menu-item's [menu_order] to that of former parent. |
0 | 233 |
$menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1; |
234 |
||
5 | 235 |
// Save changes. |
0 | 236 |
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
9 | 237 |
wp_update_post( $menu_item_data ); |
238 |
wp_update_post( $parent_data ); |
|
0 | 239 |
} |
240 |
||
9 | 241 |
// Else this menu item is not a child of the previous. |
16 | 242 |
} elseif ( empty( $menu_item_data['menu_order'] ) |
243 |
|| empty( $menu_item_data['menu_item_parent'] ) |
|
244 |
|| ! in_array( (int) $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ), true ) |
|
245 |
|| empty( $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) |
|
246 |
|| $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] !== (int) $menu_item_data['menu_item_parent'] |
|
0 | 247 |
) { |
5 | 248 |
// Just make it a child of the previous; keep the order. |
9 | 249 |
$menu_item_data['menu_item_parent'] = (int) $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ]; |
0 | 250 |
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
9 | 251 |
wp_update_post( $menu_item_data ); |
0 | 252 |
} |
253 |
} |
|
254 |
} |
|
255 |
} |
|
16 | 256 |
|
0 | 257 |
break; |
258 |
||
259 |
case 'delete-menu-item': |
|
260 |
$menu_item_id = (int) $_REQUEST['menu-item']; |
|
261 |
||
262 |
check_admin_referer( 'delete-menu_item_' . $menu_item_id ); |
|
263 |
||
9 | 264 |
if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) ) { |
265 |
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'The menu item has been successfully deleted.' ) . '</p></div>'; |
|
266 |
} |
|
16 | 267 |
|
0 | 268 |
break; |
269 |
||
270 |
case 'delete': |
|
271 |
check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id ); |
|
16 | 272 |
|
0 | 273 |
if ( is_nav_menu( $nav_menu_selected_id ) ) { |
274 |
$deletion = wp_delete_nav_menu( $nav_menu_selected_id ); |
|
275 |
} else { |
|
5 | 276 |
// Reset the selected menu. |
0 | 277 |
$nav_menu_selected_id = 0; |
278 |
unset( $_REQUEST['menu'] ); |
|
279 |
} |
|
280 |
||
9 | 281 |
if ( ! isset( $deletion ) ) { |
0 | 282 |
break; |
9 | 283 |
} |
0 | 284 |
|
9 | 285 |
if ( is_wp_error( $deletion ) ) { |
5 | 286 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>'; |
9 | 287 |
} else { |
5 | 288 |
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'The menu has been successfully deleted.' ) . '</p></div>'; |
9 | 289 |
} |
16 | 290 |
|
0 | 291 |
break; |
292 |
||
293 |
case 'delete_menus': |
|
294 |
check_admin_referer( 'nav_menus_bulk_actions' ); |
|
16 | 295 |
|
0 | 296 |
foreach ( $_REQUEST['delete_menus'] as $menu_id_to_delete ) { |
9 | 297 |
if ( ! is_nav_menu( $menu_id_to_delete ) ) { |
0 | 298 |
continue; |
9 | 299 |
} |
0 | 300 |
|
301 |
$deletion = wp_delete_nav_menu( $menu_id_to_delete ); |
|
16 | 302 |
|
0 | 303 |
if ( is_wp_error( $deletion ) ) { |
9 | 304 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>'; |
0 | 305 |
$deletion_error = true; |
306 |
} |
|
307 |
} |
|
308 |
||
9 | 309 |
if ( empty( $deletion_error ) ) { |
5 | 310 |
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Selected menus have been successfully deleted.' ) . '</p></div>'; |
9 | 311 |
} |
16 | 312 |
|
0 | 313 |
break; |
314 |
||
315 |
case 'update': |
|
316 |
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' ); |
|
317 |
||
5 | 318 |
// Merge new and existing menu locations if any new ones are set. |
0 | 319 |
if ( isset( $_POST['menu-locations'] ) ) { |
320 |
$new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); |
|
9 | 321 |
$menu_locations = array_merge( $menu_locations, $new_menu_locations ); |
0 | 322 |
} |
323 |
||
5 | 324 |
// Add Menu. |
16 | 325 |
if ( 0 === $nav_menu_selected_id ) { |
0 | 326 |
$new_menu_title = trim( esc_html( $_POST['menu-name'] ) ); |
327 |
||
328 |
if ( $new_menu_title ) { |
|
9 | 329 |
$_nav_menu_selected_id = wp_update_nav_menu_object( 0, array( 'menu-name' => $new_menu_title ) ); |
0 | 330 |
|
331 |
if ( is_wp_error( $_nav_menu_selected_id ) ) { |
|
5 | 332 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>'; |
0 | 333 |
} else { |
9 | 334 |
$_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id ); |
335 |
$nav_menu_selected_id = $_nav_menu_selected_id; |
|
0 | 336 |
$nav_menu_selected_title = $_menu_object->name; |
16 | 337 |
|
9 | 338 |
if ( isset( $_REQUEST['menu-item'] ) ) { |
0 | 339 |
wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) ); |
9 | 340 |
} |
16 | 341 |
|
342 |
// Set the menu_location value correctly for the newly created menu. |
|
343 |
foreach ( $menu_locations as $location => $id ) { |
|
344 |
if ( 0 === $id ) { |
|
345 |
$menu_locations[ $location ] = $nav_menu_selected_id; |
|
346 |
} |
|
347 |
} |
|
348 |
||
349 |
set_theme_mod( 'nav_menu_locations', $menu_locations ); |
|
350 |
||
351 |
if ( isset( $_REQUEST['zero-menu-state'] ) || ! empty( $_POST['auto-add-pages'] ) ) { |
|
352 |
// If there are menu items, add them. |
|
0 | 353 |
wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ); |
16 | 354 |
} |
355 |
||
356 |
if ( isset( $_REQUEST['zero-menu-state'] ) ) { |
|
357 |
// Auto-save nav_menu_locations. |
|
0 | 358 |
$locations = get_nav_menu_locations(); |
16 | 359 |
|
0 | 360 |
foreach ( $locations as $location => $menu_id ) { |
361 |
$locations[ $location ] = $nav_menu_selected_id; |
|
16 | 362 |
break; // There should only be 1. |
0 | 363 |
} |
16 | 364 |
|
0 | 365 |
set_theme_mod( 'nav_menu_locations', $locations ); |
366 |
} |
|
16 | 367 |
|
0 | 368 |
if ( isset( $_REQUEST['use-location'] ) ) { |
9 | 369 |
$locations = get_registered_nav_menus(); |
0 | 370 |
$menu_locations = get_nav_menu_locations(); |
16 | 371 |
|
9 | 372 |
if ( isset( $locations[ $_REQUEST['use-location'] ] ) ) { |
0 | 373 |
$menu_locations[ $_REQUEST['use-location'] ] = $nav_menu_selected_id; |
9 | 374 |
} |
16 | 375 |
|
0 | 376 |
set_theme_mod( 'nav_menu_locations', $menu_locations ); |
377 |
} |
|
5 | 378 |
|
0 | 379 |
wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) ); |
16 | 380 |
exit; |
0 | 381 |
} |
382 |
} else { |
|
5 | 383 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>'; |
0 | 384 |
} |
385 |
||
9 | 386 |
// Update existing menu. |
0 | 387 |
} else { |
16 | 388 |
// Remove menu locations that have been unchecked. |
389 |
foreach ( $locations as $location => $description ) { |
|
390 |
if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) |
|
391 |
&& isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] === $nav_menu_selected_id |
|
392 |
) { |
|
393 |
unset( $menu_locations[ $location ] ); |
|
394 |
} |
|
395 |
} |
|
396 |
||
397 |
// Set menu locations. |
|
398 |
set_theme_mod( 'nav_menu_locations', $menu_locations ); |
|
0 | 399 |
|
400 |
$_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); |
|
401 |
||
402 |
$menu_title = trim( esc_html( $_POST['menu-name'] ) ); |
|
16 | 403 |
|
0 | 404 |
if ( ! $menu_title ) { |
5 | 405 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>'; |
0 | 406 |
$menu_title = $_menu_object->name; |
407 |
} |
|
408 |
||
409 |
if ( ! is_wp_error( $_menu_object ) ) { |
|
410 |
$_nav_menu_selected_id = wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $menu_title ) ); |
|
16 | 411 |
|
0 | 412 |
if ( is_wp_error( $_nav_menu_selected_id ) ) { |
413 |
$_menu_object = $_nav_menu_selected_id; |
|
9 | 414 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>'; |
0 | 415 |
} else { |
9 | 416 |
$_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id ); |
0 | 417 |
$nav_menu_selected_title = $_menu_object->name; |
418 |
} |
|
419 |
} |
|
420 |
||
5 | 421 |
// Update menu items. |
0 | 422 |
if ( ! is_wp_error( $_menu_object ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
$messages = array_merge( $messages, wp_nav_menu_update_menu_items( $_nav_menu_selected_id, $nav_menu_selected_title ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
// If the menu ID changed, redirect to the new URL. |
16 | 426 |
if ( $nav_menu_selected_id !== $_nav_menu_selected_id ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
wp_redirect( admin_url( 'nav-menus.php?menu=' . intval( $_nav_menu_selected_id ) ) ); |
16 | 428 |
exit; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
} |
0 | 430 |
} |
431 |
} |
|
16 | 432 |
|
0 | 433 |
break; |
16 | 434 |
|
0 | 435 |
case 'locations': |
436 |
if ( ! $num_locations ) { |
|
437 |
wp_redirect( admin_url( 'nav-menus.php' ) ); |
|
16 | 438 |
exit; |
0 | 439 |
} |
440 |
||
441 |
add_filter( 'screen_options_show_screen', '__return_false' ); |
|
442 |
||
443 |
if ( isset( $_POST['menu-locations'] ) ) { |
|
444 |
check_admin_referer( 'save-menu-locations' ); |
|
445 |
||
446 |
$new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); |
|
9 | 447 |
$menu_locations = array_merge( $menu_locations, $new_menu_locations ); |
16 | 448 |
// Set menu locations. |
0 | 449 |
set_theme_mod( 'nav_menu_locations', $menu_locations ); |
450 |
||
5 | 451 |
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Menu locations updated.' ) . '</p></div>'; |
0 | 452 |
} |
16 | 453 |
|
0 | 454 |
break; |
455 |
} |
|
456 |
||
5 | 457 |
// Get all nav menus. |
9 | 458 |
$nav_menus = wp_get_nav_menus(); |
0 | 459 |
$menu_count = count( $nav_menus ); |
460 |
||
461 |
// Are we on the add new screen? |
|
16 | 462 |
$add_new_screen = ( isset( $_GET['menu'] ) && 0 === (int) $_GET['menu'] ) ? true : false; |
0 | 463 |
|
16 | 464 |
$locations_screen = ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] ) ? true : false; |
465 |
||
466 |
$page_count = wp_count_posts( 'page' ); |
|
0 | 467 |
|
5 | 468 |
/* |
469 |
* If we have one theme location, and zero menus, we take them right |
|
470 |
* into editing their first menu. |
|
471 |
*/ |
|
16 | 472 |
if ( 1 === count( get_registered_nav_menus() ) && ! $add_new_screen |
473 |
&& empty( $nav_menus ) && ! empty( $page_count->publish ) |
|
474 |
) { |
|
475 |
$one_theme_location_no_menus = true; |
|
476 |
} else { |
|
477 |
$one_theme_location_no_menus = false; |
|
478 |
} |
|
0 | 479 |
|
480 |
$nav_menus_l10n = array( |
|
481 |
'oneThemeLocationNoMenus' => $one_theme_location_no_menus, |
|
9 | 482 |
'moveUp' => __( 'Move up one' ), |
483 |
'moveDown' => __( 'Move down one' ), |
|
484 |
'moveToTop' => __( 'Move to the top' ), |
|
16 | 485 |
/* translators: %s: Previous item name. */ |
9 | 486 |
'moveUnder' => __( 'Move under %s' ), |
16 | 487 |
/* translators: %s: Previous item name. */ |
9 | 488 |
'moveOutFrom' => __( 'Move out from under %s' ), |
16 | 489 |
/* translators: %s: Previous item name. */ |
9 | 490 |
'under' => __( 'Under %s' ), |
16 | 491 |
/* translators: %s: Previous item name. */ |
9 | 492 |
'outFrom' => __( 'Out from under %s' ), |
16 | 493 |
/* translators: 1: Item name, 2: Item position, 3: Total number of items. */ |
9 | 494 |
'menuFocus' => __( '%1$s. Menu item %2$d of %3$d.' ), |
16 | 495 |
/* translators: 1: Item name, 2: Item position, 3: Parent item name. */ |
9 | 496 |
'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ), |
0 | 497 |
); |
498 |
wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n ); |
|
499 |
||
5 | 500 |
/* |
501 |
* Redirect to add screen if there are no menus and this users has either zero, |
|
502 |
* or more than 1 theme locations. |
|
503 |
*/ |
|
16 | 504 |
if ( 0 === $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus ) { |
0 | 505 |
wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) ); |
9 | 506 |
} |
0 | 507 |
|
5 | 508 |
// Get recently edited nav menu. |
0 | 509 |
$recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) ); |
9 | 510 |
if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) ) { |
0 | 511 |
$recently_edited = $nav_menu_selected_id; |
9 | 512 |
} |
0 | 513 |
|
5 | 514 |
// Use $recently_edited if none are selected. |
9 | 515 |
if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) { |
0 | 516 |
$nav_menu_selected_id = $recently_edited; |
9 | 517 |
} |
0 | 518 |
|
5 | 519 |
// On deletion of menu, if another menu exists, show it. |
16 | 520 |
if ( ! $add_new_screen && $menu_count > 0 && isset( $_GET['action'] ) && 'delete' === $_GET['action'] ) { |
0 | 521 |
$nav_menu_selected_id = $nav_menus[0]->term_id; |
9 | 522 |
} |
0 | 523 |
|
5 | 524 |
// Set $nav_menu_selected_id to 0 if no menus. |
0 | 525 |
if ( $one_theme_location_no_menus ) { |
526 |
$nav_menu_selected_id = 0; |
|
527 |
} elseif ( empty( $nav_menu_selected_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) { |
|
16 | 528 |
// If we have no selection yet, and we have menus, set to the first one in the list. |
0 | 529 |
$nav_menu_selected_id = $nav_menus[0]->term_id; |
530 |
} |
|
531 |
||
5 | 532 |
// Update the user's setting. |
16 | 533 |
if ( $nav_menu_selected_id !== $recently_edited && is_nav_menu( $nav_menu_selected_id ) ) { |
0 | 534 |
update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id ); |
9 | 535 |
} |
0 | 536 |
|
537 |
// If there's a menu, get its name. |
|
538 |
if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) { |
|
9 | 539 |
$_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); |
0 | 540 |
$nav_menu_selected_title = ! is_wp_error( $_menu_object ) ? $_menu_object->name : ''; |
541 |
} |
|
542 |
||
5 | 543 |
// Generate truncated menu names. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
544 |
foreach ( (array) $nav_menus as $key => $_nav_menu ) { |
9 | 545 |
$nav_menus[ $key ]->truncated_name = wp_html_excerpt( $_nav_menu->name, 40, '…' ); |
0 | 546 |
} |
547 |
||
5 | 548 |
// Retrieve menu locations. |
0 | 549 |
if ( current_theme_supports( 'menus' ) ) { |
9 | 550 |
$locations = get_registered_nav_menus(); |
0 | 551 |
$menu_locations = get_nav_menu_locations(); |
552 |
} |
|
553 |
||
5 | 554 |
/* |
555 |
* Ensure the user will be able to scroll horizontally |
|
556 |
* by adding a class for the max menu depth. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
557 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
* @global int $_wp_nav_menu_max_depth |
5 | 559 |
*/ |
0 | 560 |
global $_wp_nav_menu_max_depth; |
561 |
$_wp_nav_menu_max_depth = 0; |
|
562 |
||
5 | 563 |
// Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth. |
0 | 564 |
if ( is_nav_menu( $nav_menu_selected_id ) ) { |
9 | 565 |
$menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'post_status' => 'any' ) ); |
0 | 566 |
$edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); |
567 |
} |
|
568 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
569 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
* @global int $_wp_nav_menu_max_depth |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
* @param string $classes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
573 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
575 |
function wp_nav_menu_max_depth( $classes ) { |
0 | 576 |
global $_wp_nav_menu_max_depth; |
577 |
return "$classes menu-max-depth-$_wp_nav_menu_max_depth"; |
|
578 |
} |
|
579 |
||
9 | 580 |
add_filter( 'admin_body_class', 'wp_nav_menu_max_depth' ); |
0 | 581 |
|
582 |
wp_nav_menu_setup(); |
|
583 |
wp_initial_nav_menu_meta_boxes(); |
|
584 |
||
9 | 585 |
if ( ! current_theme_supports( 'menus' ) && ! $num_locations ) { |
16 | 586 |
$messages[] = '<div id="message" class="updated"><p>' . sprintf( |
587 |
/* translators: %s: URL to Widgets screen. */ |
|
588 |
__( 'Your theme does not natively support menus, but you can use them in sidebars by adding a “Navigation Menu” widget on the <a href="%s">Widgets</a> screen.' ), |
|
589 |
admin_url( 'widgets.php' ) |
|
590 |
) . '</p></div>'; |
|
9 | 591 |
} |
0 | 592 |
|
16 | 593 |
if ( ! $locations_screen ) : // Main tab. |
594 |
$overview = '<p>' . __( 'This screen is used for managing your navigation menus.' ) . '</p>'; |
|
595 |
$overview .= '<p>' . sprintf( |
|
596 |
/* translators: 1: URL to Widgets screen, 2 and 3: The names of the default themes. */ |
|
597 |
__( 'Menus can be displayed in locations defined by your theme, even used in sidebars by adding a “Navigation Menu” widget on the <a href="%1$s">Widgets</a> screen. If your theme does not support the navigation menus feature (the default themes, %2$s and %3$s, do), you can learn about adding this support by following the Documentation link to the side.' ), |
|
598 |
admin_url( 'widgets.php' ), |
|
599 |
'Twenty Nineteen', |
|
600 |
'Twenty Twenty' |
|
601 |
) . '</p>'; |
|
0 | 602 |
$overview .= '<p>' . __( 'From this screen you can:' ) . '</p>'; |
603 |
$overview .= '<ul><li>' . __( 'Create, edit, and delete menus' ) . '</li>'; |
|
604 |
$overview .= '<li>' . __( 'Add, organize, and modify individual menu items' ) . '</li></ul>'; |
|
605 |
||
9 | 606 |
get_current_screen()->add_help_tab( |
607 |
array( |
|
608 |
'id' => 'overview', |
|
609 |
'title' => __( 'Overview' ), |
|
610 |
'content' => $overview, |
|
611 |
) |
|
612 |
); |
|
0 | 613 |
|
614 |
$menu_management = '<p>' . __( 'The menu management box at the top of the screen is used to control which menu is opened in the editor below.' ) . '</p>'; |
|
615 |
$menu_management .= '<ul><li>' . __( 'To edit an existing menu, <strong>choose a menu from the drop down and click Select</strong>' ) . '</li>'; |
|
616 |
$menu_management .= '<li>' . __( 'If you haven’t yet created any menus, <strong>click the ’create a new menu’ link</strong> to get started' ) . '</li></ul>'; |
|
617 |
$menu_management .= '<p>' . __( 'You can assign theme locations to individual menus by <strong>selecting the desired settings</strong> at the bottom of the menu editor. To assign menus to all theme locations at once, <strong>visit the Manage Locations tab</strong> at the top of the screen.' ) . '</p>'; |
|
618 |
||
9 | 619 |
get_current_screen()->add_help_tab( |
620 |
array( |
|
621 |
'id' => 'menu-management', |
|
622 |
'title' => __( 'Menu Management' ), |
|
623 |
'content' => $menu_management, |
|
624 |
) |
|
625 |
); |
|
0 | 626 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
$editing_menus = '<p>' . __( 'Each navigation menu may contain a mix of links to pages, categories, custom URLs or other content types. Menu links are added by selecting items from the expanding boxes in the left-hand column below.' ) . '</p>'; |
0 | 628 |
$editing_menus .= '<p>' . __( '<strong>Clicking the arrow to the right of any menu item</strong> in the editor will reveal a standard group of settings. Additional settings such as link target, CSS classes, link relationships, and link descriptions can be enabled and disabled via the Screen Options tab.' ) . '</p>'; |
629 |
$editing_menus .= '<ul><li>' . __( 'Add one or several items at once by <strong>selecting the checkbox next to each item and clicking Add to Menu</strong>' ) . '</li>'; |
|
9 | 630 |
$editing_menus .= '<li>' . __( 'To add a custom link, <strong>expand the Custom Links section, enter a URL and link text, and click Add to Menu</strong>' ) . '</li>'; |
0 | 631 |
$editing_menus .= '<li>' . __( 'To reorganize menu items, <strong>drag and drop items with your mouse or use your keyboard</strong>. Drag or move a menu item a little to the right to make it a submenu' ) . '</li>'; |
632 |
$editing_menus .= '<li>' . __( 'Delete a menu item by <strong>expanding it and clicking the Remove link</strong>' ) . '</li></ul>'; |
|
633 |
||
9 | 634 |
get_current_screen()->add_help_tab( |
635 |
array( |
|
636 |
'id' => 'editing-menus', |
|
637 |
'title' => __( 'Editing Menus' ), |
|
638 |
'content' => $editing_menus, |
|
639 |
) |
|
640 |
); |
|
16 | 641 |
else : // Locations tab. |
0 | 642 |
$locations_overview = '<p>' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '</p>'; |
643 |
$locations_overview .= '<ul><li>' . __( 'To assign menus to one or more theme locations, <strong>select a menu from each location’s drop down.</strong> When you’re finished, <strong>click Save Changes</strong>' ) . '</li>'; |
|
644 |
$locations_overview .= '<li>' . __( 'To edit a menu currently assigned to a theme location, <strong>click the adjacent ’Edit’ link</strong>' ) . '</li>'; |
|
645 |
$locations_overview .= '<li>' . __( 'To add a new menu instead of assigning an existing one, <strong>click the ’Use new menu’ link</strong>. Your new menu will be automatically assigned to that theme location' ) . '</li></ul>'; |
|
646 |
||
9 | 647 |
get_current_screen()->add_help_tab( |
648 |
array( |
|
649 |
'id' => 'locations-overview', |
|
650 |
'title' => __( 'Overview' ), |
|
651 |
'content' => $locations_overview, |
|
652 |
) |
|
653 |
); |
|
0 | 654 |
endif; |
655 |
||
656 |
get_current_screen()->set_help_sidebar( |
|
9 | 657 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
16 | 658 |
'<p>' . __( '<a href="https://wordpress.org/support/article/appearance-menus-screen/">Documentation on Menus</a>' ) . '</p>' . |
9 | 659 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
0 | 660 |
); |
661 |
||
5 | 662 |
// Get the admin header. |
16 | 663 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
0 | 664 |
?> |
665 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
666 |
<h1 class="wp-heading-inline"><?php echo esc_html( __( 'Menus' ) ); ?></h1> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
668 |
if ( current_user_can( 'customize' ) ) : |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
$focus = $locations_screen ? array( 'section' => 'menu_locations' ) : array( 'panel' => 'nav_menus' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
' <a class="page-title-action hide-if-no-customize" href="%1$s">%2$s</a>', |
9 | 672 |
esc_url( |
673 |
add_query_arg( |
|
674 |
array( |
|
675 |
array( 'autofocus' => $focus ), |
|
676 |
'return' => urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), |
|
677 |
), |
|
678 |
admin_url( 'customize.php' ) |
|
679 |
) |
|
680 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
__( 'Manage with Live Preview' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
683 |
endif; |
9 | 684 |
|
685 |
$nav_tab_active_class = ''; |
|
686 |
$nav_aria_current = ''; |
|
16 | 687 |
|
688 |
if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' !== $_GET['action'] ) { |
|
9 | 689 |
$nav_tab_active_class = ' nav-tab-active'; |
690 |
$nav_aria_current = ' aria-current="page"'; |
|
691 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
692 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
<hr class="wp-header-end"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
|
9 | 696 |
<nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> |
697 |
<a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php echo $nav_tab_active_class; ?>"<?php echo $nav_aria_current; ?>><?php esc_html_e( 'Edit Menus' ); ?></a> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
<?php |
9 | 699 |
if ( $num_locations && $menu_count ) { |
700 |
$active_tab_class = ''; |
|
701 |
$aria_current = ''; |
|
16 | 702 |
|
9 | 703 |
if ( $locations_screen ) { |
704 |
$active_tab_class = ' nav-tab-active'; |
|
705 |
$aria_current = ' aria-current="page"'; |
|
706 |
} |
|
707 |
?> |
|
708 |
<a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php echo $active_tab_class; ?>"<?php echo $aria_current; ?>><?php esc_html_e( 'Manage Locations' ); ?></a> |
|
709 |
<?php |
|
710 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
?> |
9 | 712 |
</nav> |
0 | 713 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
foreach ( $messages as $message ) : |
0 | 715 |
echo $message . "\n"; |
716 |
endforeach; |
|
717 |
?> |
|
718 |
<?php |
|
719 |
if ( $locations_screen ) : |
|
16 | 720 |
if ( 1 === $num_locations ) { |
5 | 721 |
echo '<p>' . __( 'Your theme supports one menu. Select which menu you would like to use.' ) . '</p>'; |
722 |
} else { |
|
16 | 723 |
echo '<p>' . sprintf( |
724 |
/* translators: %s: Number of menus. */ |
|
725 |
_n( |
|
726 |
'Your theme supports %s menu. Select which menu appears in each location.', |
|
727 |
'Your theme supports %s menus. Select which menu appears in each location.', |
|
728 |
$num_locations |
|
729 |
), |
|
730 |
number_format_i18n( $num_locations ) |
|
731 |
) . '</p>'; |
|
5 | 732 |
} |
9 | 733 |
?> |
0 | 734 |
<div id="menu-locations-wrap"> |
735 |
<form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>"> |
|
5 | 736 |
<table class="widefat fixed" id="menu-locations-table"> |
0 | 737 |
<thead> |
738 |
<tr> |
|
739 |
<th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th> |
|
740 |
<th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th> |
|
741 |
</tr> |
|
742 |
</thead> |
|
743 |
<tbody class="menu-locations"> |
|
744 |
<?php foreach ( $locations as $_location => $_name ) { ?> |
|
5 | 745 |
<tr class="menu-locations-row"> |
746 |
<td class="menu-location-title"><label for="locations-<?php echo $_location; ?>"><?php echo $_name; ?></label></td> |
|
0 | 747 |
<td class="menu-location-menus"> |
748 |
<select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>"> |
|
749 |
<option value="0"><?php printf( '— %s —', esc_html__( 'Select a Menu' ) ); ?></option> |
|
9 | 750 |
<?php |
751 |
foreach ( $nav_menus as $menu ) : |
|
752 |
$data_orig = ''; |
|
16 | 753 |
$selected = isset( $menu_locations[ $_location ] ) && $menu_locations[ $_location ] === $menu->term_id; |
754 |
||
9 | 755 |
if ( $selected ) { |
756 |
$data_orig = 'data-orig="true"'; |
|
757 |
} |
|
758 |
?> |
|
759 |
<option <?php echo $data_orig; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>"> |
|
0 | 760 |
<?php echo wp_html_excerpt( $menu->name, 40, '…' ); ?> |
761 |
</option> |
|
762 |
<?php endforeach; ?> |
|
763 |
</select> |
|
764 |
<div class="locations-row-links"> |
|
16 | 765 |
<?php if ( isset( $menu_locations[ $_location ] ) && 0 !== $menu_locations[ $_location ] ) : ?> |
0 | 766 |
<span class="locations-edit-menu-link"> |
9 | 767 |
<a href=" |
768 |
<?php |
|
769 |
echo esc_url( |
|
770 |
add_query_arg( |
|
771 |
array( |
|
772 |
'action' => 'edit', |
|
773 |
'menu' => $menu_locations[ $_location ], |
|
774 |
), |
|
775 |
admin_url( 'nav-menus.php' ) |
|
776 |
) |
|
777 |
); |
|
778 |
?> |
|
779 |
"> |
|
5 | 780 |
<span aria-hidden="true"><?php _ex( 'Edit', 'menu' ); ?></span><span class="screen-reader-text"><?php _e( 'Edit selected menu' ); ?></span> |
0 | 781 |
</a> |
782 |
</span> |
|
783 |
<?php endif; ?> |
|
784 |
<span class="locations-add-menu-link"> |
|
9 | 785 |
<a href=" |
786 |
<?php |
|
787 |
echo esc_url( |
|
788 |
add_query_arg( |
|
789 |
array( |
|
790 |
'action' => 'edit', |
|
791 |
'menu' => 0, |
|
792 |
'use-location' => $_location, |
|
793 |
), |
|
794 |
admin_url( 'nav-menus.php' ) |
|
795 |
) |
|
796 |
); |
|
797 |
?> |
|
798 |
"> |
|
0 | 799 |
<?php _ex( 'Use new menu', 'menu' ); ?> |
800 |
</a> |
|
801 |
</span> |
|
5 | 802 |
</div><!-- .locations-row-links --> |
0 | 803 |
</td><!-- .menu-location-menus --> |
5 | 804 |
</tr><!-- .menu-locations-row --> |
16 | 805 |
<?php } // End foreach. ?> |
0 | 806 |
</tbody> |
807 |
</table> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
808 |
<p class="button-controls wp-clearfix"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p> |
0 | 809 |
<?php wp_nonce_field( 'save-menu-locations' ); ?> |
810 |
<input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
|
811 |
</form> |
|
812 |
</div><!-- #menu-locations-wrap --> |
|
9 | 813 |
<?php |
814 |
/** |
|
815 |
* Fires after the menu locations table is displayed. |
|
816 |
* |
|
817 |
* @since 3.6.0 |
|
818 |
*/ |
|
819 |
do_action( 'after_menu_locations_table' ); |
|
820 |
?> |
|
0 | 821 |
<?php else : ?> |
822 |
<div class="manage-menus"> |
|
9 | 823 |
<?php if ( $menu_count < 1 ) : ?> |
824 |
<span class="first-menu-message"> |
|
825 |
<?php _e( 'Create your first menu below.' ); ?> |
|
826 |
<span class="screen-reader-text"><?php _e( 'Fill in the Menu Name and click the Create Menu button to create your first menu.' ); ?></span> |
|
827 |
</span><!-- /first-menu-message --> |
|
828 |
<?php elseif ( $menu_count < 2 ) : ?> |
|
0 | 829 |
<span class="add-edit-menu-action"> |
9 | 830 |
<?php |
831 |
printf( |
|
16 | 832 |
/* translators: %s: URL to create a new menu. */ |
9 | 833 |
__( 'Edit your menu below, or <a href="%s">create a new menu</a>. Don’t forget to save your changes!' ), |
834 |
esc_url( |
|
835 |
add_query_arg( |
|
836 |
array( |
|
837 |
'action' => 'edit', |
|
838 |
'menu' => 0, |
|
839 |
), |
|
840 |
admin_url( 'nav-menus.php' ) |
|
841 |
) |
|
842 |
) |
|
843 |
); |
|
844 |
?> |
|
845 |
<span class="screen-reader-text"><?php _e( 'Click the Save Menu button to save your changes.' ); ?></span> |
|
0 | 846 |
</span><!-- /add-edit-menu-action --> |
847 |
<?php else : ?> |
|
848 |
<form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>"> |
|
849 |
<input type="hidden" name="action" value="edit" /> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
850 |
<label for="select-menu-to-edit" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
851 |
<select name="menu" id="select-menu-to-edit"> |
0 | 852 |
<?php if ( $add_new_screen ) : ?> |
5 | 853 |
<option value="0" selected="selected"><?php _e( '— Select —' ); ?></option> |
0 | 854 |
<?php endif; ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
855 |
<?php foreach ( (array) $nav_menus as $_nav_menu ) : ?> |
0 | 856 |
<option value="<?php echo esc_attr( $_nav_menu->term_id ); ?>" <?php selected( $_nav_menu->term_id, $nav_menu_selected_id ); ?>> |
857 |
<?php |
|
9 | 858 |
echo esc_html( $_nav_menu->truncated_name ); |
0 | 859 |
|
16 | 860 |
if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations, true ) ) { |
0 | 861 |
$locations_assigned_to_this_menu = array(); |
16 | 862 |
|
863 |
foreach ( array_keys( $menu_locations, $_nav_menu->term_id, true ) as $menu_location_key ) { |
|
5 | 864 |
if ( isset( $locations[ $menu_location_key ] ) ) { |
865 |
$locations_assigned_to_this_menu[] = $locations[ $menu_location_key ]; |
|
866 |
} |
|
0 | 867 |
} |
5 | 868 |
|
869 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
870 |
* Filters the number of locations listed per menu in the drop-down select. |
5 | 871 |
* |
872 |
* @since 3.6.0 |
|
873 |
* |
|
874 |
* @param int $locations Number of menu locations to list. Default 3. |
|
875 |
*/ |
|
16 | 876 |
$locations_listed_per_menu = absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ); |
877 |
||
878 |
$assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, $locations_listed_per_menu ); |
|
0 | 879 |
|
5 | 880 |
// Adds ellipses following the number of locations defined in $assigned_locations. |
881 |
if ( ! empty( $assigned_locations ) ) { |
|
9 | 882 |
printf( |
883 |
' (%1$s%2$s)', |
|
5 | 884 |
implode( ', ', $assigned_locations ), |
885 |
count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : '' |
|
886 |
); |
|
887 |
} |
|
0 | 888 |
} |
889 |
?> |
|
890 |
</option> |
|
891 |
<?php endforeach; ?> |
|
892 |
</select> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
893 |
<span class="submit-btn"><input type="submit" class="button" value="<?php esc_attr_e( 'Select' ); ?>"></span> |
0 | 894 |
<span class="add-new-menu-action"> |
9 | 895 |
<?php |
896 |
printf( |
|
16 | 897 |
/* translators: %s: URL to create a new menu. */ |
9 | 898 |
__( 'or <a href="%s">create a new menu</a>. Don’t forget to save your changes!' ), |
899 |
esc_url( |
|
900 |
add_query_arg( |
|
901 |
array( |
|
902 |
'action' => 'edit', |
|
903 |
'menu' => 0, |
|
904 |
), |
|
905 |
admin_url( 'nav-menus.php' ) |
|
906 |
) |
|
907 |
) |
|
908 |
); |
|
909 |
?> |
|
910 |
<span class="screen-reader-text"><?php _e( 'Click the Save Menu button to save your changes.' ); ?></span> |
|
0 | 911 |
</span><!-- /add-new-menu-action --> |
912 |
</form> |
|
9 | 913 |
<?php |
914 |
endif; |
|
915 |
||
916 |
$metabox_holder_disabled_class = ''; |
|
16 | 917 |
|
918 |
if ( isset( $_GET['menu'] ) && 0 === (int) $_GET['menu'] ) { |
|
9 | 919 |
$metabox_holder_disabled_class = ' metabox-holder-disabled'; |
920 |
} |
|
921 |
?> |
|
0 | 922 |
</div><!-- /manage-menus --> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
923 |
<div id="nav-menus-frame" class="wp-clearfix"> |
9 | 924 |
<div id="menu-settings-column" class="metabox-holder<?php echo $metabox_holder_disabled_class; ?>"> |
0 | 925 |
|
926 |
<div class="clear"></div> |
|
927 |
||
5 | 928 |
<form id="nav-menu-meta" class="nav-menu-meta" method="post" enctype="multipart/form-data"> |
0 | 929 |
<input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
930 |
<input type="hidden" name="action" value="add-menu-item" /> |
|
931 |
<?php wp_nonce_field( 'add-menu_item', 'menu-settings-column-nonce' ); ?> |
|
9 | 932 |
<h2><?php _e( 'Add menu items' ); ?></h2> |
0 | 933 |
<?php do_accordion_sections( 'nav-menus', 'side', null ); ?> |
934 |
</form> |
|
935 |
||
936 |
</div><!-- /#menu-settings-column --> |
|
937 |
<div id="menu-management-liquid"> |
|
938 |
<div id="menu-management"> |
|
5 | 939 |
<form id="update-nav-menu" method="post" enctype="multipart/form-data"> |
9 | 940 |
<h2><?php _e( 'Menu structure' ); ?></h2> |
16 | 941 |
<div class="menu-edit"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
942 |
<input type="hidden" name="nav-menu-data"> |
0 | 943 |
<?php |
944 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
945 |
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
946 |
wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' ); |
|
947 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
948 |
$menu_name_aria_desc = $add_new_screen ? ' aria-describedby="menu-name-desc"' : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
949 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
950 |
if ( $one_theme_location_no_menus ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
951 |
$menu_name_val = 'value="' . esc_attr( 'Menu 1' ) . '"'; |
9 | 952 |
?> |
0 | 953 |
<input type="hidden" name="zero-menu-state" value="true" /> |
9 | 954 |
<?php |
955 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
956 |
$menu_name_val = 'value="' . esc_attr( $nav_menu_selected_title ) . '"'; |
9 | 957 |
} |
958 |
?> |
|
959 |
<input type="hidden" name="action" value="update" /> |
|
0 | 960 |
<input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
961 |
<div id="nav-menu-header"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
962 |
<div class="major-publishing-actions wp-clearfix"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
963 |
<label class="menu-name-label" for="menu-name"><?php _e( 'Menu Name' ); ?></label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
964 |
<input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox" <?php echo $menu_name_val . $menu_name_aria_desc; ?> /> |
0 | 965 |
<div class="publishing-action"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
966 |
<?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'primary large menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?> |
0 | 967 |
</div><!-- END .publishing-action --> |
968 |
</div><!-- END .major-publishing-actions --> |
|
969 |
</div><!-- END .nav-menu-header --> |
|
970 |
<div id="post-body"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
<div id="post-body-content" class="wp-clearfix"> |
0 | 972 |
<?php if ( ! $add_new_screen ) : ?> |
16 | 973 |
|
9 | 974 |
<?php |
975 |
$hide_style = ''; |
|
16 | 976 |
|
977 |
if ( isset( $menu_items ) && 0 === count( $menu_items ) ) { |
|
9 | 978 |
$hide_style = 'style="display: none;"'; |
979 |
} |
|
16 | 980 |
|
981 |
if ( $one_theme_location_no_menus ) { |
|
982 |
$starter_copy = __( 'Edit your default menu by adding or removing items. Drag the items into the order you prefer. Click Create Menu to save your changes.' ); |
|
983 |
} else { |
|
984 |
$starter_copy = __( 'Drag the items into the order you prefer. Click the arrow on the right of the item to reveal additional configuration options.' ); |
|
985 |
} |
|
9 | 986 |
?> |
16 | 987 |
<div class="drag-instructions post-body-plain" <?php echo $hide_style; ?>> |
988 |
<p><?php echo $starter_copy; ?></p> |
|
989 |
</div> |
|
990 |
||
9 | 991 |
<?php |
992 |
if ( isset( $edit_markup ) && ! is_wp_error( $edit_markup ) ) { |
|
993 |
echo $edit_markup; |
|
994 |
} else { |
|
995 |
?> |
|
16 | 996 |
<ul class="menu" id="menu-to-edit"></ul> |
9 | 997 |
<?php } ?> |
16 | 998 |
|
0 | 999 |
<?php endif; ?> |
16 | 1000 |
|
0 | 1001 |
<?php if ( $add_new_screen ) : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
<p class="post-body-plain" id="menu-name-desc"><?php _e( 'Give your menu a name, then click Create Menu.' ); ?></p> |
0 | 1003 |
<?php if ( isset( $_GET['use-location'] ) ) : ?> |
1004 |
<input type="hidden" name="use-location" value="<?php echo esc_attr( $_GET['use-location'] ); ?>" /> |
|
1005 |
<?php endif; ?> |
|
16 | 1006 |
|
9 | 1007 |
<?php |
16 | 1008 |
endif; |
9 | 1009 |
|
16 | 1010 |
$no_menus_style = ''; |
1011 |
||
9 | 1012 |
if ( $one_theme_location_no_menus ) { |
1013 |
$no_menus_style = 'style="display: none;"'; |
|
1014 |
} |
|
1015 |
?> |
|
1016 |
<div class="menu-settings" <?php echo $no_menus_style; ?>> |
|
0 | 1017 |
<h3><?php _e( 'Menu Settings' ); ?></h3> |
1018 |
<?php |
|
1019 |
if ( ! isset( $auto_add ) ) { |
|
1020 |
$auto_add = get_option( 'nav_menu_options' ); |
|
16 | 1021 |
|
9 | 1022 |
if ( ! isset( $auto_add['auto_add'] ) ) { |
0 | 1023 |
$auto_add = false; |
16 | 1024 |
} elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'], true ) ) { |
0 | 1025 |
$auto_add = true; |
9 | 1026 |
} else { |
0 | 1027 |
$auto_add = false; |
9 | 1028 |
} |
1029 |
} |
|
1030 |
?> |
|
0 | 1031 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1032 |
<fieldset class="menu-settings-group auto-add-pages"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1033 |
<legend class="menu-settings-group-name howto"><?php _e( 'Auto add pages' ); ?></legend> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1034 |
<div class="menu-settings-input checkbox-input"> |
9 | 1035 |
<input type="checkbox"<?php checked( $auto_add ); ?> name="auto-add-pages" id="auto-add-pages" value="1" /> <label for="auto-add-pages"><?php printf( __( 'Automatically add new top-level pages to this menu' ), esc_url( admin_url( 'edit.php?post_type=page' ) ) ); ?></label> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1036 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1037 |
</fieldset> |
0 | 1038 |
|
1039 |
<?php if ( current_theme_supports( 'menus' ) ) : ?> |
|
1040 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1041 |
<fieldset class="menu-settings-group menu-theme-locations"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1042 |
<legend class="menu-settings-group-name howto"><?php _e( 'Display location' ); ?></legend> |
16 | 1043 |
<?php |
1044 |
foreach ( $locations as $location => $description ) : |
|
1045 |
$checked = isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] === $nav_menu_selected_id; |
|
1046 |
?> |
|
1047 |
<div class="menu-settings-input checkbox-input"> |
|
1048 |
<input type="checkbox"<?php checked( $checked ); ?> name="menu-locations[<?php echo esc_attr( $location ); ?>]" id="locations-<?php echo esc_attr( $location ); ?>" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
|
1049 |
<label for="locations-<?php echo esc_attr( $location ); ?>"><?php echo $description; ?></label> |
|
1050 |
<?php if ( ! empty( $menu_locations[ $location ] ) && $menu_locations[ $location ] !== $nav_menu_selected_id ) : ?> |
|
1051 |
<span class="theme-location-set"> |
|
1052 |
<?php |
|
1053 |
printf( |
|
1054 |
/* translators: %s: Menu name. */ |
|
1055 |
_x( '(Currently set to: %s)', 'menu location' ), |
|
1056 |
wp_get_nav_menu_object( $menu_locations[ $location ] )->name |
|
1057 |
); |
|
1058 |
?> |
|
1059 |
</span> |
|
1060 |
<?php endif; ?> |
|
1061 |
</div> |
|
0 | 1062 |
<?php endforeach; ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1063 |
</fieldset> |
0 | 1064 |
|
1065 |
<?php endif; ?> |
|
1066 |
||
1067 |
</div> |
|
1068 |
</div><!-- /#post-body-content --> |
|
1069 |
</div><!-- /#post-body --> |
|
1070 |
<div id="nav-menu-footer"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
<div class="major-publishing-actions wp-clearfix"> |
16 | 1072 |
<?php if ( $menu_count > 0 ) : ?> |
1073 |
||
1074 |
<?php if ( $add_new_screen ) : ?> |
|
1075 |
<span class="cancel-action"> |
|
1076 |
<a class="submitcancel cancellation menu-cancel" href="<?php echo esc_url( admin_url( 'nav-menus.php' ) ); ?>"><?php _e( 'Cancel' ); ?></a> |
|
1077 |
</span><!-- END .cancel-action --> |
|
1078 |
<?php else : ?> |
|
1079 |
<span class="delete-action"> |
|
1080 |
<a class="submitdelete deletion menu-delete" href=" |
|
1081 |
<?php |
|
1082 |
echo esc_url( |
|
1083 |
wp_nonce_url( |
|
1084 |
add_query_arg( |
|
1085 |
array( |
|
1086 |
'action' => 'delete', |
|
1087 |
'menu' => $nav_menu_selected_id, |
|
1088 |
), |
|
1089 |
admin_url( 'nav-menus.php' ) |
|
9 | 1090 |
), |
16 | 1091 |
'delete-nav_menu-' . $nav_menu_selected_id |
1092 |
) |
|
1093 |
); |
|
1094 |
?> |
|
1095 |
"><?php _e( 'Delete Menu' ); ?></a> |
|
1096 |
</span><!-- END .delete-action --> |
|
1097 |
<?php endif; ?> |
|
1098 |
||
0 | 1099 |
<?php endif; ?> |
1100 |
<div class="publishing-action"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1101 |
<?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'primary large menu-save', 'save_menu', false, array( 'id' => 'save_menu_footer' ) ); ?> |
0 | 1102 |
</div><!-- END .publishing-action --> |
1103 |
</div><!-- END .major-publishing-actions --> |
|
1104 |
</div><!-- /#nav-menu-footer --> |
|
1105 |
</div><!-- /.menu-edit --> |
|
1106 |
</form><!-- /#update-nav-menu --> |
|
1107 |
</div><!-- /#menu-management --> |
|
1108 |
</div><!-- /#menu-management-liquid --> |
|
1109 |
</div><!-- /#nav-menus-frame --> |
|
1110 |
<?php endif; ?> |
|
1111 |
</div><!-- /.wrap--> |
|
16 | 1112 |
<?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?> |