Changeset 982489
- Timestamp:
- 09/05/2014 10:51:17 PM (11 years ago)
- Location:
- rs-google-analytics/trunk
- Files:
-
- 5 edited
-
public/class-rs-google-analytics.php (modified) (6 diffs)
-
public/views/public.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
rs-google-analytics-model.php (modified) (2 diffs)
-
rs-google-analytics.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rs-google-analytics/trunk/public/class-rs-google-analytics.php
r900455 r982489 2 2 class RSGoogleAnalytics { 3 3 4 const VERSION = '1.0. 0';4 const VERSION = '1.0.1'; 5 5 protected $plugin_slug = 'rs-google-analytics'; 6 6 protected static $instance = null; … … 9 9 10 10 global $wpdb; 11 global $rsgoogleanalytics;12 11 13 12 // Load public-facing style sheet and JavaScript. … … 22 21 add_filter( 'vanilla', array( $this, 'filter_method_name' ) ); 23 22 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 } 25 36 } 26 37 … … 147 158 private static function single_activate() { 148 159 // We need to install the table 149 global $vanilla_db_version;150 160 global $wpdb; 151 161 $table_name = $wpdb->prefix . "rs_google_analytics"; … … 153 163 $sql = "CREATE TABLE $table_name ( 154 164 `rsgoogleanalytics_id` int(11) NOT NULL AUTO_INCREMENT, 155 `rsgoogleanalytics_code` varchar( 9) NOT NULL,165 `rsgoogleanalytics_code` varchar(255) NOT NULL, 156 166 `rsgoogleanalytics_location` varchar(6) NOT NULL, 157 167 PRIMARY KEY (`rsgoogleanalytics_id`) … … 160 170 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 161 171 dbDelta( $sql ); 162 163 add_option( "rs_google_anal", $rsgoogleanalytics ); 172 add_option( "rs_google_anal", self::VERSION ); 164 173 } 165 174 -
rs-google-analytics/trunk/public/views/public.php
r900455 r982489 8 8 */ 9 9 // 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(); 42 11 ?> -
rs-google-analytics/trunk/readme.txt
r901272 r982489 2 2 Tags: Google, Analytics, Google Analytics, UA, UA Code, Code 3 3 Requires at least: 3.8 4 Tested up to: 3.85 Stable tag: trunk4 Tested up to: 4.0 5 Stable tag: 1.0.1 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 30 30 == Changelog == 31 31 32 = 1.0.1 = 33 * Testing for 4.0, minor bug fix 34 32 35 = 1.0 = 33 36 * First version of plugin -
rs-google-analytics/trunk/rs-google-analytics-model.php
r900455 r982489 2 2 3 3 class myCode { 4 5 // protected static $myHook = ''; 4 6 5 7 public function __construct() { … … 7 9 $this->db = $wpdb; 8 10 $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; 9 31 } 10 32 -
rs-google-analytics/trunk/rs-google-analytics.php
r900455 r982489 4 4 * Plugin URI: http://www.rstandley.co.uk 5 5 * Description: Allows you to add your Google Analytics code to either your header of footer 6 * Version: 1.0. 06 * Version: 1.0.1 7 7 * Author: Rory Standley 8 8 * Author URI: http://www.rstandley.co.uk … … 13 13 die; 14 14 } 15 16 $rsgoogleanalytics = "1.0.0";17 15 18 16 require_once(plugin_dir_path( __FILE__ ) . "rs-google-analytics-model.php");
Note: See TracChangeset
for help on using the changeset viewer.