| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/wp-statistics/includes/log/widgets/ |
Upload File : |
<?php
function wp_statistics_generate_hits_postbox_content( $size = '300', $days = 20 ) {
global $wpdb, $WP_Statistics;
$id = 'visits-stats-' . rand( 111, 999 );
$visitors = array();
$visits = array();
for ( $i = $days; $i >= 0; $i -- ) {
$date[] = "'" . $WP_Statistics->Current_Date( 'M j', '-' . $i ) . "'";
}
for ( $i = $days; $i >= 0; $i -- ) {
$visitors[] = wp_statistics_visitor( '-' . $i, true );
}
for ( $i = $days; $i >= 0; $i -- ) {
$visits[] = wp_statistics_visit( '-' . $i, true );
}
?>
<canvas id="<?php echo $id; ?>" height="<?php echo $size; ?>"></canvas>
<script>
var ctx = document.getElementById("<?php echo $id; ?>").getContext('2d');
<?php if(is_rtl()) { ?> Chart.defaults.global.defaultFontFamily = "tahoma"; <?php } ?>
var ChartJs = new Chart(ctx, {
type: 'line',
data: {
labels: [<?php echo implode( ', ', $date ); ?>],
datasets: [
<?php if ( $WP_Statistics->get_option( 'visitors' ) ) { ?>
{
label: '<?php _e( 'Visitors', 'wp-statistics' ); ?>',
data: [<?php echo implode( ',', $visitors ); ?>],
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1,
fill: true,
},
<?php } ?>
<?php if ( $WP_Statistics->get_option( 'visits' ) ) { ?>
{
label: '<?php _e( 'Visits', 'wp-statistics' ); ?>',
data: [<?php echo implode( ',', $visits ); ?>],
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1,
fill: true,
},
<?php } ?>
]
},
options: {
responsive: true,
legend: {
position: 'bottom',
},
animation: {
duration: 0,
},
title: {
display: true,
text: '<?php echo sprintf( __( 'Hits in the last %s days', 'wp-statistics' ), $days ); ?>'
},
tooltips: {
mode: 'index',
intersect: false,
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
</script>
<?php
}