✏️ 正在编辑: exit-survey.js
路径:
/home/ubuntu/plugins-bkp-26012025/w3-total-cache/pub/js/exit-survey.js
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
/** * File: exit-survey.js * * JavaScript for the exit survey modal. * * @since 2.8.3 * * @global w3tcData Localized array variable. */ /** * Display the exit servey modal on plugin deactivation. * * @since 2.8.3 */ function w3tc_exit_survey_render() { W3tc_Lightbox.open({ id: 'w3tc-overlay', height: 'auto', maxWidth: 600, url: `${ajaxurl}?action=w3tc_ajax&_wpnonce=${w3tcData.nonce}&w3tc_action=exit_survey_render`, callback: function(lightbox) { // Retrieve the original deactivation URL. var deactivateUrl = jQuery('#deactivate-w3-total-cache').attr('href'); // Cancel button action jQuery('#w3tc-exit-survey-skip', lightbox.container).on( 'click', function() { // Show spinner and disable interactions. lightbox.show_spinner(); if (window.w3tc_ga) { w3tc_ga( 'event', 'button', { eventCategory: 'click', eventLabel: 'exit_survey_skip' } ); } // Close the lightbox. lightbox.close(); // Proceed with plugin deactivation. window.location.href = deactivateUrl; }); // Handle form submission. jQuery('#w3tc-exit-survey-form', lightbox.container).on('submit', function(event) { event.preventDefault(); // Show spinner and disable interactions. lightbox.show_spinner(); if (window.w3tc_ga) { w3tc_ga( 'event', 'button', { eventCategory: 'click', eventLabel: 'exit_survey_submit' } ); } // Collect form data. var reason = jQuery('input[name="reason"]:checked', lightbox.container).val(); var other = jQuery('input[name="other"]', lightbox.container).val(); var remove = jQuery('input[name="remove"]:checked', lightbox.container).val(); // Build the params object. var params = { action: 'w3tc_ajax', _wpnonce: w3tcData.nonce, w3tc_action: 'exit_survey_submit', reason: reason, other: other, remove: remove }; // Send the survey data to the API server. jQuery.post( ajaxurl, params, function(response) { if(response.success) { lightbox.close(); window.location.href = deactivateUrl; } else { if (window.w3tc_ga) { w3tc_ga( 'event', 'w3tc_error', { eventCategory: 'exit_survey', eventLabel: 'api_error' } ); } lightbox.close(); window.location.href = deactivateUrl; } }); }); lightbox.resize(); } }); } // On document ready. jQuery(function() { /** * Trigger display of exit survey on plugin deactivation link click. * * @since 2.8.3 */ jQuery('#deactivate-w3-total-cache').on( 'click', function(e) { e.preventDefault(); if (window.w3tc_ga) { w3tc_ga( 'event', 'button', { eventCategory: 'click', eventLabel: 'exit_survey_open' } ); } w3tc_exit_survey_render(); return false; }); // Listen for changes on the radio buttons. jQuery(document).on('change', 'input[name="reason"]', function() { // Enable Submit & Deactivate button once an option is selected. if (jQuery('input[name="reason"]:checked').length > 0) { jQuery('#w3tc-exit-survey-submit').prop('disabled', false); } // If the "Other" option is selected, show the text box. if (jQuery(this).val() === 'other') { jQuery('#w3tc_exit_survey_uninstall_reason_other').show(); } else { jQuery('#w3tc_exit_survey_uninstall_reason_other').hide(); } }); });
💾 保存文件
← 返回文件管理器