Skip to content

Commit

Permalink
Merge pull request #2632 from QuizandSurveyMaster/CU-86cv5xddw-condit…
Browse files Browse the repository at this point in the history
…ional-shortcode-new-ui

Cu 86cv5xddw conditional shortcode new UI
  • Loading branch information
zubairraeen authored Aug 28, 2024
2 parents af695de + 603ddaa commit f518d7a
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 10 deletions.
25 changes: 25 additions & 0 deletions css/qsm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -3469,4 +3469,29 @@ input#preferred-date-format-custom {
margin: 13px -15px 8px;
content: "";
width: calc(100% + 26px);
}

/* Extra shortcodes popup */
button.button.qsm-extra-shortcode-popup {
display: flex;
align-items: center;
position: relative;
top: 30px;
left: 197px;
z-index: 10;
}

button.button.qsm-slashcommand-variables-button {
display: flex;
align-items: center;
position: relative;
top: 30px;
left: 110px;
z-index: 10;
margin: -30px 0;
}

button.button.qsm-slashcommand-variables-button .qsm-slash-inside {
margin: 0 4px 0 -1px;
font-weight: 1000;
}
24 changes: 23 additions & 1 deletion js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1379,10 +1379,32 @@ function qsm_is_substring_in_array( text, array ) {
editor.execCommand('mceInsertContent', false, pastedValue.replace(/%([^%]+)%/g, '<qsmvariabletag>$1</qsmvariabletag>&nbsp;') );
}
});

// Stop multiple times registering click event
$(document).off('click', '.qsm-slashcommand-variables-button').on('click', '.qsm-slashcommand-variables-button', function(e) {
e.preventDefault();
let id = $(this).data('id');
let editor = tinymce.get(id);
let contentToInsert = '/';
editor.focus();
editor.selection.setContent(contentToInsert);
showAutocomplete(editor, true);
});
});
}
}
addTinyMceAutoSuggestion();

$( document ).on( 'click', '.qsm-extra-shortcode-popup', function( e ) {
e.preventDefault();
MicroModal.show('modal-extra-shortcodes');
} );

jQuery(document).on('qsm_after_add_result_block', function(event, conditions, page, redirect, total) {
let $matchingElement = $(`#results-page-${total}`);
let $button = $matchingElement.parents('.results-page-show').find('.qsm-result-editor-custom-button');
$button.attr('data-id', total - 1);
});
}
}
}(jQuery));
Expand Down Expand Up @@ -3831,7 +3853,7 @@ var import_button;
tinymce: {
plugins: "qsmslashcommands link image lists charmap colorpicker textcolor hr fullscreen wordpress",
forced_root_block: '',
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,qsm_slash_command,wp_adv',
toolbar1: 'formatselect,bold,italic,underline,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_adv',
toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help,wp_code,fullscreen',
},
quicktags: true,
Expand Down
2 changes: 1 addition & 1 deletion js/qsm-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ var qsmTimerInterval = [];
if ('0' != qmn_quiz_data[quizID].progress_bar) {
jQuery(document).trigger('qsm_init_progressbar_before', [quizID, qmn_quiz_data]);
$('#quizForm' + quizID).find('.qsm-progress-bar').show();
qmn_quiz_data[quizID].bar = createQSMProgressBar(quizID, '#quizForm' + quizID + ' .qsm-progress-bar');
qmn_quiz_data[quizID].bar = createQSMProgressBar(quizID, '#quizForm' + quizID + ' .qsm-progress-bar');
jQuery(document).trigger('qsm_init_progressbar_after', [quizID, qmn_quiz_data]);
}
QSM.goToPage(quizID, 1);
Expand Down
12 changes: 5 additions & 7 deletions php/admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1434,17 +1434,15 @@ function qsm_admin_upgrade_content( $args = array(), $type = 'popup' ) {
* @return html
*/
function qsm_quiz_theme_settings( $type, $label, $name, $value, $default_value, $options = array( 'button_text' => '' ) ) {
$tooltip = '';
if ( isset( $options['helper_text'] ) && '' !== $options['helper_text'] ) {
$tooltip .= '<span class="dashicons dashicons-editor-help qsm-tooltips-icon">';
$tooltip .= '<span class="qsm-tooltips">' . esc_html( $options['helper_text'] ) . '</span>';
$tooltip .= '</span>';
}
?>
<tr valign="top">
<th scope="row" class="qsm-opt-tr">
<label for="form_type"><?php echo esc_attr( $label ); ?></label>
<?php echo wp_kses_post( $tooltip ); ?>
<?php if ( isset( $options['helper_text'] ) && '' !== $options['helper_text'] ) { ?>
<span class="dashicons dashicons-editor-help qsm-tooltips-icon">
<span class="qsm-tooltips"><?php esc_html( $options['helper_text'] ); ?></span>
</span>
<?php } ?>
</th>
<td align ="right">
<?php
Expand Down
24 changes: 24 additions & 0 deletions php/admin/options-page-results-page-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,30 @@ function qsm_options_results_tab_template(){
<h4><?php esc_html_e( '...Show', 'quiz-master-next' ); ?></h4>
<p><?php esc_html_e( 'The following result page.', 'quiz-master-next' ); ?></p>
</div>
<button type="button" class="button qsm-slashcommand-variables-button qsm-result-editor-custom-button">
<span class="qsm-slash-inside"> / </span><?php esc_html_e('Variables', 'quiz-master-next'); ?>
</button>
<?php
if ( ! class_exists('QSM_Extra_Shortcodes') ) {
$qsm_pop_up_arguments = array(
"id" => 'modal-extra-shortcodes',
"title" => __('QSM Shortcode', 'quiz-master-next'),
"description" => __('Wondering how to setup resultpage content with QSM conditional shortcode. Easily use conditional shortcodes and make your result page with conditional content.', 'quiz-master-next'),
"chart_image" => plugins_url('', dirname(__FILE__)) . '/images/extra-shortcodes.png',
"information" => __('QSM Addon Bundle is the best way to get all our add-ons at a discount. Upgrade to save 95% today OR you can buy QSM Extra Shortodes Addon separately.', 'quiz-master-next'),
"buy_btn_text" => __('Buy QSM Extra Shortodes Addon', 'quiz-master-next'),
"doc_link" => qsm_get_plugin_link( 'docs/add-ons/extra-shortcodes/', 'qsm_list', 'extrashortcodea_button', 'extra-shortcodes-upsell_read_documentation', 'qsm_plugin_upsell' ),
"upgrade_link" => qsm_get_plugin_link( 'pricing', 'qsm_list', 'extrashortcodea_button', 'extra-shortcodes-upsell_upgrade', 'qsm_plugin_upsell' ),
"addon_link" => qsm_get_plugin_link( 'downloads/extra-shortcodes', 'qsm_list', 'extrashortcodea_button', 'extra-shortcodes-upsell_buy_addon', 'qsm_plugin_upsell' ),
);
qsm_admin_upgrade_popup($qsm_pop_up_arguments);
?>
<button type="button" class="button qsm-extra-shortcode-popup">
<span class=" dashicons dashicons-shortcode"></span>
<?php esc_html_e('Pro Shortcode', 'quiz-master-next'); ?>
</button>
<?php }
do_action( 'qsm_result_page_content_before', $quiz_id, $categories ); ?>
<textarea id="results-page-{{ data.id }}" class="results-page-template">
{{{ data.page.replace(/%([^%]+)%/g, function(match, capturedValue) {
let qsm_varaible_list = qsm_admin_messages.qsm_variables_name;
Expand Down
1 change: 1 addition & 0 deletions php/admin/settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ public function qsm_global_save_responses() {
<fieldset class="buttonset buttonset-hide">
<input type="hidden" name="qsm-quiz-settings[store_responses]" value="0">
<label for="store_responses">
<input type="hidden" name="qsm-quiz-settings[store_responses]" value="0">
<input type="checkbox" id="store_responses" name="qsm-quiz-settings[store_responses]" value="1" <?php checked( $qsm_store_responses, 1 ); ?>>
<?php esc_html_e('Store results permanently in database', 'quiz-master-next'); ?>
</label>
Expand Down
1 change: 0 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ QSM is designed to be compatible with most WordPress plugins and themes. However
* Enhancement: Improved quiz navigation with keyboard
* Enhancement: Checked compatibility with WordPress 6.6 and PHP 8.3


= 9.1.0 ( July 11, 2024 ) =
* Feature: Added case-sensitive option to paragraph and short answers question types
* Bug: Fixed vulnerability with quiz settings
Expand Down

0 comments on commit f518d7a

Please sign in to comment.