`;
let selector = jQuery("#" + key + " h2.hndle");
if (key === 'wp-statistics-useronline-widget') {
const current_online = jQuery(".wps-currently-online");
if (current_online.length && current_online.text() >= 0) {
const container = selector.find('.wps-wps-currently-online__container');
if (container.length) {
container.find('.wps-wps-currently-online__text').text(current_online.text());
} else {
const online = `
${current_online.text()}
`;
selector.append(online);
}
} else {
selector.find('.wps-wps-currently-online__container').remove()
}
}
if (key === 'wp-statistics-quickstats-widget') {
const selector = jQuery("#" + key + " div.handle-actions");
if (selector.length && !selector.find('.wps-overview-btn').length) {
const link = `${wps_js._('go_to_overview')}`;
selector.prepend(link);
const overviewBtn = selector.find('.wps-overview-btn');
if (overviewBtn.length) {
overviewBtn.on('click', function (e) {
e.preventDefault();
window.location.href = this.href;
});
}
}
}
if (response.meta && response.meta.description) {
if (selector.length && !selector.find('.wps-tooltip').length) {
const tooltip = response.meta.description;
const newTitle = '';
if (tooltip) selector.append(newTitle);
}
}
wps_js.metaBoxInner(key).append(html);
}
document.addEventListener('click', function (event) {
if (event.target && event.target.id === 'js-close-notice') {
let params = {
'action': 'wp_statistics_dismiss_notices',
'wps_nonce': wps_js.global.rest_api_nonce,
'notice_id': 'enable_email_metabox_notice'
};
jQuery.ajax({
url: wps_js.global.admin_url + 'admin-ajax.php',
type: 'POST',
dataType: 'json',
data: params,
timeout: 30000,
success: function ({data, success}) {
if (success === false) return console.log(data);
event.target.parentElement.parentElement.style.display = 'none';
},
error: function (xhr, status, error) {
console.log(error);
}
});
}
});
}