Ticket #14134: 14134.3.diff
File 14134.3.diff, 2.6 KB (added by , 9 years ago) |
---|
-
src/wp-admin/js/nav-menu.js
43 43 44 44 this.attachQuickSearchListeners(); 45 45 this.attachThemeLocationsListeners(); 46 this.attachMenuSaveSubmitListeners(); 46 47 47 48 this.attachTabsPanelListeners(); 48 49 … … 834 835 }); 835 836 }, 836 837 838 attachMenuSaveSubmitListeners : function() { 839 /* 840 * When a navigation menu is saved, store a JSON representation of all form data 841 * in a single input to avoid PHP max_input_vars limitations. See #14134. 842 */ 843 $('#update-nav-menu').submit(function() { 844 var navMenuData = jQuery('#update-nav-menu').serializeArray(); 845 $('[name="nav-menu-data"]').val( JSON.stringify( navMenuData ) ); 846 }); 847 }, 848 837 849 attachThemeLocationsListeners : function() { 838 850 var loc = $('#nav-menu-theme-locations'), params = {}; 839 851 params.action = 'menu-locations-save'; -
src/wp-admin/nav-menus.php
49 49 // Allowed actions: add, update, delete 50 50 $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit'; 51 51 52 /* 53 * If a JSON blob of navigation menu data is found, expand it and fill PHP $_POST 54 * vars to avoid PHP max_input_vars limitations. See #14134. 55 */ 56 if ( isset( $_POST['nav-menu-data'] ) ) { 57 $data = json_decode( stripslashes( $_POST['nav-menu-data'] ) ); 58 if ( ! is_null( $data ) && $data ) { 59 foreach ( $data as $post_input_data ) { 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 ) ) { 62 if ( empty( $_POST[$matches[1]] ) ) { 63 $_POST[$matches[1]] = array(); 64 } 65 $_POST[$matches[1]][(int)$matches[2]] = $post_input_data->value; 66 } else { 67 $_POST[$post_input_data->name] = $post_input_data->value; 68 } 69 } 70 } 71 } 52 72 switch ( $action ) { 53 73 case 'add-menu-item': 54 74 check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' ); … … 731 751 <div id="menu-management"> 732 752 <form id="update-nav-menu" method="post" enctype="multipart/form-data"> 733 753 <div class="menu-edit <?php if ( $add_new_screen ) echo 'blank-slate'; ?>"> 754 <input type="hidden" name="nav-menu-data"> 734 755 <?php 735 756 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 736 757 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );