author | ymh <ymh.work@gmail.com> |
Thu, 29 Sep 2022 08:06:27 +0200 | |
changeset 20 | 7b1b88e27a20 |
parent 19 | 3d72ae0968f4 |
child 21 | 48c4eec2b7e6 |
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.' ), |
|
19 | 502 |
'itemAdded' => __( 'Menu item added' ), |
503 |
'itemRemoved' => __( 'Menu item removed' ), |
|
504 |
'movedUp' => __( 'Menu item moved up' ), |
|
505 |
'movedDown' => __( 'Menu item moved down' ), |
|
506 |
'movedTop' => __( 'Menu item moved to the top' ), |
|
507 |
'movedLeft' => __( 'Menu item moved out of submenu' ), |
|
508 |
'movedRight' => __( 'Menu item is now a sub-item' ), |
|
0 | 509 |
); |
510 |
wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n ); |
|
511 |
||
5 | 512 |
/* |
513 |
* Redirect to add screen if there are no menus and this users has either zero, |
|
514 |
* or more than 1 theme locations. |
|
515 |
*/ |
|
16 | 516 |
if ( 0 === $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus ) { |
0 | 517 |
wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) ); |
9 | 518 |
} |
0 | 519 |
|
5 | 520 |
// Get recently edited nav menu. |
0 | 521 |
$recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) ); |
9 | 522 |
if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) ) { |
0 | 523 |
$recently_edited = $nav_menu_selected_id; |
9 | 524 |
} |
0 | 525 |
|
5 | 526 |
// Use $recently_edited if none are selected. |
9 | 527 |
if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) { |
0 | 528 |
$nav_menu_selected_id = $recently_edited; |
9 | 529 |
} |
0 | 530 |
|
5 | 531 |
// On deletion of menu, if another menu exists, show it. |
16 | 532 |
if ( ! $add_new_screen && $menu_count > 0 && isset( $_GET['action'] ) && 'delete' === $_GET['action'] ) { |
0 | 533 |
$nav_menu_selected_id = $nav_menus[0]->term_id; |
9 | 534 |
} |
0 | 535 |
|
5 | 536 |
// Set $nav_menu_selected_id to 0 if no menus. |
0 | 537 |
if ( $one_theme_location_no_menus ) { |
538 |
$nav_menu_selected_id = 0; |
|
539 |
} elseif ( empty( $nav_menu_selected_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) { |
|
16 | 540 |
// If we have no selection yet, and we have menus, set to the first one in the list. |
0 | 541 |
$nav_menu_selected_id = $nav_menus[0]->term_id; |
542 |
} |
|
543 |
||
5 | 544 |
// Update the user's setting. |
16 | 545 |
if ( $nav_menu_selected_id !== $recently_edited && is_nav_menu( $nav_menu_selected_id ) ) { |
0 | 546 |
update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id ); |
9 | 547 |
} |
0 | 548 |
|
549 |
// If there's a menu, get its name. |
|
550 |
if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) { |
|
9 | 551 |
$_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); |
0 | 552 |
$nav_menu_selected_title = ! is_wp_error( $_menu_object ) ? $_menu_object->name : ''; |
553 |
} |
|
554 |
||
5 | 555 |
// Generate truncated menu names. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
556 |
foreach ( (array) $nav_menus as $key => $_nav_menu ) { |
9 | 557 |
$nav_menus[ $key ]->truncated_name = wp_html_excerpt( $_nav_menu->name, 40, '…' ); |
0 | 558 |
} |
559 |
||
5 | 560 |
// Retrieve menu locations. |
0 | 561 |
if ( current_theme_supports( 'menus' ) ) { |
9 | 562 |
$locations = get_registered_nav_menus(); |
0 | 563 |
$menu_locations = get_nav_menu_locations(); |
564 |
} |
|
565 |
||
5 | 566 |
/* |
567 |
* Ensure the user will be able to scroll horizontally |
|
568 |
* 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
|
569 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
* @global int $_wp_nav_menu_max_depth |
5 | 571 |
*/ |
0 | 572 |
global $_wp_nav_menu_max_depth; |
573 |
$_wp_nav_menu_max_depth = 0; |
|
574 |
||
5 | 575 |
// Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth. |
0 | 576 |
if ( is_nav_menu( $nav_menu_selected_id ) ) { |
9 | 577 |
$menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'post_status' => 'any' ) ); |
0 | 578 |
$edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); |
579 |
} |
|
580 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
581 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
* @global int $_wp_nav_menu_max_depth |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
583 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
584 |
* @param string $classes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
587 |
function wp_nav_menu_max_depth( $classes ) { |
0 | 588 |
global $_wp_nav_menu_max_depth; |
589 |
return "$classes menu-max-depth-$_wp_nav_menu_max_depth"; |
|
590 |
} |
|
591 |
||
9 | 592 |
add_filter( 'admin_body_class', 'wp_nav_menu_max_depth' ); |
0 | 593 |
|
594 |
wp_nav_menu_setup(); |
|
595 |
wp_initial_nav_menu_meta_boxes(); |
|
596 |
||
9 | 597 |
if ( ! current_theme_supports( 'menus' ) && ! $num_locations ) { |
16 | 598 |
$messages[] = '<div id="message" class="updated"><p>' . sprintf( |
599 |
/* translators: %s: URL to Widgets screen. */ |
|
600 |
__( '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.' ), |
|
601 |
admin_url( 'widgets.php' ) |
|
602 |
) . '</p></div>'; |
|
9 | 603 |
} |
0 | 604 |
|
16 | 605 |
if ( ! $locations_screen ) : // Main tab. |
606 |
$overview = '<p>' . __( 'This screen is used for managing your navigation menus.' ) . '</p>'; |
|
607 |
$overview .= '<p>' . sprintf( |
|
608 |
/* translators: 1: URL to Widgets screen, 2 and 3: The names of the default themes. */ |
|
19 | 609 |
__( '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.' ), |
16 | 610 |
admin_url( 'widgets.php' ), |
18 | 611 |
'Twenty Twenty', |
612 |
'Twenty Twenty-One' |
|
16 | 613 |
) . '</p>'; |
0 | 614 |
$overview .= '<p>' . __( 'From this screen you can:' ) . '</p>'; |
615 |
$overview .= '<ul><li>' . __( 'Create, edit, and delete menus' ) . '</li>'; |
|
616 |
$overview .= '<li>' . __( 'Add, organize, and modify individual menu items' ) . '</li></ul>'; |
|
617 |
||
9 | 618 |
get_current_screen()->add_help_tab( |
619 |
array( |
|
620 |
'id' => 'overview', |
|
621 |
'title' => __( 'Overview' ), |
|
622 |
'content' => $overview, |
|
623 |
) |
|
624 |
); |
|
0 | 625 |
|
626 |
$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>'; |
|
627 |
$menu_management .= '<ul><li>' . __( 'To edit an existing menu, <strong>choose a menu from the drop down and click Select</strong>' ) . '</li>'; |
|
19 | 628 |
$menu_management .= '<li>' . __( 'If you have not yet created any menus, <strong>click the ’create a new menu’ link</strong> to get started' ) . '</li></ul>'; |
0 | 629 |
$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>'; |
630 |
||
9 | 631 |
get_current_screen()->add_help_tab( |
632 |
array( |
|
633 |
'id' => 'menu-management', |
|
634 |
'title' => __( 'Menu Management' ), |
|
635 |
'content' => $menu_management, |
|
636 |
) |
|
637 |
); |
|
0 | 638 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
$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 | 640 |
$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>'; |
641 |
$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 | 642 |
$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 | 643 |
$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>'; |
644 |
$editing_menus .= '<li>' . __( 'Delete a menu item by <strong>expanding it and clicking the Remove link</strong>' ) . '</li></ul>'; |
|
645 |
||
9 | 646 |
get_current_screen()->add_help_tab( |
647 |
array( |
|
648 |
'id' => 'editing-menus', |
|
649 |
'title' => __( 'Editing Menus' ), |
|
650 |
'content' => $editing_menus, |
|
651 |
) |
|
652 |
); |
|
16 | 653 |
else : // Locations tab. |
0 | 654 |
$locations_overview = '<p>' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '</p>'; |
19 | 655 |
$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 are finished, <strong>click Save Changes</strong>' ) . '</li>'; |
0 | 656 |
$locations_overview .= '<li>' . __( 'To edit a menu currently assigned to a theme location, <strong>click the adjacent ’Edit’ link</strong>' ) . '</li>'; |
657 |
$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>'; |
|
658 |
||
9 | 659 |
get_current_screen()->add_help_tab( |
660 |
array( |
|
661 |
'id' => 'locations-overview', |
|
662 |
'title' => __( 'Overview' ), |
|
663 |
'content' => $locations_overview, |
|
664 |
) |
|
665 |
); |
|
0 | 666 |
endif; |
667 |
||
668 |
get_current_screen()->set_help_sidebar( |
|
9 | 669 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
16 | 670 |
'<p>' . __( '<a href="https://wordpress.org/support/article/appearance-menus-screen/">Documentation on Menus</a>' ) . '</p>' . |
9 | 671 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
0 | 672 |
); |
673 |
||
5 | 674 |
// Get the admin header. |
16 | 675 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
0 | 676 |
?> |
677 |
<div class="wrap"> |
|
18 | 678 |
<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
|
679 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
680 |
if ( current_user_can( 'customize' ) ) : |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
$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
|
682 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
683 |
' <a class="page-title-action hide-if-no-customize" href="%1$s">%2$s</a>', |
9 | 684 |
esc_url( |
685 |
add_query_arg( |
|
686 |
array( |
|
687 |
array( 'autofocus' => $focus ), |
|
688 |
'return' => urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), |
|
689 |
), |
|
690 |
admin_url( 'customize.php' ) |
|
691 |
) |
|
692 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
__( 'Manage with Live Preview' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
endif; |
9 | 696 |
|
697 |
$nav_tab_active_class = ''; |
|
698 |
$nav_aria_current = ''; |
|
16 | 699 |
|
700 |
if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' !== $_GET['action'] ) { |
|
9 | 701 |
$nav_tab_active_class = ' nav-tab-active'; |
702 |
$nav_aria_current = ' aria-current="page"'; |
|
703 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
<hr class="wp-header-end"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
|
9 | 708 |
<nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>"> |
18 | 709 |
<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
|
710 |
<?php |
9 | 711 |
if ( $num_locations && $menu_count ) { |
712 |
$active_tab_class = ''; |
|
713 |
$aria_current = ''; |
|
16 | 714 |
|
9 | 715 |
if ( $locations_screen ) { |
716 |
$active_tab_class = ' nav-tab-active'; |
|
717 |
$aria_current = ' aria-current="page"'; |
|
718 |
} |
|
719 |
?> |
|
720 |
<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> |
|
721 |
<?php |
|
722 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
723 |
?> |
9 | 724 |
</nav> |
0 | 725 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
726 |
foreach ( $messages as $message ) : |
0 | 727 |
echo $message . "\n"; |
728 |
endforeach; |
|
729 |
?> |
|
730 |
<?php |
|
731 |
if ( $locations_screen ) : |
|
16 | 732 |
if ( 1 === $num_locations ) { |
5 | 733 |
echo '<p>' . __( 'Your theme supports one menu. Select which menu you would like to use.' ) . '</p>'; |
734 |
} else { |
|
16 | 735 |
echo '<p>' . sprintf( |
736 |
/* translators: %s: Number of menus. */ |
|
737 |
_n( |
|
738 |
'Your theme supports %s menu. Select which menu appears in each location.', |
|
739 |
'Your theme supports %s menus. Select which menu appears in each location.', |
|
740 |
$num_locations |
|
741 |
), |
|
742 |
number_format_i18n( $num_locations ) |
|
743 |
) . '</p>'; |
|
5 | 744 |
} |
9 | 745 |
?> |
0 | 746 |
<div id="menu-locations-wrap"> |
747 |
<form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>"> |
|
5 | 748 |
<table class="widefat fixed" id="menu-locations-table"> |
0 | 749 |
<thead> |
750 |
<tr> |
|
751 |
<th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th> |
|
752 |
<th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th> |
|
753 |
</tr> |
|
754 |
</thead> |
|
755 |
<tbody class="menu-locations"> |
|
756 |
<?php foreach ( $locations as $_location => $_name ) { ?> |
|
5 | 757 |
<tr class="menu-locations-row"> |
758 |
<td class="menu-location-title"><label for="locations-<?php echo $_location; ?>"><?php echo $_name; ?></label></td> |
|
0 | 759 |
<td class="menu-location-menus"> |
760 |
<select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>"> |
|
761 |
<option value="0"><?php printf( '— %s —', esc_html__( 'Select a Menu' ) ); ?></option> |
|
9 | 762 |
<?php |
763 |
foreach ( $nav_menus as $menu ) : |
|
764 |
$data_orig = ''; |
|
16 | 765 |
$selected = isset( $menu_locations[ $_location ] ) && $menu_locations[ $_location ] === $menu->term_id; |
766 |
||
9 | 767 |
if ( $selected ) { |
768 |
$data_orig = 'data-orig="true"'; |
|
769 |
} |
|
770 |
?> |
|
771 |
<option <?php echo $data_orig; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>"> |
|
0 | 772 |
<?php echo wp_html_excerpt( $menu->name, 40, '…' ); ?> |
773 |
</option> |
|
774 |
<?php endforeach; ?> |
|
775 |
</select> |
|
776 |
<div class="locations-row-links"> |
|
16 | 777 |
<?php if ( isset( $menu_locations[ $_location ] ) && 0 !== $menu_locations[ $_location ] ) : ?> |
0 | 778 |
<span class="locations-edit-menu-link"> |
9 | 779 |
<a href=" |
780 |
<?php |
|
781 |
echo esc_url( |
|
782 |
add_query_arg( |
|
783 |
array( |
|
784 |
'action' => 'edit', |
|
785 |
'menu' => $menu_locations[ $_location ], |
|
786 |
), |
|
787 |
admin_url( 'nav-menus.php' ) |
|
788 |
) |
|
789 |
); |
|
790 |
?> |
|
791 |
"> |
|
5 | 792 |
<span aria-hidden="true"><?php _ex( 'Edit', 'menu' ); ?></span><span class="screen-reader-text"><?php _e( 'Edit selected menu' ); ?></span> |
0 | 793 |
</a> |
794 |
</span> |
|
795 |
<?php endif; ?> |
|
796 |
<span class="locations-add-menu-link"> |
|
9 | 797 |
<a href=" |
798 |
<?php |
|
799 |
echo esc_url( |
|
800 |
add_query_arg( |
|
801 |
array( |
|
802 |
'action' => 'edit', |
|
803 |
'menu' => 0, |
|
804 |
'use-location' => $_location, |
|
805 |
), |
|
806 |
admin_url( 'nav-menus.php' ) |
|
807 |
) |
|
808 |
); |
|
809 |
?> |
|
810 |
"> |
|
0 | 811 |
<?php _ex( 'Use new menu', 'menu' ); ?> |
812 |
</a> |
|
813 |
</span> |
|
5 | 814 |
</div><!-- .locations-row-links --> |
0 | 815 |
</td><!-- .menu-location-menus --> |
5 | 816 |
</tr><!-- .menu-locations-row --> |
16 | 817 |
<?php } // End foreach. ?> |
0 | 818 |
</tbody> |
819 |
</table> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
820 |
<p class="button-controls wp-clearfix"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p> |
0 | 821 |
<?php wp_nonce_field( 'save-menu-locations' ); ?> |
822 |
<input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
|
823 |
</form> |
|
824 |
</div><!-- #menu-locations-wrap --> |
|
9 | 825 |
<?php |
826 |
/** |
|
827 |
* Fires after the menu locations table is displayed. |
|
828 |
* |
|
829 |
* @since 3.6.0 |
|
830 |
*/ |
|
831 |
do_action( 'after_menu_locations_table' ); |
|
832 |
?> |
|
0 | 833 |
<?php else : ?> |
834 |
<div class="manage-menus"> |
|
9 | 835 |
<?php if ( $menu_count < 1 ) : ?> |
836 |
<span class="first-menu-message"> |
|
837 |
<?php _e( 'Create your first menu below.' ); ?> |
|
838 |
<span class="screen-reader-text"><?php _e( 'Fill in the Menu Name and click the Create Menu button to create your first menu.' ); ?></span> |
|
839 |
</span><!-- /first-menu-message --> |
|
840 |
<?php elseif ( $menu_count < 2 ) : ?> |
|
0 | 841 |
<span class="add-edit-menu-action"> |
9 | 842 |
<?php |
843 |
printf( |
|
16 | 844 |
/* translators: %s: URL to create a new menu. */ |
19 | 845 |
__( 'Edit your menu below, or <a href="%s">create a new menu</a>. Do not forget to save your changes!' ), |
9 | 846 |
esc_url( |
847 |
add_query_arg( |
|
848 |
array( |
|
849 |
'action' => 'edit', |
|
850 |
'menu' => 0, |
|
851 |
), |
|
852 |
admin_url( 'nav-menus.php' ) |
|
853 |
) |
|
854 |
) |
|
855 |
); |
|
856 |
?> |
|
857 |
<span class="screen-reader-text"><?php _e( 'Click the Save Menu button to save your changes.' ); ?></span> |
|
0 | 858 |
</span><!-- /add-edit-menu-action --> |
859 |
<?php else : ?> |
|
18 | 860 |
<form method="get" action="<?php echo esc_url( admin_url( 'nav-menus.php' ) ); ?>"> |
0 | 861 |
<input type="hidden" name="action" value="edit" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
<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
|
863 |
<select name="menu" id="select-menu-to-edit"> |
0 | 864 |
<?php if ( $add_new_screen ) : ?> |
5 | 865 |
<option value="0" selected="selected"><?php _e( '— Select —' ); ?></option> |
0 | 866 |
<?php endif; ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
867 |
<?php foreach ( (array) $nav_menus as $_nav_menu ) : ?> |
0 | 868 |
<option value="<?php echo esc_attr( $_nav_menu->term_id ); ?>" <?php selected( $_nav_menu->term_id, $nav_menu_selected_id ); ?>> |
869 |
<?php |
|
9 | 870 |
echo esc_html( $_nav_menu->truncated_name ); |
0 | 871 |
|
16 | 872 |
if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations, true ) ) { |
0 | 873 |
$locations_assigned_to_this_menu = array(); |
16 | 874 |
|
875 |
foreach ( array_keys( $menu_locations, $_nav_menu->term_id, true ) as $menu_location_key ) { |
|
5 | 876 |
if ( isset( $locations[ $menu_location_key ] ) ) { |
877 |
$locations_assigned_to_this_menu[] = $locations[ $menu_location_key ]; |
|
878 |
} |
|
0 | 879 |
} |
5 | 880 |
|
881 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
882 |
* Filters the number of locations listed per menu in the drop-down select. |
5 | 883 |
* |
884 |
* @since 3.6.0 |
|
885 |
* |
|
886 |
* @param int $locations Number of menu locations to list. Default 3. |
|
887 |
*/ |
|
16 | 888 |
$locations_listed_per_menu = absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ); |
889 |
||
890 |
$assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, $locations_listed_per_menu ); |
|
0 | 891 |
|
5 | 892 |
// Adds ellipses following the number of locations defined in $assigned_locations. |
893 |
if ( ! empty( $assigned_locations ) ) { |
|
9 | 894 |
printf( |
895 |
' (%1$s%2$s)', |
|
5 | 896 |
implode( ', ', $assigned_locations ), |
897 |
count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : '' |
|
898 |
); |
|
899 |
} |
|
0 | 900 |
} |
901 |
?> |
|
902 |
</option> |
|
903 |
<?php endforeach; ?> |
|
904 |
</select> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
905 |
<span class="submit-btn"><input type="submit" class="button" value="<?php esc_attr_e( 'Select' ); ?>"></span> |
0 | 906 |
<span class="add-new-menu-action"> |
9 | 907 |
<?php |
908 |
printf( |
|
16 | 909 |
/* translators: %s: URL to create a new menu. */ |
19 | 910 |
__( 'or <a href="%s">create a new menu</a>. Do not forget to save your changes!' ), |
9 | 911 |
esc_url( |
912 |
add_query_arg( |
|
913 |
array( |
|
914 |
'action' => 'edit', |
|
915 |
'menu' => 0, |
|
916 |
), |
|
917 |
admin_url( 'nav-menus.php' ) |
|
918 |
) |
|
919 |
) |
|
920 |
); |
|
921 |
?> |
|
922 |
<span class="screen-reader-text"><?php _e( 'Click the Save Menu button to save your changes.' ); ?></span> |
|
0 | 923 |
</span><!-- /add-new-menu-action --> |
924 |
</form> |
|
9 | 925 |
<?php |
926 |
endif; |
|
927 |
||
928 |
$metabox_holder_disabled_class = ''; |
|
16 | 929 |
|
930 |
if ( isset( $_GET['menu'] ) && 0 === (int) $_GET['menu'] ) { |
|
9 | 931 |
$metabox_holder_disabled_class = ' metabox-holder-disabled'; |
932 |
} |
|
933 |
?> |
|
0 | 934 |
</div><!-- /manage-menus --> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
935 |
<div id="nav-menus-frame" class="wp-clearfix"> |
9 | 936 |
<div id="menu-settings-column" class="metabox-holder<?php echo $metabox_holder_disabled_class; ?>"> |
0 | 937 |
|
938 |
<div class="clear"></div> |
|
939 |
||
5 | 940 |
<form id="nav-menu-meta" class="nav-menu-meta" method="post" enctype="multipart/form-data"> |
0 | 941 |
<input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
942 |
<input type="hidden" name="action" value="add-menu-item" /> |
|
943 |
<?php wp_nonce_field( 'add-menu_item', 'menu-settings-column-nonce' ); ?> |
|
9 | 944 |
<h2><?php _e( 'Add menu items' ); ?></h2> |
0 | 945 |
<?php do_accordion_sections( 'nav-menus', 'side', null ); ?> |
946 |
</form> |
|
947 |
||
948 |
</div><!-- /#menu-settings-column --> |
|
949 |
<div id="menu-management-liquid"> |
|
950 |
<div id="menu-management"> |
|
5 | 951 |
<form id="update-nav-menu" method="post" enctype="multipart/form-data"> |
9 | 952 |
<h2><?php _e( 'Menu structure' ); ?></h2> |
16 | 953 |
<div class="menu-edit"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
954 |
<input type="hidden" name="nav-menu-data"> |
0 | 955 |
<?php |
956 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
957 |
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
958 |
wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' ); |
|
959 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
960 |
$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
|
961 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
962 |
if ( $one_theme_location_no_menus ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
963 |
$menu_name_val = 'value="' . esc_attr( 'Menu 1' ) . '"'; |
9 | 964 |
?> |
0 | 965 |
<input type="hidden" name="zero-menu-state" value="true" /> |
9 | 966 |
<?php |
967 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
968 |
$menu_name_val = 'value="' . esc_attr( $nav_menu_selected_title ) . '"'; |
9 | 969 |
} |
970 |
?> |
|
971 |
<input type="hidden" name="action" value="update" /> |
|
0 | 972 |
<input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
973 |
<div id="nav-menu-header"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
974 |
<div class="major-publishing-actions wp-clearfix"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
<label class="menu-name-label" for="menu-name"><?php _e( 'Menu Name' ); ?></label> |
18 | 976 |
<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 | 977 |
<div class="publishing-action"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
978 |
<?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 | 979 |
</div><!-- END .publishing-action --> |
980 |
</div><!-- END .major-publishing-actions --> |
|
981 |
</div><!-- END .nav-menu-header --> |
|
982 |
<div id="post-body"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
983 |
<div id="post-body-content" class="wp-clearfix"> |
0 | 984 |
<?php if ( ! $add_new_screen ) : ?> |
9 | 985 |
<?php |
986 |
$hide_style = ''; |
|
16 | 987 |
|
988 |
if ( isset( $menu_items ) && 0 === count( $menu_items ) ) { |
|
9 | 989 |
$hide_style = 'style="display: none;"'; |
990 |
} |
|
16 | 991 |
|
992 |
if ( $one_theme_location_no_menus ) { |
|
993 |
$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.' ); |
|
994 |
} else { |
|
995 |
$starter_copy = __( 'Drag the items into the order you prefer. Click the arrow on the right of the item to reveal additional configuration options.' ); |
|
996 |
} |
|
9 | 997 |
?> |
16 | 998 |
<div class="drag-instructions post-body-plain" <?php echo $hide_style; ?>> |
999 |
<p><?php echo $starter_copy; ?></p> |
|
1000 |
</div> |
|
1001 |
||
18 | 1002 |
<?php if ( ! $add_new_screen ) : ?> |
1003 |
<div id="nav-menu-bulk-actions-top" class="bulk-actions"> |
|
1004 |
<label class="bulk-select-button" for="bulk-select-switcher-top"> |
|
1005 |
<input type="checkbox" id="bulk-select-switcher-top" name="bulk-select-switcher-top" class="bulk-select-switcher"> |
|
1006 |
<span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span> |
|
1007 |
</label> |
|
1008 |
</div> |
|
1009 |
<?php endif; ?> |
|
1010 |
||
9 | 1011 |
<?php |
1012 |
if ( isset( $edit_markup ) && ! is_wp_error( $edit_markup ) ) { |
|
1013 |
echo $edit_markup; |
|
1014 |
} else { |
|
1015 |
?> |
|
16 | 1016 |
<ul class="menu" id="menu-to-edit"></ul> |
9 | 1017 |
<?php } ?> |
16 | 1018 |
|
0 | 1019 |
<?php endif; ?> |
16 | 1020 |
|
0 | 1021 |
<?php if ( $add_new_screen ) : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1022 |
<p class="post-body-plain" id="menu-name-desc"><?php _e( 'Give your menu a name, then click Create Menu.' ); ?></p> |
0 | 1023 |
<?php if ( isset( $_GET['use-location'] ) ) : ?> |
1024 |
<input type="hidden" name="use-location" value="<?php echo esc_attr( $_GET['use-location'] ); ?>" /> |
|
1025 |
<?php endif; ?> |
|
16 | 1026 |
|
9 | 1027 |
<?php |
16 | 1028 |
endif; |
9 | 1029 |
|
16 | 1030 |
$no_menus_style = ''; |
1031 |
||
9 | 1032 |
if ( $one_theme_location_no_menus ) { |
1033 |
$no_menus_style = 'style="display: none;"'; |
|
1034 |
} |
|
1035 |
?> |
|
18 | 1036 |
|
1037 |
<?php if ( ! $add_new_screen ) : ?> |
|
1038 |
<div id="nav-menu-bulk-actions-bottom" class="bulk-actions"> |
|
1039 |
<label class="bulk-select-button" for="bulk-select-switcher-bottom"> |
|
1040 |
<input type="checkbox" id="bulk-select-switcher-bottom" name="bulk-select-switcher-top" class="bulk-select-switcher"> |
|
1041 |
<span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span> |
|
1042 |
</label> |
|
1043 |
<input type="button" class="deletion menu-items-delete disabled" value="<?php _e( 'Remove Selected Items' ); ?>"> |
|
1044 |
<div id="pending-menu-items-to-delete"> |
|
1045 |
<p><?php _e( 'List of menu items selected for deletion:' ); ?></p> |
|
1046 |
<ul></ul> |
|
1047 |
</div> |
|
1048 |
</div> |
|
1049 |
<?php endif; ?> |
|
1050 |
||
9 | 1051 |
<div class="menu-settings" <?php echo $no_menus_style; ?>> |
0 | 1052 |
<h3><?php _e( 'Menu Settings' ); ?></h3> |
1053 |
<?php |
|
1054 |
if ( ! isset( $auto_add ) ) { |
|
1055 |
$auto_add = get_option( 'nav_menu_options' ); |
|
16 | 1056 |
|
9 | 1057 |
if ( ! isset( $auto_add['auto_add'] ) ) { |
0 | 1058 |
$auto_add = false; |
16 | 1059 |
} elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'], true ) ) { |
0 | 1060 |
$auto_add = true; |
9 | 1061 |
} else { |
0 | 1062 |
$auto_add = false; |
9 | 1063 |
} |
1064 |
} |
|
1065 |
?> |
|
0 | 1066 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1067 |
<fieldset class="menu-settings-group auto-add-pages"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1068 |
<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
|
1069 |
<div class="menu-settings-input checkbox-input"> |
9 | 1070 |
<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
|
1071 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1072 |
</fieldset> |
0 | 1073 |
|
1074 |
<?php if ( current_theme_supports( 'menus' ) ) : ?> |
|
1075 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1076 |
<fieldset class="menu-settings-group menu-theme-locations"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1077 |
<legend class="menu-settings-group-name howto"><?php _e( 'Display location' ); ?></legend> |
16 | 1078 |
<?php |
1079 |
foreach ( $locations as $location => $description ) : |
|
18 | 1080 |
$checked = false; |
1081 |
||
1082 |
if ( isset( $menu_locations[ $location ] ) |
|
1083 |
&& 0 !== $nav_menu_selected_id |
|
1084 |
&& $menu_locations[ $location ] === $nav_menu_selected_id |
|
1085 |
) { |
|
1086 |
$checked = true; |
|
1087 |
} |
|
16 | 1088 |
?> |
1089 |
<div class="menu-settings-input checkbox-input"> |
|
1090 |
<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 ); ?>" /> |
|
1091 |
<label for="locations-<?php echo esc_attr( $location ); ?>"><?php echo $description; ?></label> |
|
1092 |
<?php if ( ! empty( $menu_locations[ $location ] ) && $menu_locations[ $location ] !== $nav_menu_selected_id ) : ?> |
|
1093 |
<span class="theme-location-set"> |
|
1094 |
<?php |
|
1095 |
printf( |
|
1096 |
/* translators: %s: Menu name. */ |
|
1097 |
_x( '(Currently set to: %s)', 'menu location' ), |
|
1098 |
wp_get_nav_menu_object( $menu_locations[ $location ] )->name |
|
1099 |
); |
|
1100 |
?> |
|
1101 |
</span> |
|
1102 |
<?php endif; ?> |
|
1103 |
</div> |
|
0 | 1104 |
<?php endforeach; ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1105 |
</fieldset> |
0 | 1106 |
|
1107 |
<?php endif; ?> |
|
1108 |
||
1109 |
</div> |
|
1110 |
</div><!-- /#post-body-content --> |
|
1111 |
</div><!-- /#post-body --> |
|
1112 |
<div id="nav-menu-footer"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1113 |
<div class="major-publishing-actions wp-clearfix"> |
16 | 1114 |
<?php if ( $menu_count > 0 ) : ?> |
1115 |
||
1116 |
<?php if ( $add_new_screen ) : ?> |
|
1117 |
<span class="cancel-action"> |
|
1118 |
<a class="submitcancel cancellation menu-cancel" href="<?php echo esc_url( admin_url( 'nav-menus.php' ) ); ?>"><?php _e( 'Cancel' ); ?></a> |
|
1119 |
</span><!-- END .cancel-action --> |
|
1120 |
<?php else : ?> |
|
1121 |
<span class="delete-action"> |
|
1122 |
<a class="submitdelete deletion menu-delete" href=" |
|
1123 |
<?php |
|
1124 |
echo esc_url( |
|
1125 |
wp_nonce_url( |
|
1126 |
add_query_arg( |
|
1127 |
array( |
|
1128 |
'action' => 'delete', |
|
1129 |
'menu' => $nav_menu_selected_id, |
|
1130 |
), |
|
1131 |
admin_url( 'nav-menus.php' ) |
|
9 | 1132 |
), |
16 | 1133 |
'delete-nav_menu-' . $nav_menu_selected_id |
1134 |
) |
|
1135 |
); |
|
1136 |
?> |
|
1137 |
"><?php _e( 'Delete Menu' ); ?></a> |
|
1138 |
</span><!-- END .delete-action --> |
|
1139 |
<?php endif; ?> |
|
1140 |
||
0 | 1141 |
<?php endif; ?> |
1142 |
<div class="publishing-action"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1143 |
<?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 | 1144 |
</div><!-- END .publishing-action --> |
1145 |
</div><!-- END .major-publishing-actions --> |
|
1146 |
</div><!-- /#nav-menu-footer --> |
|
1147 |
</div><!-- /.menu-edit --> |
|
1148 |
</form><!-- /#update-nav-menu --> |
|
1149 |
</div><!-- /#menu-management --> |
|
1150 |
</div><!-- /#menu-management-liquid --> |
|
1151 |
</div><!-- /#nav-menus-frame --> |
|
1152 |
<?php endif; ?> |
|
1153 |
</div><!-- /.wrap--> |
|
16 | 1154 |
<?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?> |