Hi @azlivin008
I noticed that this behavior is only with hosting/ servers with limited resources.
When you access the “overview” page, the plug-in make (almost at the same time) several requests (POST) to https://www.wellnessdestiny.org/wp-admin/admin-ajax.php to fill all widgets data. Due to some hosting restrictions (CPU, Memory, I/O, max DB Connections, etc), my server is no able to handle all the request at the same time. So, the server begins to reject requests and the clients get “Services unavailable” messages until we closed “overview” page and decreases the server resources usage.
In order to solve this issue in my site, I have modified the log.js file at wp-content/plugins/wp-statistics/assets/js/ to delay the calls to the function wp_statistics_get_widget_contents one second instead of making all the calls at the same time.
You can replace log.js code by the following below after every Plug-in update.
/*
Function to handle the loading of widget content
*/
var cr = 1;
function wp_statistics_get_widget_contents_inc(widget, container_id) {
//console.log(“widget:”+widget+” container_id:”+ container_id+” “+new Date());
//console.log(“cr:”+cr);
var data = {
‘action’: ‘wp_statistics_get_widget_contents’,
‘widget’: widget,
};
container = jQuery(“#” + container_id);
if (container.is(‘:visible’)) {
jQuery.ajax({
url: ajaxurl,
type: ‘post’,
data: data,
datatype: ‘json’,
})
.always(function (result) {
// Take the returned result and add it to the DOM.
jQuery(“#” + container_id).html(“”).html(result);
})
.fail(function (result) {
// If we failed for some reason, like a timeout, try again.
//container.html(wp_statistics_loading_image);
//wp_statistics_get_widget_contents(widget, container_id);
});
}
}
function wp_statistics_get_widget_contents(widget, container_id) {
cr = cr + 1;
setTimeout(function(){ wp_statistics_get_widget_contents_inc(widget, container_id);}, cr*1000);
}
function wp_statistics_refresh_widget() {
var widget = this.id.replace(‘wps_’, ”);
widget = widget.replace(‘_refresh_button’, ”);
container_id = widget.replace(‘.’, ‘_’) + ‘_postbox’;
container = jQuery(“#” + container_id);
if (container.is(‘:visible’)) {
container.html(wp_statistics_loading_image);
cr = 0;
wp_statistics_get_widget_contents(widget, container_id);
}
return false;
}
function wp_statistics_refresh_on_toggle_widget() {
if (this.value.substring(0, 4) != ‘wps_’) {
return;
}
var container_id = this.value.replace(‘wps_’, ”);
var widget = container_id.replace(‘_postbox’, ”);
cr = 1;
wp_statistics_get_widget_contents(widget, container_id);
}
function wp_statistics_goto_more() {
var widget = this.id;
if (wp_statistics_destinations[widget] !== undefined) {
window.location.href = wp_statistics_destinations[widget];
}
return false;
}