Example #1
1
function wp_statistics_generate_pages_postbox($ISOCountryCode, $search_engines)
{
    global $WP_Statistics;
    if (!$WP_Statistics->get_option('pages')) {
        return;
    }
    list($total, $uris) = wp_statistics_get_top_pages();
    if ($total > 0) {
        ?>
				<div class="postbox">
					<div class="handlediv" title="<?php 
        _e('Click to toggle', 'wp_statistics');
        ?>
"><br /></div>
					<h3 class="hndle">
						<span><?php 
        _e('Top 10 Pages', 'wp_statistics');
        ?>
 <a href="?page=wps_pages_menu"><?php 
        echo wp_statistics_icons('dashicons-visibility', 'visibility');
        _e('More', 'wp_statistics');
        ?>
</a></span>
					</h3>
					<div class="inside">
							<?php 
        wp_statistics_generate_pages_postbox_content($total, $uris);
        ?>
					</div>
				</div>
<?php 
    }
}
Example #2
0
function wp_statistics_pages_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-pages-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/pages.php";
    list($total, $uris) = wp_statistics_get_top_pages();
    wp_statistics_generate_pages_postbox_content($total, $uris);
}
Example #3
0
<script type="text/javascript">
	jQuery(document).ready(function(){
		postboxes.add_postbox_toggles(pagenow);
	});
</script>
<?php 
list($total, $uris) = wp_statistics_get_top_pages();
$daysToDisplay = 20;
if (array_key_exists('hitdays', $_GET)) {
    $daysToDisplay = intval($_GET['hitdays']);
}
if (array_key_exists('rangestart', $_GET)) {
    $rangestart = $_GET['rangestart'];
} else {
    $rangestart = '';
}
if (array_key_exists('rangeend', $_GET)) {
    $rangeend = $_GET['rangeend'];
} else {
    $rangeend = '';
}
list($daysToDisplay, $rangestart_utime, $rangeend_utime) = wp_statistics_date_range_calculator($daysToDisplay, $rangestart, $rangeend);
?>
<div class="wrap">
	<?php 
screen_icon('options-general');
?>
	<h2><?php 
_e('Top Pages', 'wp_statistics');
?>
</h2>
Example #4
0
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
}
$daysToDisplay = 20;
if (array_key_exists('hitdays', $_GET)) {
    $daysToDisplay = intval($_GET['hitdays']);
}
if (array_key_exists('rangestart', $_GET)) {
    $rangestart = $_GET['rangestart'];
} else {
    $rangestart = '';
}
if (array_key_exists('rangeend', $_GET)) {
    $rangeend = $_GET['rangeend'];
} else {
    $rangeend = '';
}
list($daysToDisplay, $rangestart_utime, $rangeend_utime) = wp_statistics_date_range_calculator($daysToDisplay, $rangestart, $rangeend);
list($total, $uris) = wp_statistics_get_top_pages($WP_Statistics->Real_Current_Date('Y-m-d', '-0', $rangestart_utime), $WP_Statistics->Real_Current_Date('Y-m-d', '-0', $rangeend_utime));
?>
<div class="wrap">
	<?php 
screen_icon('options-general');
?>
	<h2><?php 
_e('Top Pages', 'wp_statistics');
?>
</h2>

	<?php 
wp_statistics_date_range_selector(WP_STATISTICS_PAGES_PAGE, $daysToDisplay);
?>

	<div class="postbox-container" id="last-log">