Changeset 47119 for trunk/src/wp-admin/includes/nav-menu.php
- Timestamp:
- 01/29/2020 12:33:45 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/nav-menu.php
r46842 r47119 139 139 */ 140 140 function wp_nav_menu_setup() { 141 // Register meta boxes 141 // Register meta boxes. 142 142 wp_nav_menu_post_type_meta_boxes(); 143 143 add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); 144 144 wp_nav_menu_taxonomy_meta_boxes(); 145 145 146 // Register advanced menu items (columns) 146 // Register advanced menu items (columns). 147 147 add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' ); 148 148 … … 423 423 } 424 424 425 // @todo transient caching of these results with proper invalidation on updating of a post of this type425 // @todo Transient caching of these results with proper invalidation on updating of a post of this type. 426 426 $get_posts = new WP_Query; 427 427 $posts = $get_posts->query( $args ); … … 922 922 // Or URL is the default. 923 923 in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ) ) || 924 ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page) 924 // Or it's not a custom menu item (but not the custom home page). 925 ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || 925 926 // Or it *is* a custom menu item that already exists. 926 927 ! empty( $_item_object_data['menu-item-db-id'] ) … … 1143 1144 $messages = array(); 1144 1145 $menu_items = array(); 1145 // Index menu items by db ID1146 // Index menu items by DB ID. 1146 1147 foreach ( $unsorted_menu_items as $_item ) { 1147 1148 $menu_items[ $_item->db_id ] = $_item; … … 1165 1166 1166 1167 wp_defer_term_counting( true ); 1167 // Loop through all the menu items' POST variables 1168 // Loop through all the menu items' POST variables. 1168 1169 if ( ! empty( $_POST['menu-item-db-id'] ) ) { 1169 1170 foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) { 1170 1171 1171 // Menu item title can't be blank 1172 // Menu item title can't be blank. 1172 1173 if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) { 1173 1174 continue; … … 1189 1190 } 1190 1191 1191 // Remove menu items from the menu that weren't in $_POST 1192 // Remove menu items from the menu that weren't in $_POST. 1192 1193 if ( ! empty( $menu_items ) ) { 1193 1194 foreach ( array_keys( $menu_items ) as $menu_item_id ) { … … 1214 1215 } 1215 1216 } 1216 // Remove non existent/deleted menus1217 // Remove non-existent/deleted menus. 1217 1218 $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); 1218 1219 update_option( 'nav_menu_options', $nav_menu_option ); … … 1253 1254 foreach ( $data as $post_input_data ) { 1254 1255 // For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`), 1255 // derive the array path 1256 // derive the array path keys via regex and set the value in $_POST. 1256 1257 preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches ); 1257 1258 … … 1265 1266 1266 1267 // Build the new array value from leaf to trunk. 1267 for ( $i = count( $array_bits ) - 1; $i >= 0; $i 1268 for ( $i = count( $array_bits ) - 1; $i >= 0; $i-- ) { 1268 1269 if ( $i == count( $array_bits ) - 1 ) { 1269 1270 $new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value );
Note: See TracChangeset
for help on using the changeset viewer.