| Server IP : 38.190.208.107 / Your IP : 216.73.217.17 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : www ( 1000) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.3/wp-content/plugins/wp-statistics/assets/dev/javascript/pages/ |
Upload File : |
if (wps_js.isset(wps_js.global, 'request_params', 'page') && wps_js.global.request_params.page === "optimization") {
const wpStatisticsOptimization = {
actions: [
{
button: '#populate-submit-button',
result: '#populate-submit-result',
action: 'wp_statistics_update_country_data',
messageKey: 'confirm_refresh_country'
},
{
button: '#populate-source-channel-submit',
result: '#populate-source-channel-result',
action: 'wp_statistics_update_source_channel_data',
messageKey: 'confirm_update_channel'
},
{
button: '#hash-ips-submit',
result: '#hash-ips-result',
action: 'wp_statistics_hash_ips',
messageKey: 'confirm_hash_ips'
},
{
button: '#repair-schema-submit-button',
result: '#repair-schema-result',
action: 'wp_statistics_repair_schema',
messageKey: 'confirm_repair_schema'
},
{
button: '#re-check-schema-submit-button',
result: '#re-check-schema-result',
action: 'wp_statistics_recheck_schema'
}
],
showModal: function (message = wps_js._('are_you_sure'), onConfirm) {
const $modal = $('#setting-confirmation');
if (!$modal.length) return console.error('Modal not found.');
$modal.find('.wps-modal__description').text(message);
const $ok = $modal.find('button[data-action="resolve"]');
$ok.off('click').on('click', () => {
$ok.addClass('wps-loading-button');
onConfirm();
});
$modal.addClass('wps-modal--open');
},
ajaxAction: function (action, $result, $button) {
const $modal = $('#setting-confirmation');
const $ok = $modal.find('button[data-action="resolve"]');
const parseMessage = (response, defaultMsg = wps_js._('operation_completed')) => {
try {
const parsed = typeof response === 'string' ? JSON.parse(response) : response;
if (parsed?.data?.message) {
return parsed.data.message;
}
if (parsed?.message) {
return parsed.message;
}
if (parsed?.data) {
return JSON.stringify(parsed.data);
}
return defaultMsg;
} catch {
return typeof response === 'string' ? response : JSON.stringify(response);
}
};
const parseErrorMessage = (jqXHR, textStatus, errorThrown) => {
try {
const parsed = JSON.parse(jqXHR.responseText);
return parsed.data?.message
? parsed.data.message
: parsed.message || JSON.stringify(parsed);
} catch {
return jqXHR.responseText || `${textStatus}: ${errorThrown}`;
}
};
$button.addClass('wps-loading-button');
jQuery.ajax({
url: wps_js.global.ajax_url,
type: 'post',
data: {
action: action,
wps_nonce: wps_js.global.rest_api_nonce
}
})
.done(function (response) {
const msg = parseMessage(response);
if (response.success) {
$result.html(`<div class="wps-alert wps-alert__success"><p>${msg}</p></div>`);
} else {
$result.html(`<div class="wps-alert wps-alert__danger"><p>${msg}</p></div>`);
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
const msg = parseErrorMessage(jqXHR, textStatus, errorThrown);
$result.html(`<div class="wps-alert wps-alert__danger"><p>${msg}</p></div>`);
})
.always(function () {
$button.removeClass('wps-loading-button');
$ok.removeClass('wps-loading-button');
$modal.removeClass('wps-modal--open');
});
},
initMaintenanceAction: function ({button, result, action, messageKey}) {
const $btn = $(button);
const $res = $(result);
$btn.off('click').on('click', e => {
e.preventDefault();
if (!messageKey) {
this.ajaxAction(action, $res, $btn);
} else {
const msg = wps_js._(messageKey);
this.showModal(msg, () => this.ajaxAction(action, $res, $btn));
}
});
},
initMigrationActions: function () {
const self = this;
$('.wps-migration-btn[data-confirmation]').each(function () {
const $link = $(this);
const requiresConfirmation = $link.attr('data-confirmation') === '1';
if ($link.hasClass('disabled') || $link.attr('aria-disabled') === 'true') {
return;
}
$link.off('click').on('click', function (e) {
e.preventDefault();
const href = $link.attr('href');
if (requiresConfirmation) {
const confirmationMessage = wps_js._('confirmation') + '\n' + wps_js._('this_action_cannot_be_undone');
self.showModal(confirmationMessage, function () {
window.location.href = href;
});
} else {
window.location.href = href;
}
});
});
},
init: function () {
this.actions.forEach(a => this.initMaintenanceAction(a));
this.initMigrationActions();
}
};
jQuery(document).ready(() => {
wpStatisticsOptimization.init();
});
}