forked from ashfame/WPRealtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine.js
36 lines (35 loc) · 1.31 KB
/
engine.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function enginerun() {
(function($){
$(document).ready(function(){
// Make ajax call to fetch fresh stats
$.ajax({
type: 'POST',
url: wprealtime.ajaxurl,
data: {
action: 'wprealtime_whats_new'
}
}).done(function(response){
response = $.parseJSON(response);
if ( response.status == 'success' ) {
var dashboard_right_now_tds = $('#dashboard_right_now td');
$(dashboard_right_now_tds).eq(0).find('a').html(response.count.posts.publish);
$(dashboard_right_now_tds).eq(2).find('a').html(response.count.pages.publish);
$(dashboard_right_now_tds).eq(4).find('a').html(response.count.categories);
$(dashboard_right_now_tds).eq(6).find('a').html(response.count.tags);
$(dashboard_right_now_tds).eq(8).find('a').html(response.count.comments.total_comments);
$(dashboard_right_now_tds).eq(10).find('a').html(response.count.comments.approved);
$(dashboard_right_now_tds).eq(12).find('a').html(response.count.comments.total_comments-response.count.comments.approved);
$(dashboard_right_now_tds).eq(14).find('a').html(response.count.comments.spam);
}
});
// Refetch stats after timeout
setTimeout(enginerun,5000);
});
})(jQuery);
}
(function($){
$(document).ready(function(){
// Initial start for engine
setTimeout(enginerun,5000);
});
})(jQuery);