Changeset 915706
- Timestamp:
- 05/16/2014 04:45:42 PM (10 years ago)
- Location:
- analytics360/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
analytics360/trunk/README.txt
r821288 r915706 4 4 Tags: analytics, google-analytics, email, statistics, stats, dashboard 5 5 Requires at least: 3.1 6 Tested up to: 3. 87 Stable tag: 1.3. 16 Tested up to: 3. 7 Stable tag: 1.3. 8 8 9 9 MailChimp'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. … … 81 81 == Changelog == 82 82 83 84 85 86 87 83 88 = 1.3.1 = 84 89 -
analytics360/trunk/analytics360.php
r821288 r915706 4 4 Plugin URI: http://www.mailchimp.com/wordpress_analytics_plugin/?pid=wordpress&source=website 5 5 Description: 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. 16 Version: 1.3. 7 7 Author: Crowd Favorite 8 8 Author URI: http://crowdfavorite.com … … 11 11 // ini_set('display_errors', '1'); ini_set('error_reporting', E_ALL); 12 12 13 define('A360_VERSION', '1.3. 1');13 define('A360_VERSION', '1.3.'); 14 14 15 15 load_plugin_textdomain('analytics360'); … … 32 32 ); 33 33 } 34 34 35 35 if ($a360_page == 'dashboard') { 36 36 header('X-UA-Compatible: IE=7'); // ask ie8 to behave like ie7 for the sake of vml … … 125 125 add_action('after_plugin_row', 'a360_warn_on_plugin_page'); 126 126 127 // returns false only when we're not using our own MCAPI, 127 // returns false only when we're not using our own MCAPI, 128 128 // and the existing version is < 2.1. 129 129 function a360_MCAPI_is_compatible() { … … 179 179 '; 180 180 } 181 181 182 182 echo $extra; 183 183 184 184 echo a360_troubleshoot_message(); 185 185 echo '</div>'; … … 263 263 } 264 264 else { 265 // connected, but no token in response. 265 // connected, but no token in response. 266 266 $error_messages = array($repsonse['body']); 267 267 } … … 292 292 $end = (preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $_GET['end_date']) ? $_GET['end_date'] : '0000-00-00'); 293 293 add_filter('posts_where', create_function( 294 '$where', 294 '$where', 295 295 'return $where." AND post_date >= \''.$start.'\' AND post_date < \''.$end.'\'";' 296 296 )); 297 297 $results = query_posts('post_status=publish&posts_per_page=999'); 298 298 299 299 header('Content-type: text/javascript'); 300 300 die(cf_json_encode(array( … … 354 354 case 'get_ga_data': 355 355 global $a360_ga_token, $a360_ga_profile_id; 356 356 357 357 $parameters = array( 358 358 'start-date' => $_GET['start_date'], … … 412 412 } 413 413 } 414 414 415 415 header('Content-type: text/javascript'); 416 416 die(cf_json_encode(array( … … 471 471 break; 472 472 } 473 473 474 474 $wp_http = a360_get_wp_http(); 475 475 $url = 'https://www.google.com/analytics/feeds/data?'.build_query($parameters, '', '&'); 476 476 477 477 $request_args = array( 478 478 'headers' => a360_get_authsub_headers(), … … 603 603 global $a360_api_key, $a360_has_key, $a360_ga_token; 604 604 header('Content-type: text/javascript'); 605 605 606 606 if ((!isset($a360_ga_token) || empty($a360_ga_token)) && $_GET['a360_page'] == 'dashboard') { 607 607 // some odd js errors happen if we don't actually have content on the dashboard page. … … 613 613 require('js/jquery.datePickerMultiMonth.js'); 614 614 require('js/a360.js'); 615 615 616 616 $pageName = 'dashboard'; 617 617 if (in_array($_GET['a360_page'], array('dashboard', 'settings'))) { … … 628 628 629 629 /** 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 631 631 * running on cURL. Left in for legacy reasons, to remove in the future 632 632 * after thorough testing. … … 670 670 671 671 $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>' : 674 674 '' 675 675 ); 676 676 677 677 include('php/header.php'); 678 678 include('php/settings.php'); … … 683 683 global $a360_api_key, $a360_ga_token, $a360_has_key; 684 684 $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>' : 687 687 '' 688 688 ); 689 689 690 690 $a360_list_options = array(); 691 691 692 692 if (!empty($a360_api_key)) { 693 693 $api = a360_get_mcapi($a360_api_key); … … 714 714 715 715 function a360_render_chimp_chatter() { 716 $ rss= a360_get_chimp_chatter(10);717 if ($ rss!== false) {716 $ = a360_get_chimp_chatter(10); 717 if ($ !== false) { 718 718 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']); 720 721 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 725 726 ); 726 727 } … … 730 731 731 732 function a360_get_chimp_chatter($num_items = -1) { 732 $url = a360_get_chimp_chatter_url();733 if ($url) {734 if ($rss = fetch_feed($url)) { // intentional assignment735 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 assignment748 return $url;749 }750 733 global $a360_api_key; 751 734 if (!empty($a360_api_key)) { 752 735 $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 747 function a360_get_chimp_chatter_url() { 748 // Deprecated 749 return false; 780 750 } 781 751 … … 813 783 814 784 /** 815 * Adapted from: 816 * 785 * Adapted from: 786 * 817 787 * GAPI - Google Analytics PHP Interface 818 788 * http://code.google.com/p/gapi-google-analytics-php-interface/ … … 827 797 $results = null; 828 798 $results = array(); 829 799 830 800 $report_root_parameters = array(); 831 801 $report_aggregate_metrics = array(); 832 802 833 803 //Load root parameters 834 804 835 805 $report_root_parameters['updated'] = strval($xml->updated); 836 806 $report_root_parameters['generator'] = strval($xml->generator); 837 807 $report_root_parameters['generatorVersion'] = strval($xml->generator->attributes()); 838 808 839 809 $open_search_results = $xml->children('http://a9.com/-/spec/opensearchrss/1.0/'); 840 810 841 811 foreach($open_search_results as $key => $open_search_result) { 842 812 $report_root_parameters[$key] = intval($open_search_result); 843 813 } 844 814 845 815 $google_results = $xml->children('http://schemas.google.com/analytics/2009'); 846 816 … … 849 819 $report_root_parameters[str_replace('ga:','',$attr->name)] = strval($attr->value); 850 820 } 851 821 852 822 $report_root_parameters['startDate'] = strval($google_results->startDate); 853 823 $report_root_parameters['endDate'] = strval($google_results->endDate); 854 824 855 825 //Load result aggregate metrics 856 826 857 827 foreach($google_results->aggregates->metric as $aggregate_metric) { 858 828 $attr = $aggregate_metric->attributes(); … … 867 837 } 868 838 } 869 839 870 840 //Load result entries 871 841 872 842 foreach($xml->entry as $entry) { 873 843 $metrics = array(); 874 844 $children = $entry->children('http://schemas.google.com/analytics/2009'); 875 845 foreach($children->metric as $metric) { 876 $attr = $metric->attributes(); 846 $attr = $metric->attributes(); 877 847 $metric_value = strval($attr->value); 878 848 $name = $attr->name; 879 849 880 850 //Check for float, or value with scientific notation 881 851 if(preg_match('/^(\d+\.\d+)|(\d+E\d+)|(\d+.\d+E\d+)$/',$metric_value)) { … … 886 856 } 887 857 } 888 858 889 859 $dimensions = array(); 890 860 $children = $entry->children('http://schemas.google.com/analytics/2009'); … … 893 863 $dimensions[str_replace('ga:','',$attr->name)] = strval($attr->value); 894 864 } 895 865 896 866 $results[] = array('metrics' => $metrics, 'dimensions' => $dimensions); 897 867 } 898 868 899 869 return $results; 900 870 } … … 919 889 * to use php_json_encode in its stead 920 890 * Works on iteratable objects as well - stdClass is iteratable, so all WP objects are gonna be iteratable 921 */ 891 */ 922 892 if(!function_exists('cf_json_encode')) { 923 893 function cf_json_encode($data) { … … 925 895 else { return cfjson_encode($data); } 926 896 } 927 897 928 898 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 933 903 return str_replace( 934 904 array( -
analytics360/trunk/css/a360.css
r821288 r915706 702 702 } 703 703 704 705 706 704 div.dp-popup h2 { 707 705 font-size:16px; … … 777 775 } 778 776 #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; 780 784 } 781 785 #chatter-messages .sent { … … 785 789 background-image: url(<?php echo plugins_url('/analytics360/images/chatter-icons/flag_16.png');?>); 786 790 background-color:#fff; 787 font-size:1em;color:#369; 791 font-size:1em; 792 color:#369; 788 793 } 789 794 #chatter-messages .best_clicks,#chatter-messages .best_opens { … … 799 804 } 800 805 #chatter-messages .unsubscribes { 801 background-position:8px -5063px;802 806 background-image: url(<?php echo plugins_url('/analytics360/images/chatter-icons/deleteuser_16.png');?>); 803 807 } … … 817 821 background-image: url(<?php echo plugins_url('/analytics360/images/chatter-icons/billing-info_16.png');?>); 818 822 background-color:#a4c6e2; 819 font-size:1em;color:#369; 823 font-size:1em; 824 color:#369; 820 825 } 821 826
Note: See TracChangeset
for help on using the changeset viewer.