Plugin Directory

Changeset 1000862


Ignore:
Timestamp:
10/02/2014 07:38:34 PM (12 years ago)
Author:
switzer
Message:

Update preview, add analytics functionality, reword quality

Location:
advertising-manager/trunk
Files:
6 added
9 edited

Legend:

Unmodified
Added
Removed
  • advertising-manager/trunk/advertising-manager.php

    r995695 r1000862  
    11<?php
     2
    23/*
    34Plugin Name: Advertising Manager
     
    67Author: Scott Switzer
    78Author URI: http://github.com/switzer
    8 Version: 3.4.28
     9Version: 3.4.29
    910Text Domain: advman
    1011Domain Path: /languages
     
    2930
    3031
    31     define('ADVMAN_VERSION', '3.4.28');
     32    define('ADVMAN_VERSION', '3.4.29');
    3233    define('ADVMAN_PATH', dirname(__FILE__));
    3334    define('ADVMAN_LIB', ADVMAN_PATH . '/lib/Advman');
  • advertising-manager/trunk/deploy.txt

    r962336 r1000862  
    3030    3.  in the readme file (stable tag at the top)
    3131    4.  In the readme file (Changelog)
    32     5.  in this build file (search for the version number 3.4.28 - there are a number of places in this file where the version exists)
     32    5.  in this build file (search for the version number 3.4.29 - there are a number of places in this file where the version exists)
    3333    6.  check the upgrade to make sure any version upgrades are correct
    3434
     
    4848- Tag the version in wordpress
    4949    cd ~/code/wordpress/advertising-manager
    50     svn cp trunk tags/3.4.28
    51     svn ci -m "tagging version 3.4.28"
     50    svn cp trunk tags/3.4.29
     51    svn ci -m "tagging version 3.4.29"
  • advertising-manager/trunk/developer.txt

    r958424 r1000862  
    99vagrant ssh
    1010
     11# Building a new docker file (not needed if you have not updated wordpress)
     12docker build --no-cache -t switzer/wordpress /home/core/share/switzer/wordpress/
     13
    1114# From coreos command prompt
    1215docker run --name mysql -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 -d mysql
     
    1720# You will now be inside the docker instance at the command prompt
    1821ln -s /usr/src/code/wordpress/advertising-manager/trunk /var/www/html/wp-content/plugins/advertising-manager
    19 exit;
     22exit
    2023
    2124# Back to the coreos command prompt
  • advertising-manager/trunk/lib/Advman/Admin.php

    r995695 r1000862  
    11<?php
    22require_once (ADVMAN_LIB . '/Tools.php');
    3 require_once (ADVMAN_LIB . '/AdList.php');
     3require_once (ADVMAN_LIB . '/List.php');
     4require_once (ADVMAN_LIB . '/Analytics.php');
    45
    56class Advman_Admin
     
    1213        global $wp_version;
    1314
    14         add_object_page(__('Ads', 'advman'), __('Ads', 'advman'), 8, 'advman-list', array('Advman_Ad_List','process'), ADVMAN_URL . '/images/advman-menu-icon.svg');
    15         $ad_list_hook = add_submenu_page('advman-list', __('All Ads', 'advman'), __('All Ads', 'advman'), 8, 'advman-list', array('Advman_Ad_List','process'));
     15        add_object_page(__('Ads', 'advman'), __('Ads', 'advman'), 8, 'advman-list', array('Advman_List','process'), ADVMAN_URL . '/images/advman-menu-icon.svg');
     16        $list_hook = add_submenu_page('advman-list', __('All Ads', 'advman'), __('All Ads', 'advman'), 8, 'advman-list', array('Advman_List','process'));
     17//        $analytics_hook = add_submenu_page('advman-list', __('Analytics', 'advman'), __('Analytics', 'advman'), 8, 'advman-analytics', array('Advman_Analytics','process'));
    1618        add_submenu_page('advman-list', __('Create New Ad', 'advman'), __('Create New', 'advman'), 8, 'advman-ad-new', array('Advman_Admin','create'));
    1719        add_submenu_page(null, __('Edit Ad', 'advman'), __('Edit', 'advman'), 8, 'advman-ad', array('Advman_Admin','edit_ad'));
     
    2123
    2224        // List items
    23         add_action("load-$ad_list_hook", array('Advman_Ad_List', 'add_options'));
    24         add_action("admin_head-$ad_list_hook", array('Advman_Ad_List', 'add_contextual_help' ));
    25         add_action("admin_head-$ad_list_hook", array('Advman_Ad_List', 'add_css' ));
     25        add_action("load-$list_hook", array('Advman_List', 'add_options'));
     26        add_action("admin_head-$list_hook", array('Advman_List', 'add_contextual_help' ));
     27        add_action("admin_head-$list_hook", array('Advman_List', 'add_css' ));
     28        // Analytics items
     29//        add_action("load-$analytics_hook", array('Advman_Analytics', 'add_options'));
     30//        add_action("admin_head-$analytics_hook", array('Advman_Analytics', 'add_contextual_help' ));
     31//        add_action("admin_head-$analytics_hook", array('Advman_Analytics', 'add_css' ));
    2632
    2733        add_action('admin_enqueue_scripts', array('Advman_Admin', 'admin_enqueue_scripts'));
     
    5157            case 'advman-ad-new'     : Advman_Admin::import_action($action); break;
    5258            case 'advman-ad'         : Advman_Admin::ad_action($action); break;
    53             case 'advman-list'       : Advman_Ad_List::init(); break;
     59            case 'advman-analytics'  : Advman_Analytics::init(); break;
     60            case 'advman-list'       : Advman_List::init(); break;
    5461            case 'advman-network'    : Advman_Admin::network_action($action); break;
    5562        }
     
    359366                }
    360367                break;
     368
     369            case 'advman-analytics' :
     370                $template = Advman_Tools::get_template('Table_Analytics');
     371                $template->display();
     372                break;
    361373        }
    362374       
    363375        if (!$template) {
    364             $template = Advman_Tools::get_template('Ad_List');
     376            $template = Advman_Tools::get_template('Table_List');
    365377            $template->display();
    366378        }
  • advertising-manager/trunk/lib/Advman/Template/Ad/List.php

    r958719 r1000862  
    11<?php
    2 class Advman_Template_Ad_List
     2class Advman_Template_List
    33{
    44    function display($target = null, $filter = null)
  • advertising-manager/trunk/lib/Advman/Upgrade.php

    r995597 r1000862  
    2424    function advman_3_4_29(&$data)
    2525    {
     26        // Convert stats to a new format
     27        $stats = $data['stats'];
     28        $new_stats = array();
     29
     30        foreach ($stats as $dt => $stat) {
     31            foreach ($stat as $adId => $impressions) {
     32                $new_stats['d'][$dt]['ad'][$adId]['i'] = $impressions;
     33            }
     34        }
     35        $data['stats'] = $new_stats;
     36
    2637        // Remove publisher-id  (not used)
    2738        if (isset($data['settings']['publisher-id'])) {
  • advertising-manager/trunk/lib/OX/Swifty.php

    r947064 r1000862  
    5757        return $this->dal->update_stats($stats);
    5858    }
    59    
    60     function getStats()
    61     {
    62         return $this->dal->select_stats();
    63     }
    64    
    65     function incrementStats($ad)
     59
     60    /*
     61     * The goal of this method is to give back stats for a date range:
     62     * - by entity
     63     * - # imps
     64     * - # clicks
     65     * - # views
     66     * - # vs. prev. imps
     67     * - # vs. prev. clicks
     68     * - # vs. prev. views
     69     * returns an array of this structure:
     70     * [ad_id][i] = number of impressions
     71     * [ad_id][i-] = number of impressions from the immediately previous segment
     72     */
     73    function getStats($date_range = null, $entity_breakdown = 'ad', $date_breakdown = 'hour', $previous = false)
     74    {
     75        // If no date range specified, then get it for today
     76        if (!$date_range) {
     77            $today = date('Y-m-d');
     78            $date_range = array(
     79                'begin' => $today,
     80                'end' => $today
     81            );
     82        }
     83
     84        // For now, entity breakdown is always 'ads'
     85        $entity_breakdown = 'ads';
     86
     87        // For now, date breakdown is always by day
     88        // $date_breakdown = 'd';
     89
     90        // If previous timeperiod, find the range of days immediately preceding the date range
     91        if ($previous) {
     92
     93        }
     94        // Get the begin and end dates.  These dates are passed in as 'Y-m-d'.
     95        $begin = strtotime($date_range['begin']);
     96        $end = strtotime($date_range['end']) + 86400;  // begin/end are inclusive, so add a day to the end
     97
     98        // If you want the previous time period, then some math is needed to get the start and end dates of the previous timeperiod
     99        if ($previous) {
     100            $diff = ($end - $begin);
     101            $begin -= $diff;
     102            $end -= $diff;
     103        }
     104
     105        // Get the raw statistics
     106        $stats = $this->dal->select_stats();
     107
     108        // Sum up stats for this date range
     109        $sum_stats = array();
     110        foreach ($stats['d'] as $dtstr => $stat) {
     111            $dt = strtotime($dtstr);
     112            if ($dt >= $begin && $dt < $end) {
     113                // Get the entity breakdown
     114                $s = $stat[$entity_breakdown];
     115                // Loop through each of the entities and sum up
     116                foreach ($s as $id => $data) {
     117                    if (!isset($sum_stats[$id])) {
     118                        $sum_stats[$id] = $data;
     119                    } else {
     120                        foreach($data as $v => $n) {
     121                            // Either create a new node or increment the node
     122                            $sum_stats[$id][$v] = (!isset($sum_stats[$id][$v])) ? $n : $sum_stats[$id][$v] + $n;
     123                        }
     124                        $sum_stats[$id]['i'] += $data['i'];
     125                    }
     126                    if ($entity_breakdown == 'ads') {
     127                        $ad = $this->getAd($id);
     128                        if ($ad) {
     129                            $sum_stats[$id]['name'] = $ad->name;
     130                        }
     131                    }
     132                }
     133            }
     134        }
     135
     136        return $sum_stats;
     137    }
     138
     139    function incrementStats($ad, $type = 'i')
    66140    {
    67141        $date = date("Y-m-d");
     142        $hour = date('H');
    68143        $adId = $ad->id;
     144
    69145        if ($this->getSetting('stats')) {
    70             $stats = $this->getStats();
    71             if (empty($stats[$date][$adId])) {
    72                 $stats[$date][$adId] = 0;
    73             }
    74             $stats[$date][$adId]++;
     146
     147            $stats = $this->dal->select_stats();
     148
     149            // Increment date stats
     150            if (empty($stats['d'][$date]['ads'][$adId][$type])) {
     151                $stats['d'][$date]['ads'][$adId][$type] = 0;
     152            }
     153            $stats['d'][$date]['ads'][$adId][$type]++;
     154
     155            // Increment hour stats
     156            if (empty($stats['h'][$date][$hour]['ads'][$adId][$type])) {
     157                $stats['h'][$date][$hour]['ads'][$adId][$type] = 0;
     158            }
     159            $stats['h'][$date][$hour]['ads'][$adId][$type]++;
     160
    75161            $this->setStats($stats);
    76162        }
  • advertising-manager/trunk/readme.txt

    r962999 r1000862  
    44Tags: ad, admin, adsense, adserver, advertisement, advertising, affiliate, banner, google, manager, rotate, widget
    55Requires at least: 2.5
    6 Tested up to: 3.9.2
    7 Stable tag: 3.4.28
     6Tested up to: 4.0
     7Stable tag: 3.4.29
    88License: GPLv2 or later
    99
     
    9797* By default, show a placeholder ad (not the real ad) for admin users so that ad quality is higher
    9898* Add ability to show in an email
    99 * Send daily and weekly statistics information
    100 
     99* Move stats into its own table http://codex.wordpress.org/Creating_Tables_with_Plugins
     100
     101== Bugs ==
     102
     103* Setting number of ads to display in ad-list does not work.
     104* Unable to configure what columns to display in ad-list.
    101105
    102106== Upgrade Notice ==
    103107
    104 = 3.4.28 =
    105 * Fixed bug when using filtering by tag or category
    106 * Removed templates for wordpress versions 2.4 and earlier
    107 * Reformatted code in preparation for ad slots
     108= 3.4.29 =
     109* Tested for Wordpress 4.0
     110* Reformatted code to prepare for Analytics - coming soon!
     111* Fixed bug with previewing ad
    108112
    109113== Change Log ==
     114
     115= 3.4.29 =
     116* Tested for Wordpress 4.0
     117* Reformatted code to prepare for Analytics - coming soon!
     118* Fixed bug with previewing ad
    110119
    111120= 3.4.28 =
  • advertising-manager/trunk/scripts/advman.css

    r949874 r1000862  
    4444    width: 10%;
    4545}
     46.fixed .column-impressions {
     47    text-align: right;
     48}
    4649.fixed .column-advman-notes {
    4750    width: 15%;
Note: See TracChangeset for help on using the changeset viewer.