Skip to content

Commit

Permalink
Merge pull request #2459 from QuizandSurveyMaster/CU-86cuh70jk-WPML-i…
Browse files Browse the repository at this point in the history
…ssue-with-contact-fields

fix contact multi option input WPML issue
  • Loading branch information
zubairraeen authored Feb 5, 2024
2 parents 3cdd87d + a698d75 commit 72178d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
45 changes: 25 additions & 20 deletions php/classes/class-qsm-contact-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -352,9 +348,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}" );
}
}
}
}

Expand Down Expand Up @@ -535,19 +539,20 @@ public static function generate_contact_field( $field, $index, $quiz_options, $d
<div class='qmn_radio_answers <?php echo esc_attr( $class ); ?>'>
<?php
$option_values = explode(",", $field['options']);
for ( $i = 0; $i < count($option_values); $i++ ) {
foreach ( $option_values as $option_key => $option ) {
?>
<div class='qmn_mc_answer_wrap'>
<input
type='radio'
class='qmn_quiz_radio'
name='contact_field_<?php echo esc_attr( $index ); ?>'
value='<?php echo esc_attr( $option_values[ $i ] ); ?>'
/>
<label class='qsm_input_label' for='<?php echo esc_attr( $field_label ); ?>'>
<?php echo esc_html( trim($option_values[ $i ]) ); ?>
</label>
</div>
<div class="qmn_mc_answer_wrap">
<input
type="radio"
class="qmn_quiz_radio"
name="contact_field_<?php echo esc_attr( $index ); ?>"
id="contact_field_<?php echo esc_attr( $index . '-' . $option_key ); ?>"
value="<?php echo esc_attr( $mlwQuizMasterNext->pluginHelper->qsm_language_support( trim( $option ), "quiz_contact_field_text-{$index}-{$option_key}-{$quiz_options->quiz_id}" ) ); ?>"
/>
<label class="qsm_input_label" for="contact_field_<?php echo esc_attr( $index . '-' . $option_key ); ?>">
<?php echo esc_html( $mlwQuizMasterNext->pluginHelper->qsm_language_support( trim( $option ), "quiz_contact_field_text-{$index}-{$option_key}-{$quiz_options->quiz_id}" ) ); ?>
</label>
</div>
<?php
}
}
Expand All @@ -572,10 +577,10 @@ class='qmn_quiz_radio'
<?php
$option_values = explode( ",", $field['options'] );
// Iterating over comma separeted values to populate option tag
for ( $i = 0; $i < count($option_values); $i++ ) {
foreach ( $option_values as $option_key => $option ) {
?>
<option value='<?php echo esc_attr( trim($option_values[ $i ]) ); ?>'>
<?php echo esc_html( trim($option_values[ $i ]) ); ?>
<option value='<?php echo esc_attr( $mlwQuizMasterNext->pluginHelper->qsm_language_support( trim( $option ), "quiz_contact_field_text-{$index}-{$option_key}-{$quiz_options->quiz_id}" ) ); ?>'>
<?php echo esc_html($mlwQuizMasterNext->pluginHelper->qsm_language_support( trim( $option ), "quiz_contact_field_text-{$index}-{$option_key}-{$quiz_options->quiz_id}" ) ); ?>
</option>
<?php
}
Expand Down

0 comments on commit 72178d1

Please sign in to comment.