X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/03f2fa83c13c1b532284205fa7efcab9b8b2c41f..refs/tags/wordpress-4.5:/wp-admin/nav-menus.php diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index 6507f0dc..ab15bede 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -49,6 +49,30 @@ $num_locations = count( array_keys( $locations ) ); // Allowed actions: add, update, delete $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit'; +/* + * 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. + */ +if ( isset( $_POST['nav-menu-data'] ) ) { + $data = json_decode( stripslashes( $_POST['nav-menu-data'] ) ); + if ( ! is_null( $data ) && $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. + if ( preg_match( '#(.*)\[(\w+)\]#', $post_input_data->name, $matches ) ) { + if ( empty( $_POST[ $matches[1] ] ) ) { + $_POST[ $matches[1] ] = array(); + } + // 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 { + $_POST[ $post_input_data->name ] = wp_slash( $post_input_data->value ); + } + } + } +} switch ( $action ) { case 'add-menu-item': check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' ); @@ -584,7 +608,7 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' ); endif; ?> -