Plugin Directory

Changeset 1060727


Ignore:
Timestamp:
01/05/2015 08:00:15 PM (11 years ago)
Author:
ashdurham
Message:

1.9.16 updates

Location:
adkingpro
Files:
100 added
6 edited

Legend:

Unmodified
Added
Removed
  • adkingpro/trunk/adkingpro.php

    r938767 r1060727  
    44    Plugin URI: http://kingpro.me/plugins/ad-king-pro/
    55    Description: Ad King Pro allows you to manage, display, document and report all of your custom advertising on your wordpress site.
    6     Version: 1.9.15
     6    Version: 1.9.16
    77    Author: Ash Durham
    88    Author URI: http://durham.net.au/
     
    2929
    3030    global $akp_db_version;
    31     $akp_db_version = "1.9.15";
     31    $akp_db_version = "1.9.16";
    3232
    3333    function akp_install() {
    34        global $wpdb;
    35        global $akp_db_version;
     34        if ( ! current_user_can( 'activate_plugins' ) )
     35            return;
     36       
     37        global $wpdb;
     38        global $akp_db_version;
    3639
    37        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    38        
    39        akp_check_db_tables();
    40        
    41        $table_name = $wpdb->prefix . "terms";
    42        $sql = "INSERT INTO $table_name
    43         (`name`, `slug`, `term_group`)
    44         VALUES ('Sidebar', 'sidebar', '0')";
    45        dbDelta($sql);
    46        
    47        $term_id = mysql_insert_id();
    48        $table_name = $wpdb->prefix . "term_taxonomy";
    49        $sql = "INSERT INTO $table_name
    50         (`term_id`, `taxonomy`, `description`, `parent`, `count`)
    51         VALUES ('".$term_id."', 'advert_types', '', '0', '0')";
    52        dbDelta($sql);
     40        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    5341
    54        add_option("apk_db_version", $akp_db_version);
    55        
    56        // Register AKP capabilities to all users
    57        $role = get_role( 'subscriber' );
    58        $role->add_cap( 'akp_edit_one' );
    59        
    60        $role = get_role( 'contributor' );
    61        $role->add_cap( 'akp_edit_one' );
    62        $role->add_cap( 'akp_edit_two' );
    63        
    64        $role = get_role( 'author' );
    65        $role->add_cap( 'akp_edit_one' );
    66        $role->add_cap( 'akp_edit_two' );
    67        $role->add_cap( 'akp_edit_three' );
    68        
    69        $role = get_role( 'editor' );
    70        $role->add_cap( 'akp_edit_one' );
    71        $role->add_cap( 'akp_edit_two' );
    72        $role->add_cap( 'akp_edit_three' );
    73        $role->add_cap( 'akp_edit_four' );
    74        
    75        $role = get_role( 'administrator' );
    76        $role->add_cap( 'akp_edit_one' );
    77        $role->add_cap( 'akp_edit_two' );
    78        $role->add_cap( 'akp_edit_three' );
    79        $role->add_cap( 'akp_edit_four' );
    80        $role->add_cap( 'akp_edit_five' );
     42        akp_check_db_tables();
     43
     44        $table_name = $wpdb->prefix . "terms";
     45        $sql = "INSERT INTO $table_name
     46         (`name`, `slug`, `term_group`)
     47         VALUES ('Sidebar', 'sidebar', '0')";
     48        dbDelta($sql);
     49
     50        $term_id = mysql_insert_id();
     51        $table_name = $wpdb->prefix . "term_taxonomy";
     52        $sql = "INSERT INTO $table_name
     53         (`term_id`, `taxonomy`, `description`, `parent`, `count`)
     54         VALUES ('".$term_id."', 'advert_types', '', '0', '0')";
     55        dbDelta($sql);
     56
     57        add_option("apk_db_version", $akp_db_version);
     58
     59        // Register AKP capabilities to all users
     60        $role = get_role( 'subscriber' );
     61        $role->add_cap( 'akp_edit_one' );
     62
     63        $role = get_role( 'contributor' );
     64        $role->add_cap( 'akp_edit_one' );
     65        $role->add_cap( 'akp_edit_two' );
     66
     67        $role = get_role( 'author' );
     68        $role->add_cap( 'akp_edit_one' );
     69        $role->add_cap( 'akp_edit_two' );
     70        $role->add_cap( 'akp_edit_three' );
     71
     72        $role = get_role( 'editor' );
     73        $role->add_cap( 'akp_edit_one' );
     74        $role->add_cap( 'akp_edit_two' );
     75        $role->add_cap( 'akp_edit_three' );
     76        $role->add_cap( 'akp_edit_four' );
     77
     78        $role = get_role( 'administrator' );
     79        $role->add_cap( 'akp_edit_one' );
     80        $role->add_cap( 'akp_edit_two' );
     81        $role->add_cap( 'akp_edit_three' );
     82        $role->add_cap( 'akp_edit_four' );
     83        $role->add_cap( 'akp_edit_five' );
    8184    }
    8285   
     
    8588   
    8689    // END INSTALL
     90   
     91    // DEACTIVATE
     92   
     93    function akp_deactivate() {
     94        if ( ! current_user_can( 'activate_plugins' ) )
     95            return;
     96        $plugin = isset( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
     97        check_admin_referer( "deactivate-plugin_{$plugin}" );
     98    }
     99   
     100    register_deactivation_hook( __FILE__, 'akp_deactivate' );
     101   
     102    // END DEACTIVATE
    87103   
    88104    function akp_languages_init() {
  • adkingpro/trunk/includes/admin_area.php

    r934037 r1060727  
    11<?php
     2global $adkingpro_options;
     3$adkingpro_options = array(
     4    'akp_clear_on_delete' => '0',
     5    'akp_track_impressions' => '1',
     6    'akp_track_clicks' => '1',
     7    'akp_ga_intergrated' => '0',
     8    'akp_ga_implemented' => 'universal',
     9    'akp_ga_imp_action' => 'Impression',
     10    'akp_ga_click_action' => 'Click',
     11    'expiry_time' => '+6 hours',
     12    'impression_expiry_time' => '+0 hours',
     13    'week_starts' => 'monday',
     14    'revenue_currency' => '$',
     15    'pdf_theme' => 'default',
     16    'akp_image_sizes' => '',
     17    'akp_auth_role' => 'subscriber',
     18    'akp_custom_css' => '/* Add any CSS you would like to modify your banner ads here */',
     19    'akp_default_media_type' => 'image',
     20    'akp_default_window_target' => 'blank',
     21    'akp_default_nofollow' => '0',
     22    'akp_default_remove_link' => '0',
     23    'akp_default_rev_imp' => '0.00',
     24    'akp_default_rev_click' => '0.00',
     25);
    226
    327function akp_check_page($hook) {
     
    2549
    2650function register_akp_options() {
    27   register_setting( 'akp-options', 'akp_track_impressions' );
    28   register_setting( 'akp-options', 'akp_track_clicks' );
    29   register_setting( 'akp-options', 'akp_ga_intergrated' );
    30   register_setting( 'akp-options', 'akp_ga_implemented' );
    31   register_setting( 'akp-options', 'akp_ga_imp_action' );
    32   register_setting( 'akp-options', 'akp_ga_click_action' );
    33   register_setting( 'akp-options', 'expiry_time' );
    34   register_setting( 'akp-options', 'impression_expiry_time' );
    35   register_setting( 'akp-options', 'week_start' );
    36   register_setting( 'akp-options', 'revenue_currency' );
    37   register_setting( 'akp-options', 'pdf_theme' );
    38   register_setting( 'akp-options', 'akp_image_sizes' );
    39   register_setting( 'akp-options', 'akp_auth_role' );
    40   register_setting( 'akp-options', 'akp_custom_css' );
    41   register_setting( 'akp-options', 'akp_default_media_type' );
    42   register_setting( 'akp-options', 'akp_default_window_target' );
    43   register_setting( 'akp-options', 'akp_default_nofollow' );
    44   register_setting( 'akp-options', 'akp_default_remove_link' );
    45   register_setting( 'akp-options', 'akp_default_rev_imp' );
    46   register_setting( 'akp-options', 'akp_default_rev_click' );
     51    global $adkingpro_options;
     52    foreach ($adkingpro_options as $option=>$default_value) register_setting( 'akp-options', $option );
    4753}
    4854add_action( 'admin_init', 'register_akp_options' );
    4955
     56function unregister_akp_options() {
     57    global $adkingpro_options;
     58    foreach ($adkingpro_options as $option=>$default_value) unregister_setting( 'akp-options', $option );
     59}
     60
     61function delete_akp_options() {
     62    global $adkingpro_options;
     63    foreach ($adkingpro_options as $option=>$default_value) delete_option( $option );
     64}
     65
    5066// Default Options
    51 add_option( 'akp_track_impressions', '1' );
    52 add_option( 'akp_track_clicks', '1' );
    53 add_option( 'akp_ga_intergrated', '0' );
    54 add_option( 'akp_ga_implemented', 'universal' );
    55 add_option( 'akp_ga_imp_action', 'Impression' );
    56 add_option( 'akp_ga_click_action', 'Click' );
    57 add_option( 'expiry_time', '+6 hours' );
    58 add_option( 'impression_expiry_time', '+0 hours' );
    59 add_option( 'week_starts', 'monday' );
    60 add_option( 'revenue_currency', '$' );
    61 add_option( 'pdf_theme', 'default' );
    62 add_option( 'akp_image_sizes', '' );
    63 add_option( 'akp_auth_role', 'subscriber');
    64 add_option( 'akp_custom_css', '/* Add any CSS you would like to modify your banner ads here */' );
    65 add_option( 'akp_default_media_type', 'image' );
    66 add_option( 'akp_default_window_target', 'blank' );
    67 add_option( 'akp_default_nofollow', '0' );
    68 add_option( 'akp_default_remove_link', '0' );
    69 add_option( 'akp_default_rev_imp', '0.00' );
    70 add_option( 'akp_default_rev_click', '0.00' );
     67foreach ($adkingpro_options as $option=>$default_value) add_option( $option, $default_value );
    7168
    7269function akp_allowed_cap() {
     
    140137            'rewrite' => false,
    141138            'query_var' => false,
    142             'menu_position' => 5,
     139            'menu_position' => 55,
    143140            'supports' => array( 'title', 'thumbnail' )
    144141        )
     
    174171            background: url(<?= plugins_url('/images/kpp-icon_16x16_sat.png', dirname(__FILE__)) ?>) no-repeat center center !important;
    175172        }
     173        #toplevel_page_kpp_menu .wp-menu-image:before {display: none;}
    176174    #toplevel_page_kpp_menu:hover .wp-menu-image, #toplevel_page_kpp_menu.wp-has-current-submenu .wp-menu-image {
    177175            background: url(<?= plugins_url('/images/kpp-icon_16x16.png', dirname(__FILE__)) ?>) no-repeat center center !important;
  • adkingpro/trunk/includes/screens/detailed.php

    r803624 r1060727  
    11<div class="wrap">
    2 <?php screen_icon(); ?>
    3 <h2>Ad King Pro <?= __("Detailed Stats", 'akptext') ?></h2>
    4 <div class="akp_detailed_stats">
    5     <?php
    6     global $wpdb;
    7    
    8     query_posts(array(
    9         'post_type'=>'adverts_posts'
    10         ));
    11     $currency_sign = get_option('revenue_currency');
    12     while (have_posts()) : the_post();
    13         $post_id = get_the_ID();
    14         $image = akp_get_featured_image($post_id);
    15         $dets = akp_return_fields($post_id);
    16        
    17         // Get All Time Click Count
    18         $all_clicks = $wpdb->get_results("SELECT COUNT(*) as clicks FROM ".$wpdb->prefix."akp_click_log WHERE post_id = '$post_id'");
    19         $all_impressions = $wpdb->get_results("SELECT COUNT(*) as impressions FROM ".$wpdb->prefix."akp_impressions_log WHERE post_id = '$post_id'");
    20        
    21         $all_impression_cost = (is_numeric($dets['akp_revenue_per_impression'][0])) ? $dets['akp_revenue_per_impression'][0] : '0.00';
    22         $all_click_cost = (is_numeric($dets['akp_revenue_per_click'][0])) ? $dets['akp_revenue_per_click'][0] : '0.00';
    23        
    24         $all_per_impression = $currency_sign.number_format($all_impression_cost, 2);
    25         $all_impression_total = $all_impression_cost * $all_impressions[0]->impressions;
    26         $all_impression_total_output = $currency_sign.number_format($all_impression_total, 2);
    27        
    28         $all_per_click = $currency_sign.number_format($all_click_cost, 2);
    29         $all_click_total = $all_click_cost * $all_clicks[0]->clicks;
    30         $all_click_total_output = $currency_sign.number_format($all_click_total, 2);
    31        
    32         $all_total_made = $all_impression_total + $all_click_total;
    33         $all_total_made_output = $currency_sign.number_format($all_total_made, 2);
    34 
    35         // Get This Month Click Count
    36         $month_start = mktime(0, 0, 0, date('n', current_time('timestamp')), 1, date('Y', current_time('timestamp')));
    37         $month_end = mktime(23, 59, 59, date('n', current_time('timestamp')), date('t', current_time('timestamp')), date('Y', current_time('timestamp')));
    38         $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'");
    39         $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'");
    40        
    41         $month_impression_cost = (is_numeric($dets['akp_revenue_per_impression'][0])) ? $dets['akp_revenue_per_impression'][0] : '0.00';
    42         $month_click_cost = (is_numeric($dets['akp_revenue_per_click'][0])) ? $dets['akp_revenue_per_click'][0] : '0.00';
    43        
    44         $month_per_impression = $currency_sign.number_format($month_impression_cost, 2);
    45         $month_impression_total = $month_impression_cost * $month_impressions[0]->impressions;
    46         $month_impression_total_output = $currency_sign.number_format($month_impression_total, 2);
    47        
    48         $month_per_click = $currency_sign.number_format($month_click_cost, 2);
    49         $month_click_total = $month_click_cost * $month_clicks[0]->clicks;
    50         $month_click_total_output = $currency_sign.number_format($month_click_total, 2);
    51        
    52         $month_total_made = $month_impression_total + $month_click_total;
    53         $month_total_made_output = $currency_sign.number_format($month_total_made, 2);
    54 
    55         // Get This Week click count
    56         $start_week = get_option('week_starts');
    57         if (strtolower(date('l', current_time('timestamp'))) == $start_week) {
    58             $day = date('j', current_time('timestamp'));
    59             $month = date('n', current_time('timestamp'));
    60             $year = date('Y', current_time('timestamp'));
    61         } else {
    62             $day = date('j', strtotime('last '.$start_week));
    63             $month = date('n', strtotime('last '.$start_week));
    64             $year = date('Y', strtotime('last '.$start_week));
    65         }
    66         $week_start = mktime(0, 0, 0, $month, $day, $year);
    67         $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)));
    68         $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'");
    69         $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'");
    70 
    71         $week_impression_cost = (is_numeric($dets['akp_revenue_per_impression'][0])) ? $dets['akp_revenue_per_impression'][0] : '0.00';
    72         $week_click_cost = (is_numeric($dets['akp_revenue_per_click'][0])) ? $dets['akp_revenue_per_click'][0] : '0.00';
    73        
    74         $week_per_impression = $currency_sign.number_format($week_impression_cost, 2);
    75         $week_impression_total = $week_impression_cost * $week_impressions[0]->impressions;
    76         $week_impression_total_output = $currency_sign.number_format($week_impression_total, 2);
    77        
    78         $week_per_click = $currency_sign.number_format($week_click_cost, 2);
    79         $week_click_total = $week_click_cost * $week_clicks[0]->clicks;
    80         $week_click_total_output = $currency_sign.number_format($week_click_total, 2);
    81        
    82         $week_total_made = $week_impression_total + $week_click_total;
    83         $week_total_made_output = $currency_sign.number_format($week_total_made, 2);
    84        
    85         // Get Today Click count
    86         $today_start = mktime(0, 0, 0, date('n', current_time('timestamp')), date('j', current_time('timestamp')), date('Y', current_time('timestamp')));
    87         $today_end = mktime(23, 59, 59, date('n', current_time('timestamp')), date('j', current_time('timestamp')), date('Y', current_time('timestamp')));
    88         $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'");
    89         $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'");
    90        
    91         $today_impression_cost = (is_numeric($dets['akp_revenue_per_impression'][0])) ? $dets['akp_revenue_per_impression'][0] : '0.00';
    92         $today_click_cost = (is_numeric($dets['akp_revenue_per_click'][0])) ? $dets['akp_revenue_per_click'][0] : '0.00';
    93        
    94         $today_per_impression = $currency_sign.number_format($today_impression_cost, 2);
    95         $today_impression_total = $today_impression_cost * $today_impressions[0]->impressions;
    96         $today_impression_total_output = $currency_sign.number_format($today_impression_total, 2);
    97        
    98         $today_per_click = $currency_sign.number_format($today_click_cost, 2);
    99         $today_click_total = $today_click_cost * $today_clicks[0]->clicks;
    100         $today_click_total_output = $currency_sign.number_format($today_click_total, 2);
    101        
    102         $today_total_made = $today_impression_total + $today_click_total;
    103         $today_total_made_output = $currency_sign.number_format($today_total_made, 2);
    104        
    105         // Initilize Detail log
    106         $all_clicks_detailed = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."akp_click_log WHERE post_id = '$post_id' ORDER BY timestamp DESC");
    107         $month_clicks_detailed = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."akp_click_log WHERE timestamp BETWEEN '$month_start' AND '$month_end' AND post_id = '$post_id' ORDER BY timestamp DESC");
    108         $week_clicks_detailed = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."akp_click_log WHERE timestamp BETWEEN '$week_start' AND '$week_end' AND post_id = '$post_id' ORDER BY timestamp DESC");
    109         $day_clicks_detailed = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."akp_click_log WHERE timestamp BETWEEN '$today_start' AND '$today_end' AND post_id = '$post_id' ORDER BY timestamp DESC");
    110 
    111         ?>
    112         <div class="banner_detailed_stat">
    113             <div class="banner">
    114                 <a href='<?= admin_url("post.php?post=".$post_id."&action=edit") ?>'><img src='<?= $image ?>' /></a><h3><?php the_title(); ?></h3>
    115             </div>
    116             <div class='stats'>
    117                 <h2><?= __("Summary", 'akptext') ?></h2>
    118                 <div class='stat'><h4><?= __("All Time", 'akptext') ?></h4><span title="<?= __("Impressions", 'akptext') ?>: <?= $all_impressions[0]->impressions ?>" alt="<?= __("Impressions", 'akptext') ?>: <?= $all_impressions[0]->impressions ?>"><?= $all_clicks[0]->clicks ?></span></div>
    119                 <div class='stat'><h4><?= __("This Month", 'akptext') ?></h4><span title="<?= __("Impressions", 'akptext') ?>: <?= $month_impressions[0]->impressions ?>" alt="<?= __("Impressions", 'akptext') ?>: <?= $month_impressions[0]->impressions ?>"><?= $month_clicks[0]->clicks ?></span></div>
    120                 <div class='stat'><h4><?= __("This Week", 'akptext') ?></h4><span title="<?= __("Impressions", 'akptext') ?>: <?= $week_impressions[0]->impressions ?>" alt="<?= __("Impressions", 'akptext') ?>: <?= $week_impressions[0]->impressions ?>"><?= $week_clicks[0]->clicks ?></span></div>
    121                 <div class='stat'><h4><?= __("Today", 'akptext') ?></h4><span title="<?= __("Impressions", 'akptext') ?>: <?= $today_impressions[0]->impressions ?>" alt="<?= __("Impressions", 'akptext') ?>: <?= $today_impressions[0]->impressions ?>"><?= $today_clicks[0]->clicks ?></span></div>
    122             </div>
    123             <div class='detailed'>
    124                 <h2><?= __("Detailed", 'akptext') ?></h2>
    125                 <div class="detailed_menu">
    126                     <a class="active akp_detailed" rel="all"><?= __("View all clicks", 'akptext') ?></a>
    127                     <a class="akp_detailed" rel="month"><?= __("View this month clicks", 'akptext') ?></a>
    128                     <a class="akp_detailed" rel="week"><?= __("View this week clicks", 'akptext') ?></a>
    129                     <a class="akp_detailed" rel="day"><?= __("View todays clicks", 'akptext') ?></a>
    130                     <a class="akp_detailed" rel="date"><?= __("View date range clicks", 'akptext') ?></a>
    131                 </div>
    132                 <div class="detailed_details">
    133                     <div class="akp_detailed_all_details" style="display: block;">
    134                         <br />
    135                         <table>
    136                             <tr>
    137                                 <td></td>
    138                                 <th class="center"><?= __("Count", 'akptext') ?></th>
    139                                 <th class="center"><?= __("Cost Per", 'akptext') ?></th>
    140                                 <th class="center"><?= __("Total", 'akptext') ?></th>
    141                             </tr>
    142                             <tr>
    143                                 <td><?= __("Impressions", 'akptext') ?></td>
    144                                 <td class="center"><?= $all_impressions[0]->impressions ?></td>
    145                                 <td class="right"><?= $all_per_impression ?></td>
    146                                 <td class="right"><?= $all_impression_total_output ?></td>
    147                             </tr>
    148                             <tr>
    149                                 <td><?= __("Clicks", 'akptext') ?></td>
    150                                 <td class="center"><?= $all_clicks[0]->clicks ?></td>
    151                                 <td class="right"><?= $all_per_click ?></td>
    152                                 <td class="right"><?= $all_click_total_output ?></td>
    153                             </tr>
    154                             <tr>
    155                                 <td></td>
    156                                 <td></td>
    157                                 <td class="right bold"><?= __("TOTAL", 'akptext') ?></td>
    158                                 <td class="right bold"><?= $all_total_made_output ?></td>
    159                             </tr>
    160                         </table>
    161                         <br />
    162                         <div class="akp_reporting">
    163                             <strong><?= __("Download report", 'akptext') ?>: </strong> <a class="akp_csv" rel="all/<?= $post_id ?>"><?= __("CSV", 'akptext') ?></a> <a class="akp_pdf" rel="all/<?= $post_id ?>"><?= __("PDF", 'akptext') ?></a>
     2    <?php screen_icon(); ?>
     3    <h2>Ad King Pro <?= __("Detailed Stats", 'akptext') ?></h2>
     4    <div class="akp_detailed_stats">
     5        <?php
     6        $using_GA = get_option('akp_ga_intergrated');
     7
     8        if (!$using_GA) :
     9
     10            global $wpdb;
     11
     12            query_posts(array(
     13                'post_type'=>'adverts_posts'
     14                ));
     15            $currency_sign = get_option('revenue_currency');
     16            while (have_posts()) : the_post();
     17                $post_id = get_the_ID();
     18                $image = akp_get_featured_image($post_id);
     19                $dets = akp_return_fields($post_id);
     20
     21                // Get All Time Click Count
     22                $all_clicks = $wpdb->get_results("SELECT COUNT(*) as clicks FROM ".$wpdb->prefix."akp_click_log WHERE post_id = '$post_id'");
     23                $all_impressions = $wpdb->get_results("SELECT COUNT(*) as impressions FROM ".$wpdb->prefix."akp_impressions_log WHERE post_id = '$post_id'");
     24
     25                $all_impression_cost = (is_numeric($dets['akp_revenue_per_impression'][0])) ? $dets['akp_revenue_per_impression'][0] : '0.00';
     26                $all_click_cost = (is_numeric($dets['akp_revenue_per_click'][0])) ? $dets['akp_revenue_per_click'][0] : '0.00';
     27
     28                $all_per_impression = $currency_sign.number_format($all_impression_cost, 2);
     29                $all_impression_total = $all_impression_cost * $all_impressions[0]->impressions;
     30                $all_impression_total_output = $currency_sign.number_format($all_impression_total, 2);
     31
     32                $all_per_click = $currency_sign.number_format($all_click_cost, 2);
     33                $all_click_total = $all_click_cost * $all_clicks[0]->clicks;
     34                $all_click_total_output = $currency_sign.number_format($all_click_total, 2);
     35
     36                $all_total_made = $all_impression_total + $all_click_total;
     37                $all_total_made_output = $currency_sign.number_format($all_total_made, 2);
     38
     39                // Get This Month Click Count
     40                $month_start = mktime(0, 0, 0, date('n', current_time('timestamp')), 1, date('Y', current_time('timestamp')));
     41                $month_end = mktime(23, 59, 59, date('n', current_time('timestamp')), date('t', current_time('timestamp')), date('Y', current_time('timestamp')));
     42                $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'");
     43                $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'");
     44
     45                $month_impression_cost = (is_numeric($dets['akp_revenue_per_impression'][0])) ? $dets['akp_revenue_per_impression'][0] : '0.00';
     46                $month_click_cost = (is_numeric($dets['akp_revenue_per_click'][0])) ? $dets['akp_revenue_per_click'][0] : '0.00';
     47
     48                $month_per_impression = $currency_sign.number_format($month_impression_cost, 2);
     49                $month_impression_total = $month_impression_cost * $month_impressions[0]->impressions;
     50                $month_impression_total_output = $currency_sign.number_format($month_impression_total, 2);
     51
     52                $month_per_click = $currency_sign.number_format($month_click_cost, 2);
     53                $month_click_total = $month_click_cost * $month_clicks[0]->clicks;
     54                $month_click_total_output = $currency_sign.number_format($month_click_total, 2);
     55
     56                $month_total_made = $month_impression_total + $month_click_total;
     57                $month_total_made_output = $currency_sign.number_format($month_total_made, 2);
     58
     59                // Get This Week click count
     60                $start_week = get_option('week_starts');
     61                if (strtolower(date('l', current_time('timestamp'))) == $start_week) {
     62                    $day = date('j', current_time('timestamp'));
     63                    $month = date('n', current_time('timestamp'));
     64                    $year = date('Y', current_time('timestamp'));
     65                } else {
     66                    $day = date('j', strtotime('last '.$start_week));
     67                    $month = date('n', strtotime('last '.$start_week));
     68                    $year = date('Y', strtotime('last '.$start_week));
     69                }
     70                $week_start = mktime(0, 0, 0, $month, $day, $year);
     71                $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)));
     72                $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'");
     73                $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'");
     74
     75                $week_impression_cost = (is_numeric($dets['akp_revenue_per_impression'][0])) ? $dets['akp_revenue_per_impression'][0] : '0.00';
     76                $week_click_cost = (is_numeric($dets['akp_revenue_per_click'][0])) ? $dets['akp_revenue_per_click'][0] : '0.00';
     77
     78                $week_per_impression = $currency_sign.number_format($week_impression_cost, 2);
     79                $week_impression_total = $week_impression_cost * $week_impressions[0]->impressions;
     80                $week_impression_total_output = $currency_sign.number_format($week_impression_total, 2);
     81
     82                $week_per_click = $currency_sign.number_format($week_click_cost, 2);
     83                $week_click_total = $week_click_cost * $week_clicks[0]->clicks;
     84                $week_click_total_output = $currency_sign.number_format($week_click_total, 2);
     85
     86                $week_total_made = $week_impression_total + $week_click_total;
     87                $week_total_made_output = $currency_sign.number_format($week_total_made, 2);
     88
     89                // Get Today Click count
     90                $today_start = mktime(0, 0, 0, date('n', current_time('timestamp')), date('j', current_time('timestamp')), date('Y', current_time('timestamp')));
     91                $today_end = mktime(23, 59, 59, date('n', current_time('timestamp')), date('j', current_time('timestamp')), date('Y', current_time('timestamp')));
     92                $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'");
     93                $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'");
     94
     95                $today_impression_cost = (is_numeric($dets['akp_revenue_per_impression'][0])) ? $dets['akp_revenue_per_impression'][0] : '0.00';
     96                $today_click_cost = (is_numeric($dets['akp_revenue_per_click'][0])) ? $dets['akp_revenue_per_click'][0] : '0.00';
     97
     98                $today_per_impression = $currency_sign.number_format($today_impression_cost, 2);
     99                $today_impression_total = $today_impression_cost * $today_impressions[0]->impressions;
     100                $today_impression_total_output = $currency_sign.number_format($today_impression_total, 2);
     101
     102                $today_per_click = $currency_sign.number_format($today_click_cost, 2);
     103                $today_click_total = $today_click_cost * $today_clicks[0]->clicks;
     104                $today_click_total_output = $currency_sign.number_format($today_click_total, 2);
     105
     106                $today_total_made = $today_impression_total + $today_click_total;
     107                $today_total_made_output = $currency_sign.number_format($today_total_made, 2);
     108
     109                // Initilize Detail log
     110                $all_clicks_detailed = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."akp_click_log WHERE post_id = '$post_id' ORDER BY timestamp DESC");
     111                $month_clicks_detailed = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."akp_click_log WHERE timestamp BETWEEN '$month_start' AND '$month_end' AND post_id = '$post_id' ORDER BY timestamp DESC");
     112                $week_clicks_detailed = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."akp_click_log WHERE timestamp BETWEEN '$week_start' AND '$week_end' AND post_id = '$post_id' ORDER BY timestamp DESC");
     113                $day_clicks_detailed = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."akp_click_log WHERE timestamp BETWEEN '$today_start' AND '$today_end' AND post_id = '$post_id' ORDER BY timestamp DESC");
     114
     115                ?>
     116                <div class="banner_detailed_stat">
     117                    <div class="banner">
     118                        <a href='<?= admin_url("post.php?post=".$post_id."&action=edit") ?>'><img src='<?= $image ?>' /></a><h3><?php the_title(); ?></h3>
     119                    </div>
     120                    <div class='stats'>
     121                        <h2><?= __("Summary", 'akptext') ?></h2>
     122                        <div class='stat'><h4><?= __("All Time", 'akptext') ?></h4><span title="<?= __("Impressions", 'akptext') ?>: <?= $all_impressions[0]->impressions ?>" alt="<?= __("Impressions", 'akptext') ?>: <?= $all_impressions[0]->impressions ?>"><?= $all_clicks[0]->clicks ?></span></div>
     123                        <div class='stat'><h4><?= __("This Month", 'akptext') ?></h4><span title="<?= __("Impressions", 'akptext') ?>: <?= $month_impressions[0]->impressions ?>" alt="<?= __("Impressions", 'akptext') ?>: <?= $month_impressions[0]->impressions ?>"><?= $month_clicks[0]->clicks ?></span></div>
     124                        <div class='stat'><h4><?= __("This Week", 'akptext') ?></h4><span title="<?= __("Impressions", 'akptext') ?>: <?= $week_impressions[0]->impressions ?>" alt="<?= __("Impressions", 'akptext') ?>: <?= $week_impressions[0]->impressions ?>"><?= $week_clicks[0]->clicks ?></span></div>
     125                        <div class='stat'><h4><?= __("Today", 'akptext') ?></h4><span title="<?= __("Impressions", 'akptext') ?>: <?= $today_impressions[0]->impressions ?>" alt="<?= __("Impressions", 'akptext') ?>: <?= $today_impressions[0]->impressions ?>"><?= $today_clicks[0]->clicks ?></span></div>
     126                    </div>
     127                    <div class='detailed'>
     128                        <h2><?= __("Detailed", 'akptext') ?></h2>
     129                        <div class="detailed_menu">
     130                            <a class="active akp_detailed" rel="all"><?= __("View all clicks", 'akptext') ?></a>
     131                            <a class="akp_detailed" rel="month"><?= __("View this month clicks", 'akptext') ?></a>
     132                            <a class="akp_detailed" rel="week"><?= __("View this week clicks", 'akptext') ?></a>
     133                            <a class="akp_detailed" rel="day"><?= __("View todays clicks", 'akptext') ?></a>
     134                            <a class="akp_detailed" rel="date"><?= __("View date range clicks", 'akptext') ?></a>
    164135                        </div>
    165                         <br />
    166                         <table>
    167                             <thead>
    168                                 <tr>
    169                                     <th><?= __("Date/Time", 'akptext') ?></th>
    170                                     <th><?= __("IP Address", 'akptext') ?></th>
    171                                 </tr>
    172                             </thead>
    173                             <tbody>
    174                             <?php foreach ($all_clicks_detailed as $acd) : ?>
    175                             <tr>
    176                                 <td><?= date('d/m/Y h:i:sa', $acd->timestamp) ?></td>
    177                                 <td><?= $acd->ip_address ?></td>
    178                             </tr>
    179                             <?php endforeach; ?>
    180                             </tbody>
    181                             <tfoot>
    182                                 <tr>
    183                                     <th><?= __("Date/Time", 'akptext') ?></th>
    184                                     <th><?= __("IP Address", 'akptext') ?></th>
    185                                 </tr>
    186                             </tfoot>
    187                         </table>
    188                     </div>
    189                     <div class="akp_detailed_month_details">
    190                         <br />
    191                         <table>
    192                             <tr>
    193                                 <td></td>
    194                                 <th class="center"><?= __("Count", 'akptext') ?></th>
    195                                 <th class="center"><?= __("Cost Per", 'akptext') ?></th>
    196                                 <th class="center"><?= __("Total", 'akptext') ?></th>
    197                             </tr>
    198                             <tr>
    199                                 <td><?= __("Impressions", 'akptext') ?></td>
    200                                 <td class="center"><?= $month_impressions[0]->impressions ?></td>
    201                                 <td class="right"><?= $month_per_impression ?></td>
    202                                 <td class="right"><?= $month_impression_total_output ?></td>
    203                             </tr>
    204                             <tr>
    205                                 <td><?= __("Clicks", 'akptext') ?></td>
    206                                 <td class="center"><?= $month_clicks[0]->clicks ?></td>
    207                                 <td class="right"><?= $month_per_click ?></td>
    208                                 <td class="right"><?= $month_click_total_output ?></td>
    209                             </tr>
    210                             <tr>
    211                                 <td></td>
    212                                 <td></td>
    213                                 <td class="right bold"><?= __("TOTAL", 'akptext') ?></td>
    214                                 <td class="right bold"><?= $month_total_made_output ?></td>
    215                             </tr>
    216                         </table>
    217                         <br />
    218                         <div class="akp_reporting">
    219                             <strong><?= __("Download report", 'akptext') ?>: </strong> <a class="akp_csv" rel="month/<?= $post_id ?>"><?= __("CSV", 'akptext') ?></a> <a class="akp_pdf" rel="month/<?= $post_id ?>"><?= __("PDF", 'akptext') ?></a>
    220                         </div>
    221                         <br />
    222                         <table>
    223                             <thead>
    224                                 <tr>
    225                                     <th><?= __("Date/Time", 'akptext') ?></th>
    226                                     <th><?= __("IP Address", 'akptext') ?></th>
    227                                 </tr>
    228                             </thead>
    229                             <tbody>
    230                             <?php foreach ($month_clicks_detailed as $acd) : ?>
    231                             <tr>
    232                                 <td><?= date('d/m/Y h:i:sa', $acd->timestamp) ?></td>
    233                                 <td><?= $acd->ip_address ?></td>
    234                             </tr>
    235                             <?php endforeach; ?>
    236                             </tbody>
    237                             <tfoot>
    238                                 <tr>
    239                                     <th><?= __("Date/Time", 'akptext') ?></th>
    240                                     <th><?= __("IP Address", 'akptext') ?></th>
    241                                 </tr>
    242                             </tfoot>
    243                         </table>
    244                     </div>
    245                     <div class="akp_detailed_week_details">
    246                         <br />
    247                         <table>
    248                             <tr>
    249                                 <td></td>
    250                                 <th class="center"><?= __("Count", 'akptext') ?></th>
    251                                 <th class="center"><?= __("Cost Per", 'akptext') ?></th>
    252                                 <th class="center"><?= __("Total", 'akptext') ?></th>
    253                             </tr>
    254                             <tr>
    255                                 <td><?= __("Impressions", 'akptext') ?></td>
    256                                 <td class="center"><?= $week_impressions[0]->impressions ?></td>
    257                                 <td class="right"><?= $week_per_impression ?></td>
    258                                 <td class="right"><?= $week_impression_total_output ?></td>
    259                             </tr>
    260                             <tr>
    261                                 <td><?= __("Clicks", 'akptext') ?></td>
    262                                 <td class="center"><?= $week_clicks[0]->clicks ?></td>
    263                                 <td class="right"><?= $week_per_click ?></td>
    264                                 <td class="right"><?= $week_click_total_output ?></td>
    265                             </tr>
    266                             <tr>
    267                                 <td></td>
    268                                 <td></td>
    269                                 <td class="right bold"><?= __("TOTAL", 'akptext') ?></td>
    270                                 <td class="right bold"><?= $week_total_made_output ?></td>
    271                             </tr>
    272                         </table>
    273                         <br />
    274                         <div class="akp_reporting">
    275                             <strong><?= __("Download report", 'akptext') ?>: </strong> <a class="akp_csv" rel="week/<?= $post_id ?>"><?= __("CSV", 'akptext') ?></a> <a class="akp_pdf" rel="week/<?= $post_id ?>"><?= __("PDF", 'akptext') ?></a>
    276                         </div>
    277                         <br />
    278                         <table>
    279                             <thead>
    280                                 <tr>
    281                                     <th><?= __("Date/Time", 'akptext') ?></th>
    282                                     <th><?= __("IP Address", 'akptext') ?></th>
    283                                 </tr>
    284                             </thead>
    285                             <tbody>
    286                             <?php foreach ($week_clicks_detailed as $acd) : ?>
    287                             <tr>
    288                                 <td><?= date('d/m/Y h:i:sa', $acd->timestamp) ?></td>
    289                                 <td><?= $acd->ip_address ?></td>
    290                             </tr>
    291                             <?php endforeach; ?>
    292                             </tbody>
    293                             <tfoot>
    294                                 <tr>
    295                                     <th><?= __("Date/Time", 'akptext') ?></th>
    296                                     <th><?= __("IP Address", 'akptext') ?></th>
    297                                 </tr>
    298                             </tfoot>
    299                         </table>
    300                     </div>
    301                     <div class="akp_detailed_day_details">
    302                         <br />
    303                         <table>
    304                             <tr>
    305                                 <td></td>
    306                                 <th class="center"><?= __("Count", 'akptext') ?></th>
    307                                 <th class="center"><?= __("Cost Per", 'akptext') ?></th>
    308                                 <th class="center"><?= __("Total", 'akptext') ?></th>
    309                             </tr>
    310                             <tr>
    311                                 <td><?= __("Impressions", 'akptext') ?></td>
    312                                 <td class="center"><?= $today_impressions[0]->impressions ?></td>
    313                                 <td class="right"><?= $today_per_impression ?></td>
    314                                 <td class="right"><?= $today_impression_total_output ?></td>
    315                             </tr>
    316                             <tr>
    317                                 <td><?= __("Clicks", 'akptext') ?></td>
    318                                 <td class="center"><?= $today_clicks[0]->clicks ?></td>
    319                                 <td class="right"><?= $today_per_click ?></td>
    320                                 <td class="right"><?= $today_click_total_output ?></td>
    321                             </tr>
    322                             <tr>
    323                                 <td></td>
    324                                 <td></td>
    325                                 <td class="right bold"><?= __("TOTAL", 'akptext') ?></td>
    326                                 <td class="right bold"><?= $today_total_made_output ?></td>
    327                             </tr>
    328                         </table>
    329                         <br />
    330                         <div class="akp_reporting">
    331                             <strong><?= __("Download report", 'akptext') ?>: </strong> <a class="akp_csv" rel="today/<?= $post_id ?>"><?= __("CSV", 'akptext') ?></a> <a class="akp_pdf" rel="today/<?= $post_id ?>"><?= __("PDF", 'akptext') ?></a>
    332                         </div>
    333                         <br />
    334                         <table>
    335                             <thead>
    336                                 <tr>
    337                                     <th><?= __("Date/Time", 'akptext') ?></th>
    338                                     <th><?= __("IP Address", 'akptext') ?></th>
    339                                 </tr>
    340                             </thead>
    341                             <tbody>
    342                             <?php foreach ($day_clicks_detailed as $acd) : ?>
    343                             <tr>
    344                                 <td><?= date('d/m/Y h:i:sa', $acd->timestamp) ?></td>
    345                                 <td><?= $acd->ip_address ?></td>
    346                             </tr>
    347                             <?php endforeach; ?>
    348                             </tbody>
    349                             <tfoot>
    350                                 <tr>
    351                                     <th><?= __("Date/Time", 'akptext') ?></th>
    352                                     <th><?= __("IP Address", 'akptext') ?></th>
    353                                 </tr>
    354                             </tfoot>
    355                         </table>
    356                     </div>
    357                     <div class="akp_detailed_date_details">
    358                         <div class="choose_custom_date">
    359                             <h4><?= __("Choose your date range", 'akptext') ?>:</h4>
    360                             <label><?= __("From", 'akptext') ?>: </label><input type="text" class="akp_datepicker from_adkingpro_date" />
    361                             <label><?= __("To", 'akptext') ?>: </label><input type="text" class="akp_datepicker to_adkingpro_date" />
    362                             <a class="akp_custom_date" rel="<?= $post_id ?>"><?= __("Search", 'akptext') ?></a>
    363                         </div>
    364                         <div class="returned_data">
    365                            
     136                        <div class="detailed_details">
     137                            <div class="akp_detailed_all_details" style="display: block;">
     138                                <br />
     139                                <table>
     140                                    <tr>
     141                                        <td></td>
     142                                        <th class="center"><?= __("Count", 'akptext') ?></th>
     143                                        <th class="center"><?= __("Cost Per", 'akptext') ?></th>
     144                                        <th class="center"><?= __("Total", 'akptext') ?></th>
     145                                    </tr>
     146                                    <tr>
     147                                        <td><?= __("Impressions", 'akptext') ?></td>
     148                                        <td class="center"><?= $all_impressions[0]->impressions ?></td>
     149                                        <td class="right"><?= $all_per_impression ?></td>
     150                                        <td class="right"><?= $all_impression_total_output ?></td>
     151                                    </tr>
     152                                    <tr>
     153                                        <td><?= __("Clicks", 'akptext') ?></td>
     154                                        <td class="center"><?= $all_clicks[0]->clicks ?></td>
     155                                        <td class="right"><?= $all_per_click ?></td>
     156                                        <td class="right"><?= $all_click_total_output ?></td>
     157                                    </tr>
     158                                    <tr>
     159                                        <td></td>
     160                                        <td></td>
     161                                        <td class="right bold"><?= __("TOTAL", 'akptext') ?></td>
     162                                        <td class="right bold"><?= $all_total_made_output ?></td>
     163                                    </tr>
     164                                </table>
     165                                <br />
     166                                <div class="akp_reporting">
     167                                    <strong><?= __("Download report", 'akptext') ?>: </strong> <a class="akp_csv" rel="all/<?= $post_id ?>"><?= __("CSV", 'akptext') ?></a> <a class="akp_pdf" rel="all/<?= $post_id ?>"><?= __("PDF", 'akptext') ?></a>
     168                                </div>
     169                                <br />
     170                                <table>
     171                                    <thead>
     172                                        <tr>
     173                                            <th><?= __("Date/Time", 'akptext') ?></th>
     174                                            <th><?= __("IP Address", 'akptext') ?></th>
     175                                        </tr>
     176                                    </thead>
     177                                    <tbody>
     178                                    <?php foreach ($all_clicks_detailed as $acd) : ?>
     179                                    <tr>
     180                                        <td><?= date('d/m/Y h:i:sa', $acd->timestamp) ?></td>
     181                                        <td><?= $acd->ip_address ?></td>
     182                                    </tr>
     183                                    <?php endforeach; ?>
     184                                    </tbody>
     185                                    <tfoot>
     186                                        <tr>
     187                                            <th><?= __("Date/Time", 'akptext') ?></th>
     188                                            <th><?= __("IP Address", 'akptext') ?></th>
     189                                        </tr>
     190                                    </tfoot>
     191                                </table>
     192                            </div>
     193                            <div class="akp_detailed_month_details">
     194                                <br />
     195                                <table>
     196                                    <tr>
     197                                        <td></td>
     198                                        <th class="center"><?= __("Count", 'akptext') ?></th>
     199                                        <th class="center"><?= __("Cost Per", 'akptext') ?></th>
     200                                        <th class="center"><?= __("Total", 'akptext') ?></th>
     201                                    </tr>
     202                                    <tr>
     203                                        <td><?= __("Impressions", 'akptext') ?></td>
     204                                        <td class="center"><?= $month_impressions[0]->impressions ?></td>
     205                                        <td class="right"><?= $month_per_impression ?></td>
     206                                        <td class="right"><?= $month_impression_total_output ?></td>
     207                                    </tr>
     208                                    <tr>
     209                                        <td><?= __("Clicks", 'akptext') ?></td>
     210                                        <td class="center"><?= $month_clicks[0]->clicks ?></td>
     211                                        <td class="right"><?= $month_per_click ?></td>
     212                                        <td class="right"><?= $month_click_total_output ?></td>
     213                                    </tr>
     214                                    <tr>
     215                                        <td></td>
     216                                        <td></td>
     217                                        <td class="right bold"><?= __("TOTAL", 'akptext') ?></td>
     218                                        <td class="right bold"><?= $month_total_made_output ?></td>
     219                                    </tr>
     220                                </table>
     221                                <br />
     222                                <div class="akp_reporting">
     223                                    <strong><?= __("Download report", 'akptext') ?>: </strong> <a class="akp_csv" rel="month/<?= $post_id ?>"><?= __("CSV", 'akptext') ?></a> <a class="akp_pdf" rel="month/<?= $post_id ?>"><?= __("PDF", 'akptext') ?></a>
     224                                </div>
     225                                <br />
     226                                <table>
     227                                    <thead>
     228                                        <tr>
     229                                            <th><?= __("Date/Time", 'akptext') ?></th>
     230                                            <th><?= __("IP Address", 'akptext') ?></th>
     231                                        </tr>
     232                                    </thead>
     233                                    <tbody>
     234                                    <?php foreach ($month_clicks_detailed as $acd) : ?>
     235                                    <tr>
     236                                        <td><?= date('d/m/Y h:i:sa', $acd->timestamp) ?></td>
     237                                        <td><?= $acd->ip_address ?></td>
     238                                    </tr>
     239                                    <?php endforeach; ?>
     240                                    </tbody>
     241                                    <tfoot>
     242                                        <tr>
     243                                            <th><?= __("Date/Time", 'akptext') ?></th>
     244                                            <th><?= __("IP Address", 'akptext') ?></th>
     245                                        </tr>
     246                                    </tfoot>
     247                                </table>
     248                            </div>
     249                            <div class="akp_detailed_week_details">
     250                                <br />
     251                                <table>
     252                                    <tr>
     253                                        <td></td>
     254                                        <th class="center"><?= __("Count", 'akptext') ?></th>
     255                                        <th class="center"><?= __("Cost Per", 'akptext') ?></th>
     256                                        <th class="center"><?= __("Total", 'akptext') ?></th>
     257                                    </tr>
     258                                    <tr>
     259                                        <td><?= __("Impressions", 'akptext') ?></td>
     260                                        <td class="center"><?= $week_impressions[0]->impressions ?></td>
     261                                        <td class="right"><?= $week_per_impression ?></td>
     262                                        <td class="right"><?= $week_impression_total_output ?></td>
     263                                    </tr>
     264                                    <tr>
     265                                        <td><?= __("Clicks", 'akptext') ?></td>
     266                                        <td class="center"><?= $week_clicks[0]->clicks ?></td>
     267                                        <td class="right"><?= $week_per_click ?></td>
     268                                        <td class="right"><?= $week_click_total_output ?></td>
     269                                    </tr>
     270                                    <tr>
     271                                        <td></td>
     272                                        <td></td>
     273                                        <td class="right bold"><?= __("TOTAL", 'akptext') ?></td>
     274                                        <td class="right bold"><?= $week_total_made_output ?></td>
     275                                    </tr>
     276                                </table>
     277                                <br />
     278                                <div class="akp_reporting">
     279                                    <strong><?= __("Download report", 'akptext') ?>: </strong> <a class="akp_csv" rel="week/<?= $post_id ?>"><?= __("CSV", 'akptext') ?></a> <a class="akp_pdf" rel="week/<?= $post_id ?>"><?= __("PDF", 'akptext') ?></a>
     280                                </div>
     281                                <br />
     282                                <table>
     283                                    <thead>
     284                                        <tr>
     285                                            <th><?= __("Date/Time", 'akptext') ?></th>
     286                                            <th><?= __("IP Address", 'akptext') ?></th>
     287                                        </tr>
     288                                    </thead>
     289                                    <tbody>
     290                                    <?php foreach ($week_clicks_detailed as $acd) : ?>
     291                                    <tr>
     292                                        <td><?= date('d/m/Y h:i:sa', $acd->timestamp) ?></td>
     293                                        <td><?= $acd->ip_address ?></td>
     294                                    </tr>
     295                                    <?php endforeach; ?>
     296                                    </tbody>
     297                                    <tfoot>
     298                                        <tr>
     299                                            <th><?= __("Date/Time", 'akptext') ?></th>
     300                                            <th><?= __("IP Address", 'akptext') ?></th>
     301                                        </tr>
     302                                    </tfoot>
     303                                </table>
     304                            </div>
     305                            <div class="akp_detailed_day_details">
     306                                <br />
     307                                <table>
     308                                    <tr>
     309                                        <td></td>
     310                                        <th class="center"><?= __("Count", 'akptext') ?></th>
     311                                        <th class="center"><?= __("Cost Per", 'akptext') ?></th>
     312                                        <th class="center"><?= __("Total", 'akptext') ?></th>
     313                                    </tr>
     314                                    <tr>
     315                                        <td><?= __("Impressions", 'akptext') ?></td>
     316                                        <td class="center"><?= $today_impressions[0]->impressions ?></td>
     317                                        <td class="right"><?= $today_per_impression ?></td>
     318                                        <td class="right"><?= $today_impression_total_output ?></td>
     319                                    </tr>
     320                                    <tr>
     321                                        <td><?= __("Clicks", 'akptext') ?></td>
     322                                        <td class="center"><?= $today_clicks[0]->clicks ?></td>
     323                                        <td class="right"><?= $today_per_click ?></td>
     324                                        <td class="right"><?= $today_click_total_output ?></td>
     325                                    </tr>
     326                                    <tr>
     327                                        <td></td>
     328                                        <td></td>
     329                                        <td class="right bold"><?= __("TOTAL", 'akptext') ?></td>
     330                                        <td class="right bold"><?= $today_total_made_output ?></td>
     331                                    </tr>
     332                                </table>
     333                                <br />
     334                                <div class="akp_reporting">
     335                                    <strong><?= __("Download report", 'akptext') ?>: </strong> <a class="akp_csv" rel="today/<?= $post_id ?>"><?= __("CSV", 'akptext') ?></a> <a class="akp_pdf" rel="today/<?= $post_id ?>"><?= __("PDF", 'akptext') ?></a>
     336                                </div>
     337                                <br />
     338                                <table>
     339                                    <thead>
     340                                        <tr>
     341                                            <th><?= __("Date/Time", 'akptext') ?></th>
     342                                            <th><?= __("IP Address", 'akptext') ?></th>
     343                                        </tr>
     344                                    </thead>
     345                                    <tbody>
     346                                    <?php foreach ($day_clicks_detailed as $acd) : ?>
     347                                    <tr>
     348                                        <td><?= date('d/m/Y h:i:sa', $acd->timestamp) ?></td>
     349                                        <td><?= $acd->ip_address ?></td>
     350                                    </tr>
     351                                    <?php endforeach; ?>
     352                                    </tbody>
     353                                    <tfoot>
     354                                        <tr>
     355                                            <th><?= __("Date/Time", 'akptext') ?></th>
     356                                            <th><?= __("IP Address", 'akptext') ?></th>
     357                                        </tr>
     358                                    </tfoot>
     359                                </table>
     360                            </div>
     361                            <div class="akp_detailed_date_details">
     362                                <div class="choose_custom_date">
     363                                    <h4><?= __("Choose your date range", 'akptext') ?>:</h4>
     364                                    <label><?= __("From", 'akptext') ?>: </label><input type="text" class="akp_datepicker from_adkingpro_date" />
     365                                    <label><?= __("To", 'akptext') ?>: </label><input type="text" class="akp_datepicker to_adkingpro_date" />
     366                                    <a class="akp_custom_date" rel="<?= $post_id ?>"><?= __("Search", 'akptext') ?></a>
     367                                </div>
     368                                <div class="returned_data">
     369
     370                                </div>
     371                            </div>
    366372                        </div>
    367373                    </div>
     374                    <br style="clear: both;" />
    368375                </div>
    369             </div>
    370             <br style="clear: both;" />
    371         </div>
    372         <?php
    373         endwhile;
    374         wp_reset_query();
     376            <?php
     377            endwhile;
     378            wp_reset_query();
     379        else:
     380            ?>
     381       
     382            <section id="auth-button"></section>
     383            <section id="view-selector"></section>
     384            <section id="timeline"></section>
     385
     386            <script>
     387            (function(w,d,s,g,js,fjs){
     388              g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(cb){this.q.push(cb)}};
     389              js=d.createElement(s);fjs=d.getElementsByTagName(s)[0];
     390              js.src='https://apis.google.com/js/platform.js';
     391              fjs.parentNode.insertBefore(js,fjs);js.onload=function(){g.load('analytics')};
     392            }(window,document,'script'));
     393            </script>
     394
     395            <script>
     396            gapi.analytics.ready(function() {
     397
     398              // Step 3: Authorize the user.
     399
     400              var CLIENT_ID = '492828431152-r55e51ifna6b2j0ecdmg2to75976e1lf.apps.googleusercontent.com';
     401
     402              gapi.analytics.auth.authorize({
     403                container: 'auth-button',
     404                clientid: CLIENT_ID,
     405              });
     406
     407              // Step 4: Create the view selector.
     408
     409              var viewSelector = new gapi.analytics.ViewSelector({
     410                container: 'view-selector'
     411              });
     412
     413              // Step 5: Create the timeline chart.
     414
     415              var timeline = new gapi.analytics.googleCharts.DataChart({
     416                reportType: 'ga',
     417                query: {
     418                  'dimensions': 'ga:date',
     419                  'metrics': 'ga:sessions',
     420                  'start-date': '30daysAgo',
     421                  'end-date': 'yesterday',
     422                },
     423                chart: {
     424                  type: 'LINE',
     425                  container: 'timeline'
     426                }
     427              });
     428
     429              // Step 6: Hook up the components to work together.
     430
     431              gapi.analytics.auth.on('success', function(response) {
     432                viewSelector.execute();
     433              });
     434
     435              viewSelector.on('change', function(ids) {
     436                var newIds = {
     437                  query: {
     438                    ids: ids
     439                  }
     440                }
     441                timeline.set(newIds).execute();
     442              });
     443            });
     444            </script>
     445            <?php
     446        endif;
    375447        ?>
     448    </div>
    376449</div>
    377 </div>
     450
     451<?php
     452    /* REPORTING SETUP INSTRUCTIONS
     453     *
     454     *      1. Navigate to https://console.developers.google.com and create a 'project' for your site if you haven't already
     455     *      2. Once in your project, we need to "Enable an API" which is under APIs & Auth -> APIs
     456     *      3. Browse for APIs and search for Analytics API. Turn this on.
     457     *      4. Under APIs & Auth in the menu, click on Credentials
     458     *      5. Click on create a Client ID. If you are prompted to complete the consent screen, do so and return to the start of this step.
     459     *      6. When prompted, choose "Web Application" as the Application type
     460     *      7.
     461     *
     462     */
     463?>
  • adkingpro/trunk/includes/screens/settings.php

    r934037 r1060727  
    9292                    <input type="checkbox" name="akp_ga_intergrated" id="akp_ga_intergrated" value="1"<?php if ($ga_intergrated == 1) echo " checked" ?> />
    9393                </td>
    94                 <td>This removes all tracking and reporting locally</td>
     94                <td>This removes all tracking and reporting locally <strong style="font-style: italic;">(Recommended but requires Google Analytics to be used on site)</strong></td>
    9595                </tr>
    9696
     
    301301                    <textarea name="akp_custom_css" style="width: 100%; height: 200px;"><?= $css ?></textarea>
    302302                </td>
     303                </tr>
     304               
     305                <tr valign="top">
     306                    <th scope="row" colspan="3"><h2><?= __("House-keeping", 'akptext' ); ?></h2></th>
     307                </tr>
     308               
     309                <tr valign="top">
     310                <th scope="row"><?= __("Remove all data on deletion of plugin", 'akptext' ); ?></th>
     311                <td>
     312                    <?php $clear_data = get_option('akp_clear_on_delete'); ?>
     313                    <input type="hidden" name="akp_clear_on_delete" value="0" />
     314                    <input type="checkbox" name="akp_clear_on_delete" id="akp_clear_on_delete" value="1"<?php if ($clear_data == 1) echo " checked" ?> />
     315                </td>
     316                <td>If checked, ALL data related to Ad King Pro will be removed from your environment.</td>
    303317                </tr>
    304318            </table>
  • adkingpro/trunk/includes/widget.php

    r938767 r1060727  
    6666            <select class="widefat" id="<?php echo $this->get_field_id( 'banner' ); ?>" name="<?php echo $this->get_field_name( 'banner' ); ?>">
    6767                <option value=''><?= __('Select Randomly', 'akptext') ?></option>
    68                 <?php $banners = get_posts(array('post_type'=>'adverts_posts'));
     68                <?php $banners = get_posts(array('post_type'=>'adverts_posts', 'posts_per_page'=>-1));
    6969                foreach ($banners as $b) : ?>
    7070                <option value='<?= $b->ID ?>'<?php if ($b->ID == esc_attr( $banner )) echo ' selected'; ?>><?= $b->ID ?></option>
  • adkingpro/trunk/readme.txt

    r938767 r1060727  
    44Tags: advertising, ads, ad, adverts, advert, advertisements, advertisement, advertise, stats, stat, statistics, statistic, promotions, promotion, banners, banner, tracking, track, detailed, adkingpro, ad king pro, page, post, reporting, reports, report, csv, pdf, revenue, charge, money, theme, themes, flash, adsense, text, resize, rotate, slideshow, multiple
    55Requires at least: 3.0.1
    6 Tested up to: 3.9.1
    7 Stable tag: 1.9.15
     6Tested up to: 4.0
     7Stable tag: 1.9.16
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    137137== Changelog ==
    138138
     139= 1.9.16 =
     140* Updates for 4.0
     141* Option to remove all stored data on delete
     142* Fix to widget banner ID dropdown
     143
    139144= 1.9.15 =
    140145* Fix to widget output when using single banner calls and having the right advert type added as class
     
    265270== Upgrade Notice ==
    266271
     272= 1.9.16 =
     273* Updates for 4.0
     274* Option to remove all stored data on delete
     275
    267276= 1.9.15 =
    268277* Fix to widget output when using single banner calls and having the right advert type added as class
Note: See TracChangeset for help on using the changeset viewer.