From 2c225f4df0a25fb79a06de7f538e22a31868807a Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Thu, 17 Oct 2024 15:46:23 -0300 Subject: [PATCH 1/5] Try to optimize how styles are saved --- classes/controllers/FrmStylesController.php | 6 +++--- classes/views/styles/_manage-styles-row.php | 4 ++-- js/formidable_admin.js | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/classes/controllers/FrmStylesController.php b/classes/controllers/FrmStylesController.php index 39d6741e35..a2f33687e2 100644 --- a/classes/controllers/FrmStylesController.php +++ b/classes/controllers/FrmStylesController.php @@ -765,12 +765,12 @@ private static function manage_styles() { $forms = FrmForm::get_published_forms(); foreach ( $forms as $form ) { - $new_style = isset( $_POST['style'] ) && isset( $_POST['style'][ $form->id ] ) ? sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing - $previous_style = isset( $_POST['prev_style'] ) && isset( $_POST['prev_style'][ $form->id ] ) ? sanitize_text_field( wp_unslash( $_POST['prev_style'][ $form->id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing - if ( $new_style == $previous_style ) { + if ( ! isset( $_POST['style'] ) || ! isset( $_POST['style'][ $form->id ] ) ) { continue; } + $new_style = sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing + $form->options['custom_style'] = $new_style; $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); unset( $form ); diff --git a/classes/views/styles/_manage-styles-row.php b/classes/views/styles/_manage-styles-row.php index ead1949088..b9c67d1c26 100644 --- a/classes/views/styles/_manage-styles-row.php +++ b/classes/views/styles/_manage-styles-row.php @@ -11,9 +11,9 @@ - + -