Пример #1
0
function wp_statistics_get_top_pages()
{
    global $wpdb;
    // Get every unique URI from the pages database.
    $result = $wpdb->get_results("SELECT DISTINCT uri FROM {$wpdb->prefix}statistics_pages", ARRAY_N);
    $total = 0;
    $uris = array();
    // Now get the total page visit count for each unique URI.
    foreach ($result as $out) {
        // Increment the total number of results.
        $total++;
        // Retreive the post ID for the URI.
        $id = wp_statistics_uri_to_id($out[0]);
        // Lookup the post title.
        $post = get_post($id);
        if (is_object($post)) {
            $title = $post->post_title;
        } else {
            if ($out[0] == '/') {
                $title = get_bloginfo();
            } else {
                $title = '';
            }
        }
        // Add the current post to the array.
        $uris[] = array($out[0], wp_statistics_pages('total', $out[0]), $id, $title);
    }
    // If we have more than one result, let's sort them using usort.
    if (count($uris) > 1) {
        // Sort the URI's based on their hit count.
        usort($uris, 'wp_stats_compare_uri_hits');
    }
    return array($total, $uris);
}
Пример #2
0
function wp_statistics_post_init()
{
    global $post;
    $id = $post->ID;
    echo "<div class='misc-pub-section'>" . __('WP Statistics - Hits', 'wp_statistics') . ': <b>' . wp_statistics_pages('total', '', $id) . '</b></div>';
}
Пример #3
0
function wp_statistics_post_init()
{
    global $post;
    $id = $post->ID;
    echo "<div class='misc-pub-section'>" . __('WP Statistics - Hits', 'wp_statistics') . ": <b><a href='" . get_admin_url() . "admin.php?page=" . WP_STATISTICS_PAGES_PAGE . "&page-id={$id}'>" . wp_statistics_pages('total', "", $id) . "</a></b></div>";
}
Пример #4
0
function wp_statistics_shortcodes($atts)
{
    /*
    	WP Statitics shortcode is in the format of:
    	
    		[wpstatistics stat=xxx time=xxxx provider=xxxx format=xxxxxx]
    		
    	Where:
    		stat = the statistic you want.
    		time = is the timeframe, strtotime() (http://php.net/manual/en/datetime.formats.php) will be used to calculate it.
    		provider = the search provider to get stats on.
    		format = i18n, english, none
    */
    if (!is_array($atts)) {
        return;
    }
    $formatnumber = array_key_exists('format', $atts);
    switch ($atts['stat']) {
        case 'usersonline':
            $result = wp_statistics_useronline();
            break;
        case 'visits':
            $result = wp_statistics_visit($atts['time']);
            break;
        case 'visitors':
            $result = wp_statistics_visitor($atts['time'], null, true);
            break;
        case 'pagevisits':
            $result = wp_statistics_pages($atts['time']);
            break;
        case 'searches':
            $result = wp_statistics_searchengine($atts['provider']);
            break;
        case 'postcount':
            $result = wp_statistics_countposts();
            break;
        case 'pagecount':
            $result = wp_statistics_countpages();
            break;
        case 'commentcount':
            $result = wp_statistics_countcomment();
            break;
        case 'spamcount':
            $result = wp_statistics_countspam();
            break;
        case 'usercount':
            $result = wp_statistics_countusers();
            break;
        case 'postaverage':
            $result = wp_statistics_average_post();
            break;
        case 'commentaverage':
            $result = wp_statistics_average_comment();
            break;
        case 'useraverage':
            $result = wp_statistics_average_registeruser();
            break;
        case 'lpd':
            $result = wp_statistics_lastpostdate();
            $formatnumber = false;
            break;
    }
    if ($formatnumber) {
        switch (strtolower($atts['format'])) {
            case 'i18n':
                $result = number_format_i18n($result);
                break;
            case 'english':
                $result = number_format($result);
                break;
        }
    }
    return $result;
}
Пример #5
0
function wp_statistics_generate_page_postbox_content($pageuri, $pageid, $days = 20, $chart_title = null, $rangestart = '', $rangeend = '')
{
    global $WP_Statistics;
    if (!$WP_Statistics->get_option('pages')) {
        return;
    }
    if ($chart_title == null) {
        $chart_title = __('Page Trending Stats', 'wp_statistics');
    }
    if ($pageuri && !$pageid) {
        $pageid = wp_statistics_uri_to_id($pageuri);
    }
    $post = get_post($pageid);
    if (is_object($post)) {
        $title = $post->post_title;
    } else {
        $title = "";
    }
    $urlfields = "&page-id={$pageid}";
    if ($pageuri) {
        $urlfields .= "&page-uri={$pageuri}";
    }
    list($daysToDisplay, $rangestart_utime, $rangeend_utime) = wp_statistics_date_range_calculator($days, $rangestart, $rangeend);
    ?>
						<script type="text/javascript">
						var pages_chart;
						jQuery(document).ready(function() {
<?php 
    echo "var page_data_line = [";
    for ($i = $daysToDisplay; $i >= 0; $i--) {
        $stat = wp_statistics_pages('-' . $i, $pageuri, $pageid);
        echo "['" . $WP_Statistics->Real_Current_Date('Y-m-d', '-' . $i, $rangeend_utime) . "'," . $stat . "], ";
    }
    echo "];\n";
    $tickInterval = $daysToDisplay / 20;
    if ($tickInterval < 1) {
        $tickInterval = 1;
    }
    ?>
							pages_jqchart = jQuery.jqplot('page-stats', [page_data_line], {
								title: {
									text: '<b>' + <?php 
    echo json_encode(__($chart_title, 'wp_statistics'));
    ?>
 + '</b>',
									fontSize: '12px',
									fontFamily: 'Tahoma',
									textColor: '#000000',
									},
								axes: {
									xaxis: {
											min: '<?php 
    echo $WP_Statistics->Real_Current_Date('Y-m-d', '-' . $daysToDisplay, $rangeend_utime);
    ?>
',
											max: '<?php 
    echo $WP_Statistics->Real_Current_Date('Y-m-d', '-0', $rangeend_utime);
    ?>
',
											tickInterval:  '<?php 
    echo $tickInterval;
    ?>
 day',
											renderer:jQuery.jqplot.DateAxisRenderer,
											tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
											tickOptions: { 
												angle: -45,
												formatString:'%b %#d',
												showGridline: false, 
												},
										},										
									yaxis: {
											min: 0,
											padMin: 1.0,
											label: <?php 
    echo json_encode(__('Number of Hits', 'wp_statistics'));
    ?>
,
											labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
											labelOptions: {
												angle: -90,
												fontSize: '12px',
												fontFamily: 'Tahoma',
												fontWeight: 'bold',
											},
										}
									},
								legend: {
									show: true,
									location: 's',
									placement: 'outsideGrid',
									labels: [ '<?php 
    echo $pageid . ' - ' . $title;
    ?>
' ],
									renderer: jQuery.jqplot.EnhancedLegendRenderer,
									rendererOptions:
										{
											numberColumns: 5, 
											disableIEFading: false,
											border: 'none',
										},
									},
								highlighter: {
									show: true,
									bringSeriesToFront: true,
									tooltipAxes: 'xy',
									formatString: '%s:&nbsp;<b>%i</b>&nbsp;',
									tooltipContentEditor: tooltipContentEditor,
								},
								grid: {
								 drawGridlines: true,
								 borderColor: 'transparent',
								 shadow: false,
								 drawBorder: false,
								 shadowColor: 'transparent'
								},
							} );

							function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
								// display series_label, x-axis_tick, y-axis value
								return plot.legend.labels[seriesIndex] + ", " + str;;
							}
							
							jQuery(window).resize(function() {
								JQPlotPagesChartLengendClickRedraw()
							});

							function JQPlotPagesChartLengendClickRedraw() {
								pages_jqchart.replot( {resetAxes: ['yaxis'] } );
								jQuery('div[id="page-stats"] .jqplot-table-legend').click(function() {
									JQPlotPagesChartLengendClickRedraw();
								});
							}
							
							jQuery('div[id="page-stats"] .jqplot-table-legend').click(function() {
								JQPlotPagesChartLengendClickRedraw()
							});
						});
						</script>
						
						<div id="page-stats" style="height:500px;"></div>

<?php 
}
Пример #6
0
 /**
  * Outputs the content of the widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     global $WP_Statistics;
     extract($args);
     $widget_options = $WP_Statistics->get_option('widget');
     echo $before_widget;
     echo $before_title . $widget_options['name_widget'] . $after_title;
     echo "<ul>";
     if ($widget_options['useronline_widget']) {
         echo "<li>";
         echo __('User Online', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_useronline());
         echo "</li>";
     }
     if ($widget_options['tvisit_widget']) {
         echo "<li>";
         echo __('Today Visit', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_visit('today'));
         echo "</li>";
     }
     if ($widget_options['tvisitor_widget']) {
         echo "<li>";
         echo __('Today Visitor', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_visitor('today', null, true));
         echo "</li>";
     }
     if ($widget_options['yvisit_widget']) {
         echo "<li>";
         echo __('Yesterday Visit', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_visit('yesterday'));
         echo "</li>";
     }
     if ($widget_options['yvisitor_widget']) {
         echo "<li>";
         echo __('Yesterday Visitor', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_visitor('yesterday', null, true));
         echo "</li>";
     }
     if ($widget_options['wvisit_widget']) {
         echo "<li>";
         echo __('Week Visit', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_visit('week'));
         echo "</li>";
     }
     if ($widget_options['mvisit_widget']) {
         echo "<li>";
         echo __('Month Visit', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_visit('month'));
         echo "</li>";
     }
     if ($widget_options['ysvisit_widget']) {
         echo "<li>";
         echo __('Years Visit', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_visit('year'));
         echo "</li>";
     }
     if ($widget_options['ttvisit_widget']) {
         echo "<li>";
         echo __('Total Visit', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_visit('total'));
         echo "</li>";
     }
     if ($widget_options['ttvisitor_widget']) {
         echo "<li>";
         echo __('Total Visitor', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_visitor('total', null, true));
         echo "</li>";
     }
     if ($widget_options['tpviews_widget']) {
         echo "<li>";
         echo __('Total Page Views', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_pages('total'));
         echo "</li>";
     }
     if ($widget_options['ser_widget']) {
         echo "<li>";
         echo __('Search Engine referred', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_searchengine($widget_options['select_se']));
         echo "</li>";
     }
     if ($widget_options['tp_widget']) {
         echo "<li>";
         echo __('Total Posts', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_countposts());
         echo "</li>";
     }
     if ($widget_options['tpg_widget']) {
         echo "<li>";
         echo __('Total Pages', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_countpages());
         echo "</li>";
     }
     if ($widget_options['tc_widget']) {
         echo "<li>";
         echo __('Total Comments', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_countcomment());
         echo "</li>";
     }
     if ($widget_options['ts_widget']) {
         echo "<li>";
         echo __('Total Spams', 'wp_statistics') . ": ";
         echo wp_statistics_countspam();
         echo "</li>";
     }
     if ($widget_options['tu_widget']) {
         echo "<li>";
         echo __('Total Users', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_countusers());
         echo "</li>";
     }
     if ($widget_options['ap_widget']) {
         echo "<li>";
         echo __('Average Posts', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_average_post());
         echo "</li>";
     }
     if ($widget_options['ac_widget']) {
         echo "<li>";
         echo __('Average Comments', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_average_comment());
         echo "</li>";
     }
     if ($widget_options['au_widget']) {
         echo "<li>";
         echo __('Average Users', 'wp_statistics') . ": ";
         echo number_format_i18n(wp_statistics_average_registeruser());
         echo "</li>";
     }
     if ($widget_options['lpd_widget']) {
         echo "<li>";
         echo __('Last Post Date', 'wp_statistics') . ": ";
         echo wp_statistics_lastpostdate();
         echo "</li>";
     }
     echo "</ul>";
     echo $after_widget;
 }
Пример #7
0
"><br /></div>
					<h3 class="hndle"><span><?php 
_e('Top 5 Pages Trends', 'wp_statistics');
?>
</span></h3>
					<div class="inside">
						<script type="text/javascript">
						var pages_jqchart;
						jQuery(document).ready(function() {
<?php 
$count = 0;
foreach ($uris as $uri) {
    $count++;
    echo "var pages_data_line" . $count . " = [";
    for ($i = $daysToDisplay; $i >= 0; $i--) {
        $stat = wp_statistics_pages('-' . $i, $uri[0]);
        echo "['" . $WP_Statistics->Real_Current_Date('Y-m-d', '-' . $i, $rangeend_utime) . "'," . $stat . "], ";
    }
    echo "];\n";
    if ($count > 4) {
        break;
    }
}
$tickInterval = $daysToDisplay / 20;
if ($tickInterval < 1) {
    $tickInterval = 1;
}
?>

							pages_jqchart = jQuery.jqplot('jqpage-stats', [pages_data_line1, pages_data_line2, pages_data_line3, pages_data_line4, pages_data_line5], {
								title: {