Skip to content

Commit

Permalink
Fixed wpml issue with fill in the blank type question
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-pranav committed Feb 5, 2024
1 parent 8b1a3be commit f1bcc29
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion php/question-types/qsm-question-title.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,47 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_
</div>
<?php
do_action('qsm_question_title_func_after',$question, $question_type, $new_question_title, $question_id );
}
}

function qsm_wpml_support_for_question_desc($question, $question_type, $id) {
global $mlwQuizMasterNext;
if ( strpos( $question, '%BLANK%' ) !== false ) {
$allowedposttags['input'] = array(
'autocomplete' => true,
'class' => true,
'id' => true,
'height' => true,
'min' => true,
'max' => true,
'minlength' => true,
'maxlength' => true,
'name' => true,
'pattern' => true,
'placeholder' => true,
'readonly' => true,
'required' => true,
'size' => true,
'step' => true,
'type' => true,
'value' => true,
'width' => true,
);
$required = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'required' );
$autofill = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'autofill' );
$limit_text = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'limit_text' );
$min_fill_text = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'min_text_length' );
$autofill_att = $autofill ? "autocomplete='off' " : '';
$limit_text_att = $limit_text ? "maxlength='" . $limit_text . "' " : '';
$min_fill_text_att = $min_fill_text ? "minlength='" . $min_fill_text . "' " : '';
if ( 0 == $required ) {
$mlw_require_class = 'mlwRequiredText';
} else {
$mlw_require_class = '';
}
$input_text = '<input ' . $min_fill_text_att . $autofill_att . $limit_text_att . " type='text' class='qmn_fill_blank $mlw_require_class' name='question" . $id . "[]' />";
$input_text = apply_filters( 'qsm_wpml_text_replace_after', $input_text, $id, $question, $mlw_require_class );
$question = str_replace( '%BLANK%', $input_text, do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) );
}
return $question;
}
add_filter( 'qsm_question_description_before', 'qsm_wpml_support_for_question_desc', 20, 3 );

0 comments on commit f1bcc29

Please sign in to comment.