From 82f6555acf1fb5ae69b13908f9989aa1205ffa32 Mon Sep 17 00:00:00 2001 From: Mohammad Zubair Ali Date: Mon, 5 Feb 2024 19:41:38 +0530 Subject: [PATCH 1/2] fix contact multi option input WPML issue --- php/classes/class-qmn-quiz-manager.php | 2 +- php/classes/class-qsm-contact-manager.php | 41 ++++++++++++++--------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index a3a70a293..707e22ec4 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -1362,7 +1362,7 @@ public function display_questions( $qmn_quiz_options, $qmn_quiz_questions, $qmn_ $question_id_list = ''; $animation_effect = isset( $qmn_quiz_options->quiz_animation ) && '' !== $qmn_quiz_options->quiz_animation ? ' animated ' . $qmn_quiz_options->quiz_animation : ''; $enable_pagination_quiz = isset( $qmn_quiz_options->enable_pagination_quiz ) && $qmn_quiz_options->enable_pagination_quiz ? $qmn_quiz_options->enable_pagination_quiz : 0; - $pagination_option = $qmn_quiz_options->pagination; + $pagination_option = intval( $qmn_quiz_options->pagination ); $total_pagination = $total_pages_count = 1; if ( $enable_pagination_quiz && $pagination_option ) { $total_pages_count = count( $qmn_quiz_questions ); diff --git a/php/classes/class-qsm-contact-manager.php b/php/classes/class-qsm-contact-manager.php index 76894ca73..3af35c4e8 100644 --- a/php/classes/class-qsm-contact-manager.php +++ b/php/classes/class-qsm-contact-manager.php @@ -352,9 +352,17 @@ public static function save_fields( $quiz_id, $fields ) { if ( ! empty( $fields ) ) { $total_fields = count( $fields ); for ( $i = 0; $i < $total_fields; $i ++ ) { - $label = $is_not_allow_html ? $fields[ $i ]['label'] : wp_kses( wp_unslash( $fields[ $i ]['label'] ), $allowed_html ); + $label = $is_not_allow_html ? $fields[ $i ]['label'] : sanitize_text_field( wp_unslash( $fields[ $i ]['label'] ), $allowed_html ); $fields[ $i ]['label'] = $label; $mlwQuizMasterNext->pluginHelper->qsm_register_language_support( $label, "quiz_contact_field_text-{$i}-{$quiz_id}" ); + if ( ! empty( $fields[ $i ]['options'] ) ) { + $options = sanitize_text_field( wp_unslash( $fields[ $i ]['options'] ) ); + $fields[ $i ]['options'] = $options; + $option_values = explode(",", $options); + foreach ( $option_values as $option_key => $option ) { + $mlwQuizMasterNext->pluginHelper->qsm_register_language_support( $option, "quiz_contact_field_text-{$i}-{$option_key}-{$quiz_id}" ); + } + } } } @@ -535,19 +543,20 @@ public static function generate_contact_field( $field, $index, $quiz_options, $d
$option ) { ?> -
- - -
+
+ quiz_id}" ) ); ?>" + /> + +
$option ) { ?> - Date: Mon, 5 Feb 2024 19:48:58 +0530 Subject: [PATCH 2/2] fixed sonar issue --- php/classes/class-qsm-contact-manager.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/php/classes/class-qsm-contact-manager.php b/php/classes/class-qsm-contact-manager.php index 3af35c4e8..1bead68fc 100644 --- a/php/classes/class-qsm-contact-manager.php +++ b/php/classes/class-qsm-contact-manager.php @@ -331,10 +331,6 @@ public static function save_fields( $quiz_id, $fields ) { return true; } - if ( ! is_array( $fields ) || empty( $fields ) ) { - //return false; - } - $quiz_id = intval( $quiz_id ); if ( 0 === $quiz_id ) { return false;