Menus: Ensure theme location setting data is saved with a large menu.
[36510] introduced a fix to allow users to save large menus on the Edit Menu screen (70+ menu items). The form data is stored as JSON which is used to inject the `$_POST` variable in the form submission handler. This injection was not setting form items with named array elements properly (e.g. `menu-locations[primary]`), which did not save theme location data in a large form. Props keraweb. See #14134. Built from https://develop.svn.wordpress.org/trunk@36852 git-svn-id: http://core.svn.wordpress.org/trunk@36819 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a8ca958d43
commit
0c1cca9961
|
@ -51,18 +51,22 @@ $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a JSON blob of navigation menu data is found, expand it and inject it
|
* If a JSON blob of navigation menu data is found, expand it and inject it
|
||||||
* into `$_POST` to avoid PHP `max_input_vars` limitations. See #14134.
|
* into `$_POST` to avoid PHP `max_input_vars` limitations. See #14134.
|
||||||
*/
|
*/
|
||||||
if ( isset( $_POST['nav-menu-data'] ) ) {
|
if ( isset( $_POST['nav-menu-data'] ) ) {
|
||||||
$data = json_decode( stripslashes( $_POST['nav-menu-data'] ) );
|
$data = json_decode( stripslashes( $_POST['nav-menu-data'] ) );
|
||||||
if ( ! is_null( $data ) && $data ) {
|
if ( ! is_null( $data ) && $data ) {
|
||||||
foreach ( $data as $post_input_data ) {
|
foreach ( $data as $post_input_data ) {
|
||||||
// For input names that are arrays (e.g. `menu-item-db-id[3]`), derive the array path keys via regex.
|
// For input names that are arrays (e.g. `menu-item-db-id[3]`), derive the array path keys via regex.
|
||||||
if ( preg_match( '#(.*)(?:\[(\d+)\])#', $post_input_data->name, $matches ) ) {
|
if ( preg_match( '#(.*)\[(\w+)\]#', $post_input_data->name, $matches ) ) {
|
||||||
if ( empty( $_POST[ $matches[1] ] ) ) {
|
if ( empty( $_POST[ $matches[1] ] ) ) {
|
||||||
$_POST[ $matches[1] ] = array();
|
$_POST[ $matches[1] ] = array();
|
||||||
}
|
}
|
||||||
$_POST[ $matches[1] ][ (int) $matches[2] ] = wp_slash( $post_input_data->value );
|
// Cast input elements with a numeric array index to integers.
|
||||||
|
if ( is_numeric( $matches[2] ) ) {
|
||||||
|
$matches[2] = (int) $matches[2];
|
||||||
|
}
|
||||||
|
$_POST[ $matches[1] ][ $matches[2] ] = wp_slash( $post_input_data->value );
|
||||||
} else {
|
} else {
|
||||||
$_POST[ $post_input_data->name ] = wp_slash( $post_input_data->value );
|
$_POST[ $post_input_data->name ] = wp_slash( $post_input_data->value );
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.5-beta2-36851';
|
$wp_version = '4.5-beta2-36852';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue