Plugin Directory

Changeset 982489


Ignore:
Timestamp:
09/05/2014 10:51:17 PM (11 years ago)
Author:
rorystandley
Message:

Bug fixes and testing for 4.0

Location:
rs-google-analytics/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • rs-google-analytics/trunk/public/class-rs-google-analytics.php

    r900455 r982489  
    22class RSGoogleAnalytics {
    33
    4     const VERSION = '1.0.0';
     4    const VERSION = '1.0.1';
    55    protected $plugin_slug = 'rs-google-analytics';
    66    protected static $instance = null;
     
    99
    1010        global $wpdb;
    11         global $rsgoogleanalytics;
    1211
    1312        // Load public-facing style sheet and JavaScript.
     
    2221        add_filter( 'vanilla', array( $this, 'filter_method_name' ) );
    2322
    24 
     23        $this->checkDBVersion();
     24
     25    }
     26
     27    public function checkDBVersion(){
     28        global $wpdb;
     29        if (get_site_option( 'rs_google_anal' ) != self::VERSION) {
     30            // Update table
     31            $table_name = $wpdb->prefix . "rs_google_analytics";
     32            $wpdb->query("ALTER TABLE $table_name CHANGE COLUMN rsgoogleanalytics_code rsgoogleanalytics_code VARCHAR(255)");
     33            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     34            update_option( "rs_google_anal", self::VERSION );
     35        }
    2536    }
    2637
     
    147158    private static function single_activate() {
    148159        // We need to install the table
    149         global $vanilla_db_version;
    150160        global $wpdb;
    151161        $table_name = $wpdb->prefix . "rs_google_analytics";
     
    153163        $sql = "CREATE TABLE $table_name (
    154164        `rsgoogleanalytics_id` int(11) NOT NULL AUTO_INCREMENT,
    155         `rsgoogleanalytics_code` varchar(9) NOT NULL,
     165        `rsgoogleanalytics_code` varchar(255) NOT NULL,
    156166        `rsgoogleanalytics_location` varchar(6) NOT NULL,
    157167        PRIMARY KEY (`rsgoogleanalytics_id`)
     
    160170        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    161171        dbDelta( $sql );
    162 
    163         add_option( "rs_google_anal", $rsgoogleanalytics );
     172        add_option( "rs_google_anal", self::VERSION );
    164173    }
    165174
  • rs-google-analytics/trunk/public/views/public.php

    r900455 r982489  
    88 */
    99// This file is used to markup the public facing aspect of the plugin.
    10 $code = $myCode->getCode();
    11 foreach ($code as $key => $value) {
    12     $location   = $value->rsgoogleanalytics_location;
    13     $code       = $value->rsgoogleanalytics_code;
    14 }
    15 switch($location){
    16     case 'header':
    17         $hook = "wp_head";
    18     break;
    19     case 'footer':
    20         $hook = "wp_footer";
    21     break;
    22 }
    23 add_action($hook, 'outputCode');
    24 function outputCode(){
    25     $code = '<script>';
    26     $code .= '//<![CDATA[';
    27     $code .= 'var _gaq = _gaq || [];';
    28     $code .= '_gaq.push(["_setAccount", "UA-'.$code.'"]);';
    29     $code .= '_gaq.push(["_trackPageview"]);';
    30     $code .= '(function () {';
    31     $code .= 'var ga = document.createElement("script");';
    32     $code .= 'ga.type = "text/javascript";';
    33     $code .= 'ga.async = true;';
    34     $code .= 'ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";';
    35     $code .= 'var s = document.getElementsByTagName("script")[0];';
    36     $code .= 's.parentNode.insertBefore(ga, s);';
    37     $code .= '})();';
    38     $code .= '//]]>';
    39     $code .= '</script>';
    40     echo $code;
    41 }
     10$myCode->initPlugin();
    4211?>
  • rs-google-analytics/trunk/readme.txt

    r901272 r982489  
    22Tags: Google, Analytics, Google Analytics, UA, UA Code, Code
    33Requires at least: 3.8
    4 Tested up to: 3.8
    5 Stable tag: trunk
     4Tested up to: 4.0
     5Stable tag: 1.0.1
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3030== Changelog ==
    3131
     32= 1.0.1 =
     33* Testing for 4.0, minor bug fix
     34
    3235= 1.0 =
    3336* First version of plugin
  • rs-google-analytics/trunk/rs-google-analytics-model.php

    r900455 r982489  
    22
    33class myCode {
     4
     5    // protected static $myHook = '';
    46
    57    public function __construct() {
     
    79        $this->db = $wpdb;
    810        $this->table = $wpdb->prefix."rs_google_analytics";
     11    }
     12
     13    public function initPlugin(){
     14        $myCodeDetails = $this->getCode();
     15        $this->myCode = $myCodeDetails[0]->rsgoogleanalytics_code;
     16        $this->myHook = $myCodeDetails[0]->rsgoogleanalytics_location;
     17
     18        add_action("wp_".$this->myHook, array($this,'outputCode'));
     19    }
     20
     21    public function outputCode(){
     22        $code = '<script>';
     23        $code .= '(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){';
     24        $code .= '(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),';
     25        $code .= 'm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)';
     26        $code .= '})(window,document,"script","//www.google-analytics.com/analytics.js","ga");';
     27        $code .= 'ga("create", "UA-'.$this->myCode.'", "auto");';
     28        $code .= 'ga("send", "pageview");';
     29        $code .= '</script>';
     30        echo $code;
    931    }
    1032
  • rs-google-analytics/trunk/rs-google-analytics.php

    r900455 r982489  
    44 * Plugin URI:        http://www.rstandley.co.uk
    55 * Description:       Allows you to add your Google Analytics code to either your header of footer
    6  * Version:           1.0.0
     6 * Version:           1.0.1
    77 * Author:            Rory Standley
    88 * Author URI:        http://www.rstandley.co.uk
     
    1313    die;
    1414}
    15 
    16 $rsgoogleanalytics = "1.0.0";
    1715
    1816require_once(plugin_dir_path( __FILE__ ) . "rs-google-analytics-model.php");
Note: See TracChangeset for help on using the changeset viewer.