Hi y'all,
I've done a number of searches and haven't been able to find this question already asked...
I have a simple, (in a single php file) URL Redirect in the form of a Wordpress plugin.
I already have a simple "define->function->echo" code for displaying the total hits/visits count for each URL redirect.
My question is, does anyone know of a "simple" way to expand on the total hits count and show the hits by date? While keeping everything all in the one PHP file? (everything I know of would require multiple files, folders, .js etc)
What I'd like, in addition to the "total" hits/views is to also have hits count broken out for "Today", "Yesterday", "Last 7 Days", "Last 30 Days" and a variable "date range".
Thanks in advance for any advice.
Below is the "define->function->echo" code I'm using to track the total hits per URL.
if($url != '') {
hit_count($post->ID);
header( 'Location: '.$url );
exit();
}
function hit_count($post_id) {
$count = get_post_meta($post_id,'redirect_count',true);
if(!$count) {
$count = 0;
}
$count = $count + 1;
update_post_meta($post_id,'redirect_count',$count);
}
$count = get_post_meta($post->ID,'redirect_count',true);
if(!$count) {
$count = 0;
}
echo '<br /><br />This URL has redirected <strong>'.$count.'</strong> times';
}