function wp_statistics_generate_hits_postbox($ISOCountryCode, $search_engines) { global $wpdb, $WP_Statistics; if ($WP_Statistics->get_option('visits') || $WP_Statistics->get_option('visitors')) { ?> <div class="postbox"> <div class="handlediv" title="<?php _e('Click to toggle', 'wp_statistics'); ?> "><br /></div> <h3 class="hndle"><span><?php _e('Hit Statistics', 'wp_statistics'); ?> <a href="?page=wps_hits_menu"> <?php echo wp_statistics_icons('dashicons-visibility', 'visibility'); _e('More', 'wp_statistics'); ?> </a></span></h3> <div class="inside"> <?php wp_statistics_generate_hits_postbox_content(); ?> </div> </div> <?php } }
function wp_statistics_hits_widget() { global $WP_Statistics; // If the widget isn't visible, don't output the stats as they take too much memory and CPU to compute for no reason. if (($is_visible = wp_statistics_is_wp_widget_visible('wp-statistics-hits-widget', 'dashboard')) !== true) { echo $is_visible; return; } // Load the css we use for the statistics pages. wp_statistics_load_widget_css_and_scripts(); // Include the hits chart widget, we're going to display the last 10 days only as the WordPress columns are kind of small to do much else. include_once dirname(__FILE__) . "/includes/log/widgets/hits.php"; wp_statistics_generate_hits_postbox_content("300px", 10); }
function wp_statistics_get_widget_contents_callback() { global $WP_Statistics, $wpdb; // this is how you get access to the database $widgets = array('about', 'browsers', 'map', 'countries', 'hits', 'hitsmap', 'page', 'pages', 'quickstats', 'recent', 'referring', 'search', 'summary', 'top.visitors', 'words'); $view_cap = wp_statistics_validate_capability($WP_Statistics->get_option('read_capability', 'manage_options')); if (current_user_can($view_cap)) { $widget = ''; if (array_key_exists('widget', $_POST)) { // Get the widget we're going to display. if (in_array($_POST['widget'], $widgets)) { $widget = $_POST['widget']; } } if ('map' == $widget || 'hitsmap' == $widget) { if ($WP_Statistics->get_option('map_type') == 'jqvmap') { $widget = 'jqv.map'; } else { $widget = 'google.map'; } } if ('' == $widget) { _e('No matching widget found!', 'wp_statistics'); wp_die(); } $ISOCountryCode = $WP_Statistics->get_country_codes(); $search_engines = wp_statistics_searchengine_list(); require $WP_Statistics->plugin_dir . '/includes/log/widgets/' . $widget . '.php'; switch ($widget) { case 'summary': wp_statistics_generate_summary_postbox_content($search_engines); break; case 'quickstats': wp_statistics_generate_quickstats_postbox_content($search_engines); break; case 'browsers': wp_statistics_generate_browsers_postbox_content(); break; case 'referring': wp_statistics_generate_referring_postbox_content(); break; case 'countries': wp_statistics_generate_countries_postbox_content($ISOCountryCode); break; case 'jqv.map': case 'google.map': wp_statistics_generate_map_postbox_content($ISOCountryCode); break; case 'hits': wp_statistics_generate_hits_postbox_content(); break; case 'search': wp_statistics_generate_search_postbox_content($search_engines); break; case 'words': wp_statistics_generate_words_postbox_content($ISOCountryCode); break; case 'page': $pageid = (int) $_POST['page-id']; wp_statistics_generate_page_postbox_content(null, $pageid); break; case 'pages': list($total, $uris) = wp_statistics_get_top_pages(); wp_statistics_generate_pages_postbox_content($total, $uris); break; case 'recent': wp_statistics_generate_recent_postbox_content($ISOCountryCode); break; case 'top.visitors': wp_statistics_generate_top_visitors_postbox_content($ISOCountryCode); break; case 'about': wp_statistics_generate_about_postbox_content($ISOCountryCode); break; default: _e('ERROR: Widget not found!', 'wp_statistics'); } } else { _e('Access denied!', 'wp_statistics'); } wp_die(); // this is required to terminate immediately and return a proper response }
function wp_statistics_generate_quickstats_postbox_content($search_engines, $search = false, $time = false) { global $wpdb, $WP_Statistics; $show_visitors = $WP_Statistics->get_option('visitor'); ?> <table width="100%" class="widefat table-stats" id="summary-stats"> <tbody> <?php if ($WP_Statistics->get_option('useronline')) { ?> <tr> <th><?php _e('User(s) Online', 'wp_statistics'); ?> :</th> <th colspan="2" id="th-colspan"> <span><a href="admin.php?page=<?php echo WP_STATISTICS_ONLINE_PAGE; ?> "><?php echo wp_statistics_useronline(); ?> </a></span> </th> </tr> <?php } if ($WP_Statistics->get_option('visitors') || $WP_Statistics->get_option('visits')) { ?> <tr> <th width="60%"></th> <th class="th-center"><?php if ($WP_Statistics->get_option('visitors')) { _e('Visitor', 'wp_statistics'); } else { echo ''; } ?> </th> <th class="th-center"><?php if ($WP_Statistics->get_option('visits')) { _e('Visit', 'wp_statistics'); } else { echo ''; } ?> </th> </tr> <tr> <th><?php _e('Today', 'wp_statistics'); ?> :</th> <th class="th-center"><?php if ($WP_Statistics->get_option('visitors')) { echo '<a href="admin.php?page=' . WP_STATISTICS_VISITORS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visitor('today', null, true)) . '</span></a>'; } else { echo ''; } ?> </th> <th class="th-center"><?php if ($WP_Statistics->get_option('visits')) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visit('today')) . '</span></a>'; } else { echo ''; } ?> </th> </tr> <tr> <th><?php _e('Yesterday', 'wp_statistics'); ?> :</th> <th class="th-center"><?php if ($WP_Statistics->get_option('visitors')) { echo '<a href="admin.php?page=wps_visitors_menu&hitdays=1"><span>' . number_format_i18n(wp_statistics_visitor('yesterday', null, true)) . '</span></a>'; } else { echo ''; } ?> </th> <th class="th-center"><?php if ($WP_Statistics->get_option('visits')) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=1"><span>' . number_format_i18n(wp_statistics_visit('yesterday')) . '</span></a>'; } else { echo ''; } ?> </th> </tr> <tr> <th><?php _e('Last 7 Days (Week)', 'wp_statistics'); ?> :</th> <th class="th-center"><?php if ($WP_Statistics->get_option('visitors')) { echo '<a href="admin.php?page=wps_visitors_menu&hitdays=7"><span>' . number_format_i18n(wp_statistics_visitor('week', null, true)) . '</span></a>'; } else { echo ''; } ?> </th> <th class="th-center"><?php if ($WP_Statistics->get_option('visits')) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=7"><span>' . number_format_i18n(wp_statistics_visit('week')) . '</span></a>'; } else { echo ''; } ?> </th> </tr> <tr> <th><?php _e('Last 30 Days (Month)', 'wp_statistics'); ?> :</th> <th class="th-center"><?php if ($WP_Statistics->get_option('visitors')) { echo '<a href="admin.php?page=wps_visitors_menu&hitdays=30"><span>' . number_format_i18n(wp_statistics_visitor('month', null, true)) . '</span></a>'; } else { echo ''; } ?> </th> <th class="th-center"><?php if ($WP_Statistics->get_option('visits')) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=30"><span>' . number_format_i18n(wp_statistics_visit('month')) . '</span></a>'; } else { echo ''; } ?> </th> </tr> <tr> <th><?php _e('Last 365 Days (Year)', 'wp_statistics'); ?> :</th> <th class="th-center"><?php if ($WP_Statistics->get_option('visitors')) { echo '<a href="admin.php?page=wps_visitors_menu&hitdays=365"><span>' . number_format_i18n(wp_statistics_visitor('year', null, true)) . '</span></a>'; } else { echo ''; } ?> </th> <th class="th-center"><?php if ($WP_Statistics->get_option('visits')) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visit('year')) . '</span></a>'; } else { echo ''; } ?> </th> </tr> <tr> <th><?php _e('Total', 'wp_statistics'); ?> :</th> <th class="th-center"><?php if ($WP_Statistics->get_option('visitors')) { echo '<a href="admin.php?page=wps_visitors_menu&hitdays=365"><span>' . number_format_i18n(wp_statistics_visitor('total', null, true)) . '</span></a>'; } else { echo ''; } ?> </th> <th class="th-center"><?php if ($WP_Statistics->get_option('visits')) { echo '<a href="admin.php?page=' . WP_STATISTICS_HITS_PAGE . '&hitdays=365"><span>' . number_format_i18n(wp_statistics_visit('total')) . '</span></a>'; } else { echo ''; } ?> </th> </tr> <?php } if ($search == true && $WP_Statistics->get_option('visitors')) { if ($WP_Statistics->get_option('visitors') || $WP_Statistics->get_option('visits') || $WP_Statistics->get_option('useronline')) { ?> <tr> <th colspan="3"><br><hr></th> </tr> <?php } ?> <tr> <th colspan="3" style="text-align: center;"><?php _e('Search Engine Referrals', 'wp_statistics'); ?> </th> </tr> <tr> <th width="60%"></th> <th class="th-center"><?php _e('Today', 'wp_statistics'); ?> </th> <th class="th-center"><?php _e('Yesterday', 'wp_statistics'); ?> </th> </tr> <?php $se_today_total = 0; $se_yesterday_total = 0; foreach ($search_engines as $se) { ?> <tr> <th><img src='<?php echo plugins_url('wp-statistics/assets/images/' . $se['image']); ?> '> <?php _e($se['name'], 'wp_statistics'); ?> :</th> <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine($se['tag'], 'today'); $se_today_total += $se_temp; echo number_format_i18n($se_temp); ?> </span></th> <th class="th-center"><span><?php $se_temp = wp_statistics_searchengine($se['tag'], 'yesterday'); $se_yesterday_total += $se_temp; echo number_format_i18n($se_temp); ?> </span></th> </tr> <?php } ?> <tr> <th><?php _e('Daily Total', 'wp_statistics'); ?> :</th> <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n($se_today_total); ?> </span></td> <td id="th-colspan" class="th-center"><span><?php echo number_format_i18n($se_yesterday_total); ?> </span></td> </tr> <tr> <th><?php _e('Total', 'wp_statistics'); ?> :</th> <th colspan="2" id="th-colspan"><span><?php echo number_format_i18n(wp_statistics_searchengine('all')); ?> </span></th> </tr> <?php } if ($time == true) { ?> <tr> <th colspan="3"><br><hr></th> </tr> <tr> <th colspan="3" style="text-align: center;"><?php _e('Current Time and Date', 'wp_statistics'); ?> <span id="time_zone"><a href="<?php echo admin_url('options-general.php'); ?> "><?php _e('(Adjustment)', 'wp_statistics'); ?> </a></span></th> </tr> <tr> <th colspan="3"><?php echo sprintf(__('Date: %s', 'wp_statistics'), '<code dir="ltr">' . $WP_Statistics->Current_Date_i18n(get_option('date_format')) . '</code>'); ?> </th> </tr> <tr> <th colspan="3"><?php echo sprintf(__('Time: %s', 'wp_statistics'), '<code dir="ltr">' . $WP_Statistics->Current_Date_i18n(get_option('time_format')) . '</code>'); ?> </th> </tr> <?php } ?> </tbody> </table> <br> <hr width="80%"/> <br> <?php // Include the hits chart widget, we're going to display the last 10 days only as the WordPress columns are kind of small to do much else. include_once dirname(__FILE__) . "/hits.php"; wp_statistics_generate_hits_postbox_content("300px", 10); }