WordPress 4.4-scripts
[autoinstalls/wordpress.git] / wp-admin / nav-menus.php
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 */
13 require_once( dirname( __FILE__ ) . '/admin.php' );
14
15 // Load all the nav menu interface functions
16 require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
17
18 if ( ! current_theme_supports( 'menus' ) && ! current_theme_supports( 'widgets' ) )
19         wp_die( __( 'Your theme does not support navigation menus or widgets.' ) );
20
21 // Permissions Check
22 if ( ! current_user_can( 'edit_theme_options' ) ) {
23         wp_die(
24                 '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
25                 '<p>' . __( 'You are not allowed to edit theme options on this site.' ) . '</p>',
26                 403
27         );
28 }
29
30 wp_enqueue_script( 'nav-menu' );
31
32 if ( wp_is_mobile() )
33         wp_enqueue_script( 'jquery-touch-punch' );
34
35 // Container for any messages displayed to the user
36 $messages = array();
37
38 // Container that stores the name of the active menu
39 $nav_menu_selected_title = '';
40
41 // The menu id of the current menu being edited
42 $nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0;
43
44 // Get existing menu locations assignments
45 $locations = get_registered_nav_menus();
46 $menu_locations = get_nav_menu_locations();
47 $num_locations = count( array_keys( $locations ) );
48
49 // Allowed actions: add, update, delete
50 $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit';
51
52 switch ( $action ) {
53         case 'add-menu-item':
54                 check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' );
55                 if ( isset( $_REQUEST['nav-menu-locations'] ) )
56                         set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_REQUEST['menu-locations'] ) );
57                 elseif ( isset( $_REQUEST['menu-item'] ) )
58                         wp_save_nav_menu_items( $nav_menu_selected_id, $_REQUEST['menu-item'] );
59                 break;
60         case 'move-down-menu-item' :
61
62                 // Moving down a menu item is the same as moving up the next in order.
63                 check_admin_referer( 'move-menu_item' );
64                 $menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0;
65                 if ( is_nav_menu_item( $menu_item_id ) ) {
66                         $menus = isset( $_REQUEST['menu'] ) ? array( (int) $_REQUEST['menu'] ) : wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) );
67                         if ( ! is_wp_error( $menus ) && ! empty( $menus[0] ) ) {
68                                 $menu_id = (int) $menus[0];
69                                 $ordered_menu_items = wp_get_nav_menu_items( $menu_id );
70                                 $menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
71
72                                 // Set up the data we need in one pass through the array of menu items.
73                                 $dbids_to_orders = array();
74                                 $orders_to_dbids = array();
75                                 foreach ( (array) $ordered_menu_items as $ordered_menu_item_object ) {
76                                         if ( isset( $ordered_menu_item_object->ID ) ) {
77                                                 if ( isset( $ordered_menu_item_object->menu_order ) ) {
78                                                         $dbids_to_orders[$ordered_menu_item_object->ID] = $ordered_menu_item_object->menu_order;
79                                                         $orders_to_dbids[$ordered_menu_item_object->menu_order] = $ordered_menu_item_object->ID;
80                                                 }
81                                         }
82                                 }
83
84                                 // Get next in order.
85                                 if (
86                                         isset( $orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1] )
87                                 ) {
88                                         $next_item_id = $orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1];
89                                         $next_item_data = (array) wp_setup_nav_menu_item( get_post( $next_item_id ) );
90
91                                         // If not siblings of same parent, bubble menu item up but keep order.
92                                         if (
93                                                 ! empty( $menu_item_data['menu_item_parent'] ) &&
94                                                 (
95                                                         empty( $next_item_data['menu_item_parent'] ) ||
96                                                         $next_item_data['menu_item_parent'] != $menu_item_data['menu_item_parent']
97                                                 )
98                                         ) {
99
100                                                 $parent_db_id = in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) ? (int) $menu_item_data['menu_item_parent'] : 0;
101
102                                                 $parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) );
103
104                                                 if ( ! is_wp_error( $parent_object ) ) {
105                                                         $parent_data = (array) $parent_object;
106                                                         $menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent'];
107                                                         update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
108
109                                                 }
110
111                                         // Make menu item a child of its next sibling.
112                                         } else {
113                                                 $next_item_data['menu_order'] = $next_item_data['menu_order'] - 1;
114                                                 $menu_item_data['menu_order'] = $menu_item_data['menu_order'] + 1;
115
116                                                 $menu_item_data['menu_item_parent'] = $next_item_data['ID'];
117                                                 update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
118
119                                                 wp_update_post($menu_item_data);
120                                                 wp_update_post($next_item_data);
121                                         }
122
123                                 // The item is last but still has a parent, so bubble up.
124                                 } elseif (
125                                         ! empty( $menu_item_data['menu_item_parent'] ) &&
126                                         in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids )
127                                 ) {
128                                         $menu_item_data['menu_item_parent'] = (int) get_post_meta( $menu_item_data['menu_item_parent'], '_menu_item_menu_item_parent', true);
129                                         update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
130                                 }
131                         }
132                 }
133
134                 break;
135         case 'move-up-menu-item' :
136                 check_admin_referer( 'move-menu_item' );
137                 $menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0;
138                 if ( is_nav_menu_item( $menu_item_id ) ) {
139                         $menus = isset( $_REQUEST['menu'] ) ? array( (int) $_REQUEST['menu'] ) : wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) );
140                         if ( ! is_wp_error( $menus ) && ! empty( $menus[0] ) ) {
141                                 $menu_id = (int) $menus[0];
142                                 $ordered_menu_items = wp_get_nav_menu_items( $menu_id );
143                                 $menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
144
145                                 // Set up the data we need in one pass through the array of menu items.
146                                 $dbids_to_orders = array();
147                                 $orders_to_dbids = array();
148                                 foreach ( (array) $ordered_menu_items as $ordered_menu_item_object ) {
149                                         if ( isset( $ordered_menu_item_object->ID ) ) {
150                                                 if ( isset( $ordered_menu_item_object->menu_order ) ) {
151                                                         $dbids_to_orders[$ordered_menu_item_object->ID] = $ordered_menu_item_object->menu_order;
152                                                         $orders_to_dbids[$ordered_menu_item_object->menu_order] = $ordered_menu_item_object->ID;
153                                                 }
154                                         }
155                                 }
156
157                                 // If this menu item is not first.
158                                 if ( ! empty( $dbids_to_orders[$menu_item_id] ) && ! empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ) {
159
160                                         // If this menu item is a child of the previous.
161                                         if (
162                                                 ! empty( $menu_item_data['menu_item_parent'] ) &&
163                                                 in_array( $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ) ) &&
164                                                 isset( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) &&
165                                                 ( $menu_item_data['menu_item_parent'] == $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] )
166                                         ) {
167                                                 $parent_db_id = in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) ? (int) $menu_item_data['menu_item_parent'] : 0;
168                                                 $parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) );
169
170                                                 if ( ! is_wp_error( $parent_object ) ) {
171                                                         $parent_data = (array) $parent_object;
172
173                                                         /*
174                                                          * If there is something before the parent and parent a child of it,
175                                                          * make menu item a child also of it.
176                                                          */
177                                                         if (
178                                                                 ! empty( $dbids_to_orders[$parent_db_id] ) &&
179                                                                 ! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] ) &&
180                                                                 ! empty( $parent_data['menu_item_parent'] )
181                                                         ) {
182                                                                 $menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent'];
183
184                                                         /*
185                                                          * Else if there is something before parent and parent not a child of it,
186                                                          * make menu item a child of that something's parent
187                                                          */
188                                                         } elseif (
189                                                                 ! empty( $dbids_to_orders[$parent_db_id] ) &&
190                                                                 ! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] )
191                                                         ) {
192                                                                 $_possible_parent_id = (int) get_post_meta( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1], '_menu_item_menu_item_parent', true);
193                                                                 if ( in_array( $_possible_parent_id, array_keys( $dbids_to_orders ) ) )
194                                                                         $menu_item_data['menu_item_parent'] = $_possible_parent_id;
195                                                                 else
196                                                                         $menu_item_data['menu_item_parent'] = 0;
197
198                                                         // Else there isn't something before the parent.
199                                                         } else {
200                                                                 $menu_item_data['menu_item_parent'] = 0;
201                                                         }
202
203                                                         // Set former parent's [menu_order] to that of menu-item's.
204                                                         $parent_data['menu_order'] = $parent_data['menu_order'] + 1;
205
206                                                         // Set menu-item's [menu_order] to that of former parent.
207                                                         $menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1;
208
209                                                         // Save changes.
210                                                         update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
211                                                         wp_update_post($menu_item_data);
212                                                         wp_update_post($parent_data);
213                                                 }
214
215                                         // Else this menu item is not a child of the previous.
216                                         } elseif (
217                                                 empty( $menu_item_data['menu_order'] ) ||
218                                                 empty( $menu_item_data['menu_item_parent'] ) ||
219                                                 ! in_array( $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ) ) ||
220                                                 empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ||
221                                                 $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] != $menu_item_data['menu_item_parent']
222                                         ) {
223                                                 // Just make it a child of the previous; keep the order.
224                                                 $menu_item_data['menu_item_parent'] = (int) $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1];
225                                                 update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
226                                                 wp_update_post($menu_item_data);
227                                         }
228                                 }
229                         }
230                 }
231                 break;
232
233         case 'delete-menu-item':
234                 $menu_item_id = (int) $_REQUEST['menu-item'];
235
236                 check_admin_referer( 'delete-menu_item_' . $menu_item_id );
237
238                 if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) )
239                         $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('The menu item has been successfully deleted.') . '</p></div>';
240                 break;
241
242         case 'delete':
243                 check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id );
244                 if ( is_nav_menu( $nav_menu_selected_id ) ) {
245                         $deletion = wp_delete_nav_menu( $nav_menu_selected_id );
246                 } else {
247                         // Reset the selected menu.
248                         $nav_menu_selected_id = 0;
249                         unset( $_REQUEST['menu'] );
250                 }
251
252                 if ( ! isset( $deletion ) )
253                         break;
254
255                 if ( is_wp_error( $deletion ) )
256                         $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>';
257                 else
258                         $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'The menu has been successfully deleted.' ) . '</p></div>';
259                 break;
260
261         case 'delete_menus':
262                 check_admin_referer( 'nav_menus_bulk_actions' );
263                 foreach ( $_REQUEST['delete_menus'] as $menu_id_to_delete ) {
264                         if ( ! is_nav_menu( $menu_id_to_delete ) )
265                                 continue;
266
267                         $deletion = wp_delete_nav_menu( $menu_id_to_delete );
268                         if ( is_wp_error( $deletion ) ) {
269                                 $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>';
270                                 $deletion_error = true;
271                         }
272                 }
273
274                 if ( empty( $deletion_error ) )
275                         $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Selected menus have been successfully deleted.' ) . '</p></div>';
276                 break;
277
278         case 'update':
279                 check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
280
281                 // Remove menu locations that have been unchecked.
282                 foreach ( $locations as $location => $description ) {
283                         if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id )
284                                 unset( $menu_locations[ $location ] );
285                 }
286
287                 // Merge new and existing menu locations if any new ones are set.
288                 if ( isset( $_POST['menu-locations'] ) ) {
289                         $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
290                         $menu_locations = array_merge( $menu_locations, $new_menu_locations );
291                 }
292
293                 // Set menu locations.
294                 set_theme_mod( 'nav_menu_locations', $menu_locations );
295
296                 // Add Menu.
297                 if ( 0 == $nav_menu_selected_id ) {
298                         $new_menu_title = trim( esc_html( $_POST['menu-name'] ) );
299
300                         if ( $new_menu_title ) {
301                                 $_nav_menu_selected_id = wp_update_nav_menu_object( 0, array('menu-name' => $new_menu_title) );
302
303                                 if ( is_wp_error( $_nav_menu_selected_id ) ) {
304                                         $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
305                                 } else {
306                                         $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
307                                         $nav_menu_selected_id = $_nav_menu_selected_id;
308                                         $nav_menu_selected_title = $_menu_object->name;
309                                         if ( isset( $_REQUEST['menu-item'] ) )
310                                                 wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) );
311                                         if ( isset( $_REQUEST['zero-menu-state'] ) ) {
312                                                 // If there are menu items, add them
313                                                 wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title );
314                                                 // Auto-save nav_menu_locations
315                                                 $locations = get_nav_menu_locations();
316                                                 foreach ( $locations as $location => $menu_id ) {
317                                                                 $locations[ $location ] = $nav_menu_selected_id;
318                                                                 break; // There should only be 1
319                                                 }
320                                                 set_theme_mod( 'nav_menu_locations', $locations );
321                                         }
322                                         if ( isset( $_REQUEST['use-location'] ) ) {
323                                                 $locations = get_registered_nav_menus();
324                                                 $menu_locations = get_nav_menu_locations();
325                                                 if ( isset( $locations[ $_REQUEST['use-location'] ] ) )
326                                                         $menu_locations[ $_REQUEST['use-location'] ] = $nav_menu_selected_id;
327                                                 set_theme_mod( 'nav_menu_locations', $menu_locations );
328                                         }
329
330                                         // $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%s</strong> has been created.' ), $nav_menu_selected_title ) . '</p></div>';
331                                         wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) );
332                                         exit();
333                                 }
334                         } else {
335                                 $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>';
336                         }
337
338                 // Update existing menu.
339                 } else {
340
341                         $_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id );
342
343                         $menu_title = trim( esc_html( $_POST['menu-name'] ) );
344                         if ( ! $menu_title ) {
345                                 $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>';
346                                 $menu_title = $_menu_object->name;
347                         }
348
349                         if ( ! is_wp_error( $_menu_object ) ) {
350                                 $_nav_menu_selected_id = wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $menu_title ) );
351                                 if ( is_wp_error( $_nav_menu_selected_id ) ) {
352                                         $_menu_object = $_nav_menu_selected_id;
353                                         $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
354                                 } else {
355                                         $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
356                                         $nav_menu_selected_title = $_menu_object->name;
357                                 }
358                         }
359
360                         // Update menu items.
361                         if ( ! is_wp_error( $_menu_object ) ) {
362                                 $messages = array_merge( $messages, wp_nav_menu_update_menu_items( $_nav_menu_selected_id, $nav_menu_selected_title ) );
363
364                                 // If the menu ID changed, redirect to the new URL.
365                                 if ( $nav_menu_selected_id != $_nav_menu_selected_id ) {
366                                         wp_redirect( admin_url( 'nav-menus.php?menu=' . intval( $_nav_menu_selected_id ) ) );
367                                         exit();
368                                 }
369                         }
370                 }
371                 break;
372         case 'locations':
373                 if ( ! $num_locations ) {
374                         wp_redirect( admin_url( 'nav-menus.php' ) );
375                         exit();
376                 }
377
378                 add_filter( 'screen_options_show_screen', '__return_false' );
379
380                 if ( isset( $_POST['menu-locations'] ) ) {
381                         check_admin_referer( 'save-menu-locations' );
382
383                         $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
384                         $menu_locations = array_merge( $menu_locations, $new_menu_locations );
385                         // Set menu locations
386                         set_theme_mod( 'nav_menu_locations', $menu_locations );
387
388                         $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Menu locations updated.' ) . '</p></div>';
389                 }
390                 break;
391 }
392
393 // Get all nav menus.
394 $nav_menus = wp_get_nav_menus();
395 $menu_count = count( $nav_menus );
396
397 // Are we on the add new screen?
398 $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false;
399
400 $locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false;
401
402 /*
403  * If we have one theme location, and zero menus, we take them right
404  * into editing their first menu.
405  */
406 $page_count = wp_count_posts( 'page' );
407 $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
408
409 $nav_menus_l10n = array(
410         'oneThemeLocationNoMenus' => $one_theme_location_no_menus,
411         'moveUp'       => __( 'Move up one' ),
412         'moveDown'     => __( 'Move down one' ),
413         'moveToTop'    => __( 'Move to the top' ),
414         /* translators: %s: previous item name */
415         'moveUnder'    => __( 'Move under %s' ),
416         /* translators: %s: previous item name */
417         'moveOutFrom'  => __( 'Move out from under %s' ),
418         /* translators: %s: previous item name */
419         'under'        => __( 'Under %s' ),
420         /* translators: %s: previous item name */
421         'outFrom'      => __( 'Out from under %s' ),
422         /* translators: 1: item name, 2: item position, 3: total number of items */
423         'menuFocus'    => __( '%1$s. Menu item %2$d of %3$d.' ),
424         /* translators: 1: item name, 2: item position, 3: parent item name */
425         'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ),
426 );
427 wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n );
428
429 /*
430  * Redirect to add screen if there are no menus and this users has either zero,
431  * or more than 1 theme locations.
432  */
433 if ( 0 == $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus )
434         wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) );
435
436 // Get recently edited nav menu.
437 $recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) );
438 if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) )
439         $recently_edited = $nav_menu_selected_id;
440
441 // Use $recently_edited if none are selected.
442 if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) )
443         $nav_menu_selected_id = $recently_edited;
444
445 // On deletion of menu, if another menu exists, show it.
446 if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] )
447         $nav_menu_selected_id = $nav_menus[0]->term_id;
448
449 // Set $nav_menu_selected_id to 0 if no menus.
450 if ( $one_theme_location_no_menus ) {
451         $nav_menu_selected_id = 0;
452 } elseif ( empty( $nav_menu_selected_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) {
453         // if we have no selection yet, and we have menus, set to the first one in the list.
454         $nav_menu_selected_id = $nav_menus[0]->term_id;
455 }
456
457 // Update the user's setting.
458 if ( $nav_menu_selected_id != $recently_edited && is_nav_menu( $nav_menu_selected_id ) )
459         update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id );
460
461 // If there's a menu, get its name.
462 if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) {
463         $_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id );
464         $nav_menu_selected_title = ! is_wp_error( $_menu_object ) ? $_menu_object->name : '';
465 }
466
467 // Generate truncated menu names.
468 foreach ( (array) $nav_menus as $key => $_nav_menu ) {
469         $nav_menus[$key]->truncated_name = wp_html_excerpt( $_nav_menu->name, 40, '&hellip;' );
470 }
471
472 // Retrieve menu locations.
473 if ( current_theme_supports( 'menus' ) ) {
474         $locations = get_registered_nav_menus();
475         $menu_locations = get_nav_menu_locations();
476 }
477
478 /*
479  * Ensure the user will be able to scroll horizontally
480  * by adding a class for the max menu depth.
481  *
482  * @global int $_wp_nav_menu_max_depth
483  */
484 global $_wp_nav_menu_max_depth;
485 $_wp_nav_menu_max_depth = 0;
486
487 // Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth.
488 if ( is_nav_menu( $nav_menu_selected_id ) ) {
489         $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'post_status' => 'any' ) );
490         $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id );
491 }
492
493 /**
494  *
495  * @global int $_wp_nav_menu_max_depth
496  *
497  * @param string $classes
498  * @return string
499  */
500 function wp_nav_menu_max_depth( $classes ) {
501         global $_wp_nav_menu_max_depth;
502         return "$classes menu-max-depth-$_wp_nav_menu_max_depth";
503 }
504
505 add_filter('admin_body_class', 'wp_nav_menu_max_depth');
506
507 wp_nav_menu_setup();
508 wp_initial_nav_menu_meta_boxes();
509
510 if ( ! current_theme_supports( 'menus' ) && ! $num_locations )
511         $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( 'Your theme does not natively support menus, but you can use them in sidebars by adding a &#8220;Custom Menu&#8221; widget on the <a href="%s">Widgets</a> screen.' ), admin_url( 'widgets.php' ) ) . '</p></div>';
512
513 if ( ! $locations_screen ) : // Main tab
514         $overview  = '<p>' . __( 'This screen is used for managing your custom navigation menus.' ) . '</p>';
515         $overview .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme, even used in sidebars by adding a &#8220;Custom Menu&#8221; widget on the <a href="%1$s">Widgets</a> screen. If your theme does not support the custom 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.' ), admin_url( 'widgets.php' ), 'Twenty Fifteen', 'Twenty Fourteen' ) . '</p>';
516         $overview .= '<p>' . __( 'From this screen you can:' ) . '</p>';
517         $overview .= '<ul><li>' . __( 'Create, edit, and delete menus' ) . '</li>';
518         $overview .= '<li>' . __( 'Add, organize, and modify individual menu items' ) . '</li></ul>';
519
520         get_current_screen()->add_help_tab( array(
521                 'id'      => 'overview',
522                 'title'   => __( 'Overview' ),
523                 'content' => $overview
524         ) );
525
526         $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>';
527         $menu_management .= '<ul><li>' . __( 'To edit an existing menu, <strong>choose a menu from the drop down and click Select</strong>' ) . '</li>';
528         $menu_management .= '<li>' . __( 'If you haven&#8217;t yet created any menus, <strong>click the &#8217;create a new menu&#8217; link</strong> to get started' ) . '</li></ul>';
529         $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>';
530
531         get_current_screen()->add_help_tab( array(
532                 'id'      => 'menu-management',
533                 'title'   => __( 'Menu Management' ),
534                 'content' => $menu_management
535         ) );
536
537         $editing_menus  = '<p>' . __( 'Each custom 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>';
538         $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>';
539         $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>';
540         $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>';
541         $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>';
542         $editing_menus .= '<li>' . __( 'Delete a menu item by <strong>expanding it and clicking the Remove link</strong>' ) . '</li></ul>';
543
544         get_current_screen()->add_help_tab( array(
545                 'id'      => 'editing-menus',
546                 'title'   => __( 'Editing Menus' ),
547                 'content' => $editing_menus
548         ) );
549 else : // Locations Tab.
550         $locations_overview  = '<p>' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '</p>';
551         $locations_overview .= '<ul><li>' . __( 'To assign menus to one or more theme locations, <strong>select a menu from each location&#8217;s drop down.</strong> When you&#8217;re finished, <strong>click Save Changes</strong>' ) . '</li>';
552         $locations_overview .= '<li>' . __( 'To edit a menu currently assigned to a theme location, <strong>click the adjacent &#8217;Edit&#8217; link</strong>' ) . '</li>';
553         $locations_overview .= '<li>' . __( 'To add a new menu instead of assigning an existing one, <strong>click the &#8217;Use new menu&#8217; link</strong>. Your new menu will be automatically assigned to that theme location' ) . '</li></ul>';
554
555         get_current_screen()->add_help_tab( array(
556                 'id'      => 'locations-overview',
557                 'title'   => __( 'Overview' ),
558                 'content' => $locations_overview
559         ) );
560 endif;
561
562 get_current_screen()->set_help_sidebar(
563         '<p><strong>' . __('For more information:') . '</strong></p>' .
564         '<p>' . __('<a href="https://codex.wordpress.org/Appearance_Menus_Screen" target="_blank">Documentation on Menus</a>') . '</p>' .
565         '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
566 );
567
568 // Get the admin header.
569 require_once( ABSPATH . 'wp-admin/admin-header.php' );
570 ?>
571 <div class="wrap">
572         <h1><?php echo esc_html( __( 'Menus' ) ); ?>
573                 <?php
574                 if ( current_user_can( 'customize' ) ) :
575                         $focus = $locations_screen ? array( 'section' => 'menu_locations' ) : array( 'panel' => 'nav_menus' );
576                         printf(
577                                 ' <a class="page-title-action hide-if-no-customize" href="%1$s">%2$s</a>',
578                                 esc_url( add_query_arg( array(
579                                         array( 'autofocus' => $focus ),
580                                         'return' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
581                                 ), admin_url( 'customize.php' ) ) ),
582                                 __( 'Manage in Customizer' )
583                         );
584                 endif;
585                 ?>
586         </h1>
587         <h2 class="nav-tab-wrapper">
588                 <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a>
589                 <?php if ( $num_locations && $menu_count ) : ?>
590                         <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a>
591                 <?php
592                         endif;
593                 ?>
594         </h2>
595         <?php
596         foreach ( $messages as $message ) :
597                 echo $message . "\n";
598         endforeach;
599         ?>
600         <?php
601         if ( $locations_screen ) :
602                 if ( 1 == $num_locations ) {
603                         echo '<p>' . __( 'Your theme supports one menu. Select which menu you would like to use.' ) . '</p>';
604                 } else {
605                         echo '<p>' .  sprintf( _n( 'Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) ) . '</p>';
606                 }
607         ?>
608         <div id="menu-locations-wrap">
609                 <form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>">
610                         <table class="widefat fixed" id="menu-locations-table">
611                                 <thead>
612                                 <tr>
613                                         <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th>
614                                         <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th>
615                                 </tr>
616                                 </thead>
617                                 <tbody class="menu-locations">
618                                 <?php foreach ( $locations as $_location => $_name ) { ?>
619                                         <tr class="menu-locations-row">
620                                                 <td class="menu-location-title"><label for="locations-<?php echo $_location; ?>"><?php echo $_name; ?></label></td>
621                                                 <td class="menu-location-menus">
622                                                         <select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>">
623                                                                 <option value="0"><?php printf( '&mdash; %s &mdash;', esc_html__( 'Select a Menu' ) ); ?></option>
624                                                                 <?php foreach ( $nav_menus as $menu ) : ?>
625                                                                         <?php $selected = isset( $menu_locations[$_location] ) && $menu_locations[$_location] == $menu->term_id; ?>
626                                                                         <option <?php if ( $selected ) echo 'data-orig="true"'; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>">
627                                                                                 <?php echo wp_html_excerpt( $menu->name, 40, '&hellip;' ); ?>
628                                                                         </option>
629                                                                 <?php endforeach; ?>
630                                                         </select>
631                                                         <div class="locations-row-links">
632                                                                 <?php if ( isset( $menu_locations[ $_location ] ) && 0 != $menu_locations[ $_location ] ) : ?>
633                                                                 <span class="locations-edit-menu-link">
634                                                                         <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => $menu_locations[$_location] ), admin_url( 'nav-menus.php' ) ) ); ?>">
635                                                                                 <span aria-hidden="true"><?php _ex( 'Edit', 'menu' ); ?></span><span class="screen-reader-text"><?php _e( 'Edit selected menu' ); ?></span>
636                                                                         </a>
637                                                                 </span>
638                                                                 <?php endif; ?>
639                                                                 <span class="locations-add-menu-link">
640                                                                         <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0, 'use-location' => $_location ), admin_url( 'nav-menus.php' ) ) ); ?>">
641                                                                                 <?php _ex( 'Use new menu', 'menu' ); ?>
642                                                                         </a>
643                                                                 </span>
644                                                         </div><!-- .locations-row-links -->
645                                                 </td><!-- .menu-location-menus -->
646                                         </tr><!-- .menu-locations-row -->
647                                 <?php } // foreach ?>
648                                 </tbody>
649                         </table>
650                         <p class="button-controls"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p>
651                         <?php wp_nonce_field( 'save-menu-locations' ); ?>
652                         <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
653                 </form>
654         </div><!-- #menu-locations-wrap -->
655         <?php
656         /**
657          * Fires after the menu locations table is displayed.
658          *
659          * @since 3.6.0
660          */
661         do_action( 'after_menu_locations_table' ); ?>
662         <?php else : ?>
663         <div class="manage-menus">
664                 <?php if ( $menu_count < 2 ) : ?>
665                 <span class="add-edit-menu-action">
666                         <?php printf( __( 'Edit your menu below, or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?>
667                 </span><!-- /add-edit-menu-action -->
668                 <?php else : ?>
669                         <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>">
670                         <input type="hidden" name="action" value="edit" />
671                         <label for="select-menu-to-edit" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label>
672                         <select name="menu" id="select-menu-to-edit">
673                                 <?php if ( $add_new_screen ) : ?>
674                                         <option value="0" selected="selected"><?php _e( '&mdash; Select &mdash;' ); ?></option>
675                                 <?php endif; ?>
676                                 <?php foreach ( (array) $nav_menus as $_nav_menu ) : ?>
677                                         <option value="<?php echo esc_attr( $_nav_menu->term_id ); ?>" <?php selected( $_nav_menu->term_id, $nav_menu_selected_id ); ?>>
678                                                 <?php
679                                                 echo esc_html( $_nav_menu->truncated_name ) ;
680
681                                                 if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations ) ) {
682                                                         $locations_assigned_to_this_menu = array();
683                                                         foreach ( array_keys( $menu_locations, $_nav_menu->term_id ) as $menu_location_key ) {
684                                                                 if ( isset( $locations[ $menu_location_key ] ) ) {
685                                                                         $locations_assigned_to_this_menu[] = $locations[ $menu_location_key ];
686                                                                 }
687                                                         }
688
689                                                         /**
690                                                          * Filter the number of locations listed per menu in the drop-down select.
691                                                          *
692                                                          * @since 3.6.0
693                                                          *
694                                                          * @param int $locations Number of menu locations to list. Default 3.
695                                                          */
696                                                         $assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ) );
697
698                                                         // Adds ellipses following the number of locations defined in $assigned_locations.
699                                                         if ( ! empty( $assigned_locations ) ) {
700                                                                 printf( ' (%1$s%2$s)',
701                                                                         implode( ', ', $assigned_locations ),
702                                                                         count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' &hellip;' : ''
703                                                                 );
704                                                         }
705                                                 }
706                                                 ?>
707                                         </option>
708                                 <?php endforeach; ?>
709                         </select>
710                         <span class="submit-btn"><input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Select' ); ?>"></span>
711                         <span class="add-new-menu-action">
712                                 <?php printf( __( 'or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?>
713                         </span><!-- /add-new-menu-action -->
714                 </form>
715         <?php endif; ?>
716         </div><!-- /manage-menus -->
717         <div id="nav-menus-frame">
718         <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) { echo ' metabox-holder-disabled'; } ?>">
719
720                 <div class="clear"></div>
721
722                 <form id="nav-menu-meta" class="nav-menu-meta" method="post" enctype="multipart/form-data">
723                         <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
724                         <input type="hidden" name="action" value="add-menu-item" />
725                         <?php wp_nonce_field( 'add-menu_item', 'menu-settings-column-nonce' ); ?>
726                         <?php do_accordion_sections( 'nav-menus', 'side', null ); ?>
727                 </form>
728
729         </div><!-- /#menu-settings-column -->
730         <div id="menu-management-liquid">
731                 <div id="menu-management">
732                         <form id="update-nav-menu" method="post" enctype="multipart/form-data">
733                                 <div class="menu-edit <?php if ( $add_new_screen ) echo 'blank-slate'; ?>">
734                                         <?php
735                                         wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
736                                         wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
737                                         wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' );
738
739                                         if ( $one_theme_location_no_menus ) { ?>
740                                                 <input type="hidden" name="zero-menu-state" value="true" />
741                                         <?php } ?>
742                                         <input type="hidden" name="action" value="update" />
743                                         <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
744                                         <div id="nav-menu-header">
745                                                 <div class="major-publishing-actions">
746                                                         <label class="menu-name-label howto open-label" for="menu-name">
747                                                                 <span><?php _e( 'Menu Name' ); ?></span>
748                                                                 <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e( 'Enter menu name here' ); ?>" value="<?php if ( $one_theme_location_no_menus ) _e( 'Menu 1' ); else echo esc_attr( $nav_menu_selected_title ); ?>" />
749                                                         </label>
750                                                         <div class="publishing-action">
751                                                                 <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?>
752                                                         </div><!-- END .publishing-action -->
753                                                 </div><!-- END .major-publishing-actions -->
754                                         </div><!-- END .nav-menu-header -->
755                                         <div id="post-body">
756                                                 <div id="post-body-content">
757                                                         <?php if ( ! $add_new_screen ) : ?>
758                                                         <h3><?php _e( 'Menu Structure' ); ?></h3>
759                                                         <?php $starter_copy = ( $one_theme_location_no_menus ) ? __( 'Edit your default menu by adding or removing items. Drag each item into the order you prefer. Click Create Menu to save your changes.' ) : __( 'Drag each item into the order you prefer. Click the arrow on the right of the item to reveal additional configuration options.' ); ?>
760                                                         <div class="drag-instructions post-body-plain" <?php if ( isset( $menu_items ) && 0 == count( $menu_items ) ) { ?>style="display: none;"<?php } ?>>
761                                                                 <p><?php echo $starter_copy; ?></p>
762                                                         </div>
763                                                         <?php
764                                                         if ( isset( $edit_markup ) && ! is_wp_error( $edit_markup ) ) {
765                                                                 echo $edit_markup;
766                                                         } else {
767                                                         ?>
768                                                         <ul class="menu" id="menu-to-edit"></ul>
769                                                         <?php } ?>
770                                                         <?php endif; ?>
771                                                         <?php if ( $add_new_screen ) : ?>
772                                                                 <p class="post-body-plain"><?php _e( 'Give your menu a name above, then click Create Menu.' ); ?></p>
773                                                                 <?php if ( isset( $_GET['use-location'] ) ) : ?>
774                                                                         <input type="hidden" name="use-location" value="<?php echo esc_attr( $_GET['use-location'] ); ?>" />
775                                                                 <?php endif; ?>
776                                                         <?php endif; ?>
777                                                         <div class="menu-settings" <?php if ( $one_theme_location_no_menus ) { ?>style="display: none;"<?php } ?>>
778                                                                 <h3><?php _e( 'Menu Settings' ); ?></h3>
779                                                                 <?php
780                                                                 if ( ! isset( $auto_add ) ) {
781                                                                         $auto_add = get_option( 'nav_menu_options' );
782                                                                         if ( ! isset( $auto_add['auto_add'] ) )
783                                                                                 $auto_add = false;
784                                                                         elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'] ) )
785                                                                                 $auto_add = true;
786                                                                         else
787                                                                                 $auto_add = false;
788                                                                 } ?>
789
790                                                                 <dl class="auto-add-pages">
791                                                                         <dt class="howto"><?php _e( 'Auto add pages' ); ?></dt>
792                                                                         <dd class="checkbox-input"><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></dd>
793                                                                 </dl>
794
795                                                                 <?php if ( current_theme_supports( 'menus' ) ) : ?>
796
797                                                                         <dl class="menu-theme-locations">
798                                                                                 <dt class="howto"><?php _e( 'Theme locations' ); ?></dt>
799                                                                                 <?php foreach ( $locations as $location => $description ) : ?>
800                                                                                 <dd class="checkbox-input">
801                                                                                         <input type="checkbox"<?php checked( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ); ?> name="menu-locations[<?php echo esc_attr( $location ); ?>]" id="locations-<?php echo esc_attr( $location ); ?>" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
802                                                                                         <label for="locations-<?php echo esc_attr( $location ); ?>"><?php echo $description; ?></label>
803                                                                                         <?php if ( ! empty( $menu_locations[ $location ] ) && $menu_locations[ $location ] != $nav_menu_selected_id ) : ?>
804                                                                                                 <span class="theme-location-set"><?php 
805                                                                                                         /* translators: %s: menu name */
806                                                                                                         printf( _x( '(Currently set to: %s)', 'menu location' ),
807                                                                                                                 wp_get_nav_menu_object( $menu_locations[ $location ] )->name
808                                                                                                         );
809                                                                                                 ?></span>
810                                                                                         <?php endif; ?>
811                                                                                 </dd>
812                                                                                 <?php endforeach; ?>
813                                                                         </dl>
814
815                                                                 <?php endif; ?>
816
817                                                         </div>
818                                                 </div><!-- /#post-body-content -->
819                                         </div><!-- /#post-body -->
820                                         <div id="nav-menu-footer">
821                                                 <div class="major-publishing-actions">
822                                                         <?php if ( 0 != $menu_count && ! $add_new_screen ) : ?>
823                                                         <span class="delete-action">
824                                                                 <a class="submitdelete deletion menu-delete" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'menu' => $nav_menu_selected_id, admin_url() ) ), 'delete-nav_menu-' . $nav_menu_selected_id) ); ?>"><?php _e('Delete Menu'); ?></a>
825                                                         </span><!-- END .delete-action -->
826                                                         <?php endif; ?>
827                                                         <div class="publishing-action">
828                                                                 <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_footer' ) ); ?>
829                                                         </div><!-- END .publishing-action -->
830                                                 </div><!-- END .major-publishing-actions -->
831                                         </div><!-- /#nav-menu-footer -->
832                                 </div><!-- /.menu-edit -->
833                         </form><!-- /#update-nav-menu -->
834                 </div><!-- /#menu-management -->
835         </div><!-- /#menu-management-liquid -->
836         </div><!-- /#nav-menus-frame -->
837         <?php endif; ?>
838 </div><!-- /.wrap-->
839 <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>