Skip to content

Commit

Permalink
Merge pull request #2590 from QuizandSurveyMaster/dev
Browse files Browse the repository at this point in the history
Release 9.0.5
  • Loading branch information
zubairraeen committed Jun 19, 2024
2 parents a7762cf + 5593f43 commit ec8e3ef
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 22 deletions.
2 changes: 1 addition & 1 deletion css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ footer.qsm-popup__footer button.qsm-popup-secondary-button:hover {
align-content: center;
}
.qsm-quiz-container .qsm-contact-type-checkbox input {
margin: 0 5px 0 3px;
margin: 0 5px 9px 3px;
}
.mlw_qmn_question_number {
font-weight: bold;
Expand Down
2 changes: 1 addition & 1 deletion css/qsm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -2683,7 +2683,7 @@ input#duplicate_questions {
flex-wrap: wrap;
justify-content: flex-start;
align-content: flex-start;
margin-bottom: 150px;
margin-bottom: 250px;
}
.contact-form-builder-wrap a {
display: inline-block;
Expand Down
30 changes: 29 additions & 1 deletion js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3209,7 +3209,11 @@ var import_button;
var questionType = $('#question_type').val();
var answer_length = $('#answers').find('.answers-single').length;
var answerType = $('#change-answer-editor').val();
if (answer_length > 1 && $('#question_type').val() == 13) {
let isMultiPolar = {
isActive: false,
}
jQuery(document).trigger('qsm_new_answer_button_before', [isMultiPolar, question_id]);
if (answer_length > 1 && $('#question_type').val() == 13 && !isMultiPolar.isActive) {
alert(qsm_admin_messages.polar_options_validation);
return;
}
Expand Down Expand Up @@ -4111,4 +4115,28 @@ var import_button;
});
} );

}(jQuery));

(function ($) {
$(document).ready(function() {
let $settingsFields = $('.settings-field');
let $popups = $('.qsm-contact-form-field-settings');

// Function to hide all popups
function qsmHideAllPopups() {
$popups.hide();
}

// Close popup on document click if popup is open and clicking outside
$(document).on('click', function(event) {
if (!$settingsFields.is(event.target) && $settingsFields.has(event.target).length === 0) {
qsmHideAllPopups();
}
});

// Prevent the click event from propagating to the document when clicking inside the popup
$popups.on('click', function(event) {
event.stopPropagation();
});
});
}(jQuery));
7 changes: 4 additions & 3 deletions mlw_quizmaster2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Quiz And Survey Master
* Description: Easily and quickly add quizzes and surveys to your website.
* Version: 9.0.4
* Version: 9.0.5
* Author: ExpressTech
* Author URI: https://quizandsurveymaster.com/
* Plugin URI: https://expresstech.io/
Expand Down Expand Up @@ -43,7 +43,7 @@ class MLWQuizMasterNext {
* @var string
* @since 4.0.0
*/
public $version = '9.0.4';
public $version = '9.0.5';

/**
* QSM Alert Manager Object
Expand Down Expand Up @@ -473,7 +473,8 @@ public function qsm_admin_scripts_style( $hook ) {
}
}
// load admin JS after all dependencies are loaded
wp_enqueue_script( 'qsm_admin_js', plugins_url( 'js/qsm-admin.js', __FILE__ ), array( 'jquery', 'backbone', 'underscore', 'wp-util', 'jquery-ui-sortable', 'jquery-touch-punch', 'qsm-jquery-multiselect-js' ), $this->version, true );
/** Fixed wpApiSettings is not defined js error by using 'wp-api-request' core script to allow the use of localized version of wpApiSettings. **/
wp_enqueue_script( 'qsm_admin_js', plugins_url( 'js/qsm-admin.js', __FILE__ ), array( 'jquery', 'backbone', 'underscore', 'wp-util', 'jquery-ui-sortable', 'jquery-touch-punch', 'qsm-jquery-multiselect-js', 'wp-api-request' ), $this->version, true );
wp_enqueue_style( 'jquer-multiselect-css', QSM_PLUGIN_CSS_URL . '/jquery.multiselect.min.css', array(), $this->version );
wp_enqueue_script( 'qsm-jquery-multiselect-js', QSM_PLUGIN_JS_URL . '/jquery.multiselect.min.js', array( 'jquery' ), $this->version, true );
wp_enqueue_script( 'micromodal_script', plugins_url( 'js/micromodal.min.js', __FILE__ ), array( 'jquery', 'qsm_admin_js' ), $this->version, true );
Expand Down
2 changes: 1 addition & 1 deletion php/classes/class-qmn-plugin-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ public function convert_contacts_to_preferred_date_format( $qsm_qna_array ) {

$qsm_contact_array = $qsm_qna_array['contact'];
foreach ( $qsm_contact_array as $qsm_contact_id => $qsm_contact ) {
if ( 'date' === $qsm_contact['type'] && null !== $GLOBALS['qsm_date_format'] ) {
if ( 'date' === $qsm_contact['type'] && '' !== $qsm_contact['value'] && null !== $GLOBALS['qsm_date_format'] ) {
$qsm_qna_array['contact'][ $qsm_contact_id ]['value'] = date_i18n( $GLOBALS['qsm_date_format'], strtotime( ( $qsm_contact['value'] ) ) );
}
}
Expand Down
33 changes: 26 additions & 7 deletions php/classes/class-qsm-contact-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,25 @@ public static function save_fields( $quiz_id, $fields ) {
$fields[ $i ]['label'] = $label;
$mlwQuizMasterNext->pluginHelper->qsm_register_language_support( $label, "quiz_contact_field_text-{$i}-{$quiz_id}" );
$mlwQuizMasterNext->pluginHelper->qsm_register_language_support( $placeholder, "quiz_contact_field_placeholder-{$i}-{$quiz_id}" );

// Validate allowed domains
if ( ! empty( $fields[ $i ]['allowdomains'] ) ) {
$allowdomains = explode( ',', $fields[ $i ]['allowdomains'] );
// Trim domains
$allowdomains = array_map( 'trim', $allowdomains );
// filter domain
$allowdomains = array_filter( $allowdomains, function( $allowdomain ) {
/**
* full domain name may not exceed a total length of 253 ASCII characters
* The domain name consists of valid labels (1-63 characters of letters, digits,
* or hyphens) followed by a dot. The domain ends with a valid TLD
* (2-63 characters of letters).
*/
return preg_match( '/^([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}$/', $allowdomain ) && ( strlen( $allowdomain ) <= 253 );
} );

$fields[ $i ]['allowdomains'] = implode( ',', $allowdomains );
}
if ( ! empty( $fields[ $i ]['options'] ) ) {
$options = sanitize_text_field( wp_unslash( $fields[ $i ]['options'] ) );
$fields[ $i ]['options'] = $options;
Expand Down Expand Up @@ -394,6 +413,8 @@ public static function generate_contact_field( $field, $index, $quiz_options, $d
$class .= ' mlwRequiredRadio ';
}elseif ( 'select' === $field["type"] ) {
$class .= 'qsmRequiredSelect';
}elseif ( 'number' === $field["type"] ) {
$class .= 'mlwRequiredNumber';
}else {
$class .= 'mlwRequiredText qsm_required_text';
if ( 'checkbox' === $field["type"] ) {
Expand Down Expand Up @@ -533,7 +554,7 @@ public static function generate_contact_field( $field, $index, $quiz_options, $d
?>
<span class='mlw_qmn_question qsm_question'><label for="contact_field_<?php echo esc_attr( $index ) ?>"><?php echo esc_attr( $field_label ); ?></label></span>
<?php } ?>
<input type='number' class='mlwRequiredNumber <?php echo esc_attr( $class ); ?>' <?php echo $fieldAttr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> <?php if ( isset( $field['maxlength'] ) && 0 < intval( $field['maxlength'] ) ) : ?>maxlength='<?php echo intval( $field['maxlength'] ); ?>' oninput='maxLengthCheck(this)' <?php endif; ?> />
<input type='number' class='<?php echo esc_attr( $class ); ?>' <?php echo $fieldAttr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> <?php if ( isset( $field['maxlength'] ) && 0 < intval( $field['maxlength'] ) ) : ?>maxlength='<?php echo intval( $field['maxlength'] ); ?>' oninput='maxLengthCheck(this)' <?php endif; ?> />
<?php
break;

Expand All @@ -548,7 +569,7 @@ public static function generate_contact_field( $field, $index, $quiz_options, $d
/**
* Add options validation
*/
if ( isset( $field['options'] ) ) {
if ( isset( $field['options'] ) && ! empty( trim( $field['options'] ) ) ) {
?>
<span class='mlw_qmn_question qsm_question'><?php echo esc_attr( $field_label ); ?></span>
<div class='qmn_radio_answers <?php echo esc_attr( $class ); ?>'>
Expand All @@ -570,8 +591,8 @@ class="qmn_quiz_radio"
</div>
<?php
}
}
echo '</div>';
}
break;
case 'select':
// Filer Value
Expand All @@ -582,7 +603,7 @@ class="qmn_quiz_radio"
$fieldAttr .= " autocomplete='off' ";
}
// If REQUIRED is set then assigning the required class
if ( isset( $field['options'] ) ) {
if ( isset( $field['options'] ) && ! empty( trim( $field['options'] ) ) ) {
?>
<span class='mlw_qmn_question qsm_question'><label for="contact_field_<?php echo esc_attr( $index ) ?>"><?php echo esc_attr( $field_label ); ?></label></span>
<select class='<?php echo esc_attr( $class ); ?>' name='contact_field_<?php echo esc_attr( $index ); ?>' id='contact_field_<?php echo esc_attr( $index ); ?>'>
Expand All @@ -601,10 +622,8 @@ class="qmn_quiz_radio"
</option>
<?php
}
echo '</select>';
}
?>
</select>
<?php
break;
default:
do_action( 'qsm_extra_contact_form_field_display', $field, $quiz_options, $index,$default_value );
Expand Down
4 changes: 4 additions & 0 deletions php/classes/class-qsm-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public static function send_emails( $transient_id ) {
foreach ( $emails as $index => $email ) {

$email_subject = $mlwQuizMasterNext->pluginHelper->qsm_language_support( $email['subject'], "quiz-email-subject-{$index}-{$response_data['quiz_id']}" );

// kses converts ampersands to &amp; core.trac.wordpress.org/ticket/11311.
$email_subject = str_replace( '&amp;', '&', $email_subject );

$email_content = $mlwQuizMasterNext->pluginHelper->qsm_language_support( $email['content'], "quiz-email-content-{$index}-{$response_data['quiz_id']}" );
// Checks if any conditions are present. Else, send it always.
if ( ! empty( $email['conditions'] ) ) {
Expand Down
4 changes: 3 additions & 1 deletion php/classes/class-qsm-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,9 @@ public function update() {
if ( ! get_option( 'fixed_duplicate_questions' ) ) {
QSM_Migrate::fix_duplicate_questions();
}
QSM_Migrate::fix_deleted_quiz_posts();
if ( ! get_option( 'fix_deleted_quiz_posts' ) ) {
QSM_Migrate::fix_deleted_quiz_posts();
}

update_option( 'mlw_quiz_master_version', $data );
}
Expand Down
3 changes: 2 additions & 1 deletion php/classes/class-qsm-migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static function fix_duplicate_questions() {
if ( ! empty( $all_quizzes ) ) {
foreach ( $all_quizzes as $quiz ) {
$quiz_id = $quiz->quiz_id;
$settings = maybe_unserialize( $quiz->quiz_settings );
$settings = ! empty( $quiz->quiz_settings ) ? maybe_unserialize( $quiz->quiz_settings ) : array();
$pages = isset( $settings['pages'] ) ? maybe_unserialize( $settings['pages'] ) : array();
$qpages = isset( $settings['qpages'] ) ? maybe_unserialize( $settings['qpages'] ) : array();
if ( ! empty( $pages ) ) {
Expand Down Expand Up @@ -179,6 +179,7 @@ public static function fix_deleted_quiz_posts() {
}
}
}
update_option( 'fix_deleted_quiz_posts', 1 );
}

}
6 changes: 5 additions & 1 deletion php/question-types/qsm-question-type-polar.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ function qmn_polar_display( $id, $question, $answers ) {
}
$new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
qsm_question_title_func( $question, '', $new_question_title, $id );

$show = true;
$show = apply_filters( 'qsm_check_advance_polar_show_status', $show, $id );
echo apply_filters( 'qmn_polar_display_front_before', '', $id, $question, $answers );
if ( $show ) {
?>
<span class="mlw_qmn_question question-type-polar-s">
<div class='left-polar-title'> <?php
Expand Down Expand Up @@ -100,6 +103,7 @@ function qmn_polar_display( $id, $question, $answers ) {
?></div>
</span>
<?php
}
echo apply_filters( 'qmn_polar_display_front', '', $id, $question, $answers );
}

Expand Down
25 changes: 21 additions & 4 deletions php/template-variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,32 @@ function qsm_contact_field_variable( $content, $results_array ) {
* @return string The HTML for the content
*/
function qsm_all_contact_fields_variable( $content, $results ) {
global $mlwQuizMasterNext;
$contact_form = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'contact_form' );

$return = '';
if ( isset( $results['contact'] ) && ( is_array( $results['contact'] ) || is_object( $results['contact'] ) ) ) {
for ( $i = 0; $i < count( $results['contact'] ); $i++ ) {
$return .= $results['contact'][ $i ]['label'] . ': ' . $results['contact'][ $i ]['value'] . '<br>';
foreach ( $results['contact'] as $results_contact ) {
$options = qsm_get_options_of_contact_fields($contact_form, $results_contact['label'], $results_contact['type'] );
$isRadioOrSelect = in_array($results_contact['type'], ['radio', 'select']);
$hasOptions = !empty(trim($options));

if (($isRadioOrSelect && $hasOptions) || !$isRadioOrSelect) {
$return .= $results_contact['label'] . ': ' . $results_contact['value'] . '<br>';
}
}
}
$content = str_replace( '%CONTACT_ALL%', $return, $content );
return $content;
}

function qsm_get_options_of_contact_fields($data, $label, $type) {
foreach ($data as $item) {
if ($item['label'] === $label && $item['type'] === $type) {
return $item['options'];
}
}
return null; // Option not found
}
/**
* Converts the %QUESTIONS_ANSWERS% into the template
*
Expand Down Expand Up @@ -1557,7 +1573,8 @@ function qmn_polar_display_on_resultspage( $id, $question, $answers, $answer ) {
$input_text .= "</div>";
$question = $input_text;
$question_display .= "<span class='mlw_qmn_question mlw-qmn-question-result-$id question-type-polar-s'>" . do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) . '</span>';
return apply_filters( 'qmn_polar_display_front', $question_display, $id, $question, $answers );
$question_display = apply_filters( 'qmn_polar_display_front', $question_display, $id, $question, $answers );
return apply_filters( 'qmn_polar_display_result_page', $question_display, $id, $question, $answers, $answer );
}

/**
Expand Down
9 changes: 8 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: quiz, survey, test, exam, online assessment
Requires at least: 4.9
Tested up to: 6.5
Requires PHP: 5.4
Stable tag: 9.0.4
Stable tag: 9.0.5
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -163,6 +163,13 @@ This is usually a theme conflict. You can [checkout out our common conflict solu
18. Database

== Changelog ==
= 9.0.5 ( June 19, 2024 ) =
* Bug: Resolved a security vulnerability
* Bug: Fixed the wpApiSettings JavaScript error
* Bug: Fixed an issue with & character in email templates
* Bug: Fixed the date contact field issue
* Enhancement: Improved contact field UI

= 9.0.4 ( June 10, 2024 ) =
* Enhancement: Improved HTML code management on the result page

Expand Down

0 comments on commit ec8e3ef

Please sign in to comment.