';
echo ' Please note that only impressions are tracked for these ads as the clicks are registers via AdSense';
}
// Output stats for post
function akp_post_click_stats($object, $box) {
global $wpdb;
$clicks = $wpdb->get_results("SELECT COUNT(*) as clicks FROM ".$wpdb->prefix."akp_click_log WHERE post_id = '$object->ID'");
echo "This banner has had ".$clicks[0]->clicks." since being published. View Detailed Report";
}
// Add checkbox to remove URL Link off advert
function akp_remove_url_link($object, $box) {
global $post;
$remove_url = get_post_meta( $post->ID, 'akp_remove_url', true );
// Use nonce for verification
echo '';
echo '';
}
// Add checkbox to remove URL Link off advert
function akp_revenue_values($object, $box) {
global $post;
$revenue_impression = get_post_meta( $post->ID, 'akp_revenue_per_impression', true );
$revenue_click = get_post_meta( $post->ID, 'akp_revenue_per_click', true );
echo '
";
while (have_posts()) : the_post();
$post_id = get_the_ID();
$image = akp_get_featured_image($post_id);
// Get All Time Click Count
$all_clicks = $wpdb->get_results("SELECT COUNT(*) as clicks FROM ".$wpdb->prefix."akp_click_log WHERE post_id = '$post_id'");
$all_impressions = $wpdb->get_results("SELECT COUNT(*) as impressions FROM ".$wpdb->prefix."akp_impressions_log WHERE post_id = '$post_id'");
// Get This Month Click Count
$month_start = mktime(0, 0, 0, date('n', current_time('timestamp')), 1, date('Y', current_time('timestamp')));
$month_end = mktime(23, 59, 59, date('n', current_time('timestamp')), date('t', current_time('timestamp')), date('Y', current_time('timestamp')));
$month_clicks = $wpdb->get_results("SELECT COUNT(*) as clicks FROM ".$wpdb->prefix."akp_click_log WHERE timestamp BETWEEN '$month_start' AND '$month_end' AND post_id = '$post_id'");
$month_impressions = $wpdb->get_results("SELECT COUNT(*) as impressions FROM ".$wpdb->prefix."akp_impressions_log WHERE timestamp BETWEEN '$month_start' AND '$month_end' AND post_id = '$post_id'");
// Get This Week click count
$start_week = get_option('week_starts');
if (strtolower(date('l', current_time('timestamp'))) == $start_week) {
$day = date('j', current_time('timestamp'));
$month = date('n', current_time('timestamp'));
$year = date('Y', current_time('timestamp'));
} else {
$day = date('j', strtotime('last '.$start_week));
$month = date('n', strtotime('last '.$start_week));
$year = date('Y', strtotime('last '.$start_week));
}
$week_start = mktime(0, 0, 0, $month, $day, $year);
$week_end = mktime(23, 59, 59, date('n', strtotime("+7 days", $week_start)), date('j', strtotime("+7 days", $week_start)), date('Y', strtotime("+7 days", $week_start)));
$week_clicks = $wpdb->get_results("SELECT COUNT(*) as clicks FROM ".$wpdb->prefix."akp_click_log WHERE timestamp BETWEEN '$week_start' AND '$week_end' AND post_id = '$post_id'");
$week_impressions = $wpdb->get_results("SELECT COUNT(*) as impressions FROM ".$wpdb->prefix."akp_impressions_log WHERE timestamp BETWEEN '$week_start' AND '$week_end' AND post_id = '$post_id'");
// Get Today Click count
$today_start = mktime(0, 0, 0, date('n', current_time('timestamp')), date('j', current_time('timestamp')), date('Y', current_time('timestamp')));
$today_end = mktime(23, 59, 59, date('n', current_time('timestamp')), date('j', current_time('timestamp')), date('Y', current_time('timestamp')));
$today_clicks = $wpdb->get_results("SELECT COUNT(*) as clicks FROM ".$wpdb->prefix."akp_click_log WHERE timestamp BETWEEN '$today_start' AND '$today_end' AND post_id = '$post_id'");
$today_impressions = $wpdb->get_results("SELECT COUNT(*) as impressions FROM ".$wpdb->prefix."akp_impressions_log WHERE timestamp BETWEEN '$today_start' AND '$today_end' AND post_id = '$post_id'");
?>
All Time
= $all_clicks[0]->clicks ?>
This Month
= $month_clicks[0]->clicks ?>
This Week
= $week_clicks[0]->clicks ?>
Today
= $today_clicks[0]->clicks ?>
";
wp_reset_query();
}
} else {
// No advert types set
}
}
function akp_add_dashboard_widgets() {
wp_add_dashboard_widget('akp_dashboard_widget', 'Ad King Pro - Banner Stats Summary', 'akp_dashboard');
}
add_action('wp_dashboard_setup', 'akp_add_dashboard_widgets' );
// Add settings area
function adkingpro_settings() {
add_options_page('Ad King Pro', 'Ad King Pro', 'manage_options', 'adkingpro', 'akp_settings_output');
add_dashboard_page('Ad King Pro Detailed Stats', 'Ad King Pro Stats', 'read', 'akp-detailed-stats', 'akp_detailed_output');
}
add_action('admin_menu', 'adkingpro_settings');
function register_akp_options() {
register_setting( 'akp-options', 'expiry_time' );
register_setting( 'akp-options', 'impression_expiry_time' );
register_setting( 'akp-options', 'week_start' );
register_setting( 'akp-options', 'revenue_currency' );
register_setting( 'akp-options', 'pdf_theme' );
}
add_action( 'admin_init', 'register_akp_options' );
function akp_settings_output() {
?>
Ad King Pro
How To
Use Shortcodes
Shortcodes can be used in any page or post on your site. By default:
[adkingpro]
is defaulting to the advert type 'Sidebar' and randomly chosing from that. You can define your own advert type and display the adverts attached to that type by:
[adkingpro type="your-advert-type-slug"]
Alternatively, you can display a single advert by entering its "Banner ID" which can be found in the table under the Adverts section:
[adkingpro banner="{banner_id}"]
To add this into a template, just use the "do_shortcode" function:
<?= do_shortcode("[adkingpro]"); ?>
Install PDF Themes
Download themes from my plugin page. Locate the themes folder in the adkingpro plugin folder, generally located:
/wp-content/plugins/adkingpro/themes/
Unzip the downloaded zip file and upload the entire folder into the themes folder mentioned above.
Once uploaded, return to this page and your theme will be present in the PDF Theme dropdown to the left. Choose the theme and save the options. Next time you generate a report, the theme you have chosen will be used.
The ability to upload the zip file straight from here will be added soon
FAQ
Q. After activating this plugin, my site has broken! Why?
Nine times out of ten it will be due to your own scripts being added above the standard area where all the plugins are included.
If you move your javascript files below the function, "wp_head()" in the "header.php" file of your theme, it should fix your problem.
Q. I want to track clicks on a banner that scrolls to or opens a flyout div on my site. Is it possible?
Yes. Enter a '#' in as the URL for the banner when setting it up. At output, the banner is given a number of classes to allow for styling, one being "banner{banner_id}",
where you would replace the "{banner_id}" for the number in the required adverts class.
Use this in a jquery click event and prevent the default action of the click to make it do the action you require:
$(".adkingprobanner.banner{banner_id}").click(
function(e) {
e.preventDefault();
// Your action here
});