author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3 |
* Core Navigation Menu API |
0 | 4 |
* |
5 |
* @package WordPress |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
* @subpackage Nav_Menus |
0 | 7 |
* @since 3.0.0 |
8 |
*/ |
|
9 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
/** Walker_Nav_Menu_Edit class */ |
16 | 11 |
require_once ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php'; |
0 | 12 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
/** Walker_Nav_Menu_Checklist class */ |
16 | 14 |
require_once ABSPATH . 'wp-admin/includes/class-walker-nav-menu-checklist.php'; |
0 | 15 |
|
16 |
/** |
|
17 |
* Prints the appropriate response to a menu quick search. |
|
18 |
* |
|
19 |
* @since 3.0.0 |
|
20 |
* |
|
21 |
* @param array $request The unsanitized request values. |
|
22 |
*/ |
|
23 |
function _wp_ajax_menu_quick_search( $request = array() ) { |
|
9 | 24 |
$args = array(); |
25 |
$type = isset( $request['type'] ) ? $request['type'] : ''; |
|
26 |
$object_type = isset( $request['object_type'] ) ? $request['object_type'] : ''; |
|
27 |
$query = isset( $request['q'] ) ? $request['q'] : ''; |
|
16 | 28 |
$response_format = isset( $request['response-format'] ) ? $request['response-format'] : ''; |
0 | 29 |
|
16 | 30 |
if ( ! $response_format || ! in_array( $response_format, array( 'json', 'markup' ), true ) ) { |
31 |
$response_format = 'json'; |
|
32 |
} |
|
33 |
||
34 |
if ( 'markup' === $response_format ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
35 |
$args['walker'] = new Walker_Nav_Menu_Checklist(); |
0 | 36 |
} |
37 |
||
16 | 38 |
if ( 'get-post-item' === $type ) { |
0 | 39 |
if ( post_type_exists( $object_type ) ) { |
40 |
if ( isset( $request['ID'] ) ) { |
|
41 |
$object_id = (int) $request['ID']; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
42 |
|
16 | 43 |
if ( 'markup' === $response_format ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
44 |
echo walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
45 |
array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
46 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
47 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
48 |
); |
16 | 49 |
} elseif ( 'json' === $response_format ) { |
5 | 50 |
echo wp_json_encode( |
0 | 51 |
array( |
9 | 52 |
'ID' => $object_id, |
0 | 53 |
'post_title' => get_the_title( $object_id ), |
9 | 54 |
'post_type' => get_post_type( $object_id ), |
0 | 55 |
) |
56 |
); |
|
57 |
echo "\n"; |
|
58 |
} |
|
59 |
} |
|
60 |
} elseif ( taxonomy_exists( $object_type ) ) { |
|
61 |
if ( isset( $request['ID'] ) ) { |
|
62 |
$object_id = (int) $request['ID']; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
63 |
|
16 | 64 |
if ( 'markup' === $response_format ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
65 |
echo walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
66 |
array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
67 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
68 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
69 |
); |
16 | 70 |
} elseif ( 'json' === $response_format ) { |
0 | 71 |
$post_obj = get_term( $object_id, $object_type ); |
5 | 72 |
echo wp_json_encode( |
0 | 73 |
array( |
9 | 74 |
'ID' => $object_id, |
0 | 75 |
'post_title' => $post_obj->name, |
9 | 76 |
'post_type' => $object_type, |
0 | 77 |
) |
78 |
); |
|
79 |
echo "\n"; |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
9 | 83 |
} elseif ( preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches ) ) { |
16 | 84 |
if ( 'posttype' === $matches[1] && get_post_type_object( $matches[2] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
$post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) ); |
9 | 86 |
$args = array_merge( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
$args, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
'no_found_rows' => true, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
'update_post_meta_cache' => false, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
'update_post_term_cache' => false, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
'posts_per_page' => 10, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
'post_type' => $matches[2], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
's' => $query, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
97 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
if ( isset( $post_type_obj->_default_query ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
$args = array_merge( $args, (array) $post_type_obj->_default_query ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
101 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
$search_results_query = new WP_Query( $args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
if ( ! $search_results_query->have_posts() ) { |
0 | 104 |
return; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
106 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
while ( $search_results_query->have_posts() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
$post = $search_results_query->next_post(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
109 |
|
16 | 110 |
if ( 'markup' === $response_format ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
$var_by_ref = $post->ID; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
112 |
echo walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
113 |
array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
114 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
115 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
116 |
); |
16 | 117 |
} elseif ( 'json' === $response_format ) { |
5 | 118 |
echo wp_json_encode( |
0 | 119 |
array( |
9 | 120 |
'ID' => $post->ID, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
'post_title' => get_the_title( $post->ID ), |
9 | 122 |
'post_type' => $matches[2], |
0 | 123 |
) |
124 |
); |
|
125 |
echo "\n"; |
|
126 |
} |
|
127 |
} |
|
16 | 128 |
} elseif ( 'taxonomy' === $matches[1] ) { |
9 | 129 |
$terms = get_terms( |
130 |
array( |
|
131 |
'taxonomy' => $matches[2], |
|
132 |
'name__like' => $query, |
|
133 |
'number' => 10, |
|
16 | 134 |
'hide_empty' => false, |
9 | 135 |
) |
136 |
); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
137 |
|
9 | 138 |
if ( empty( $terms ) || is_wp_error( $terms ) ) { |
0 | 139 |
return; |
9 | 140 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
141 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
foreach ( (array) $terms as $term ) { |
16 | 143 |
if ( 'markup' === $response_format ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
144 |
echo walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
145 |
array_map( 'wp_setup_nav_menu_item', array( $term ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
146 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
147 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
148 |
); |
16 | 149 |
} elseif ( 'json' === $response_format ) { |
5 | 150 |
echo wp_json_encode( |
0 | 151 |
array( |
9 | 152 |
'ID' => $term->term_id, |
0 | 153 |
'post_title' => $term->name, |
9 | 154 |
'post_type' => $matches[2], |
0 | 155 |
) |
156 |
); |
|
157 |
echo "\n"; |
|
158 |
} |
|
159 |
} |
|
160 |
} |
|
161 |
} |
|
162 |
} |
|
163 |
||
164 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
165 |
* Register nav menu meta boxes and advanced menu items. |
0 | 166 |
* |
167 |
* @since 3.0.0 |
|
9 | 168 |
*/ |
0 | 169 |
function wp_nav_menu_setup() { |
16 | 170 |
// Register meta boxes. |
0 | 171 |
wp_nav_menu_post_type_meta_boxes(); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
172 |
add_meta_box( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
173 |
'add-custom-links', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
174 |
__( 'Custom Links' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
175 |
'wp_nav_menu_item_link_meta_box', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
176 |
'nav-menus', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
177 |
'side', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
178 |
'default' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
179 |
); |
0 | 180 |
wp_nav_menu_taxonomy_meta_boxes(); |
181 |
||
16 | 182 |
// Register advanced menu items (columns). |
0 | 183 |
add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' ); |
184 |
||
185 |
// If first time editing, disable advanced items by default. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) { |
0 | 187 |
$user = wp_get_current_user(); |
18 | 188 |
update_user_meta( |
9 | 189 |
$user->ID, |
190 |
'managenav-menuscolumnshidden', |
|
191 |
array( |
|
192 |
0 => 'link-target', |
|
193 |
1 => 'css-classes', |
|
194 |
2 => 'xfn', |
|
195 |
3 => 'description', |
|
196 |
4 => 'title-attribute', |
|
18 | 197 |
) |
9 | 198 |
); |
0 | 199 |
} |
200 |
} |
|
201 |
||
202 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
203 |
* Limit the amount of meta boxes to pages, posts, links, and categories for first time users. |
0 | 204 |
* |
205 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
206 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
207 |
* @global array $wp_meta_boxes Global meta box state. |
9 | 208 |
*/ |
0 | 209 |
function wp_initial_nav_menu_meta_boxes() { |
210 |
global $wp_meta_boxes; |
|
211 |
||
9 | 212 |
if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array( $wp_meta_boxes ) ) { |
0 | 213 |
return; |
9 | 214 |
} |
0 | 215 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' ); |
9 | 217 |
$hidden_meta_boxes = array(); |
0 | 218 |
|
9 | 219 |
foreach ( array_keys( $wp_meta_boxes['nav-menus'] ) as $context ) { |
220 |
foreach ( array_keys( $wp_meta_boxes['nav-menus'][ $context ] ) as $priority ) { |
|
221 |
foreach ( $wp_meta_boxes['nav-menus'][ $context ][ $priority ] as $box ) { |
|
16 | 222 |
if ( in_array( $box['id'], $initial_meta_boxes, true ) ) { |
0 | 223 |
unset( $box['id'] ); |
224 |
} else { |
|
225 |
$hidden_meta_boxes[] = $box['id']; |
|
226 |
} |
|
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
$user = wp_get_current_user(); |
|
18 | 232 |
update_user_meta( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes ); |
0 | 233 |
} |
234 |
||
235 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
* Creates meta boxes for any post type menu item.. |
0 | 237 |
* |
238 |
* @since 3.0.0 |
|
239 |
*/ |
|
240 |
function wp_nav_menu_post_type_meta_boxes() { |
|
241 |
$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
|
242 |
||
9 | 243 |
if ( ! $post_types ) { |
0 | 244 |
return; |
9 | 245 |
} |
0 | 246 |
|
247 |
foreach ( $post_types as $post_type ) { |
|
5 | 248 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
* Filters whether a menu items meta box will be added for the current |
5 | 250 |
* object type. |
251 |
* |
|
252 |
* If a falsey value is returned instead of an object, the menu items |
|
253 |
* meta box for the current meta box object will not be added. |
|
254 |
* |
|
255 |
* @since 3.0.0 |
|
256 |
* |
|
16 | 257 |
* @param WP_Post_Type|false $post_type The current object to add a menu items |
258 |
* meta box for. |
|
5 | 259 |
*/ |
0 | 260 |
$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
261 |
|
0 | 262 |
if ( $post_type ) { |
263 |
$id = $post_type->name; |
|
5 | 264 |
// Give pages a higher priority. |
16 | 265 |
$priority = ( 'page' === $post_type->name ? 'core' : 'default' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
266 |
add_meta_box( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
267 |
"add-post-type-{$id}", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
268 |
$post_type->labels->name, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
269 |
'wp_nav_menu_item_post_type_meta_box', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
270 |
'nav-menus', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
271 |
'side', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
272 |
$priority, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
273 |
$post_type |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
274 |
); |
0 | 275 |
} |
276 |
} |
|
277 |
} |
|
278 |
||
279 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
* Creates meta boxes for any taxonomy menu item. |
0 | 281 |
* |
282 |
* @since 3.0.0 |
|
283 |
*/ |
|
284 |
function wp_nav_menu_taxonomy_meta_boxes() { |
|
285 |
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); |
|
286 |
||
9 | 287 |
if ( ! $taxonomies ) { |
0 | 288 |
return; |
9 | 289 |
} |
0 | 290 |
|
291 |
foreach ( $taxonomies as $tax ) { |
|
5 | 292 |
/** This filter is documented in wp-admin/includes/nav-menu.php */ |
0 | 293 |
$tax = apply_filters( 'nav_menu_meta_box_object', $tax ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
294 |
|
0 | 295 |
if ( $tax ) { |
296 |
$id = $tax->name; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
297 |
add_meta_box( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
298 |
"add-{$id}", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
299 |
$tax->labels->name, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
300 |
'wp_nav_menu_item_taxonomy_meta_box', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
301 |
'nav-menus', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
302 |
'side', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
303 |
'default', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
304 |
$tax |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
305 |
); |
0 | 306 |
} |
307 |
} |
|
308 |
} |
|
309 |
||
310 |
/** |
|
16 | 311 |
* Check whether to disable the Menu Locations meta box submit button and inputs. |
0 | 312 |
* |
313 |
* @since 3.6.0 |
|
19 | 314 |
* @since 5.3.1 The `$display` parameter was added. |
0 | 315 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
* @global bool $one_theme_location_no_menus to determine if no menus exist |
0 | 317 |
* |
16 | 318 |
* @param int|string $nav_menu_selected_id ID, name, or slug of the currently selected menu. |
19 | 319 |
* @param bool $display Whether to display or just return the string. |
16 | 320 |
* @return string|false Disabled attribute if at least one menu exists, false if not. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
*/ |
19 | 322 |
function wp_nav_menu_disabled_check( $nav_menu_selected_id, $display = true ) { |
0 | 323 |
global $one_theme_location_no_menus; |
324 |
||
9 | 325 |
if ( $one_theme_location_no_menus ) { |
0 | 326 |
return false; |
9 | 327 |
} |
0 | 328 |
|
19 | 329 |
return disabled( $nav_menu_selected_id, 0, $display ); |
0 | 330 |
} |
331 |
||
332 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
* Displays a meta box for the custom links menu item. |
0 | 334 |
* |
335 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
* @global int $_nav_menu_placeholder |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
* @global int|string $nav_menu_selected_id |
0 | 339 |
*/ |
340 |
function wp_nav_menu_item_link_meta_box() { |
|
341 |
global $_nav_menu_placeholder, $nav_menu_selected_id; |
|
342 |
||
343 |
$_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1; |
|
344 |
||
345 |
?> |
|
346 |
<div class="customlinkdiv" id="customlinkdiv"> |
|
347 |
<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" /> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
<p id="menu-item-url-wrap" class="wp-clearfix"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
350 |
<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
351 |
type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
352 |
class="code menu-item-textbox form-required" placeholder="https://" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
353 |
/> |
0 | 354 |
</p> |
355 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
<p id="menu-item-name-wrap" class="wp-clearfix"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
358 |
<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
359 |
type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
360 |
class="regular-text menu-item-textbox" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
361 |
/> |
0 | 362 |
</p> |
363 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
<p class="button-controls wp-clearfix"> |
0 | 365 |
<span class="add-to-menu"> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
366 |
<input id="submit-customlinkdiv" name="add-custom-menu-item" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
367 |
type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
368 |
class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
369 |
/> |
0 | 370 |
<span class="spinner"></span> |
371 |
</span> |
|
372 |
</p> |
|
373 |
||
374 |
</div><!-- /.customlinkdiv --> |
|
375 |
<?php |
|
376 |
} |
|
377 |
||
378 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
* Displays a meta box for a post type menu item. |
0 | 380 |
* |
381 |
* @since 3.0.0 |
|
382 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
* @global int $_nav_menu_placeholder |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
* @global int|string $nav_menu_selected_id |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
* |
19 | 386 |
* @param string $data_object Not used. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
* @param array $box { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
* Post type menu item meta box arguments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
* @type string $id Meta box 'id' attribute. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
* @type string $title Meta box title. |
16 | 392 |
* @type callable $callback Meta box display callback. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
* @type WP_Post_Type $args Extra meta box arguments (the post type object for this meta box). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
* } |
0 | 395 |
*/ |
19 | 396 |
function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) { |
0 | 397 |
global $_nav_menu_placeholder, $nav_menu_selected_id; |
398 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
$post_type_name = $box['args']->name; |
16 | 400 |
$post_type = get_post_type_object( $post_type_name ); |
401 |
$tab_name = $post_type_name . '-tab'; |
|
0 | 402 |
|
5 | 403 |
// Paginate browsing for large numbers of post objects. |
0 | 404 |
$per_page = 50; |
16 | 405 |
$pagenum = isset( $_REQUEST[ $tab_name ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; |
9 | 406 |
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; |
0 | 407 |
|
408 |
$args = array( |
|
9 | 409 |
'offset' => $offset, |
410 |
'order' => 'ASC', |
|
411 |
'orderby' => 'title', |
|
412 |
'posts_per_page' => $per_page, |
|
413 |
'post_type' => $post_type_name, |
|
414 |
'suppress_filters' => true, |
|
0 | 415 |
'update_post_term_cache' => false, |
9 | 416 |
'update_post_meta_cache' => false, |
0 | 417 |
); |
418 |
||
9 | 419 |
if ( isset( $box['args']->_default_query ) ) { |
420 |
$args = array_merge( $args, (array) $box['args']->_default_query ); |
|
421 |
} |
|
0 | 422 |
|
16 | 423 |
/* |
424 |
* If we're dealing with pages, let's prioritize the Front Page, |
|
425 |
* Posts Page and Privacy Policy Page at the top of the list. |
|
426 |
*/ |
|
427 |
$important_pages = array(); |
|
428 |
if ( 'page' === $post_type_name ) { |
|
429 |
$suppress_page_ids = array(); |
|
430 |
||
431 |
// Insert Front Page or custom Home link. |
|
432 |
$front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; |
|
433 |
||
434 |
$front_page_obj = null; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
435 |
|
16 | 436 |
if ( ! empty( $front_page ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
437 |
$front_page_obj = get_post( $front_page ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
438 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
439 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
440 |
if ( $front_page_obj ) { |
16 | 441 |
$front_page_obj->front_or_home = true; |
442 |
||
443 |
$important_pages[] = $front_page_obj; |
|
444 |
$suppress_page_ids[] = $front_page_obj->ID; |
|
445 |
} else { |
|
18 | 446 |
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1; |
16 | 447 |
$front_page_obj = (object) array( |
448 |
'front_or_home' => true, |
|
449 |
'ID' => 0, |
|
450 |
'object_id' => $_nav_menu_placeholder, |
|
451 |
'post_content' => '', |
|
452 |
'post_excerpt' => '', |
|
453 |
'post_parent' => '', |
|
454 |
'post_title' => _x( 'Home', 'nav menu home label' ), |
|
455 |
'post_type' => 'nav_menu_item', |
|
456 |
'type' => 'custom', |
|
457 |
'url' => home_url( '/' ), |
|
458 |
); |
|
459 |
||
460 |
$important_pages[] = $front_page_obj; |
|
461 |
} |
|
462 |
||
463 |
// Insert Posts Page. |
|
464 |
$posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0; |
|
465 |
||
466 |
if ( ! empty( $posts_page ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
467 |
$posts_page_obj = get_post( $posts_page ); |
16 | 468 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
469 |
if ( $posts_page_obj ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
470 |
$front_page_obj->posts_page = true; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
471 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
472 |
$important_pages[] = $posts_page_obj; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
473 |
$suppress_page_ids[] = $posts_page_obj->ID; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
474 |
} |
16 | 475 |
} |
476 |
||
477 |
// Insert Privacy Policy Page. |
|
478 |
$privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); |
|
479 |
||
480 |
if ( ! empty( $privacy_policy_page_id ) ) { |
|
481 |
$privacy_policy_page = get_post( $privacy_policy_page_id ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
482 |
|
16 | 483 |
if ( $privacy_policy_page instanceof WP_Post && 'publish' === $privacy_policy_page->post_status ) { |
484 |
$privacy_policy_page->privacy_policy_page = true; |
|
485 |
||
486 |
$important_pages[] = $privacy_policy_page; |
|
487 |
$suppress_page_ids[] = $privacy_policy_page->ID; |
|
488 |
} |
|
489 |
} |
|
490 |
||
491 |
// Add suppression array to arguments for WP_Query. |
|
492 |
if ( ! empty( $suppress_page_ids ) ) { |
|
493 |
$args['post__not_in'] = $suppress_page_ids; |
|
494 |
} |
|
495 |
} |
|
496 |
||
497 |
// @todo Transient caching of these results with proper invalidation on updating of a post of this type. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
498 |
$get_posts = new WP_Query(); |
9 | 499 |
$posts = $get_posts->query( $args ); |
16 | 500 |
|
501 |
// Only suppress and insert when more than just suppression pages available. |
|
0 | 502 |
if ( ! $get_posts->post_count ) { |
16 | 503 |
if ( ! empty( $suppress_page_ids ) ) { |
504 |
unset( $args['post__not_in'] ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
505 |
$get_posts = new WP_Query(); |
16 | 506 |
$posts = $get_posts->query( $args ); |
507 |
} else { |
|
508 |
echo '<p>' . __( 'No items.' ) . '</p>'; |
|
509 |
return; |
|
510 |
} |
|
511 |
} elseif ( ! empty( $important_pages ) ) { |
|
512 |
$posts = array_merge( $important_pages, $posts ); |
|
0 | 513 |
} |
514 |
||
515 |
$num_pages = $get_posts->max_num_pages; |
|
516 |
||
9 | 517 |
$page_links = paginate_links( |
518 |
array( |
|
519 |
'base' => add_query_arg( |
|
520 |
array( |
|
16 | 521 |
$tab_name => 'all', |
522 |
'paged' => '%#%', |
|
523 |
'item-type' => 'post_type', |
|
524 |
'item-object' => $post_type_name, |
|
9 | 525 |
) |
526 |
), |
|
527 |
'format' => '', |
|
528 |
'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>', |
|
529 |
'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>', |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
530 |
/* translators: Hidden accessibility text. */ |
9 | 531 |
'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ', |
532 |
'total' => $num_pages, |
|
533 |
'current' => $pagenum, |
|
534 |
) |
|
535 |
); |
|
0 | 536 |
|
537 |
$db_fields = false; |
|
538 |
if ( is_post_type_hierarchical( $post_type_name ) ) { |
|
9 | 539 |
$db_fields = array( |
540 |
'parent' => 'post_parent', |
|
541 |
'id' => 'ID', |
|
542 |
); |
|
0 | 543 |
} |
544 |
||
545 |
$walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
546 |
||
547 |
$current_tab = 'most-recent'; |
|
16 | 548 |
|
549 |
if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array( 'all', 'search' ), true ) ) { |
|
550 |
$current_tab = $_REQUEST[ $tab_name ]; |
|
0 | 551 |
} |
552 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
553 |
if ( ! empty( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ) ) { |
0 | 554 |
$current_tab = 'search'; |
555 |
} |
|
556 |
||
557 |
$removed_args = array( |
|
558 |
'action', |
|
559 |
'customlink-tab', |
|
560 |
'edit-menu-item', |
|
561 |
'menu-item', |
|
562 |
'page-tab', |
|
563 |
'_wpnonce', |
|
564 |
); |
|
565 |
||
16 | 566 |
$most_recent_url = ''; |
567 |
$view_all_url = ''; |
|
568 |
$search_url = ''; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
569 |
|
9 | 570 |
if ( $nav_menu_selected_id ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
571 |
$most_recent_url = add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
572 |
$view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
573 |
$search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ); |
9 | 574 |
} |
0 | 575 |
?> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
576 |
<div id="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>" class="posttypediv"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
577 |
<ul id="<?php echo esc_attr( "posttype-{$post_type_name}-tabs" ); ?>" class="posttype-tabs add-menu-item-tabs"> |
16 | 578 |
<li <?php echo ( 'most-recent' === $current_tab ? ' class="tabs"' : '' ); ?>> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
579 |
<a class="nav-tab-link" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
580 |
data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
581 |
href="<?php echo esc_url( $most_recent_url . "#tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
582 |
> |
0 | 583 |
<?php _e( 'Most Recent' ); ?> |
584 |
</a> |
|
585 |
</li> |
|
16 | 586 |
<li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
587 |
<a class="nav-tab-link" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
588 |
data-type="<?php echo esc_attr( "{$post_type_name}-all" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
589 |
href="<?php echo esc_url( $view_all_url . "#{$post_type_name}-all" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
590 |
> |
0 | 591 |
<?php _e( 'View All' ); ?> |
592 |
</a> |
|
593 |
</li> |
|
16 | 594 |
<li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
595 |
<a class="nav-tab-link" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
596 |
data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
597 |
href="<?php echo esc_url( $search_url . "#tabs-panel-posttype-{$post_type_name}-search" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
598 |
> |
9 | 599 |
<?php _e( 'Search' ); ?> |
0 | 600 |
</a> |
601 |
</li> |
|
602 |
</ul><!-- .posttype-tabs --> |
|
603 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
604 |
<div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
605 |
class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
606 |
role="region" aria-label="<?php esc_attr_e( 'Most Recent' ); ?>" tabindex="0" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
607 |
> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
608 |
<ul id="<?php echo esc_attr( "{$post_type_name}checklist-most-recent" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
609 |
class="categorychecklist form-no-clear" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
610 |
> |
0 | 611 |
<?php |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
612 |
$recent_args = array_merge( |
9 | 613 |
$args, |
614 |
array( |
|
615 |
'orderby' => 'post_date', |
|
616 |
'order' => 'DESC', |
|
617 |
'posts_per_page' => 15, |
|
618 |
) |
|
619 |
); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
620 |
$most_recent = $get_posts->query( $recent_args ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
621 |
|
0 | 622 |
$args['walker'] = $walker; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
* Filters the posts displayed in the 'Most Recent' tab of the current |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
626 |
* post type's menu items meta box. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
* The dynamic portion of the hook name, `$post_type_name`, refers to the post type name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
629 |
* |
18 | 630 |
* Possible hook names include: |
631 |
* |
|
632 |
* - `nav_menu_items_post_recent` |
|
633 |
* - `nav_menu_items_page_recent` |
|
634 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
635 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
* @since 4.9.0 Added the `$recent_args` parameter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
637 |
* |
9 | 638 |
* @param WP_Post[] $most_recent An array of post objects being listed. |
639 |
* @param array $args An array of `WP_Query` arguments for the meta box. |
|
640 |
* @param array $box Arguments passed to `wp_nav_menu_item_post_type_meta_box()`. |
|
641 |
* @param array $recent_args An array of `WP_Query` arguments for 'Most Recent' tab. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
643 |
$most_recent = apply_filters( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
644 |
"nav_menu_items_{$post_type_name}_recent", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
645 |
$most_recent, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
646 |
$args, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
647 |
$box, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
648 |
$recent_args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
649 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
651 |
echo walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
652 |
array_map( 'wp_setup_nav_menu_item', $most_recent ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
653 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
654 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
655 |
); |
0 | 656 |
?> |
657 |
</ul> |
|
658 |
</div><!-- /.tabs-panel --> |
|
659 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
660 |
<div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
661 |
class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
662 |
role="region" aria-label="<?php echo esc_attr( $post_type->labels->search_items ); ?>" tabindex="0" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
663 |
> |
0 | 664 |
<?php |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
665 |
if ( isset( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
666 |
$searched = esc_attr( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ); |
9 | 667 |
$search_results = get_posts( |
668 |
array( |
|
669 |
's' => $searched, |
|
670 |
'post_type' => $post_type_name, |
|
671 |
'fields' => 'all', |
|
672 |
'order' => 'DESC', |
|
673 |
) |
|
674 |
); |
|
0 | 675 |
} else { |
9 | 676 |
$searched = ''; |
0 | 677 |
$search_results = array(); |
678 |
} |
|
679 |
?> |
|
680 |
<p class="quick-search-wrap"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
681 |
<label for="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" class="screen-reader-text"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
682 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
683 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
684 |
_e( 'Search' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
685 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
686 |
</label> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
687 |
<input type="search"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
688 |
class="quick-search" value="<?php echo $searched; ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
689 |
name="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
690 |
id="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
691 |
/> |
0 | 692 |
<span class="spinner"></span> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
693 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
694 |
submit_button( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
695 |
__( 'Search' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
696 |
'small quick-search-submit hide-if-js', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
697 |
'submit', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
698 |
false, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
699 |
array( 'id' => "submit-quick-search-posttype-{$post_type_name}" ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
700 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
701 |
?> |
0 | 702 |
</p> |
703 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
704 |
<ul id="<?php echo esc_attr( "{$post_type_name}-search-checklist" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
705 |
data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
706 |
class="categorychecklist form-no-clear" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
707 |
> |
0 | 708 |
<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
709 |
<?php |
|
710 |
$args['walker'] = $walker; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
711 |
echo walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
712 |
array_map( 'wp_setup_nav_menu_item', $search_results ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
713 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
714 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
715 |
); |
0 | 716 |
?> |
717 |
<?php elseif ( is_wp_error( $search_results ) ) : ?> |
|
718 |
<li><?php echo $search_results->get_error_message(); ?></li> |
|
719 |
<?php elseif ( ! empty( $searched ) ) : ?> |
|
9 | 720 |
<li><?php _e( 'No results found.' ); ?></li> |
0 | 721 |
<?php endif; ?> |
722 |
</ul> |
|
723 |
</div><!-- /.tabs-panel --> |
|
724 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
725 |
<div id="<?php echo esc_attr( "{$post_type_name}-all" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
726 |
class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
727 |
role="region" aria-label="<?php echo esc_attr( $post_type->labels->all_items ); ?>" tabindex="0" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
728 |
> |
0 | 729 |
<?php if ( ! empty( $page_links ) ) : ?> |
730 |
<div class="add-menu-item-pagelinks"> |
|
731 |
<?php echo $page_links; ?> |
|
732 |
</div> |
|
733 |
<?php endif; ?> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
734 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
735 |
<ul id="<?php echo esc_attr( "{$post_type_name}checklist" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
736 |
data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
737 |
class="categorychecklist form-no-clear" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
738 |
> |
0 | 739 |
<?php |
740 |
$args['walker'] = $walker; |
|
741 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
742 |
if ( $post_type->has_archive ) { |
18 | 743 |
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1; |
9 | 744 |
array_unshift( |
745 |
$posts, |
|
746 |
(object) array( |
|
747 |
'ID' => 0, |
|
748 |
'object_id' => $_nav_menu_placeholder, |
|
749 |
'object' => $post_type_name, |
|
750 |
'post_content' => '', |
|
751 |
'post_excerpt' => '', |
|
752 |
'post_title' => $post_type->labels->archives, |
|
753 |
'post_type' => 'nav_menu_item', |
|
754 |
'type' => 'post_type_archive', |
|
755 |
'url' => get_post_type_archive_link( $post_type_name ), |
|
756 |
) |
|
757 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
758 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
|
5 | 760 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
* Filters the posts displayed in the 'View All' tab of the current |
5 | 762 |
* post type's menu items meta box. |
763 |
* |
|
764 |
* The dynamic portion of the hook name, `$post_type_name`, refers |
|
765 |
* to the slug of the current post type. |
|
766 |
* |
|
18 | 767 |
* Possible hook names include: |
768 |
* |
|
769 |
* - `nav_menu_items_post` |
|
770 |
* - `nav_menu_items_page` |
|
771 |
* |
|
5 | 772 |
* @since 3.2.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
773 |
* @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object. |
5 | 774 |
* |
775 |
* @see WP_Query::query() |
|
776 |
* |
|
9 | 777 |
* @param object[] $posts The posts for the current post type. Mostly `WP_Post` objects, but |
778 |
* can also contain "fake" post objects to represent other menu items. |
|
779 |
* @param array $args An array of `WP_Query` arguments. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
780 |
* @param WP_Post_Type $post_type The current post type object for this menu item meta box. |
5 | 781 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
782 |
$posts = apply_filters( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
783 |
"nav_menu_items_{$post_type_name}", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
784 |
$posts, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
785 |
$args, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
786 |
$post_type |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
787 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
788 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
789 |
$checkbox_items = walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
790 |
array_map( 'wp_setup_nav_menu_item', $posts ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
791 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
792 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
793 |
); |
0 | 794 |
|
795 |
echo $checkbox_items; |
|
796 |
?> |
|
797 |
</ul> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
798 |
|
0 | 799 |
<?php if ( ! empty( $page_links ) ) : ?> |
800 |
<div class="add-menu-item-pagelinks"> |
|
801 |
<?php echo $page_links; ?> |
|
802 |
</div> |
|
803 |
<?php endif; ?> |
|
804 |
</div><!-- /.tabs-panel --> |
|
805 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
806 |
<p class="button-controls wp-clearfix" data-items-type="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>"> |
16 | 807 |
<span class="list-controls hide-if-no-js"> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
808 |
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
809 |
id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
810 |
/> |
16 | 811 |
<label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> |
0 | 812 |
</span> |
813 |
||
814 |
<span class="add-to-menu"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
815 |
<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
816 |
class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
817 |
name="add-post-type-menu-item" id="<?php echo esc_attr( "submit-posttype-{$post_type_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
818 |
/> |
0 | 819 |
<span class="spinner"></span> |
820 |
</span> |
|
821 |
</p> |
|
822 |
||
823 |
</div><!-- /.posttypediv --> |
|
824 |
<?php |
|
825 |
} |
|
826 |
||
827 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
828 |
* Displays a meta box for a taxonomy menu item. |
0 | 829 |
* |
830 |
* @since 3.0.0 |
|
831 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
832 |
* @global int|string $nav_menu_selected_id |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
833 |
* |
19 | 834 |
* @param string $data_object Not used. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
835 |
* @param array $box { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
* Taxonomy menu item meta box arguments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
837 |
* |
16 | 838 |
* @type string $id Meta box 'id' attribute. |
839 |
* @type string $title Meta box title. |
|
840 |
* @type callable $callback Meta box display callback. |
|
841 |
* @type object $args Extra meta box arguments (the taxonomy object for this meta box). |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
842 |
* } |
0 | 843 |
*/ |
19 | 844 |
function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) { |
0 | 845 |
global $nav_menu_selected_id; |
16 | 846 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
$taxonomy_name = $box['args']->name; |
9 | 848 |
$taxonomy = get_taxonomy( $taxonomy_name ); |
16 | 849 |
$tab_name = $taxonomy_name . '-tab'; |
0 | 850 |
|
5 | 851 |
// Paginate browsing for large numbers of objects. |
0 | 852 |
$per_page = 50; |
16 | 853 |
$pagenum = isset( $_REQUEST[ $tab_name ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; |
9 | 854 |
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; |
0 | 855 |
|
856 |
$args = array( |
|
16 | 857 |
'taxonomy' => $taxonomy_name, |
9 | 858 |
'child_of' => 0, |
859 |
'exclude' => '', |
|
860 |
'hide_empty' => false, |
|
0 | 861 |
'hierarchical' => 1, |
9 | 862 |
'include' => '', |
863 |
'number' => $per_page, |
|
864 |
'offset' => $offset, |
|
865 |
'order' => 'ASC', |
|
866 |
'orderby' => 'name', |
|
867 |
'pad_counts' => false, |
|
0 | 868 |
); |
869 |
||
16 | 870 |
$terms = get_terms( $args ); |
0 | 871 |
|
9 | 872 |
if ( ! $terms || is_wp_error( $terms ) ) { |
0 | 873 |
echo '<p>' . __( 'No items.' ) . '</p>'; |
874 |
return; |
|
875 |
} |
|
876 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
877 |
$num_pages = (int) ceil( |
9 | 878 |
wp_count_terms( |
879 |
array_merge( |
|
880 |
$args, |
|
881 |
array( |
|
882 |
'number' => '', |
|
883 |
'offset' => '', |
|
884 |
) |
|
885 |
) |
|
886 |
) / $per_page |
|
887 |
); |
|
0 | 888 |
|
9 | 889 |
$page_links = paginate_links( |
890 |
array( |
|
891 |
'base' => add_query_arg( |
|
892 |
array( |
|
16 | 893 |
$tab_name => 'all', |
894 |
'paged' => '%#%', |
|
895 |
'item-type' => 'taxonomy', |
|
896 |
'item-object' => $taxonomy_name, |
|
9 | 897 |
) |
898 |
), |
|
899 |
'format' => '', |
|
900 |
'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>', |
|
901 |
'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>', |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
902 |
/* translators: Hidden accessibility text. */ |
9 | 903 |
'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ', |
904 |
'total' => $num_pages, |
|
905 |
'current' => $pagenum, |
|
906 |
) |
|
907 |
); |
|
0 | 908 |
|
909 |
$db_fields = false; |
|
910 |
if ( is_taxonomy_hierarchical( $taxonomy_name ) ) { |
|
9 | 911 |
$db_fields = array( |
912 |
'parent' => 'parent', |
|
913 |
'id' => 'term_id', |
|
914 |
); |
|
0 | 915 |
} |
916 |
||
917 |
$walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
918 |
||
919 |
$current_tab = 'most-used'; |
|
16 | 920 |
|
921 |
if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array( 'all', 'most-used', 'search' ), true ) ) { |
|
922 |
$current_tab = $_REQUEST[ $tab_name ]; |
|
0 | 923 |
} |
924 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
925 |
if ( ! empty( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ) ) { |
0 | 926 |
$current_tab = 'search'; |
927 |
} |
|
928 |
||
929 |
$removed_args = array( |
|
930 |
'action', |
|
931 |
'customlink-tab', |
|
932 |
'edit-menu-item', |
|
933 |
'menu-item', |
|
934 |
'page-tab', |
|
935 |
'_wpnonce', |
|
936 |
); |
|
937 |
||
16 | 938 |
$most_used_url = ''; |
939 |
$view_all_url = ''; |
|
940 |
$search_url = ''; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
941 |
|
9 | 942 |
if ( $nav_menu_selected_id ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
943 |
$most_used_url = add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
944 |
$view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
945 |
$search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ); |
9 | 946 |
} |
0 | 947 |
?> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
948 |
<div id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}" ); ?>" class="taxonomydiv"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
949 |
<ul id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}-tabs" ); ?>" class="taxonomy-tabs add-menu-item-tabs"> |
16 | 950 |
<li <?php echo ( 'most-used' === $current_tab ? ' class="tabs"' : '' ); ?>> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
951 |
<a class="nav-tab-link" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
952 |
data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
953 |
href="<?php echo esc_url( $most_used_url . "#tabs-panel-{$taxonomy_name}-pop" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
954 |
> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
955 |
<?php echo esc_html( $taxonomy->labels->most_used ); ?> |
0 | 956 |
</a> |
957 |
</li> |
|
16 | 958 |
<li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
959 |
<a class="nav-tab-link" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
960 |
data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-all" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
961 |
href="<?php echo esc_url( $view_all_url . "#tabs-panel-{$taxonomy_name}-all" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
962 |
> |
0 | 963 |
<?php _e( 'View All' ); ?> |
964 |
</a> |
|
965 |
</li> |
|
16 | 966 |
<li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
967 |
<a class="nav-tab-link" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
968 |
data-type="<?php echo esc_attr( "tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
969 |
href="<?php echo esc_url( $search_url . "#tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
970 |
> |
0 | 971 |
<?php _e( 'Search' ); ?> |
972 |
</a> |
|
973 |
</li> |
|
974 |
</ul><!-- .taxonomy-tabs --> |
|
975 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
976 |
<div id="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
977 |
class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
978 |
role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->most_used ); ?>" tabindex="0" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
979 |
> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
980 |
<ul id="<?php echo esc_attr( "{$taxonomy_name}checklist-pop" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
981 |
class="categorychecklist form-no-clear" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
982 |
> |
0 | 983 |
<?php |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
984 |
$popular_terms = get_terms( |
9 | 985 |
array( |
16 | 986 |
'taxonomy' => $taxonomy_name, |
9 | 987 |
'orderby' => 'count', |
988 |
'order' => 'DESC', |
|
989 |
'number' => 10, |
|
990 |
'hierarchical' => false, |
|
991 |
) |
|
992 |
); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
993 |
|
0 | 994 |
$args['walker'] = $walker; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
995 |
echo walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
996 |
array_map( 'wp_setup_nav_menu_item', $popular_terms ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
997 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
998 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
999 |
); |
0 | 1000 |
?> |
1001 |
</ul> |
|
1002 |
</div><!-- /.tabs-panel --> |
|
1003 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1004 |
<div id="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-all" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1005 |
class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1006 |
role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->all_items ); ?>" tabindex="0" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1007 |
> |
0 | 1008 |
<?php if ( ! empty( $page_links ) ) : ?> |
1009 |
<div class="add-menu-item-pagelinks"> |
|
1010 |
<?php echo $page_links; ?> |
|
1011 |
</div> |
|
1012 |
<?php endif; ?> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1013 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1014 |
<ul id="<?php echo esc_attr( "{$taxonomy_name}checklist" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1015 |
data-wp-lists="<?php echo esc_attr( "list:{$taxonomy_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1016 |
class="categorychecklist form-no-clear" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1017 |
> |
0 | 1018 |
<?php |
1019 |
$args['walker'] = $walker; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1020 |
echo walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1021 |
array_map( 'wp_setup_nav_menu_item', $terms ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1022 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1023 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1024 |
); |
0 | 1025 |
?> |
1026 |
</ul> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1027 |
|
0 | 1028 |
<?php if ( ! empty( $page_links ) ) : ?> |
1029 |
<div class="add-menu-item-pagelinks"> |
|
1030 |
<?php echo $page_links; ?> |
|
1031 |
</div> |
|
1032 |
<?php endif; ?> |
|
1033 |
</div><!-- /.tabs-panel --> |
|
1034 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1035 |
<div id="<?php echo esc_attr( "tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1036 |
class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1037 |
role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->search_items ); ?>" tabindex="0"> |
0 | 1038 |
<?php |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1039 |
if ( isset( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1040 |
$searched = esc_attr( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ); |
9 | 1041 |
$search_results = get_terms( |
1042 |
array( |
|
16 | 1043 |
'taxonomy' => $taxonomy_name, |
9 | 1044 |
'name__like' => $searched, |
1045 |
'fields' => 'all', |
|
1046 |
'orderby' => 'count', |
|
1047 |
'order' => 'DESC', |
|
1048 |
'hierarchical' => false, |
|
1049 |
) |
|
1050 |
); |
|
0 | 1051 |
} else { |
9 | 1052 |
$searched = ''; |
0 | 1053 |
$search_results = array(); |
1054 |
} |
|
1055 |
?> |
|
1056 |
<p class="quick-search-wrap"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1057 |
<label for="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" class="screen-reader-text"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1058 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1059 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1060 |
_e( 'Search' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1061 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1062 |
</label> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1063 |
<input type="search" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1064 |
class="quick-search" value="<?php echo $searched; ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1065 |
name="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1066 |
id="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1067 |
/> |
0 | 1068 |
<span class="spinner"></span> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1069 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1070 |
submit_button( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1071 |
__( 'Search' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1072 |
'small quick-search-submit hide-if-js', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1073 |
'submit', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1074 |
false, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1075 |
array( 'id' => "submit-quick-search-taxonomy-{$taxonomy_name}" ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1076 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1077 |
?> |
0 | 1078 |
</p> |
1079 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1080 |
<ul id="<?php echo esc_attr( "{$taxonomy_name}-search-checklist" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1081 |
data-wp-lists="<?php echo esc_attr( "list:{$taxonomy_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1082 |
class="categorychecklist form-no-clear" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1083 |
> |
0 | 1084 |
<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
1085 |
<?php |
|
1086 |
$args['walker'] = $walker; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1087 |
echo walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1088 |
array_map( 'wp_setup_nav_menu_item', $search_results ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1089 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1090 |
(object) $args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1091 |
); |
0 | 1092 |
?> |
1093 |
<?php elseif ( is_wp_error( $search_results ) ) : ?> |
|
1094 |
<li><?php echo $search_results->get_error_message(); ?></li> |
|
1095 |
<?php elseif ( ! empty( $searched ) ) : ?> |
|
9 | 1096 |
<li><?php _e( 'No results found.' ); ?></li> |
0 | 1097 |
<?php endif; ?> |
1098 |
</ul> |
|
1099 |
</div><!-- /.tabs-panel --> |
|
1100 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1101 |
<p class="button-controls wp-clearfix" data-items-type="<?php echo esc_attr( "taxonomy-{$taxonomy_name}" ); ?>"> |
16 | 1102 |
<span class="list-controls hide-if-no-js"> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1103 |
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1104 |
id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1105 |
/> |
16 | 1106 |
<label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> |
0 | 1107 |
</span> |
1108 |
||
1109 |
<span class="add-to-menu"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1110 |
<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1111 |
class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1112 |
name="add-taxonomy-menu-item" id="<?php echo esc_attr( "submit-taxonomy-{$taxonomy_name}" ); ?>" |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1113 |
/> |
0 | 1114 |
<span class="spinner"></span> |
1115 |
</span> |
|
1116 |
</p> |
|
1117 |
||
1118 |
</div><!-- /.taxonomydiv --> |
|
1119 |
<?php |
|
1120 |
} |
|
1121 |
||
1122 |
/** |
|
1123 |
* Save posted nav menu item data. |
|
1124 |
* |
|
1125 |
* @since 3.0.0 |
|
1126 |
* |
|
9 | 1127 |
* @param int $menu_id The menu ID for which to save this item. Value of 0 makes a draft, orphaned menu item. Default 0. |
1128 |
* @param array[] $menu_data The unsanitized POSTed menu item data. |
|
1129 |
* @return int[] The database IDs of the items saved |
|
0 | 1130 |
*/ |
1131 |
function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { |
|
9 | 1132 |
$menu_id = (int) $menu_id; |
0 | 1133 |
$items_saved = array(); |
1134 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1135 |
if ( 0 === $menu_id || is_nav_menu( $menu_id ) ) { |
0 | 1136 |
|
5 | 1137 |
// Loop through all the menu items' POST values. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1138 |
foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) { |
0 | 1139 |
if ( |
5 | 1140 |
// Checkbox is not checked. |
1141 |
empty( $_item_object_data['menu-item-object-id'] ) && |
|
0 | 1142 |
( |
5 | 1143 |
// And item type either isn't set. |
1144 |
! isset( $_item_object_data['menu-item-type'] ) || |
|
1145 |
// Or URL is the default. |
|
16 | 1146 |
in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ), true ) || |
1147 |
// Or it's not a custom menu item (but not the custom home page). |
|
1148 |
! ( 'custom' === $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || |
|
5 | 1149 |
// Or it *is* a custom menu item that already exists. |
1150 |
! empty( $_item_object_data['menu-item-db-id'] ) |
|
0 | 1151 |
) |
1152 |
) { |
|
5 | 1153 |
// Then this potential menu item is not getting added to this menu. |
1154 |
continue; |
|
0 | 1155 |
} |
1156 |
||
5 | 1157 |
// If this possible menu item doesn't actually have a menu database ID yet. |
0 | 1158 |
if ( |
1159 |
empty( $_item_object_data['menu-item-db-id'] ) || |
|
1160 |
( 0 > $_possible_db_id ) || |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1161 |
$_possible_db_id !== (int) $_item_object_data['menu-item-db-id'] |
0 | 1162 |
) { |
1163 |
$_actual_db_id = 0; |
|
1164 |
} else { |
|
1165 |
$_actual_db_id = (int) $_item_object_data['menu-item-db-id']; |
|
1166 |
} |
|
1167 |
||
1168 |
$args = array( |
|
9 | 1169 |
'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ), |
1170 |
'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ), |
|
1171 |
'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ), |
|
1172 |
'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ), |
|
1173 |
'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ), |
|
1174 |
'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ), |
|
1175 |
'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ), |
|
1176 |
'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ), |
|
0 | 1177 |
'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ), |
9 | 1178 |
'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ), |
1179 |
'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ), |
|
1180 |
'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ), |
|
1181 |
'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ), |
|
0 | 1182 |
); |
1183 |
||
1184 |
$items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args ); |
|
1185 |
||
1186 |
} |
|
1187 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1188 |
|
0 | 1189 |
return $items_saved; |
1190 |
} |
|
1191 |
||
1192 |
/** |
|
1193 |
* Adds custom arguments to some of the meta box object types. |
|
1194 |
* |
|
1195 |
* @since 3.0.0 |
|
1196 |
* |
|
1197 |
* @access private |
|
1198 |
* |
|
19 | 1199 |
* @param object $data_object The post type or taxonomy meta-object. |
16 | 1200 |
* @return object The post type or taxonomy object. |
0 | 1201 |
*/ |
19 | 1202 |
function _wp_nav_menu_meta_box_object( $data_object = null ) { |
1203 |
if ( isset( $data_object->name ) ) { |
|
0 | 1204 |
|
19 | 1205 |
if ( 'page' === $data_object->name ) { |
1206 |
$data_object->_default_query = array( |
|
9 | 1207 |
'orderby' => 'menu_order title', |
0 | 1208 |
'post_status' => 'publish', |
1209 |
); |
|
1210 |
||
9 | 1211 |
// Posts should show only published items. |
19 | 1212 |
} elseif ( 'post' === $data_object->name ) { |
1213 |
$data_object->_default_query = array( |
|
0 | 1214 |
'post_status' => 'publish', |
1215 |
); |
|
1216 |
||
9 | 1217 |
// Categories should be in reverse chronological order. |
19 | 1218 |
} elseif ( 'category' === $data_object->name ) { |
1219 |
$data_object->_default_query = array( |
|
0 | 1220 |
'orderby' => 'id', |
9 | 1221 |
'order' => 'DESC', |
0 | 1222 |
); |
1223 |
||
9 | 1224 |
// Custom post types should show only published items. |
0 | 1225 |
} else { |
19 | 1226 |
$data_object->_default_query = array( |
0 | 1227 |
'post_status' => 'publish', |
1228 |
); |
|
1229 |
} |
|
1230 |
} |
|
1231 |
||
19 | 1232 |
return $data_object; |
0 | 1233 |
} |
1234 |
||
1235 |
/** |
|
1236 |
* Returns the menu formatted to edit. |
|
1237 |
* |
|
1238 |
* @since 3.0.0 |
|
1239 |
* |
|
5 | 1240 |
* @param int $menu_id Optional. The ID of the menu to format. Default 0. |
16 | 1241 |
* @return string|WP_Error The menu formatted to edit or error object on failure. |
0 | 1242 |
*/ |
1243 |
function wp_get_nav_menu_to_edit( $menu_id = 0 ) { |
|
1244 |
$menu = wp_get_nav_menu_object( $menu_id ); |
|
1245 |
||
1246 |
// If the menu exists, get its items. |
|
1247 |
if ( is_nav_menu( $menu ) ) { |
|
9 | 1248 |
$menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'post_status' => 'any' ) ); |
1249 |
$result = '<div id="menu-instructions" class="post-body-plain'; |
|
1250 |
$result .= ( ! empty( $menu_items ) ) ? ' menu-instructions-inactive">' : '">'; |
|
1251 |
$result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>'; |
|
1252 |
$result .= '</div>'; |
|
0 | 1253 |
|
9 | 1254 |
if ( empty( $menu_items ) ) { |
0 | 1255 |
return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
9 | 1256 |
} |
0 | 1257 |
|
5 | 1258 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1259 |
* Filters the Walker class used when adding nav menu items. |
5 | 1260 |
* |
1261 |
* @since 3.0.0 |
|
1262 |
* |
|
1263 |
* @param string $class The walker class to use. Default 'Walker_Nav_Menu_Edit'. |
|
1264 |
* @param int $menu_id ID of the menu being rendered. |
|
1265 |
*/ |
|
0 | 1266 |
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); |
1267 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
if ( class_exists( $walker_class_name ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1269 |
$walker = new $walker_class_name(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
} else { |
9 | 1271 |
return new WP_Error( |
1272 |
'menu_walker_not_exist', |
|
1273 |
sprintf( |
|
16 | 1274 |
/* translators: %s: Walker class name. */ |
9 | 1275 |
__( 'The Walker class named %s does not exist.' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
'<strong>' . $walker_class_name . '</strong>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1278 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1279 |
} |
0 | 1280 |
|
16 | 1281 |
$some_pending_menu_items = false; |
1282 |
$some_invalid_menu_items = false; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1283 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1284 |
foreach ( (array) $menu_items as $menu_item ) { |
16 | 1285 |
if ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) { |
0 | 1286 |
$some_pending_menu_items = true; |
9 | 1287 |
} |
1288 |
if ( ! empty( $menu_item->_invalid ) ) { |
|
0 | 1289 |
$some_invalid_menu_items = true; |
9 | 1290 |
} |
0 | 1291 |
} |
1292 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1293 |
if ( $some_pending_menu_items ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1294 |
$message = __( 'Click Save Menu to make pending menu items public.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1295 |
$notice_args = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1296 |
'type' => 'info', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1297 |
'additional_classes' => array( 'notice-alt', 'inline' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1298 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1299 |
$result .= wp_get_admin_notice( $message, $notice_args ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
} |
0 | 1301 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
if ( $some_invalid_menu_items ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1303 |
$message = __( 'There are some invalid menu items. Please check or delete them.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1304 |
$notice_args = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1305 |
'type' => 'error', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1306 |
'additional_classes' => array( 'notice-alt', 'inline' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1307 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1308 |
$result .= wp_get_admin_notice( $message, $notice_args ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1309 |
} |
0 | 1310 |
|
1311 |
$result .= '<ul class="menu" id="menu-to-edit"> '; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1312 |
$result .= walk_nav_menu_tree( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1313 |
array_map( 'wp_setup_nav_menu_item', $menu_items ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1314 |
0, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1315 |
(object) array( 'walker' => $walker ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1316 |
); |
0 | 1317 |
$result .= ' </ul> '; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1318 |
|
0 | 1319 |
return $result; |
1320 |
} elseif ( is_wp_error( $menu ) ) { |
|
1321 |
return $menu; |
|
1322 |
} |
|
1323 |
} |
|
1324 |
||
1325 |
/** |
|
1326 |
* Returns the columns for the nav menus page. |
|
1327 |
* |
|
1328 |
* @since 3.0.0 |
|
1329 |
* |
|
16 | 1330 |
* @return string[] Array of column titles keyed by their column name. |
0 | 1331 |
*/ |
1332 |
function wp_nav_menu_manage_columns() { |
|
1333 |
return array( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1334 |
'_title' => __( 'Show advanced menu properties' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1335 |
'cb' => '<input type="checkbox" />', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1336 |
'link-target' => __( 'Link Target' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1337 |
'title-attribute' => __( 'Title Attribute' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1338 |
'css-classes' => __( 'CSS Classes' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1339 |
'xfn' => __( 'Link Relationship (XFN)' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1340 |
'description' => __( 'Description' ), |
0 | 1341 |
); |
1342 |
} |
|
1343 |
||
1344 |
/** |
|
1345 |
* Deletes orphaned draft menu items |
|
1346 |
* |
|
1347 |
* @access private |
|
1348 |
* @since 3.0.0 |
|
1349 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1350 |
* @global wpdb $wpdb WordPress database abstraction object. |
0 | 1351 |
*/ |
1352 |
function _wp_delete_orphaned_draft_menu_items() { |
|
1353 |
global $wpdb; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1354 |
|
0 | 1355 |
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
1356 |
||
5 | 1357 |
// Delete orphaned draft menu items. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1358 |
$menu_items_to_delete = $wpdb->get_col( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1359 |
$wpdb->prepare( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1360 |
"SELECT ID FROM $wpdb->posts AS p |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1361 |
LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1362 |
WHERE post_type = 'nav_menu_item' AND post_status = 'draft' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1363 |
AND meta_key = '_menu_item_orphaned' AND meta_value < %d", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1364 |
$delete_timestamp |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1365 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1366 |
); |
0 | 1367 |
|
9 | 1368 |
foreach ( (array) $menu_items_to_delete as $menu_item_id ) { |
0 | 1369 |
wp_delete_post( $menu_item_id, true ); |
9 | 1370 |
} |
0 | 1371 |
} |
1372 |
||
1373 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1374 |
* Saves nav menu items. |
0 | 1375 |
* |
1376 |
* @since 3.6.0 |
|
1377 |
* |
|
16 | 1378 |
* @param int|string $nav_menu_selected_id ID, slug, or name of the currently-selected menu. |
1379 |
* @param string $nav_menu_selected_title Title of the currently-selected menu. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1380 |
* @return string[] The menu updated messages. |
0 | 1381 |
*/ |
9 | 1382 |
function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) { |
1383 |
$unsorted_menu_items = wp_get_nav_menu_items( |
|
1384 |
$nav_menu_selected_id, |
|
1385 |
array( |
|
1386 |
'orderby' => 'ID', |
|
1387 |
'output' => ARRAY_A, |
|
1388 |
'output_key' => 'ID', |
|
1389 |
'post_status' => 'draft,publish', |
|
1390 |
) |
|
1391 |
); |
|
16 | 1392 |
|
1393 |
$messages = array(); |
|
1394 |
$menu_items = array(); |
|
1395 |
||
1396 |
// Index menu items by DB ID. |
|
9 | 1397 |
foreach ( $unsorted_menu_items as $_item ) { |
1398 |
$menu_items[ $_item->db_id ] = $_item; |
|
1399 |
} |
|
0 | 1400 |
|
1401 |
$post_fields = array( |
|
9 | 1402 |
'menu-item-db-id', |
1403 |
'menu-item-object-id', |
|
1404 |
'menu-item-object', |
|
1405 |
'menu-item-parent-id', |
|
1406 |
'menu-item-position', |
|
1407 |
'menu-item-type', |
|
1408 |
'menu-item-title', |
|
1409 |
'menu-item-url', |
|
1410 |
'menu-item-description', |
|
1411 |
'menu-item-attr-title', |
|
1412 |
'menu-item-target', |
|
1413 |
'menu-item-classes', |
|
1414 |
'menu-item-xfn', |
|
0 | 1415 |
); |
1416 |
||
1417 |
wp_defer_term_counting( true ); |
|
16 | 1418 |
|
1419 |
// Loop through all the menu items' POST variables. |
|
0 | 1420 |
if ( ! empty( $_POST['menu-item-db-id'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1421 |
foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) { |
0 | 1422 |
|
16 | 1423 |
// Menu item title can't be blank. |
1424 |
if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' === $_POST['menu-item-title'][ $_key ] ) { |
|
0 | 1425 |
continue; |
9 | 1426 |
} |
0 | 1427 |
|
1428 |
$args = array(); |
|
9 | 1429 |
foreach ( $post_fields as $field ) { |
1430 |
$args[ $field ] = isset( $_POST[ $field ][ $_key ] ) ? $_POST[ $field ][ $_key ] : ''; |
|
1431 |
} |
|
0 | 1432 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1433 |
$menu_item_db_id = wp_update_nav_menu_item( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1434 |
$nav_menu_selected_id, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1435 |
( (int) $_POST['menu-item-db-id'][ $_key ] !== $_key ? 0 : $_key ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1436 |
$args |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1437 |
); |
0 | 1438 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
if ( is_wp_error( $menu_item_db_id ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1440 |
$messages[] = wp_get_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1441 |
$menu_item_db_id->get_error_message(), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1442 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1443 |
'id' => 'message', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1444 |
'additional_classes' => array( 'error' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1445 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1446 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1448 |
unset( $menu_items[ $menu_item_db_id ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
} |
0 | 1450 |
} |
1451 |
} |
|
1452 |
||
16 | 1453 |
// Remove menu items from the menu that weren't in $_POST. |
0 | 1454 |
if ( ! empty( $menu_items ) ) { |
1455 |
foreach ( array_keys( $menu_items ) as $menu_item_id ) { |
|
1456 |
if ( is_nav_menu_item( $menu_item_id ) ) { |
|
1457 |
wp_delete_post( $menu_item_id ); |
|
1458 |
} |
|
1459 |
} |
|
1460 |
} |
|
1461 |
||
1462 |
// Store 'auto-add' pages. |
|
9 | 1463 |
$auto_add = ! empty( $_POST['auto-add-pages'] ); |
0 | 1464 |
$nav_menu_option = (array) get_option( 'nav_menu_options' ); |
16 | 1465 |
|
9 | 1466 |
if ( ! isset( $nav_menu_option['auto_add'] ) ) { |
0 | 1467 |
$nav_menu_option['auto_add'] = array(); |
9 | 1468 |
} |
16 | 1469 |
|
0 | 1470 |
if ( $auto_add ) { |
16 | 1471 |
if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'], true ) ) { |
0 | 1472 |
$nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
9 | 1473 |
} |
0 | 1474 |
} else { |
16 | 1475 |
$key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'], true ); |
1476 |
if ( false !== $key ) { |
|
9 | 1477 |
unset( $nav_menu_option['auto_add'][ $key ] ); |
1478 |
} |
|
0 | 1479 |
} |
16 | 1480 |
|
1481 |
// Remove non-existent/deleted menus. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1482 |
$nav_menu_option['auto_add'] = array_intersect( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1483 |
$nav_menu_option['auto_add'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1484 |
wp_get_nav_menus( array( 'fields' => 'ids' ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1485 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1486 |
|
0 | 1487 |
update_option( 'nav_menu_options', $nav_menu_option ); |
1488 |
||
1489 |
wp_defer_term_counting( false ); |
|
1490 |
||
5 | 1491 |
/** This action is documented in wp-includes/nav-menu.php */ |
0 | 1492 |
do_action( 'wp_update_nav_menu', $nav_menu_selected_id ); |
1493 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1494 |
/* translators: %s: Nav menu title. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1495 |
$message = sprintf( __( '%s has been updated.' ), '<strong>' . $nav_menu_selected_title . '</strong>' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1496 |
$notice_args = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1497 |
'id' => 'message', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1498 |
'dismissible' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1499 |
'additional_classes' => array( 'updated' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1500 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1501 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1502 |
$messages[] = wp_get_admin_notice( $message, $notice_args ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1503 |
|
0 | 1504 |
unset( $menu_items, $unsorted_menu_items ); |
1505 |
||
1506 |
return $messages; |
|
1507 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1508 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1509 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1510 |
* If a JSON blob of navigation menu data is in POST data, expand it and inject |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1511 |
* it 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
|
1512 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1513 |
* @ignore |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1514 |
* @since 4.5.3 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1515 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1516 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1517 |
function _wp_expand_nav_menu_post_data() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1518 |
if ( ! isset( $_POST['nav-menu-data'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1519 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1520 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1521 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1522 |
$data = json_decode( stripslashes( $_POST['nav-menu-data'] ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1523 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1524 |
if ( ! is_null( $data ) && $data ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1525 |
foreach ( $data as $post_input_data ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1526 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1527 |
* For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1528 |
* derive the array path keys via regex and set the value in $_POST. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1529 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1530 |
preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1531 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1532 |
$array_bits = array( $matches[1] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1533 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1534 |
if ( isset( $matches[3] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1535 |
$array_bits = array_merge( $array_bits, explode( '][', $matches[3] ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1536 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1537 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1538 |
$new_post_data = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1539 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1540 |
// Build the new array value from leaf to trunk. |
16 | 1541 |
for ( $i = count( $array_bits ) - 1; $i >= 0; $i-- ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1542 |
if ( count( $array_bits ) - 1 === $i ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1543 |
$new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1544 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1545 |
$new_post_data = array( $array_bits[ $i ] => $new_post_data ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1546 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1547 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1548 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1549 |
$_POST = array_replace_recursive( $_POST, $new_post_data ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1550 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1551 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1552 |
} |