author | ymh <ymh.work@gmail.com> |
Wed, 21 Sep 2022 18:19:35 +0200 | |
changeset 18 | be944660c56a |
parent 16 | a86126ab1dd4 |
child 19 | 3d72ae0968f4 |
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. |
18 | 319 |
$new_menu_locations = array(); |
0 | 320 |
if ( isset( $_POST['menu-locations'] ) ) { |
321 |
$new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); |
|
9 | 322 |
$menu_locations = array_merge( $menu_locations, $new_menu_locations ); |
0 | 323 |
} |
324 |
||
5 | 325 |
// Add Menu. |
16 | 326 |
if ( 0 === $nav_menu_selected_id ) { |
0 | 327 |
$new_menu_title = trim( esc_html( $_POST['menu-name'] ) ); |
328 |
||
329 |
if ( $new_menu_title ) { |
|
9 | 330 |
$_nav_menu_selected_id = wp_update_nav_menu_object( 0, array( 'menu-name' => $new_menu_title ) ); |
0 | 331 |
|
332 |
if ( is_wp_error( $_nav_menu_selected_id ) ) { |
|
5 | 333 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>'; |
0 | 334 |
} else { |
9 | 335 |
$_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id ); |
336 |
$nav_menu_selected_id = $_nav_menu_selected_id; |
|
0 | 337 |
$nav_menu_selected_title = $_menu_object->name; |
16 | 338 |
|
9 | 339 |
if ( isset( $_REQUEST['menu-item'] ) ) { |
0 | 340 |
wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) ); |
9 | 341 |
} |
16 | 342 |
|
343 |
if ( isset( $_REQUEST['zero-menu-state'] ) || ! empty( $_POST['auto-add-pages'] ) ) { |
|
344 |
// If there are menu items, add them. |
|
0 | 345 |
wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ); |
16 | 346 |
} |
347 |
||
348 |
if ( isset( $_REQUEST['zero-menu-state'] ) ) { |
|
349 |
// Auto-save nav_menu_locations. |
|
0 | 350 |
$locations = get_nav_menu_locations(); |
16 | 351 |
|
0 | 352 |
foreach ( $locations as $location => $menu_id ) { |
353 |
$locations[ $location ] = $nav_menu_selected_id; |
|
16 | 354 |
break; // There should only be 1. |
0 | 355 |
} |
16 | 356 |
|
0 | 357 |
set_theme_mod( 'nav_menu_locations', $locations ); |
18 | 358 |
} elseif ( count( $new_menu_locations ) > 0 ) { |
359 |
// If locations have been selected for the new menu, save those. |
|
360 |
$locations = get_nav_menu_locations(); |
|
361 |
||
362 |
foreach ( array_keys( $new_menu_locations ) as $location ) { |
|
363 |
$locations[ $location ] = $nav_menu_selected_id; |
|
364 |
} |
|
365 |
||
366 |
set_theme_mod( 'nav_menu_locations', $locations ); |
|
0 | 367 |
} |
16 | 368 |
|
0 | 369 |
if ( isset( $_REQUEST['use-location'] ) ) { |
9 | 370 |
$locations = get_registered_nav_menus(); |
0 | 371 |
$menu_locations = get_nav_menu_locations(); |
16 | 372 |
|
9 | 373 |
if ( isset( $locations[ $_REQUEST['use-location'] ] ) ) { |
0 | 374 |
$menu_locations[ $_REQUEST['use-location'] ] = $nav_menu_selected_id; |
9 | 375 |
} |
16 | 376 |
|
0 | 377 |
set_theme_mod( 'nav_menu_locations', $menu_locations ); |
378 |
} |
|
5 | 379 |
|
0 | 380 |
wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) ); |
16 | 381 |
exit; |
0 | 382 |
} |
383 |
} else { |
|
5 | 384 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>'; |
0 | 385 |
} |
386 |
||
9 | 387 |
// Update existing menu. |
0 | 388 |
} else { |
16 | 389 |
// Remove menu locations that have been unchecked. |
390 |
foreach ( $locations as $location => $description ) { |
|
391 |
if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) |
|
392 |
&& isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] === $nav_menu_selected_id |
|
393 |
) { |
|
394 |
unset( $menu_locations[ $location ] ); |
|
395 |
} |
|
396 |
} |
|
397 |
||
398 |
// Set menu locations. |
|
399 |
set_theme_mod( 'nav_menu_locations', $menu_locations ); |
|
0 | 400 |
|
401 |
$_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); |
|
402 |
||
403 |
$menu_title = trim( esc_html( $_POST['menu-name'] ) ); |
|
16 | 404 |
|
0 | 405 |
if ( ! $menu_title ) { |
5 | 406 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>'; |
0 | 407 |
$menu_title = $_menu_object->name; |
408 |
} |
|
409 |
||
410 |
if ( ! is_wp_error( $_menu_object ) ) { |
|
411 |
$_nav_menu_selected_id = wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $menu_title ) ); |
|
16 | 412 |
|
0 | 413 |
if ( is_wp_error( $_nav_menu_selected_id ) ) { |
414 |
$_menu_object = $_nav_menu_selected_id; |
|
9 | 415 |
$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>'; |
0 | 416 |
} else { |
9 | 417 |
$_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id ); |
0 | 418 |
$nav_menu_selected_title = $_menu_object->name; |
419 |
} |
|
420 |
} |
|
421 |
||
5 | 422 |
// Update menu items. |
0 | 423 |
if ( ! is_wp_error( $_menu_object ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
$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
|
425 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
// If the menu ID changed, redirect to the new URL. |
16 | 427 |
if ( $nav_menu_selected_id !== $_nav_menu_selected_id ) { |
18 | 428 |
wp_redirect( admin_url( 'nav-menus.php?menu=' . (int) $_nav_menu_selected_id ) ); |
16 | 429 |
exit; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
} |
0 | 431 |
} |
432 |
} |
|
16 | 433 |
|
0 | 434 |
break; |
16 | 435 |
|
0 | 436 |
case 'locations': |
437 |
if ( ! $num_locations ) { |
|
438 |
wp_redirect( admin_url( 'nav-menus.php' ) ); |
|
16 | 439 |
exit; |
0 | 440 |
} |
441 |
||
442 |
add_filter( 'screen_options_show_screen', '__return_false' ); |
|
443 |
||
444 |
if ( isset( $_POST['menu-locations'] ) ) { |
|
445 |
check_admin_referer( 'save-menu-locations' ); |
|
446 |
||
447 |
$new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); |
|
9 | 448 |
$menu_locations = array_merge( $menu_locations, $new_menu_locations ); |
16 | 449 |
// Set menu locations. |
0 | 450 |
set_theme_mod( 'nav_menu_locations', $menu_locations ); |
451 |
||
5 | 452 |
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Menu locations updated.' ) . '</p></div>'; |
0 | 453 |
} |
16 | 454 |
|
0 | 455 |
break; |
456 |
} |
|
457 |
||
5 | 458 |
// Get all nav menus. |
9 | 459 |
$nav_menus = wp_get_nav_menus(); |
0 | 460 |
$menu_count = count( $nav_menus ); |
461 |
||
462 |
// Are we on the add new screen? |
|
16 | 463 |
$add_new_screen = ( isset( $_GET['menu'] ) && 0 === (int) $_GET['menu'] ) ? true : false; |
0 | 464 |
|
16 | 465 |
$locations_screen = ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] ) ? true : false; |
466 |
||
467 |
$page_count = wp_count_posts( 'page' ); |
|
0 | 468 |
|
5 | 469 |
/* |
470 |
* If we have one theme location, and zero menus, we take them right |
|
471 |
* into editing their first menu. |
|
472 |
*/ |
|
16 | 473 |
if ( 1 === count( get_registered_nav_menus() ) && ! $add_new_screen |
474 |
&& empty( $nav_menus ) && ! empty( $page_count->publish ) |
|
475 |
) { |
|
476 |
$one_theme_location_no_menus = true; |
|
477 |
} else { |
|
478 |
$one_theme_location_no_menus = false; |
|
479 |
} |
|
0 | 480 |
|
481 |
$nav_menus_l10n = array( |
|
482 |
'oneThemeLocationNoMenus' => $one_theme_location_no_menus, |
|
9 | 483 |
'moveUp' => __( 'Move up one' ), |
484 |
'moveDown' => __( 'Move down one' ), |
|
485 |
'moveToTop' => __( 'Move to the top' ), |
|
16 | 486 |
/* translators: %s: Previous item name. */ |
9 | 487 |
'moveUnder' => __( 'Move under %s' ), |
16 | 488 |
/* translators: %s: Previous item name. */ |
9 | 489 |
'moveOutFrom' => __( 'Move out from under %s' ), |
16 | 490 |
/* translators: %s: Previous item name. */ |
9 | 491 |
'under' => __( 'Under %s' ), |
16 | 492 |
/* translators: %s: Previous item name. */ |
9 | 493 |
'outFrom' => __( 'Out from under %s' ), |
16 | 494 |
/* translators: 1: Item name, 2: Item position, 3: Total number of items. */ |
9 | 495 |
'menuFocus' => __( '%1$s. Menu item %2$d of %3$d.' ), |
16 | 496 |
/* translators: 1: Item name, 2: Item position, 3: Parent item name. */ |
9 | 497 |
'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ), |
18 | 498 |
/* translators: %s: Item name. */ |
499 |
'menuItemDeletion' => __( 'item %s' ), |
|
500 |
/* translators: %s: Item name. */ |
|
501 |
'itemsDeleted' => __( 'Deleted menu item: %s.' ), |
|
0 | 502 |
); |
503 |
wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n ); |
|
504 |
||
5 | 505 |
/* |
506 |
* Redirect to add screen if there are no menus and this users has either zero, |
|
507 |
* or more than 1 theme locations. |
|
508 |
*/ |
|
16 | 509 |
if ( 0 === $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus ) { |
0 | 510 |
wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) ); |
9 | 511 |
} |
0 | 512 |
|
5 | 513 |
// Get recently edited nav menu. |
0 | 514 |
$recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) ); |
9 | 515 |
if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) ) { |
0 | 516 |
$recently_edited = $nav_menu_selected_id; |
9 | 517 |
} |
0 | 518 |
|
5 | 519 |
// Use $recently_edited if none are selected. |
9 | 520 |
if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) { |
0 | 521 |
$nav_menu_selected_id = $recently_edited; |
9 | 522 |
} |
0 | 523 |
|
5 | 524 |
// On deletion of menu, if another menu exists, show it. |
16 | 525 |
if ( ! $add_new_screen && $menu_count > 0 && isset( $_GET['action'] ) && 'delete' === $_GET['action'] ) { |
0 | 526 |
$nav_menu_selected_id = $nav_menus[0]->term_id; |
9 | 527 |
} |
0 | 528 |
|
5 | 529 |
// Set $nav_menu_selected_id to 0 if no menus. |
0 | 530 |
if ( $one_theme_location_no_menus ) { |
531 |
$nav_menu_selected_id = 0; |
|
532 |
} elseif ( empty( $nav_menu_selected_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) { |
|
16 | 533 |
// If we have no selection yet, and we have menus, set to the first one in the list. |
0 | 534 |
$nav_menu_selected_id = $nav_menus[0]->term_id; |
535 |
} |
|
536 |
||
5 | 537 |
// Update the user's setting. |
16 | 538 |
if ( $nav_menu_selected_id !== $recently_edited && is_nav_menu( $nav_menu_selected_id ) ) { |
0 | 539 |
update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id ); |
9 | 540 |
} |
0 | 541 |
|
542 |
// If there's a menu, get its name. |
|
543 |
if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) { |
|
9 | 544 |
$_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); |
0 | 545 |
$nav_menu_selected_title = ! is_wp_error( $_menu_object ) ? $_menu_object->name : ''; |
546 |
} |
|
547 |
||
5 | 548 |
// Generate truncated menu names. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
foreach ( (array) $nav_menus as $key => $_nav_menu ) { |
9 | 550 |
$nav_menus[ $key ]->truncated_name = wp_html_excerpt( $_nav_menu->name, 40, '…' ); |
0 | 551 |
} |
552 |
||
5 | 553 |
// Retrieve menu locations. |
0 | 554 |
if ( current_theme_supports( 'menus' ) ) { |
9 | 555 |
$locations = get_registered_nav_menus(); |
0 | 556 |
$menu_locations = get_nav_menu_locations(); |
557 |
} |
|
558 |
||
5 | 559 |
/* |
560 |
* Ensure the user will be able to scroll horizontally |
|
561 |
* 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
|
562 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
* @global int $_wp_nav_menu_max_depth |
5 | 564 |
*/ |
0 | 565 |
global $_wp_nav_menu_max_depth; |
566 |
$_wp_nav_menu_max_depth = 0; |
|
567 |
||
5 | 568 |
// Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth. |
0 | 569 |
if ( is_nav_menu( $nav_menu_selected_id ) ) { |
9 | 570 |
$menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'post_status' => 'any' ) ); |
0 | 571 |
$edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); |
572 |
} |
|
573 |
||
7
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 |
* @global int $_wp_nav_menu_max_depth |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
577 |
* @param string $classes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
579 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
function wp_nav_menu_max_depth( $classes ) { |
0 | 581 |
global $_wp_nav_menu_max_depth; |
582 |
return "$classes menu-max-depth-$_wp_nav_menu_max_depth"; |
|
583 |
} |
|
584 |
||
9 | 585 |
add_filter( 'admin_body_class', 'wp_nav_menu_max_depth' ); |
0 | 586 |
|
587 |
wp_nav_menu_setup(); |
|
588 |
wp_initial_nav_menu_meta_boxes(); |
|
589 |
||
9 | 590 |
if ( ! current_theme_supports( 'menus' ) && ! $num_locations ) { |
16 | 591 |
$messages[] = '<div id="message" class="updated"><p>' . sprintf( |
592 |
/* translators: %s: URL to Widgets screen. */ |
|
593 |
__( '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.' ), |
|
594 |
admin_url( 'widgets.php' ) |
|
595 |
) . '</p></div>'; |
|
9 | 596 |
} |
0 | 597 |
|
16 | 598 |
if ( ! $locations_screen ) : // Main tab. |
599 |
$overview = '<p>' . __( 'This screen is used for managing your navigation menus.' ) . '</p>'; |
|
600 |
$overview .= '<p>' . sprintf( |
|
601 |
/* translators: 1: URL to Widgets screen, 2 and 3: The names of the default themes. */ |
|
602 |
__( '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.' ), |
|
603 |
admin_url( 'widgets.php' ), |
|
18 | 604 |
'Twenty Twenty', |
605 |
'Twenty Twenty-One' |
|
16 | 606 |
) . '</p>'; |
0 | 607 |
$overview .= '<p>' . __( 'From this screen you can:' ) . '</p>'; |
608 |
$overview .= '<ul><li>' . __( 'Create, edit, and delete menus' ) . '</li>'; |
|
609 |
$overview .= '<li>' . __( 'Add, organize, and modify individual menu items' ) . '</li></ul>'; |
|
610 |
||
9 | 611 |
get_current_screen()->add_help_tab( |
612 |
array( |
|
613 |
'id' => 'overview', |
|
614 |
'title' => __( 'Overview' ), |
|
615 |
'content' => $overview, |
|
616 |
) |
|
617 |
); |
|
0 | 618 |
|
619 |
$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>'; |
|
620 |
$menu_management .= '<ul><li>' . __( 'To edit an existing menu, <strong>choose a menu from the drop down and click Select</strong>' ) . '</li>'; |
|
621 |
$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>'; |
|
622 |
$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>'; |
|
623 |
||
9 | 624 |
get_current_screen()->add_help_tab( |
625 |
array( |
|
626 |
'id' => 'menu-management', |
|
627 |
'title' => __( 'Menu Management' ), |
|
628 |
'content' => $menu_management, |
|
629 |
) |
|
630 |
); |
|
0 | 631 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
632 |
$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 | 633 |
$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>'; |
634 |
$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 | 635 |
$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 | 636 |
$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>'; |
637 |
$editing_menus .= '<li>' . __( 'Delete a menu item by <strong>expanding it and clicking the Remove link</strong>' ) . '</li></ul>'; |
|
638 |
||
9 | 639 |
get_current_screen()->add_help_tab( |
640 |
array( |
|
641 |
'id' => 'editing-menus', |
|
642 |
'title' => __( 'Editing Menus' ), |
|
643 |
'content' => $editing_menus, |
|
644 |
) |
|
645 |
); |
|
16 | 646 |
else : // Locations tab. |
0 | 647 |
$locations_overview = '<p>' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '</p>'; |
648 |
$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>'; |
|
649 |
$locations_overview .= '<li>' . __( 'To edit a menu currently assigned to a theme location, <strong>click the adjacent ’Edit’ link</strong>' ) . '</li>'; |
|
650 |
$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>'; |
|
651 |
||
9 | 652 |
get_current_screen()->add_help_tab( |
653 |
array( |
|
654 |
'id' => 'locations-overview', |
|
655 |
'title' => __( 'Overview' ), |
|
656 |
'content' => $locations_overview, |
|
657 |
) |
|
658 |
); |
|
0 | 659 |
endif; |
660 |
||
661 |
get_current_screen()->set_help_sidebar( |
|
9 | 662 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
16 | 663 |
'<p>' . __( '<a href="https://wordpress.org/support/article/appearance-menus-screen/">Documentation on Menus</a>' ) . '</p>' . |
9 | 664 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
0 | 665 |
); |
666 |
||
5 | 667 |
// Get the admin header. |
16 | 668 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
0 | 669 |
?> |
670 |
<div class="wrap"> |
|
18 | 671 |
<h1 class="wp-heading-inline"><?php esc_html_e( 'Menus' ); ?></h1> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
if ( current_user_can( 'customize' ) ) : |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
674 |
$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
|
675 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
676 |
' <a class="page-title-action hide-if-no-customize" href="%1$s">%2$s</a>', |
9 | 677 |
esc_url( |
678 |
add_query_arg( |
|
679 |
array( |
|
680 |
array( 'autofocus' => $focus ), |
|
681 |
'return' => urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), |
|
682 |
), |
|
683 |
admin_url( 'customize.php' ) |
|
684 |
) |
|
685 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
686 |
__( 'Manage with Live Preview' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
688 |
endif; |
9 | 689 |
|
690 |
$nav_tab_active_class = ''; |
|
691 |
$nav_aria_current = ''; |
|
16 | 692 |
|
693 |
if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' !== $_GET['action'] ) { |
|
9 | 694 |
$nav_tab_active_class = ' nav-tab-active'; |
695 |
$nav_aria_current = ' aria-current="page"'; |
|
696 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
<hr class="wp-header-end"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
|
9 | 701 |
<nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> |
18 | 702 |
<a href="<?php echo esc_url( 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
|
703 |
<?php |
9 | 704 |
if ( $num_locations && $menu_count ) { |
705 |
$active_tab_class = ''; |
|
706 |
$aria_current = ''; |
|
16 | 707 |
|
9 | 708 |
if ( $locations_screen ) { |
709 |
$active_tab_class = ' nav-tab-active'; |
|
710 |
$aria_current = ' aria-current="page"'; |
|
711 |
} |
|
712 |
?> |
|
713 |
<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> |
|
714 |
<?php |
|
715 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
716 |
?> |
9 | 717 |
</nav> |
0 | 718 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
719 |
foreach ( $messages as $message ) : |
0 | 720 |
echo $message . "\n"; |
721 |
endforeach; |
|
722 |
?> |
|
723 |
<?php |
|
724 |
if ( $locations_screen ) : |
|
16 | 725 |
if ( 1 === $num_locations ) { |
5 | 726 |
echo '<p>' . __( 'Your theme supports one menu. Select which menu you would like to use.' ) . '</p>'; |
727 |
} else { |
|
16 | 728 |
echo '<p>' . sprintf( |
729 |
/* translators: %s: Number of menus. */ |
|
730 |
_n( |
|
731 |
'Your theme supports %s menu. Select which menu appears in each location.', |
|
732 |
'Your theme supports %s menus. Select which menu appears in each location.', |
|
733 |
$num_locations |
|
734 |
), |
|
735 |
number_format_i18n( $num_locations ) |
|
736 |
) . '</p>'; |
|
5 | 737 |
} |
9 | 738 |
?> |
0 | 739 |
<div id="menu-locations-wrap"> |
740 |
<form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>"> |
|
5 | 741 |
<table class="widefat fixed" id="menu-locations-table"> |
0 | 742 |
<thead> |
743 |
<tr> |
|
744 |
<th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th> |
|
745 |
<th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th> |
|
746 |
</tr> |
|
747 |
</thead> |
|
748 |
<tbody class="menu-locations"> |
|
749 |
<?php foreach ( $locations as $_location => $_name ) { ?> |
|
5 | 750 |
<tr class="menu-locations-row"> |
751 |
<td class="menu-location-title"><label for="locations-<?php echo $_location; ?>"><?php echo $_name; ?></label></td> |
|
0 | 752 |
<td class="menu-location-menus"> |
753 |
<select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>"> |
|
754 |
<option value="0"><?php printf( '— %s —', esc_html__( 'Select a Menu' ) ); ?></option> |
|
9 | 755 |
<?php |
756 |
foreach ( $nav_menus as $menu ) : |
|
757 |
$data_orig = ''; |
|
16 | 758 |
$selected = isset( $menu_locations[ $_location ] ) && $menu_locations[ $_location ] === $menu->term_id; |
759 |
||
9 | 760 |
if ( $selected ) { |
761 |
$data_orig = 'data-orig="true"'; |
|
762 |
} |
|
763 |
?> |
|
764 |
<option <?php echo $data_orig; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>"> |
|
0 | 765 |
<?php echo wp_html_excerpt( $menu->name, 40, '…' ); ?> |
766 |
</option> |
|
767 |
<?php endforeach; ?> |
|
768 |
</select> |
|
769 |
<div class="locations-row-links"> |
|
16 | 770 |
<?php if ( isset( $menu_locations[ $_location ] ) && 0 !== $menu_locations[ $_location ] ) : ?> |
0 | 771 |
<span class="locations-edit-menu-link"> |
9 | 772 |
<a href=" |
773 |
<?php |
|
774 |
echo esc_url( |
|
775 |
add_query_arg( |
|
776 |
array( |
|
777 |
'action' => 'edit', |
|
778 |
'menu' => $menu_locations[ $_location ], |
|
779 |
), |
|
780 |
admin_url( 'nav-menus.php' ) |
|
781 |
) |
|
782 |
); |
|
783 |
?> |
|
784 |
"> |
|
5 | 785 |
<span aria-hidden="true"><?php _ex( 'Edit', 'menu' ); ?></span><span class="screen-reader-text"><?php _e( 'Edit selected menu' ); ?></span> |
0 | 786 |
</a> |
787 |
</span> |
|
788 |
<?php endif; ?> |
|
789 |
<span class="locations-add-menu-link"> |
|
9 | 790 |
<a href=" |
791 |
<?php |
|
792 |
echo esc_url( |
|
793 |
add_query_arg( |
|
794 |
array( |
|
795 |
'action' => 'edit', |
|
796 |
'menu' => 0, |
|
797 |
'use-location' => $_location, |
|
798 |
), |
|
799 |
admin_url( 'nav-menus.php' ) |
|
800 |
) |
|
801 |
); |
|
802 |
?> |
|
803 |
"> |
|
0 | 804 |
<?php _ex( 'Use new menu', 'menu' ); ?> |
805 |
</a> |
|
806 |
</span> |
|
5 | 807 |
</div><!-- .locations-row-links --> |
0 | 808 |
</td><!-- .menu-location-menus --> |
5 | 809 |
</tr><!-- .menu-locations-row --> |
16 | 810 |
<?php } // End foreach. ?> |
0 | 811 |
</tbody> |
812 |
</table> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
813 |
<p class="button-controls wp-clearfix"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p> |
0 | 814 |
<?php wp_nonce_field( 'save-menu-locations' ); ?> |
815 |
<input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
|
816 |
</form> |
|
817 |
</div><!-- #menu-locations-wrap --> |
|
9 | 818 |
<?php |
819 |
/** |
|
820 |
* Fires after the menu locations table is displayed. |
|
821 |
* |
|
822 |
* @since 3.6.0 |
|
823 |
*/ |
|
824 |
do_action( 'after_menu_locations_table' ); |
|
825 |
?> |
|
0 | 826 |
<?php else : ?> |
827 |
<div class="manage-menus"> |
|
9 | 828 |
<?php if ( $menu_count < 1 ) : ?> |
829 |
<span class="first-menu-message"> |
|
830 |
<?php _e( 'Create your first menu below.' ); ?> |
|
831 |
<span class="screen-reader-text"><?php _e( 'Fill in the Menu Name and click the Create Menu button to create your first menu.' ); ?></span> |
|
832 |
</span><!-- /first-menu-message --> |
|
833 |
<?php elseif ( $menu_count < 2 ) : ?> |
|
0 | 834 |
<span class="add-edit-menu-action"> |
9 | 835 |
<?php |
836 |
printf( |
|
16 | 837 |
/* translators: %s: URL to create a new menu. */ |
9 | 838 |
__( 'Edit your menu below, or <a href="%s">create a new menu</a>. Don’t forget to save your changes!' ), |
839 |
esc_url( |
|
840 |
add_query_arg( |
|
841 |
array( |
|
842 |
'action' => 'edit', |
|
843 |
'menu' => 0, |
|
844 |
), |
|
845 |
admin_url( 'nav-menus.php' ) |
|
846 |
) |
|
847 |
) |
|
848 |
); |
|
849 |
?> |
|
850 |
<span class="screen-reader-text"><?php _e( 'Click the Save Menu button to save your changes.' ); ?></span> |
|
0 | 851 |
</span><!-- /add-edit-menu-action --> |
852 |
<?php else : ?> |
|
18 | 853 |
<form method="get" action="<?php echo esc_url( admin_url( 'nav-menus.php' ) ); ?>"> |
0 | 854 |
<input type="hidden" name="action" value="edit" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
855 |
<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
|
856 |
<select name="menu" id="select-menu-to-edit"> |
0 | 857 |
<?php if ( $add_new_screen ) : ?> |
5 | 858 |
<option value="0" selected="selected"><?php _e( '— Select —' ); ?></option> |
0 | 859 |
<?php endif; ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
860 |
<?php foreach ( (array) $nav_menus as $_nav_menu ) : ?> |
0 | 861 |
<option value="<?php echo esc_attr( $_nav_menu->term_id ); ?>" <?php selected( $_nav_menu->term_id, $nav_menu_selected_id ); ?>> |
862 |
<?php |
|
9 | 863 |
echo esc_html( $_nav_menu->truncated_name ); |
0 | 864 |
|
16 | 865 |
if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations, true ) ) { |
0 | 866 |
$locations_assigned_to_this_menu = array(); |
16 | 867 |
|
868 |
foreach ( array_keys( $menu_locations, $_nav_menu->term_id, true ) as $menu_location_key ) { |
|
5 | 869 |
if ( isset( $locations[ $menu_location_key ] ) ) { |
870 |
$locations_assigned_to_this_menu[] = $locations[ $menu_location_key ]; |
|
871 |
} |
|
0 | 872 |
} |
5 | 873 |
|
874 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
875 |
* Filters the number of locations listed per menu in the drop-down select. |
5 | 876 |
* |
877 |
* @since 3.6.0 |
|
878 |
* |
|
879 |
* @param int $locations Number of menu locations to list. Default 3. |
|
880 |
*/ |
|
16 | 881 |
$locations_listed_per_menu = absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ); |
882 |
||
883 |
$assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, $locations_listed_per_menu ); |
|
0 | 884 |
|
5 | 885 |
// Adds ellipses following the number of locations defined in $assigned_locations. |
886 |
if ( ! empty( $assigned_locations ) ) { |
|
9 | 887 |
printf( |
888 |
' (%1$s%2$s)', |
|
5 | 889 |
implode( ', ', $assigned_locations ), |
890 |
count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : '' |
|
891 |
); |
|
892 |
} |
|
0 | 893 |
} |
894 |
?> |
|
895 |
</option> |
|
896 |
<?php endforeach; ?> |
|
897 |
</select> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
898 |
<span class="submit-btn"><input type="submit" class="button" value="<?php esc_attr_e( 'Select' ); ?>"></span> |
0 | 899 |
<span class="add-new-menu-action"> |
9 | 900 |
<?php |
901 |
printf( |
|
16 | 902 |
/* translators: %s: URL to create a new menu. */ |
9 | 903 |
__( 'or <a href="%s">create a new menu</a>. Don’t forget to save your changes!' ), |
904 |
esc_url( |
|
905 |
add_query_arg( |
|
906 |
array( |
|
907 |
'action' => 'edit', |
|
908 |
'menu' => 0, |
|
909 |
), |
|
910 |
admin_url( 'nav-menus.php' ) |
|
911 |
) |
|
912 |
) |
|
913 |
); |
|
914 |
?> |
|
915 |
<span class="screen-reader-text"><?php _e( 'Click the Save Menu button to save your changes.' ); ?></span> |
|
0 | 916 |
</span><!-- /add-new-menu-action --> |
917 |
</form> |
|
9 | 918 |
<?php |
919 |
endif; |
|
920 |
||
921 |
$metabox_holder_disabled_class = ''; |
|
16 | 922 |
|
923 |
if ( isset( $_GET['menu'] ) && 0 === (int) $_GET['menu'] ) { |
|
9 | 924 |
$metabox_holder_disabled_class = ' metabox-holder-disabled'; |
925 |
} |
|
926 |
?> |
|
0 | 927 |
</div><!-- /manage-menus --> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
928 |
<div id="nav-menus-frame" class="wp-clearfix"> |
9 | 929 |
<div id="menu-settings-column" class="metabox-holder<?php echo $metabox_holder_disabled_class; ?>"> |
0 | 930 |
|
931 |
<div class="clear"></div> |
|
932 |
||
5 | 933 |
<form id="nav-menu-meta" class="nav-menu-meta" method="post" enctype="multipart/form-data"> |
0 | 934 |
<input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
935 |
<input type="hidden" name="action" value="add-menu-item" /> |
|
936 |
<?php wp_nonce_field( 'add-menu_item', 'menu-settings-column-nonce' ); ?> |
|
9 | 937 |
<h2><?php _e( 'Add menu items' ); ?></h2> |
0 | 938 |
<?php do_accordion_sections( 'nav-menus', 'side', null ); ?> |
939 |
</form> |
|
940 |
||
941 |
</div><!-- /#menu-settings-column --> |
|
942 |
<div id="menu-management-liquid"> |
|
943 |
<div id="menu-management"> |
|
5 | 944 |
<form id="update-nav-menu" method="post" enctype="multipart/form-data"> |
9 | 945 |
<h2><?php _e( 'Menu structure' ); ?></h2> |
16 | 946 |
<div class="menu-edit"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
947 |
<input type="hidden" name="nav-menu-data"> |
0 | 948 |
<?php |
949 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
950 |
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
951 |
wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' ); |
|
952 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
$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
|
954 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
955 |
if ( $one_theme_location_no_menus ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
956 |
$menu_name_val = 'value="' . esc_attr( 'Menu 1' ) . '"'; |
9 | 957 |
?> |
0 | 958 |
<input type="hidden" name="zero-menu-state" value="true" /> |
9 | 959 |
<?php |
960 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
961 |
$menu_name_val = 'value="' . esc_attr( $nav_menu_selected_title ) . '"'; |
9 | 962 |
} |
963 |
?> |
|
964 |
<input type="hidden" name="action" value="update" /> |
|
0 | 965 |
<input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
966 |
<div id="nav-menu-header"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
967 |
<div class="major-publishing-actions wp-clearfix"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
968 |
<label class="menu-name-label" for="menu-name"><?php _e( 'Menu Name' ); ?></label> |
18 | 969 |
<input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox form-required" required="required" <?php echo $menu_name_val . $menu_name_aria_desc; ?> /> |
0 | 970 |
<div class="publishing-action"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
<?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 | 972 |
</div><!-- END .publishing-action --> |
973 |
</div><!-- END .major-publishing-actions --> |
|
974 |
</div><!-- END .nav-menu-header --> |
|
975 |
<div id="post-body"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
976 |
<div id="post-body-content" class="wp-clearfix"> |
0 | 977 |
<?php if ( ! $add_new_screen ) : ?> |
9 | 978 |
<?php |
979 |
$hide_style = ''; |
|
16 | 980 |
|
981 |
if ( isset( $menu_items ) && 0 === count( $menu_items ) ) { |
|
9 | 982 |
$hide_style = 'style="display: none;"'; |
983 |
} |
|
16 | 984 |
|
985 |
if ( $one_theme_location_no_menus ) { |
|
986 |
$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.' ); |
|
987 |
} else { |
|
988 |
$starter_copy = __( 'Drag the items into the order you prefer. Click the arrow on the right of the item to reveal additional configuration options.' ); |
|
989 |
} |
|
9 | 990 |
?> |
16 | 991 |
<div class="drag-instructions post-body-plain" <?php echo $hide_style; ?>> |
992 |
<p><?php echo $starter_copy; ?></p> |
|
993 |
</div> |
|
994 |
||
18 | 995 |
<?php if ( ! $add_new_screen ) : ?> |
996 |
<div id="nav-menu-bulk-actions-top" class="bulk-actions"> |
|
997 |
<label class="bulk-select-button" for="bulk-select-switcher-top"> |
|
998 |
<input type="checkbox" id="bulk-select-switcher-top" name="bulk-select-switcher-top" class="bulk-select-switcher"> |
|
999 |
<span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span> |
|
1000 |
</label> |
|
1001 |
</div> |
|
1002 |
<?php endif; ?> |
|
1003 |
||
9 | 1004 |
<?php |
1005 |
if ( isset( $edit_markup ) && ! is_wp_error( $edit_markup ) ) { |
|
1006 |
echo $edit_markup; |
|
1007 |
} else { |
|
1008 |
?> |
|
16 | 1009 |
<ul class="menu" id="menu-to-edit"></ul> |
9 | 1010 |
<?php } ?> |
16 | 1011 |
|
0 | 1012 |
<?php endif; ?> |
16 | 1013 |
|
0 | 1014 |
<?php if ( $add_new_screen ) : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
<p class="post-body-plain" id="menu-name-desc"><?php _e( 'Give your menu a name, then click Create Menu.' ); ?></p> |
0 | 1016 |
<?php if ( isset( $_GET['use-location'] ) ) : ?> |
1017 |
<input type="hidden" name="use-location" value="<?php echo esc_attr( $_GET['use-location'] ); ?>" /> |
|
1018 |
<?php endif; ?> |
|
16 | 1019 |
|
9 | 1020 |
<?php |
16 | 1021 |
endif; |
9 | 1022 |
|
16 | 1023 |
$no_menus_style = ''; |
1024 |
||
9 | 1025 |
if ( $one_theme_location_no_menus ) { |
1026 |
$no_menus_style = 'style="display: none;"'; |
|
1027 |
} |
|
1028 |
?> |
|
18 | 1029 |
|
1030 |
<?php if ( ! $add_new_screen ) : ?> |
|
1031 |
<div id="nav-menu-bulk-actions-bottom" class="bulk-actions"> |
|
1032 |
<label class="bulk-select-button" for="bulk-select-switcher-bottom"> |
|
1033 |
<input type="checkbox" id="bulk-select-switcher-bottom" name="bulk-select-switcher-top" class="bulk-select-switcher"> |
|
1034 |
<span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span> |
|
1035 |
</label> |
|
1036 |
<input type="button" class="deletion menu-items-delete disabled" value="<?php _e( 'Remove Selected Items' ); ?>"> |
|
1037 |
<div id="pending-menu-items-to-delete"> |
|
1038 |
<p><?php _e( 'List of menu items selected for deletion:' ); ?></p> |
|
1039 |
<ul></ul> |
|
1040 |
</div> |
|
1041 |
</div> |
|
1042 |
<?php endif; ?> |
|
1043 |
||
9 | 1044 |
<div class="menu-settings" <?php echo $no_menus_style; ?>> |
0 | 1045 |
<h3><?php _e( 'Menu Settings' ); ?></h3> |
1046 |
<?php |
|
1047 |
if ( ! isset( $auto_add ) ) { |
|
1048 |
$auto_add = get_option( 'nav_menu_options' ); |
|
16 | 1049 |
|
9 | 1050 |
if ( ! isset( $auto_add['auto_add'] ) ) { |
0 | 1051 |
$auto_add = false; |
16 | 1052 |
} elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'], true ) ) { |
0 | 1053 |
$auto_add = true; |
9 | 1054 |
} else { |
0 | 1055 |
$auto_add = false; |
9 | 1056 |
} |
1057 |
} |
|
1058 |
?> |
|
0 | 1059 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1060 |
<fieldset class="menu-settings-group auto-add-pages"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
<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
|
1062 |
<div class="menu-settings-input checkbox-input"> |
9 | 1063 |
<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
|
1064 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1065 |
</fieldset> |
0 | 1066 |
|
1067 |
<?php if ( current_theme_supports( 'menus' ) ) : ?> |
|
1068 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1069 |
<fieldset class="menu-settings-group menu-theme-locations"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1070 |
<legend class="menu-settings-group-name howto"><?php _e( 'Display location' ); ?></legend> |
16 | 1071 |
<?php |
1072 |
foreach ( $locations as $location => $description ) : |
|
18 | 1073 |
$checked = false; |
1074 |
||
1075 |
if ( isset( $menu_locations[ $location ] ) |
|
1076 |
&& 0 !== $nav_menu_selected_id |
|
1077 |
&& $menu_locations[ $location ] === $nav_menu_selected_id |
|
1078 |
) { |
|
1079 |
$checked = true; |
|
1080 |
} |
|
16 | 1081 |
?> |
1082 |
<div class="menu-settings-input checkbox-input"> |
|
1083 |
<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 ); ?>" /> |
|
1084 |
<label for="locations-<?php echo esc_attr( $location ); ?>"><?php echo $description; ?></label> |
|
1085 |
<?php if ( ! empty( $menu_locations[ $location ] ) && $menu_locations[ $location ] !== $nav_menu_selected_id ) : ?> |
|
1086 |
<span class="theme-location-set"> |
|
1087 |
<?php |
|
1088 |
printf( |
|
1089 |
/* translators: %s: Menu name. */ |
|
1090 |
_x( '(Currently set to: %s)', 'menu location' ), |
|
1091 |
wp_get_nav_menu_object( $menu_locations[ $location ] )->name |
|
1092 |
); |
|
1093 |
?> |
|
1094 |
</span> |
|
1095 |
<?php endif; ?> |
|
1096 |
</div> |
|
0 | 1097 |
<?php endforeach; ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
</fieldset> |
0 | 1099 |
|
1100 |
<?php endif; ?> |
|
1101 |
||
1102 |
</div> |
|
1103 |
</div><!-- /#post-body-content --> |
|
1104 |
</div><!-- /#post-body --> |
|
1105 |
<div id="nav-menu-footer"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
<div class="major-publishing-actions wp-clearfix"> |
16 | 1107 |
<?php if ( $menu_count > 0 ) : ?> |
1108 |
||
1109 |
<?php if ( $add_new_screen ) : ?> |
|
1110 |
<span class="cancel-action"> |
|
1111 |
<a class="submitcancel cancellation menu-cancel" href="<?php echo esc_url( admin_url( 'nav-menus.php' ) ); ?>"><?php _e( 'Cancel' ); ?></a> |
|
1112 |
</span><!-- END .cancel-action --> |
|
1113 |
<?php else : ?> |
|
1114 |
<span class="delete-action"> |
|
1115 |
<a class="submitdelete deletion menu-delete" href=" |
|
1116 |
<?php |
|
1117 |
echo esc_url( |
|
1118 |
wp_nonce_url( |
|
1119 |
add_query_arg( |
|
1120 |
array( |
|
1121 |
'action' => 'delete', |
|
1122 |
'menu' => $nav_menu_selected_id, |
|
1123 |
), |
|
1124 |
admin_url( 'nav-menus.php' ) |
|
9 | 1125 |
), |
16 | 1126 |
'delete-nav_menu-' . $nav_menu_selected_id |
1127 |
) |
|
1128 |
); |
|
1129 |
?> |
|
1130 |
"><?php _e( 'Delete Menu' ); ?></a> |
|
1131 |
</span><!-- END .delete-action --> |
|
1132 |
<?php endif; ?> |
|
1133 |
||
0 | 1134 |
<?php endif; ?> |
1135 |
<div class="publishing-action"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1136 |
<?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 | 1137 |
</div><!-- END .publishing-action --> |
1138 |
</div><!-- END .major-publishing-actions --> |
|
1139 |
</div><!-- /#nav-menu-footer --> |
|
1140 |
</div><!-- /.menu-edit --> |
|
1141 |
</form><!-- /#update-nav-menu --> |
|
1142 |
</div><!-- /#menu-management --> |
|
1143 |
</div><!-- /#menu-management-liquid --> |
|
1144 |
</div><!-- /#nav-menus-frame --> |
|
1145 |
<?php endif; ?> |
|
1146 |
</div><!-- /.wrap--> |
|
16 | 1147 |
<?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?> |