Plugin Directory

Changeset 915706

Timestamp:
05/16/2014 04:45:42 PM (10 years ago)
Author:
alexkingorg
Message:

version 1.3.2

Location:
analytics360/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • analytics360/trunk/README.txt

    r821288 r915706  
    44Tags: analytics, google-analytics, email, statistics, stats, dashboard
    55Requires at least: 3.1
    6 Tested up to: 3.8
    7 Stable tag: 1.3.1
     6Tested up to: 3.
     7Stable tag: 1.3.
    88
    99MailChimp's Analytics360 plugin allows you to pull Google Analytics and MailChimp data directly into your dashboard, so you can access robust analytics tools without leaving WordPress.
     
    8181== Changelog ==
    8282
     83
     84
     85
     86
     87
    8388= 1.3.1 =
    8489
  • analytics360/trunk/analytics360.php

    r821288 r915706  
    44Plugin URI: http://www.mailchimp.com/wordpress_analytics_plugin/?pid=wordpress&source=website
    55Description: Allows you to pull Google Analytics and MailChimp data directly into your dashboard, so you can access robust analytics tools without leaving WordPress. Compliments of <a href="http://mailchimp.com/">MailChimp</a>.
    6 Version: 1.3.1
     6Version: 1.3.
    77Author: Crowd Favorite
    88Author URI: http://crowdfavorite.com
     
    1111// ini_set('display_errors', '1'); ini_set('error_reporting', E_ALL);
    1212
    13 define('A360_VERSION', '1.3.1');
     13define('A360_VERSION', '1.3.');
    1414
    1515load_plugin_textdomain('analytics360');
     
    3232        );
    3333    }
    34    
     34
    3535    if ($a360_page == 'dashboard') {
    3636        header('X-UA-Compatible: IE=7');    // ask ie8 to behave like ie7 for the sake of vml
     
    125125add_action('after_plugin_row', 'a360_warn_on_plugin_page');
    126126
    127 // returns false only when we're not using our own MCAPI, 
     127// returns false only when we're not using our own MCAPI,
    128128// and the existing version is < 2.1.
    129129function a360_MCAPI_is_compatible() {
     
    179179        ';
    180180    }
    181    
     181
    182182    echo $extra;
    183    
     183
    184184    echo a360_troubleshoot_message();
    185185    echo '</div>';
     
    263263                        }
    264264                        else {
    265                             // connected, but no token in response. 
     265                            // connected, but no token in response.
    266266                            $error_messages = array($repsonse['body']);
    267267                        }
     
    292292                $end = (preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $_GET['end_date']) ? $_GET['end_date'] : '0000-00-00');
    293293                add_filter('posts_where', create_function(
    294                     '$where', 
     294                    '$where',
    295295                    'return $where." AND post_date >= \''.$start.'\' AND post_date < \''.$end.'\'";'
    296296                ));
    297297                $results = query_posts('post_status=publish&posts_per_page=999');
    298                
     298
    299299                header('Content-type: text/javascript');
    300300                die(cf_json_encode(array(
     
    354354            case 'get_ga_data':
    355355                global $a360_ga_token, $a360_ga_profile_id;
    356                
     356
    357357                $parameters = array(
    358358                    'start-date' => $_GET['start_date'],
     
    412412                        }
    413413                    }
    414                    
     414
    415415                    header('Content-type: text/javascript');
    416416                    die(cf_json_encode(array(
     
    471471                        break;
    472472                    }
    473                    
     473
    474474                    $wp_http = a360_get_wp_http();
    475475                    $url = 'https://www.google.com/analytics/feeds/data?'.build_query($parameters, '', '&');
    476                
     476
    477477                    $request_args = array(
    478478                        'headers' => a360_get_authsub_headers(),
     
    603603    global $a360_api_key, $a360_has_key, $a360_ga_token;
    604604    header('Content-type: text/javascript');
    605    
     605
    606606    if ((!isset($a360_ga_token) || empty($a360_ga_token)) && $_GET['a360_page'] == 'dashboard') {
    607607        // some odd js errors happen if we don't actually have content on the dashboard page.
     
    613613    require('js/jquery.datePickerMultiMonth.js');
    614614    require('js/a360.js');
    615    
     615
    616616    $pageName = 'dashboard';
    617617    if (in_array($_GET['a360_page'], array('dashboard', 'settings'))) {
     
    628628
    629629/**
    630  * Formerly worked around a bug in WP 2.7's implementation of WP_Http 
     630 * Formerly worked around a bug in WP 2.7's implementation of WP_Http
    631631 * running on cURL. Left in for legacy reasons, to remove in the future
    632632 * after thorough testing.
     
    670670
    671671    $notification = (
    672         isset($_GET['a360_error']) ? 
    673             '<span class="error" style="padding:3px;"><strong>Error</strong>: '.esc_html(stripslashes($_GET['a360_error'])).'</span>' : 
     672        isset($_GET['a360_error']) ?
     673            '<span class="error" style="padding:3px;"><strong>Error</strong>: '.esc_html(stripslashes($_GET['a360_error'])).'</span>' :
    674674            ''
    675675    );
    676        
     676
    677677    include('php/header.php');
    678678    include('php/settings.php');
     
    683683    global $a360_api_key, $a360_ga_token, $a360_has_key;
    684684    $notification = (
    685         isset($_GET['a360_error']) ? 
    686             '<span class="error" style="padding:3px;"><strong>Error</strong>: '.esc_html(stripslashes($_GET['a360_error'])).'</span>' : 
     685        isset($_GET['a360_error']) ?
     686            '<span class="error" style="padding:3px;"><strong>Error</strong>: '.esc_html(stripslashes($_GET['a360_error'])).'</span>' :
    687687            ''
    688688    );
    689    
     689
    690690    $a360_list_options = array();
    691    
     691
    692692    if (!empty($a360_api_key)) {
    693693        $api = a360_get_mcapi($a360_api_key);
     
    714714
    715715function a360_render_chimp_chatter() {
    716     $rss = a360_get_chimp_chatter(10);
    717     if ($rss !== false) {
     716    $ = a360_get_chimp_chatter(10);
     717    if ($ !== false) {
    718718        echo '<ul id="chatter-messages">';
    719         foreach ((array)$rss->items as $item) {
     719        foreach ((array)$chimp_chatter as $item) {
     720            $class = str_replace('lists:', '', $item['type']);
    720721            printf(
    721                 '<li class="'.$item['category'].'"><a href="%1$s" title="%2$s">%3$s</a></li>',
    722                 clean_url($item['link']),
    723                 attribute_escape(strip_tags($item['description'])),
    724                 $item['title']
     722                '<li class="'..'"><a href="%1$s" title="%2$s">%3$s</a></li>',
     723                ']),
     724                '])),
     725               
    725726            );
    726727        }
     
    730731
    731732function a360_get_chimp_chatter($num_items = -1) {
    732     $url = a360_get_chimp_chatter_url();
    733     if ($url) {
    734         if ($rss = fetch_feed($url)) {  // intentional assignment
    735             if (!is_wp_error($rss)) {
    736                 if ($num_items !== -1) {
    737                     $rss->items = array_slice($rss->items, 0, $num_items);
    738                 }
    739                 return $rss;
    740             }
    741         }
    742     }
    743     return false;
    744 }
    745 
    746 function a360_get_chimp_chatter_url() {
    747     if ($url = get_option('a360_chimp_chatter_url')) {  // intentional assignment
    748         return $url;
    749     }
    750733    global $a360_api_key;
    751734    if (!empty($a360_api_key)) {
    752735        $api = a360_get_mcapi($a360_api_key);
    753         if (!empty($api->errorCode)) {
    754             return null;
    755         }
    756        
    757         if (method_exists($api, 'getAccountDetails')) {
    758             $result = $api->getAccountDetails();
    759         }
    760         else {
    761             // this call is deprecated, but if user has an old version of MCAPI powering another MC plugin...
    762             $result = $api->getAffiliateInfo();
    763         }
    764        
    765         if (!empty($api->errorCode)) {
    766             return null;
    767         }
    768        
    769         // determine the right datacenter/endpoint
    770         list($key, $dc) = explode('-', $api->api_key, 2);
    771         if (!$dc) {
    772             $dc = 'us1';
    773         }
    774         $host = $dc.'.admin.mailchimp.com';
    775 
    776         $url = 'http://'.$host.'/chatter/feed?u='.$result['user_id'];
    777         update_option('a360_chimp_chatter_url', $url);
    778         return $url;
    779     }
     736        if (empty($api->errorCode)) {
     737            $chimp_chatter = $api->chimpChatter();
     738            if (is_array($chimp_chatter) && !empty($chimp_chatter)) {
     739                $chimp_chatter = array_slice($chimp_chatter, 0, $num_items);
     740            }
     741            return $chimp_chatter;
     742        }
     743    }
     744    return false;
     745}
     746
     747function a360_get_chimp_chatter_url() {
     748    // Deprecated
     749    return false;
    780750}
    781751
     
    813783
    814784/**
    815  * Adapted from: 
    816  * 
     785 * Adapted from:
     786 *
    817787 * GAPI - Google Analytics PHP Interface
    818788 * http://code.google.com/p/gapi-google-analytics-php-interface/
     
    827797    $results = null;
    828798    $results = array();
    829    
     799
    830800    $report_root_parameters = array();
    831801    $report_aggregate_metrics = array();
    832    
     802
    833803    //Load root parameters
    834    
     804
    835805    $report_root_parameters['updated'] = strval($xml->updated);
    836806    $report_root_parameters['generator'] = strval($xml->generator);
    837807    $report_root_parameters['generatorVersion'] = strval($xml->generator->attributes());
    838    
     808
    839809    $open_search_results = $xml->children('http://a9.com/-/spec/opensearchrss/1.0/');
    840    
     810
    841811    foreach($open_search_results as $key => $open_search_result) {
    842812        $report_root_parameters[$key] = intval($open_search_result);
    843813    }
    844    
     814
    845815    $google_results = $xml->children('http://schemas.google.com/analytics/2009');
    846816
     
    849819        $report_root_parameters[str_replace('ga:','',$attr->name)] = strval($attr->value);
    850820    }
    851    
     821
    852822    $report_root_parameters['startDate'] = strval($google_results->startDate);
    853823    $report_root_parameters['endDate'] = strval($google_results->endDate);
    854    
     824
    855825    //Load result aggregate metrics
    856    
     826
    857827    foreach($google_results->aggregates->metric as $aggregate_metric) {
    858828        $attr = $aggregate_metric->attributes();
     
    867837        }
    868838    }
    869    
     839
    870840    //Load result entries
    871    
     841
    872842    foreach($xml->entry as $entry) {
    873843        $metrics = array();
    874844        $children = $entry->children('http://schemas.google.com/analytics/2009');
    875845        foreach($children->metric as $metric) {
    876             $attr = $metric->attributes(); 
     846            $attr = $metric->attributes();
    877847            $metric_value = strval($attr->value);
    878848            $name = $attr->name;
    879            
     849
    880850            //Check for float, or value with scientific notation
    881851            if(preg_match('/^(\d+\.\d+)|(\d+E\d+)|(\d+.\d+E\d+)$/',$metric_value)) {
     
    886856            }
    887857        }
    888        
     858
    889859        $dimensions = array();
    890860        $children = $entry->children('http://schemas.google.com/analytics/2009');
     
    893863            $dimensions[str_replace('ga:','',$attr->name)] = strval($attr->value);
    894864        }
    895        
     865
    896866        $results[] = array('metrics' => $metrics, 'dimensions' => $dimensions);
    897867    }
    898        
     868
    899869    return $results;
    900870}
     
    919889 * to use php_json_encode in its stead
    920890 * Works on iteratable objects as well - stdClass is iteratable, so all WP objects are gonna be iteratable
    921  */ 
     891 */
    922892if(!function_exists('cf_json_encode')) {
    923893    function cf_json_encode($data) {
     
    925895        else { return cfjson_encode($data); }
    926896    }
    927    
     897
    928898    function cfjson_encode_string($str) {
    929         if(is_bool($str)) { 
    930             return $str ? 'true' : 'false'; 
    931         }
    932    
     899        if(is_bool($str)) {
     900            return $str ? 'true' : 'false';
     901        }
     902
    933903        return str_replace(
    934904            array(
  • analytics360/trunk/css/a360.css

    r821288 r915706  
    702702}
    703703
    704 
    705 
    706704div.dp-popup h2 {
    707705    font-size:16px;
     
    777775}
    778776#chatter-messages .screenshot {
    779     float:none;display:block;margin:2em 0;text-align:center;font-size:125%;color:#c60;text-decoration:underline;
     777    float:none;
     778    display:block;
     779    margin:2em 0;
     780    text-align:center;
     781    font-size:125%;
     782    color:#c60;
     783    text-decoration:underline;
    780784}
    781785#chatter-messages .sent {
     
    785789    background-image: url(<?php echo plugins_url('/analytics360/images/chatter-icons/flag_16.png');?>);
    786790    background-color:#fff;
    787     font-size:1em;color:#369;
     791    font-size:1em;
     792    color:#369;
    788793}
    789794#chatter-messages .best_clicks,#chatter-messages .best_opens {
     
    799804}
    800805#chatter-messages .unsubscribes {
    801     background-position:8px -5063px;
    802806    background-image: url(<?php echo plugins_url('/analytics360/images/chatter-icons/deleteuser_16.png');?>);
    803807}
     
    817821    background-image: url(<?php echo plugins_url('/analytics360/images/chatter-icons/billing-info_16.png');?>);
    818822    background-color:#a4c6e2;
    819     font-size:1em;color:#369;
     823    font-size:1em;
     824    color:#369;
    820825}
    821826
Note: See TracChangeset for help on using the changeset viewer.