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