forked from lesterchan/wp-useronline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-stats.php
41 lines (31 loc) · 1.31 KB
/
wp-stats.php
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
37
38
39
40
<?php
class UserOnline_WpStats {
function init() {
add_filter( 'wp_stats_page_admin_plugins', array( __CLASS__, 'page_admin_general_stats' ) );
add_filter( 'wp_stats_page_plugins', array( __CLASS__, 'page_general_stats' ) );
}
// Add WP-UserOnline General Stats To WP-Stats Page Options
function page_admin_general_stats( $content ) {
$stats_display = get_option( 'stats_display' );
$content .= '<input type="checkbox" name="stats_display[]" id="wpstats_useronline" value="useronline"' . checked( $stats_display['useronline'], 1, false ) . '/> <label for="wpstats_useronline">'.__( 'WP-UserOnline', 'wp-useronline' ).'</label><br />'."\n";
return $content;
}
// Add WP-UserOnline General Stats To WP-Stats Page
function page_general_stats( $content ) {
$stats_display = get_option( 'stats_display' );
$str = _n(
'<strong>%s</strong> user online now.',
'<strong>%s</strong> users online now.',
get_users_online_count(), 'wp-useronline'
);
if ( $stats_display['useronline'] == 1 )
$content .=
html( 'p', html( 'strong', __( 'WP-UserOnline', 'wp-useronline' ) ) )
.html( 'ul',
html( 'li', sprintf( $str, number_format_i18n( get_users_online_count() ) ) )
.html( 'li', UserOnline_Template::format_most_users() )
);
return $content;
}
}
UserOnline_WpStats::init();