Skip to content

Commit

Permalink
fix: experimental solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Oct 10, 2024
1 parent 775835d commit 93319ed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ function ppom_admin_save_form_meta() {
wp_send_json( $resp );
}

if ( is_string( $_REQUEST['ppom'] ) ) {
$ppom_encoded = $_REQUEST['ppom'];
parse_str( $ppom_encoded, $ppom_decoded);
$_REQUEST['ppom'] = $ppom_decoded;
}

global $wpdb;

extract( $_REQUEST );
Expand Down Expand Up @@ -450,6 +456,12 @@ function ppom_admin_update_form_meta() {
}
global $wpdb;

if ( is_string( $_REQUEST['ppom'] ) ) {
$ppom_encoded = $_REQUEST['ppom'];
parse_str( $ppom_encoded, $ppom_decoded);
$_REQUEST['ppom'] = $ppom_decoded;
}

$ppom_meta = isset( $_REQUEST['ppom_meta'] ) ? $_REQUEST['ppom_meta'] : $_REQUEST['ppom'];
$product_meta = apply_filters( 'ppom_meta_data_saving', (array) $ppom_meta, $productmeta_id );
$product_meta = ppom_sanitize_array_data( $product_meta );
Expand Down
16 changes: 15 additions & 1 deletion js/admin/ppom-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,24 @@ jQuery(function($) {
jQuery(".ppom-meta-save-notice").html('<img src="' + ppom_vars.loader + '">').show();

$('.ppom-unsave-data').remove();

const formData = new FormData();
const ppomFields = new URLSearchParams();

// NOTE: since the request is to big for small values of `max_input_vars`, we will send the PPOM fields as a single string.
(new FormData(this)).forEach(( value, key) => {
if ( key.startsWith('ppom[') && typeof value === 'string' ) {
ppomFields.append( key, value );
} else {
formData.append(key, value);
}
});

formData.append('ppom', ppomFields.toString());

fetch(ajaxurl, {
method: 'POST',
body: new FormData(this)
body: formData
})
.then(response => response.json())
.then(resp => {
Expand Down

0 comments on commit 93319ed

Please sign in to comment.