Skip to content

Commit

Permalink
fixed code tag issue
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairraeen committed Jan 9, 2024
1 parent 874d67f commit b71aaa4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion php/question-types/qsm-question-title.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_
$allow_html['input']['id'] = 1;
$allow_html['input']['maxlength'] = 1;
$allow_html = apply_filters( 'qsm_allow_html_question_title_after', $allow_html, $question_id );
$pattern = '/<code>(.*?)<\/code>/s';
$question_title_modified_html = preg_replace_callback($pattern, function ( $matches ) {
$replacement = preg_replace([ '/<(?!(\/?code|br)[ >])/', '/>(?!(\/?code|br)[ \/>])/' ], [ '&lt;', '&gt;' ], $matches[0]);
return $replacement;
}, $question_title);
$question_title_modified_html = str_replace([ 'code&gt;', 'br /&gt;' ],[ 'code/>', 'br />' ], $question_title_modified_html );
?>
<p><?php echo do_shortcode( wp_kses( $question_title . $deselect_answer, $allow_html ) ); ?></p>
<p><?php echo do_shortcode( wp_kses( $question_title_modified_html . $deselect_answer, $allow_html ) ); ?></p>
</div>
<?php
do_action('qsm_question_title_func_after',$question, $question_type, $new_question_title, $question_id );
Expand Down

0 comments on commit b71aaa4

Please sign in to comment.