Ticket #14134: 14134.6.diff
File 14134.6.diff, 1.3 KB (added by , 9 years ago) |
---|
-
src/wp-admin/nav-menus.php
51 51 52 52 /* 53 53 * If a JSON blob of navigation menu data is found, expand it and inject it 54 * into `$_POST` to avoid PHP `max_input_vars` limitations. See #14134. 54 * into `$_POST` to avoid PHP `max_input_vars` limitations. See #14134. 55 55 */ 56 56 if ( isset( $_POST['nav-menu-data'] ) ) { 57 57 $data = json_decode( stripslashes( $_POST['nav-menu-data'] ) ); … … 58 58 if ( ! is_null( $data ) && $data ) { 59 59 foreach ( $data as $post_input_data ) { 60 60 // For input names that are arrays (e.g. `menu-item-db-id[3]`), derive the array path keys via regex. 61 if ( preg_match( '#(.*) (?:\[(\d+)\])#', $post_input_data->name, $matches ) ) {61 if ( preg_match( '#(.*)\[(\w+)\]#', $post_input_data->name, $matches ) ) { 62 62 if ( empty( $_POST[ $matches[1] ] ) ) { 63 63 $_POST[ $matches[1] ] = array(); 64 64 } 65 $_POST[ $matches[1] ][ (int) $matches[2] ] = wp_slash( $post_input_data->value ); 65 if( is_numeric( $matches[2] ) ) { 66 $matches[2] = (int) $matches[2]; 67 } 68 $_POST[ $matches[1] ][ $matches[2] ] = wp_slash( $post_input_data->value ); 66 69 } else { 67 70 $_POST[ $post_input_data->name ] = wp_slash( $post_input_data->value ); 68 71 }