/* * WP Force SSL * (c) WebFactory Ltd 2019 - 2022 */ (function ($) { $('#wfssl-tabs') .tabs({ create: function () { if (window.location.hash && window.location.hash != '#' && window.location.hash != '#open-pro-dialog') { $('#wfssl-tabs').tabs( 'option', 'active', $('a[href="' + location.hash + '"]') .parent() .index() ); window.location.hash = ''; } }, beforeActivate: function (event, ui) { if (ui.newTab.hasClass('wfssl-tab-pro')) { return false; } }, activate: function (event, ui) { localStorage.setItem('wfssl-tabs', $('#wfssl-tabs').tabs('option', 'active')); }, active: localStorage.getItem('wfssl-tabs') || 0, }) .show(); $(window).on('hashchange', function () { $('#wfssl-tabs').tabs( 'option', 'active', $('a[href="' + location.hash + '"]') .parent() .index() ); }); // helper for switching tabs & linking anchors in different tabs $('.settings_page_wpfs-settings').on('click', '.change-tab', function (e) { e.preventDefault(); $('#wfssl-tabs').tabs('option', 'active', $(this).data('tab')); // get the link anchor and scroll to it target = this.href.split('#')[1]; if (target) { $.scrollTo('#' + target, 500, { offset: { top: -50, left: 0 } }); } $(this).blur(); return false; }); // jump to tab/anchor helper // helper for scrolling to anchor $('.settings_page_wpfs-settings').on('click', '.scrollto', function (e) { e.preventDefault(); // get the link anchor and scroll to it target = this.href.split('#')[1]; if (target) { $.scrollTo('#' + target, 500, { offset: { top: -50, left: 0 } }); } $(this).blur(); return false; }); // scroll to anchor helper // display a loading message while an action is performed function block_ui(message) { tmp = swal({ text: message, type: false, imageUrl: wpfs.loading_icon_url, onOpen: () => { $(swal.getImage()).addClass('wfssl_flicker'); }, heightAuto: false, imageWidth: 100, imageHeight: 100, imageAlt: message, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, showConfirmButton: false, width: 600, }); return tmp; } // block_ui // test SSL certificate $('.wpfs_test_ssl').on('click', function (e) { e.preventDefault(); var _ajax_nonce = wpfs.nonce_test_ssl; var action = 'wpfs_test_ssl'; var form_data = '_ajax_nonce=' + _ajax_nonce + '&action=' + action; block_ui(wpfs.testing); $.post({ url: wpfs.ajaxurl, data: form_data, }) .always(function (data) { swal.close(); }) .done(function (result) { if (typeof result.success != 'undefined' && result.success) { jQuery.get(wpfs.home_url).always(function (data, text, xhr) { wphe_changed = false; if (xhr.status.substr(0, 1) != '2') { swal({ type: 'error', heightAuto: false, title: wpfs.undocumented_error }); } else { swal({ type: 'success', heightAuto: false, title: wpfs.test_success, html: result.data, }); } }); } else if (typeof result.success != 'undefined' && !result.success) { swal({ heightAuto: false, type: 'error', title: wpfs.test_failed, html: result.data }); } else { swal({ heightAuto: false, type: 'error', title: wpfs.undocumented_error }); } }) .fail(function (data) { if (data.data) { swal({ type: 'error', heightAuto: false, title: wpfs.documented_error + ' ' + data.data, }); } else { swal({ heightAuto: false, type: 'error', title: wpfs.undocumented_error }); } }); return false; }); // test SSL certificate // save settings $('.settings_page_wpfs-settings').on('click', '.save-ssl-options', function (e) { e.preventDefault(); var _ajax_nonce = wpfs.nonce_save_settings; var action = 'wpfs_save_settting'; var form_data = $('#wpfs_form').serialize() + '&_ajax_nonce=' + _ajax_nonce + '&action=' + action; block_ui(wpfs.saving); $.post({ url: wpfs.ajaxurl, data: form_data, }) .always(function (data) { swal.close(); }) .done(function (result) { if (typeof result.success != 'undefined' && result.success) { load_test_results(true); swal({ type: 'success', heightAuto: false, title: wpfs.save_success, showConfirmButton: false, timer: 1400, }); } else if (typeof result.success != 'undefined' && !result.success) { swal({ heightAuto: false, type: 'error', title: result.data }); } else { swal({ heightAuto: false, type: 'error', title: wpfs.undocumented_error }); } }) .fail(function (data) { if (data.data) { swal({ type: 'error', heightAuto: false, title: wpfs.documented_error + ' ' + data.data, }); } else { swal({ heightAuto: false, type: 'error', title: wpfs.undocumented_error }); } }); return false; }); load_test_results(false); $('.settings_page_wpfs-settings').on('click', '.run-tests', function () { load_test_results(true); }); function load_test_results(force) { $('#status_progress_wrapper').hide(); $('.run-tests').hide(); $('#status_tasks').hide(); $('#test-results-wrapper').html( '
Loading. Please wait.
| ';
switch (tests_results[test].status) {
case 'fail':
tests_results_html += ' failed ';
tests_fail++;
break;
case 'warning':
tests_results_html += 'warning ';
tests_warning++;
break;
case 'pass':
tests_results_html += 'passed ';
tests_pass++;
break;
}
tests_results_html += ' | ';
tests_results_html +=
'' + tests_results[test].title + ' ' + tests_results[test].description + ' | ';
tests_results_html += '