Changeset 55873 for trunk/src/wp-admin/includes/menu.php
- Timestamp:
- 05/31/2023 02:51:22 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/menu.php
r55703 r55873 45 45 foreach ( $menu as $menu_page ) { 46 46 $pos = strpos( $menu_page[2], '?' ); 47 47 48 if ( false !== $pos ) { 48 49 // Handle post_type=post|page|foo pages. … … 50 51 $hook_args = substr( $menu_page[2], $pos + 1 ); 51 52 wp_parse_str( $hook_args, $hook_args ); 53 52 54 // Set the hook name to be the post type. 53 55 if ( isset( $hook_args['post_type'] ) ) { … … 60 62 $hook_name = basename( $menu_page[2], '.php' ); 61 63 } 64 62 65 $hook_name = sanitize_title( $hook_name ); 63 66 … … 99 102 continue; 100 103 } 104 101 105 $subs = $submenu[ $data[2] ]; 102 106 $first_sub = reset( $subs ); 103 107 $old_parent = $data[2]; 104 108 $new_parent = $first_sub[2]; 109 105 110 /* 106 111 * If the first submenu is not the same as the assigned parent, 107 112 * make the first submenu the new parent. 108 113 */ 109 if ( $new_parent != $old_parent ) {114 if ( $new_parent !== $old_parent ) { 110 115 $_wp_real_parent_file[ $old_parent ] = $new_parent; 111 $menu[ $id ][2] = $new_parent; 116 117 $menu[ $id ][2] = $new_parent; 112 118 113 119 foreach ( $submenu[ $old_parent ] as $index => $data ) { … … 172 178 $subs = $submenu[ $data[2] ]; 173 179 $first_sub = reset( $subs ); 174 if ( $data[2] == $first_sub[2] ) { 180 181 if ( $data[2] === $first_sub[2] ) { 175 182 unset( $submenu[ $data[2] ] ); 176 183 } … … 218 225 $last_order = false; 219 226 $items_count = count( $menu ); 220 $i = 0; 227 228 $i = 0; 221 229 222 230 foreach ( $menu as $order => $top ) { 223 231 $i++; 224 232 225 if ( 0 == $order ) { // Dashboard is always shown/single.233 if ( 0 === $order ) { // Dashboard is always shown/single. 226 234 $menu[0][4] = add_cssclass( 'menu-top-first', $top[4] ); 227 235 $last_order = 0; … … 230 238 231 239 if ( str_starts_with( $top[2], 'separator' ) && false !== $last_order ) { // If separator. 232 $first_item = true; 233 $classes = $menu[ $last_order ][4]; 240 $first_item = true; 241 $classes = $menu[ $last_order ][4]; 242 234 243 $menu[ $last_order ][4] = add_cssclass( 'menu-top-last', $classes ); 235 244 continue; … … 237 246 238 247 if ( $first_item ) { 239 $classes = $menu[ $order ][4]; 248 $first_item = false; 249 $classes = $menu[ $order ][4]; 250 240 251 $menu[ $order ][4] = add_cssclass( 'menu-top-first', $classes ); 241 $first_item = false;242 252 } 243 253 244 254 if ( $i === $items_count ) { // Last item. 245 $classes = $menu[ $order ][4]; 255 $classes = $menu[ $order ][4]; 256 246 257 $menu[ $order ][4] = add_cssclass( 'menu-top-last', $classes ); 247 258 } … … 273 284 if ( apply_filters( 'custom_menu_order', false ) ) { 274 285 $menu_order = array(); 286 275 287 foreach ( $menu as $menu_item ) { 276 288 $menu_order[] = $menu_item[2]; 277 289 } 278 290 unset( $menu_item ); 291 279 292 $default_menu_order = $menu_order; 280 293 … … 291 304 * @param array $menu_order An ordered array of menu items. 292 305 */ 293 $menu_order = apply_filters( 'menu_order', $menu_order ); 294 $menu_order = array_flip( $menu_order ); 306 $menu_order = apply_filters( 'menu_order', $menu_order ); 307 $menu_order = array_flip( $menu_order ); 308 295 309 $default_menu_order = array_flip( $default_menu_order ); 296 310 … … 305 319 function sort_menu( $a, $b ) { 306 320 global $menu_order, $default_menu_order; 321 307 322 $a = $a[2]; 308 323 $b = $b[2]; 324 309 325 if ( isset( $menu_order[ $a ] ) && ! isset( $menu_order[ $b ] ) ) { 310 326 return -1; … … 312 328 return 1; 313 329 } elseif ( isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) { 314 if ( $menu_order[ $a ] == $menu_order[ $b ] ) {330 if ( $menu_order[ $a ] === $menu_order[ $b ] ) { 315 331 return 0; 316 332 }
Note: See TracChangeset
for help on using the changeset viewer.