diff --git a/css/admin-dashboard-rtl.css b/css/admin-dashboard-rtl.css index ecd3beddb..108e401e0 100644 --- a/css/admin-dashboard-rtl.css +++ b/css/admin-dashboard-rtl.css @@ -296,86 +296,6 @@ display: inline-block; } -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner { - width: 31%; - margin-left: 2%; - float: right; - border: 1px solid #dfd4d4; - height: 210px; - text-align: center; - margin-bottom: 2%; - position: relative; - cursor: pointer; - box-sizing: border-box; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:hover, -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner.selected-quiz-template { - border-color: #1e8cbe; - -webkit-box-shadow: 2px -1px 13px -1px rgba(30, 140, 190, 1); - -moz-box-shadow: 2px -1px 13px -1px rgba(30, 140, 190, 1); - box-shadow: 2px -1px 13px -1px rgba(30, 140, 190, 1); - transition: 0.2s all; - -ms-transition: 0.2s all; - -o-transition: 0.2s all; - -webkit-transition: 0.2s all; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(3n + 3) { - width: 33%; - margin-left: 0%; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner .template-center-vertical { - /*position: absolute; - top: 50%; - left: 50%; - -ms-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); */ - margin-top: 21px; - height: 96px; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:first-child .template-center-vertical { - height: auto; - position: absolute; - top: 50%; - right: 50%; - -ms-transform: translate(50%, -50%); - transform: translate(50%, -50%); - margin-top: 0; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner .dashicons { - font-size: 75px; - color: #9ea3a8; - display: inline-block; - height: auto; - width: auto; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner p.start_scratch { - font-size: 14px; - text-transform: uppercase; - letter-spacing: 1px; - color: #9ea3a8; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner h3 { - margin: 0; - padding: 10px; - border-top: 1px solid #dfd4d4; - font-size: 15px; - position: absolute; - width: 100%; - box-sizing: border-box; - bottom: 0; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner.inner-json { - background: #fff; -} - #model-wizard .qsm-popup__footer { text-align: left; background: #fff; @@ -1079,22 +999,6 @@ h2.hndle.ui-sortable-handle { } } -@media (min-width: 768px) and (max-width: 991px) { - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner { - width: 48%; - } - - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(2n + 2) { - margin-left: 0; - width: 50%; - } - - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(3n + 3) { - margin-left: 2%; - width: 48%; - } -} - @media screen and (max-width: 767px) { #model-wizard .qsm-popup__container { width: 90%; @@ -1104,11 +1008,6 @@ h2.hndle.ui-sortable-handle { width: 100%; } - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(2n + 2), - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner { - width: 100% !important; - } - #model-wizard .qsm-wizard-setting-section { width: 100%; height: auto !important; diff --git a/css/admin-dashboard.css b/css/admin-dashboard.css index 212fc195c..1467e104f 100644 --- a/css/admin-dashboard.css +++ b/css/admin-dashboard.css @@ -303,86 +303,6 @@ ul.popuar-addon-ul::after { display: inline-block; } -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner { - width: 31%; - margin-right: 2%; - float: left; - border: 1px solid #dfd4d4; - height: 210px; - text-align: center; - margin-bottom: 2%; - position: relative; - cursor: pointer; - box-sizing: border-box; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:hover, -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner.selected-quiz-template { - border-color: #1e8cbe; - -webkit-box-shadow: -2px -1px 13px -1px rgba(30, 140, 190, 1); - -moz-box-shadow: -2px -1px 13px -1px rgba(30, 140, 190, 1); - box-shadow: -2px -1px 13px -1px rgba(30, 140, 190, 1); - transition: 0.2s all; - -ms-transition: 0.2s all; - -o-transition: 0.2s all; - -webkit-transition: 0.2s all; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(3n + 3) { - width: 33%; - margin-right: 0%; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner .template-center-vertical { - /*position: absolute; - top: 50%; - left: 50%; - -ms-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); */ - margin-top: 21px; - height: 96px; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:first-child .template-center-vertical { - height: auto; - position: absolute; - top: 50%; - left: 50%; - -ms-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); - margin-top: 0; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner .dashicons { - font-size: 75px; - color: #9ea3a8; - display: inline-block; - height: auto; - width: auto; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner p.start_scratch { - font-size: 14px; - text-transform: uppercase; - letter-spacing: 1px; - color: #9ea3a8; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner h3 { - margin: 0; - padding: 10px; - border-top: 1px solid #dfd4d4; - font-size: 15px; - position: absolute; - width: 100%; - box-sizing: border-box; - bottom: 0; -} - -#model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner.inner-json { - background: #fff; -} - #model-wizard .qsm-popup__footer { text-align: right; background: #fff; @@ -1120,22 +1040,6 @@ h2.hndle.ui-sortable-handle { } } -@media (min-width: 768px) and (max-width: 991px) { - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner { - width: 48%; - } - - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(2n + 2) { - margin-right: 0; - width: 50%; - } - - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(3n + 3) { - margin-right: 2%; - width: 48%; - } -} - @media screen and (max-width: 767px) { #model-wizard .qsm-popup__container { width: 90%; @@ -1145,11 +1049,6 @@ h2.hndle.ui-sortable-handle { width: 100%; } - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner:nth-child(2n + 2), - #model-wizard .qsm-popup__content .template-inner-wrap .template-list .template-list-inner { - width: 100% !important; - } - #model-wizard .qsm-wizard-setting-section { width: 100%; height: auto !important; diff --git a/js/qsm-admin.js b/js/qsm-admin.js index 5203ca12e..9201a78ab 100644 --- a/js/qsm-admin.js +++ b/js/qsm-admin.js @@ -203,13 +203,13 @@ var QSMAdmin; if (confirm(qsm_admin_messages.confirm_message)) { var action = 'qsm_dashboard_delete_result'; var result_id = jQuery(this).data('result_id'); - $.post(ajaxurl, { result_id: result_id, action: action }, - function (data) { - if (data == 'failed') { - alert(qsm_admin_messages.error_delete_result); - } else { - $this.parents('li').slideUp(); + $.post(ajaxurl, { result_id: result_id, action: action, nonce: wpApiSettings.nonce }, + function (response) { + if (response.success) { $this.parents('li').remove(); + $this.parents('li').slideUp(); + } else { + alert(qsm_admin_messages.error_delete_result); } } ); @@ -231,37 +231,8 @@ var QSMAdmin; heightStyle: "content" }); jQuery('#accordion h3.ui-accordion-header').next().slideDown(); - jQuery('.template-list .template-list-inner:first-child').trigger('click'); } }); - //Get quiz options - jQuery('.template-list-inner').click(function () { - var action = 'qsm_wizard_template_quiz_options'; - var settings = jQuery(this).data('settings'); - var addons = jQuery(this).data('addons'); - jQuery('.template-list .template-list-inner').removeClass('selected-quiz-template'); - jQuery(this).addClass('selected-quiz-template'); - jQuery('#quiz_settings_wrapper').html('').html('
'); - jQuery('#recomm_addons_wrapper').html('').html('
'); - $.post(ajaxurl, { settings: settings, addons: addons, action: action }, - function (data) { - var diff_html = data.split('====='); - jQuery('#quiz_settings_wrapper').html(''); - jQuery('#quiz_settings_wrapper').html(diff_html[0]); - jQuery('#recomm_addons_wrapper').html(''); - jQuery('#recomm_addons_wrapper').html(diff_html[1]); - jQuery("#accordion").accordion(); - jQuery('#accordion h3.ui-accordion-header').next().slideDown(); - $('#quiz_settings_wrapper select').each(function () { - var name = $(this).attr('name'); - var value = $(this).val(); - if ($('.' + name + '_' + value).length > 0) { - $('.' + name + '_' + value).show(); - } - }); - } - ); - }); //Dismiss the welcome panel jQuery('.qsm-welcome-panel-dismiss').click(function (e) { @@ -932,41 +903,9 @@ if(current_id == 'qsm_variable_text'){ jQuery(".current_variable")[0].click();} heightStyle: "content" }); jQuery('#accordion h3.ui-accordion-header').next().slideDown(); - jQuery('.template-list .template-list-inner:first-child').trigger('click'); } }); - //Get quiz options - $('.template-list-inner').click(function () { - var action = 'qsm_wizard_template_quiz_options'; - var settings = $(this).data('settings'); - var addons = $(this).data('addons'); - $('.template-list .template-list-inner').removeClass('selected-quiz-template'); - $(this).addClass('selected-quiz-template'); - $('#quiz_settings_wrapper').html('').html('
'); - $('#recomm_addons_wrapper').html('').html('
'); - $.post(ajaxurl, { - settings: settings, - addons: addons, - action: action - }, - function (data) { - var diff_html = data.split('====='); - $('#quiz_settings_wrapper').html(''); - $('#quiz_settings_wrapper').html(diff_html[0]); - $('#recomm_addons_wrapper').html(''); - $('#recomm_addons_wrapper').html(diff_html[1]); - $("#accordion").accordion(); - $('#accordion h3.ui-accordion-header').next().slideDown(); - $('#quiz_settings_wrapper select').each(function () { - var name = $(this).attr('name'); - var value = $(this).val(); - if ($('.' + name + '_' + value).length > 0) { - $('.' + name + '_' + value).show(); - } - }); - } - ); - }); + $('#show_import_export_popup').on('click', function (event) { event.preventDefault(); MicroModal.show('modal-export-import'); @@ -1222,12 +1161,12 @@ if(current_id == 'qsm_variable_text'){ jQuery(".current_variable")[0].click();} url: ajaxurl, data: { action: 'enable_multiple_categories', - value: 'enable' + value: 'enable', + nonce: wpApiSettings.nonce }, - success: function (r) { - response = JSON.parse(r); + success: function (response) { clearInterval(category_interval); - if (response.status) { + if (response.success) { $('.category-action').parents('.multiple-category-notice').removeClass('notice-info').addClass('notice-success').html('

' + qsm_admin_messages.update_db_success + '

'); } else { $('.category-action').parents('.multiple-category-notice').removeClass('notice-info').addClass('notice-error').html(qsm_admin_messages.error + '! ' + qsm_admin_messages.try_again); @@ -1245,10 +1184,11 @@ if(current_id == 'qsm_variable_text'){ jQuery(".current_variable")[0].click();} url: ajaxurl, data: { action: 'enable_multiple_categories', - value: 'cancel' + value: 'cancel', + nonce: wpApiSettings.nonce }, success: function (status) { - if (status) { + if (response.success) { $('.multiple-category-notice').hide(); } } @@ -1498,7 +1438,7 @@ var QSMContact; $(document).on('change', '.show-disabled-fields', function (event) { event.preventDefault(); var is_show = $(this).prop('checked'); - jQuery.post(ajaxurl, { action: 'qsm_show_disabled_contact_fields', show: is_show }); + jQuery.post(ajaxurl, { action: 'qsm_show_disabled_contact_fields', show: is_show, 'nonce': qsmContactObject.saveNonce, 'quiz_id': qsmContactObject.quizID }); if (is_show) { $('.contact-form-field').removeClass('hidden-field'); } else { @@ -3309,6 +3249,8 @@ var import_button; var new_category_data = { action: 'save_new_category', name: new_category, + quiz_id: qsmQuestionSettings.quizID, + nonce: qsmQuestionSettings.saveNonce, parent: parent_category }; $('#modal-9-content .info').html(''); diff --git a/php/admin/admin-dashboard.php b/php/admin/admin-dashboard.php index c8b52e634..53dd064c3 100644 --- a/php/admin/admin-dashboard.php +++ b/php/admin/admin-dashboard.php @@ -277,55 +277,6 @@ function qsm_generate_dashboard_page() { qsm_create_new_quiz_wizard(); } -/** - * @since 7.0 - * @global Obj $mlwQuizMasterNext - * Generate the post settings and required plugin in popup - */ -function qsm_wizard_template_quiz_options() { - global $mlwQuizMasterNext; - $settings = isset( $_POST['settings'] ) ? qsm_sanitize_rec_array( wp_unslash( $_POST['settings'] ) ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - $addons = isset( $_POST['addons'] ) ? qsm_sanitize_rec_array( wp_unslash( $_POST['addons'] ) ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - $all_settings = $mlwQuizMasterNext->quiz_settings->load_setting_fields( 'quiz_options' ); - $recommended_addon_str = ''; - if ( $settings ) { - foreach ( $settings as $key => $single_setting ) { - $key = array_search( $key, array_column( $all_settings, 'id' ), true ); - $field = $all_settings[ $key ]; - $field['label'] = $single_setting['option_name']; - $field['default'] = $single_setting['value']; - QSM_Fields::generate_field( $field, $single_setting['value'] ); - } - } else { - esc_html_e( 'No settings are found!', 'quiz-master-next' ); - } - echo '====='; - if ( $addons ) { - $recommended_addon_str .= ''; - } else { - $recommended_addon_str .= __( 'No addons are found!', 'quiz-master-next' ); - } - echo wp_kses_post( $recommended_addon_str ); - exit; -} -add_action( 'wp_ajax_qsm_wizard_template_quiz_options', 'qsm_wizard_template_quiz_options' ); - /** * @since 7.0 * @param str $widget_id diff --git a/php/admin/options-page-contact-tab.php b/php/admin/options-page-contact-tab.php index 7afd93534..08f5cf8bf 100644 --- a/php/admin/options-page-contact-tab.php +++ b/php/admin/options-page-contact-tab.php @@ -120,12 +120,12 @@ function qsm_contact_form_admin_ajax() { function qsm_show_disabled_contact_fields() { global $wpdb, $mlwQuizMasterNext; $user_id = get_current_user_id(); - if ( isset( $_POST['show'] ) ) { + $quiz_id = isset( $_POST['quiz_id'] ) ? intval( $_POST['quiz_id'] ) : 0; + if ( isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'ajax-nonce-contact-save-' . $quiz_id . '-' . $user_id ) && isset( $_POST['show'] ) ) { update_user_meta( $user_id, 'qsm_show_disabled_contact_fields', sanitize_text_field( wp_unslash( $_POST['show'] ) ) ); } // Sends posted form data to Contact Manager to sanitize and save. - echo '1'; - die(); + wp_send_json_success(); } function qsm_options_contact_tab_template() { diff --git a/php/admin/options-page-questions-tab.php b/php/admin/options-page-questions-tab.php index b46e4c3ae..61be2b601 100644 --- a/php/admin/options-page-questions-tab.php +++ b/php/admin/options-page-questions-tab.php @@ -960,7 +960,7 @@ function qsm_send_data_sendy() { add_action( 'wp_ajax_qsm_dashboard_delete_result', 'qsm_dashboard_delete_result' ); function qsm_dashboard_delete_result() { $result_id = isset( $_POST['result_id'] ) ? intval( $_POST['result_id'] ) : 0; - if ( $result_id ) { + if ( isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'wp_rest' ) && $result_id ) { global $wpdb; $wpdb->update( $wpdb->prefix . 'mlw_results', @@ -973,11 +973,9 @@ function qsm_dashboard_delete_result() { ), array( '%d' ) ); - echo 'success'; - exit; + wp_send_json_success(); } - echo 'failed'; - exit; + wp_send_json_error(); } /** @@ -1070,15 +1068,19 @@ function qsm_delete_question_from_database() { function qsm_save_new_category() { $category = isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : ''; $parent = isset( $_POST['parent'] ) ? intval( $_POST['parent'] ) : ''; + $user_id = get_current_user_id(); + $quiz_id = isset( $_POST['quiz_id'] ) ? intval( $_POST['quiz_id'] ) : 0; $parent = ( -1 == $parent ) ? 0 : $parent; - $term_array = wp_insert_term( - $category, - 'qsm_category', - array( - 'parent' => $parent, - ) - ); - echo wp_json_encode( $term_array ); + if ( isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'ajax-nonce-sandy-page' ) ) { + $term_array = wp_insert_term( + $category, + 'qsm_category', + array( + 'parent' => $parent, + ) + ); + echo wp_json_encode( $term_array ); + } exit; } diff --git a/php/classes/class-qsm-migrate.php b/php/classes/class-qsm-migrate.php index f7f0fb46f..374c33ec2 100644 --- a/php/classes/class-qsm-migrate.php +++ b/php/classes/class-qsm-migrate.php @@ -23,6 +23,9 @@ public function __construct() { * @return void */ public function enable_multiple_categories() { + if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'wp_rest' ) ) { + wp_send_json_error(); + } global $wpdb; global $mlwQuizMasterNext; $value = isset( $_POST['value'] ) ? sanitize_text_field( wp_unslash( $_POST['value'] ) ) : ''; @@ -69,12 +72,12 @@ public function enable_multiple_categories() { ); update_option( 'qsm_multiple_category_enabled', gmdate( time() ) ); } - echo wp_json_encode( $response ); + wp_send_json_success(); break; case 'cancel': update_option( 'qsm_multiple_category_enabled', 'cancelled' ); - return true; + wp_send_json_success(); break; } exit;