Google Analytics for WordPress by MonsterInsights - Version 1.6

Version Description

Download this release

Release Info

Developer joostdevalk
Plugin Icon 128x128 Google Analytics for WordPress by MonsterInsights
Version 1.6
Comparing to
See all releases

Code changes from version 1.5 to 1.6

Files changed (2) hide show
  1. gapp/googleanalytics.php +48 -40
  2. readme.txt +1 -1
gapp/googleanalytics.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Google Analytics for WordPress
4
  Plugin URI: http://www.joostdevalk.nl/wordpress/analytics/
5
  Description: This plugin makes it simple to add Google Analytics with extra search engines and automatic clickout and download tracking to your WordPress blog.
6
  Author: Joost de Valk
7
- Version: 1.5
8
  Author URI: http://www.joostdevalk.nl/
9
  License: GPL
10
 
@@ -272,10 +272,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
272
  $opt = get_option('GoogleAnalyticsPP');
273
  $options = unserialize($opt);
274
 
275
- global $user_level;
276
- get_currentuserinfo();
277
-
278
- if ($options["uastring"] != "" && ($user_level != 10 || $options["admintracking"]) ) {
279
  echo("\n\t<!-- Google Analytics for WordPress | http://www.joostdevalk.nl/wordpress/google-analytics/ -->\n");
280
  echo("\t<script src=\"http://www.google-analytics.com/urchin.js\" type=\"text/javascript\"></script>\n");
281
  if ( $options["extrase"] == true ) {
@@ -364,40 +361,48 @@ if ( ! class_exists( 'GA_Filter' ) ) {
364
  }
365
 
366
  function the_content($text) {
367
- static $anchorPattern = '/<a (.*?)href="(.*?)\/\/(.*?)"(.*?)>(.*?)<\/a>/i';
368
- $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_article_link'),$text);
 
 
369
  return $text;
370
  }
371
 
372
  function comment_text($text) {
373
- static $anchorPattern = '/<a (.*?)href="(.*?)\/\/(.*?)"(.*?)>(.*?)<\/a>/i';
374
- $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_comment_link'),$text);
 
 
375
  return $text;
376
  }
377
 
378
  function comment_author_link($text) {
379
- $opt = get_option('GoogleAnalyticsPP');
380
- $options = unserialize($opt);
 
381
 
382
- static $anchorPattern = '/(.*\s+.*?href\s*=\s*)["\'](.*?)["\'](.*)/';
383
- preg_match($anchorPattern, $text, $matches);
384
- if ($matches[2] == "") return $text;
385
 
386
- $target = GA_Filter::ga_get_domain($matches[2]);
387
- $coolbit = "";
388
- $origin = GA_Filter::ga_get_domain($_SERVER["HTTP_HOST"]);
389
- if ( $target["domain"] != $origin["domain"] ){
390
- if ($options['domainorurl'] == "domain") {
391
- $coolBit .= "onclick=\"javascript:urchinTracker('".$options['comautprefix']."/".$target["host"]."');\"";
392
- } else if ($options['domainorurl'] == "url") {
393
- $coolBit .= "onclick=\"javascript:urchinTracker('".$options['comautprefix']."/".$matches[2]."');\"";
394
- }
395
- }
396
- return $matches[1] . "\"" . $matches[2] . "\" " . $coolBit ." ". $matches[3];
 
 
 
397
  }
398
 
399
  function bookmarks($bookmarks) {
400
- if (!is_admin()) {
401
  $opt = get_option('GoogleAnalyticsPP');
402
  $options = unserialize($opt);
403
 
@@ -454,19 +459,22 @@ if ($opt == "") {
454
  // adds the menu item to the admin interface
455
  add_action('admin_menu', array('GA_Admin','add_config_page'));
456
 
457
- // adds the footer so the javascript is loaded
458
- if ($options['position'] =='footer') {
459
- add_action('wp_footer', array('GA_Filter','spool_analytics'));
460
- } else if ($options['position'] =='header') {
461
- add_action('wp_head', array('GA_Filter','spool_analytics'));
462
- }
463
 
464
- if ($options['trackoutbound']) {
465
- // filters alter the existing content
466
- add_filter('the_content', array('GA_Filter','the_content'), 99);
467
- add_filter('the_excerpt', array('GA_Filter','the_content'), 99);
468
- add_filter('comment_text', array('GA_Filter','comment_text'), 99);
469
- add_filter('get_bookmarks', array('GA_Filter','bookmarks'), 99);
470
- add_filter('get_comment_author_link', array('GA_Filter','comment_author_link'), 99);
471
- }
 
 
 
 
 
 
 
 
472
  ?>
4
  Plugin URI: http://www.joostdevalk.nl/wordpress/analytics/
5
  Description: This plugin makes it simple to add Google Analytics with extra search engines and automatic clickout and download tracking to your WordPress blog.
6
  Author: Joost de Valk
7
+ Version: 1.6
8
  Author URI: http://www.joostdevalk.nl/
9
  License: GPL
10
 
272
  $opt = get_option('GoogleAnalyticsPP');
273
  $options = unserialize($opt);
274
 
275
+ if ($options["uastring"] != "" && (!current_user_can('edit_users') || $options["admintracking"]) ) {
 
 
 
276
  echo("\n\t<!-- Google Analytics for WordPress | http://www.joostdevalk.nl/wordpress/google-analytics/ -->\n");
277
  echo("\t<script src=\"http://www.google-analytics.com/urchin.js\" type=\"text/javascript\"></script>\n");
278
  if ( $options["extrase"] == true ) {
361
  }
362
 
363
  function the_content($text) {
364
+ if (!current_user_can('edit_users')|| $options['admintracking'] ) {
365
+ static $anchorPattern = '/<a (.*?)href="(.*?)\/\/(.*?)"(.*?)>(.*?)<\/a>/i';
366
+ $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_article_link'),$text);
367
+ }
368
  return $text;
369
  }
370
 
371
  function comment_text($text) {
372
+ if (!current_user_can('edit_users')|| $options['admintracking'] ) {
373
+ static $anchorPattern = '/<a (.*?)href="(.*?)\/\/(.*?)"(.*?)>(.*?)<\/a>/i';
374
+ $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_comment_link'),$text);
375
+ }
376
  return $text;
377
  }
378
 
379
  function comment_author_link($text) {
380
+ if (!current_user_can('edit_users')|| $options['admintracking'] ) {
381
+ $opt = get_option('GoogleAnalyticsPP');
382
+ $options = unserialize($opt);
383
 
384
+ static $anchorPattern = '/(.*\s+.*?href\s*=\s*)["\'](.*?)["\'](.*)/';
385
+ preg_match($anchorPattern, $text, $matches);
386
+ if ($matches[2] == "") return $text;
387
 
388
+ $target = GA_Filter::ga_get_domain($matches[2]);
389
+ $coolbit = "";
390
+ $origin = GA_Filter::ga_get_domain($_SERVER["HTTP_HOST"]);
391
+ if ( $target["domain"] != $origin["domain"] ){
392
+ if ($options['domainorurl'] == "domain") {
393
+ $coolBit .= "onclick=\"javascript:urchinTracker('".$options['comautprefix']."/".$target["host"]."');\"";
394
+ } else if ($options['domainorurl'] == "url") {
395
+ $coolBit .= "onclick=\"javascript:urchinTracker('".$options['comautprefix']."/".$matches[2]."');\"";
396
+ }
397
+ }
398
+ return $matches[1] . "\"" . $matches[2] . "\" " . $coolBit ." ". $matches[3];
399
+ } else {
400
+ return $text;
401
+ }
402
  }
403
 
404
  function bookmarks($bookmarks) {
405
+ if (!is_admin() && (!current_user_can('edit_users') || $options['admintracking'] ) ) {
406
  $opt = get_option('GoogleAnalyticsPP');
407
  $options = unserialize($opt);
408
 
459
  // adds the menu item to the admin interface
460
  add_action('admin_menu', array('GA_Admin','add_config_page'));
461
 
462
+ //get_currentuserinfo();
 
 
 
 
 
463
 
464
+ // adds the footer so the javascript is loaded
465
+ if ($options['position'] =='footer') {
466
+ add_action('wp_footer', array('GA_Filter','spool_analytics'));
467
+ } else if ($options['position'] =='header') {
468
+ add_action('wp_head', array('GA_Filter','spool_analytics'));
469
+ }
470
+
471
+ if ($options['trackoutbound']) {
472
+ // filters alter the existing content
473
+ add_filter('the_content', array('GA_Filter','the_content'), 99);
474
+ add_filter('the_excerpt', array('GA_Filter','the_content'), 99);
475
+ add_filter('comment_text', array('GA_Filter','comment_text'), 99);
476
+ add_filter('get_bookmarks', array('GA_Filter','bookmarks'), 99);
477
+ add_filter('get_comment_author_link', array('GA_Filter','comment_author_link'), 99);
478
+ }
479
+ //}
480
  ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.joostdevalk.nl/donate/
4
  Tags: analytics, google analytics, statistics
5
  Requires at least: 2.2
6
  Tested up to: 2.3
7
- Stable tag: 1.5
8
 
9
  The Google Analytics for WordPress plugina automatically tracks and segments all outbound links from within posts, comment author links, links within comments, blogroll links and downloads. It also allows you to add extra search engines, track image search queries and it will even work together with Urchin.
10
 
4
  Tags: analytics, google analytics, statistics
5
  Requires at least: 2.2
6
  Tested up to: 2.3
7
+ Stable tag: 1.6
8
 
9
  The Google Analytics for WordPress plugina automatically tracks and segments all outbound links from within posts, comment author links, links within comments, blogroll links and downloads. It also allows you to add extra search engines, track image search queries and it will even work together with Urchin.
10