Changeset 3058404
- Timestamp:
- 03/25/2024 02:59:42 PM (21 months ago)
- Location:
- lightweight-google-analytics
- Files:
-
- 3 added
- 2 edited
-
tags/1.4.2 (added)
-
tags/1.4.2/lightweight-google-analytics.php (added)
-
tags/1.4.2/readme.txt (added)
-
trunk/lightweight-google-analytics.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lightweight-google-analytics/trunk/lightweight-google-analytics.php
r2970054 r3058404 4 4 * Plugin URI: https://smartwp.co/lightweight-google-analytics 5 5 * Description: Extremely simple plugin to add Google Analytics to your WordPress site using your tracking ID. 6 * Version: 1.4. 26 * Version: 1.4.3 7 7 * Text Domain: lightweight_ga 8 8 * Author: Andy Feliciotti 9 * Author URI: https://smartwp.co 9 * Author URI: https://smartwp.com 10 10 */ 11 12 if ( ! defined( 'ABSPATH' ) ) { 13 exit; // Exit if accessed directly. 14 } 15 16 define( 'LIGHTWEIGHT_GA_VERSION', '1.4.3' ); 11 17 12 18 class lightweight_ga_plugin_options { … … 17 23 add_action( 'admin_init', array( $this, 'init_settings' ) ); 18 24 19 if( !isset(get_option('lightweight_ga_settings')['tracking_id']) ) {25 if( !isset(get_option('lightweight_ga_settings')['tracking_id']) || empty(get_option('lightweight_ga_settings')['tracking_id']) ) { 20 26 add_action('admin_notices', array( $this, 'setup_lightweight_ga_message')); 21 27 } … … 32 38 33 39 public function setup_lightweight_ga_message() { 34 echo "<div class='lightweightga notice notice-success'><p>" . sprintf(__('Thank you for installing <strong>Lightweight Google Analytics</strong> - Remember to head to the <a href="%s" title="Lightweight Google Analytics Settings">settings</a> to finish setting up Google Analytics.', 'lightweight_ga'), menu_page_url('lightweight-google-analytics', false)) . "</p></div>"; 40 $settings_link = '<a href="' . esc_url(menu_page_url('lightweight-google-analytics', false)) . '" title="' . esc_attr__('Lightweight Google Analytics Settings', 'lightweight_ga') . '">'; 41 $message = __('Thank you for installing <strong>Lightweight Google Analytics</strong> - Remember to head to the %ssettings%s to finish setting up Google Analytics.', 'lightweight_ga'); 42 printf('<div class="lightweightga notice notice-success"><p>%s</p></div>', sprintf($message, $settings_link, '</a>')); 35 43 } 36 44 … … 123 131 124 132 // Admin Page Layout 125 echo '<div id="lightweight-google-analytics-admin-header"><div id="lightweight-google-analytics-page-title">' . get_admin_page_title() . '</div><div id="lightweight-google-analytics-admin-header-buttons"><a href="?page=lightweight-google-analytics" class="lightweight-google-analytics-active" title="Options">Options</a><a href="https://analytics.google.com" title="Open Google Analytics" target="_blank" rel="nofollow">Open Google Analytics</a><span style="color: rgba(255,255,255,0.5); margin: 0px 10px;">v 1.4.1</span></div></div>';133 echo '<div id="lightweight-google-analytics-admin-header"><div id="lightweight-google-analytics-page-title">' . get_admin_page_title() . '</div><div id="lightweight-google-analytics-admin-header-buttons"><a href="?page=lightweight-google-analytics" class="lightweight-google-analytics-active" title="Options">Options</a><a href="https://analytics.google.com" title="Open Google Analytics" target="_blank" rel="nofollow">Open Google Analytics</a><span style="color: rgba(255,255,255,0.5); margin: 0px 10px;">v'.esc_attr( LIGHTWEIGHT_GA_VERSION ).'</span></div></div>'; 126 134 echo '<div id="poststuff"><div class="postbox"><div id="lightweight-google-analytics-settings" class="inside">' . "\n"; 127 135 echo ' <h2>' . __( 'Options', 'lightweight_ga' ) . '</h2>' . "\n"; … … 310 318 if(!empty($lightweight_ga['tracking_code']) && $lightweight_ga['tracking_code'] == "minimalanalytics-inline"){ 311 319 $output .= '<!-- Google Analytics --> 312 <script> function a(){const n=localStorage,e=sessionStorage,t=document,o=navigator||{},w="'.$lightweight_ga['tracking_id'].'",a=()=>Math.floor(Math.random()*1e9)+1,r=()=>Math.floor(Date.now()/1e3),y=()=>(e._p||(e._p=a()),e._p),b=()=>a()+"."+r(),g=()=>(n.cid_v4||(n.cid_v4=b()),n.cid_v4),f=n.getItem("cid_v4"),A=()=>f?void 0:"1",j=()=>(e.sid||(e.sid=r()),e.sid),m=()=>{if(!e._ss)return e._ss="1",e._ss;if(e.getItem("_ss")=="1")return void 0},d="1",p=()=>(e.sct?(x=+e.getItem("sct")+ +d,e.sct=x):e.sct=d,e.sct),s=t.location.search,v=new URLSearchParams(s),l=["q","s","search","query","keyword"],h=l.some(e=>s.includes("&"+e+"=")||s.includes("?"+e+"=")),c=()=>h==!0?"view_search_results":"page_view",_=()=>{if(c()=="view_search_results"){for(let e of v)if(l.includes(e[0]))return e[1]}else return void 0},i=encodeURIComponent,O=e=>{let t=[];for(let n in e)e.hasOwnProperty(n)&&e[n]!==void 0&&t.push(i(n)+"="+i(e[n]));return t.join("&")},C=!1,E="https://www.google-analytics.com/g/collect",k=O({v:"2",tid:w,_p:y(),sr:(screen.width*window.devicePixelRatio+"x"+screen.height*window.devicePixelRatio).toString(),ul:(o.language||void 0).toLowerCase(),cid:g(),_fv:A(),_s:"1",dl:t.location.origin+t.location.pathname+s,dt:t.title||void 0,dr:t.referrer||void 0,sid:j(),sct:p(),seg:"1",en:c(),\'ep.search_term\':_(),_ss:m(),_dbg:C?1:void 0}),u=E+"?"+k;if(o.sendBeacon)o.sendBeacon(u);else{let e=new XMLHttpRequest;e.open("POST",u,!0)}}a()</script>';320 <script>enScroll=!1,enFdl=!1,extCurrent=void 0,filename=void 0,targetText=void 0,splitOrigin=void 0;const lStor=localStorage,sStor=sessionStorage,doc=document,docEl=document.documentElement,docBody=document.body,docLoc=document.location,w=window,s=screen,nav=navigator||{},extensions=["pdf","xls","xlsx","doc","docx","txt","rtf","csv","exe","key","pps","ppt","pptx","7z","pkg","rar","gz","zip","avi","mov","mp4","mpe","mpeg","wmv","mid","midi","mp3","wav","wma"];function a(e,t,n,o){const j="'.$lightweight_ga['tracking_id'].'",r=()=>Math.floor(Math.random()*1e9)+1,c=()=>Math.floor(Date.now()/1e3),F=()=>(sStor._p||(sStor._p=r()),sStor._p),E=()=>r()+"."+c(),_=()=>(lStor.cid_v4||(lStor.cid_v4=E()),lStor.cid_v4),m=lStor.getItem("cid_v4"),v=()=>m?void 0:enScroll==!0?void 0:"1",p=()=>(sStor.sid||(sStor.sid=c()),sStor.sid),O=()=>{if(!sStor._ss)return sStor._ss="1",sStor._ss;if(sStor.getItem("_ss")=="1")return void 0},a="1",g=()=>{if(sStor.sct)if(enScroll==!0)return sStor.sct;else x=+sStor.getItem("sct")+ +a,sStor.sct=x;else sStor.sct=a;return sStor.sct},i=docLoc.search,b=new URLSearchParams(i),h=["q","s","search","query","keyword"],y=h.some(e=>i.includes("&"+e+"=")||i.includes("?"+e+"=")),u=()=>y==!0?"view_search_results":enScroll==!0?"scroll":enFdl==!0?"file_download":"page_view",f=()=>enScroll==!0?"90":void 0,C=()=>{if(u()=="view_search_results"){for(let e of b)if(h.includes(e[0]))return e[1]}else return void 0},d=encodeURIComponent,k=e=>{let t=[];for(let n in e)e.hasOwnProperty(n)&&e[n]!==void 0&&t.push(d(n)+"="+d(e[n]));return t.join("&")},A=!1,S="https://www.google-analytics.com/g/collect",M=k({v:"2",tid:j,_p:F(),sr:(s.width*w.devicePixelRatio+"x"+s.height*w.devicePixelRatio).toString(),ul:(nav.language||void 0).toLowerCase(),cid:_(),_fv:v(),_s:"1",dl:docLoc.origin+docLoc.pathname+i,dt:doc.title||void 0,dr:doc.referrer||void 0,sid:p(),sct:g(),seg:"1",en:u(),"epn.percent_scrolled":f(),"ep.search_term":C(),"ep.file_extension":e||void 0,"ep.file_name":t||void 0,"ep.link_text":n||void 0,"ep.link_url":o||void 0,_ss:O(),_dbg:A?1:void 0}),l=S+"?"+M;if(nav.sendBeacon)nav.sendBeacon(l);else{let e=new XMLHttpRequest;e.open("POST",l,!0)}}a();function sPr(){return(docEl.scrollTop||docBody.scrollTop)/((docEl.scrollHeight||docBody.scrollHeight)-docEl.clientHeight)*100}doc.addEventListener("scroll",sEv,{passive:!0});function sEv(){const e=sPr();if(e<90)return;enScroll=!0,a(),doc.removeEventListener("scroll",sEv,{passive:!0}),enScroll=!1}document.addEventListener("DOMContentLoaded",function(){let e=document.getElementsByTagName("a");for(let t=0;t<e.length;t++)if(e[t].getAttribute("href")!=null){const n=e[t].getAttribute("href"),s=n.substring(n.lastIndexOf("/")+1),o=s.split(".").pop();(e[t].hasAttribute("download")||extensions.includes(o))&&e[t].addEventListener("click",fDl,{passive:!0})}});function fDl(e){enFdl=!0;const t=e.currentTarget.getAttribute("href"),n=t.substring(t.lastIndexOf("/")+1),s=n.split(".").pop(),o=n.replace("."+s,""),i=e.currentTarget.text,r=t.replace(docLoc.origin,"");a(s,o,i,r),enFdl=!1}</script>'; 313 321 }else{ 314 322 $output .= '<!-- Global site tag (gtag.js) - Google Analytics --> … … 342 350 if(!empty($lightweight_ga['tracking_code']) && $lightweight_ga['tracking_code'] == "minimalanalytics-inline"){ 343 351 $output .= '(function(a,b,c){var d=a.history,e=document,f=navigator||{},g=localStorage, 344 h=encodeURIComponent,i=d.pushState,k=function(){return Math.random().toString(36)},345 l=function(){return g.cid||(g.cid=k()),g.cid},m=function(r){var s=[];for(var t in r)346 r.hasOwnProperty(t)&&void 0!==r[t]&&s.push(h(t)+"="+h(r[t]));return s.join("&")},347 n=function(r,s,t,u,v,w,x){var z="https://www.google-analytics.com/collect",348 A=m({v:"1",ds:"web",aip:c.anonymizeIp?1:void 0,tid:b,cid:l(),t:r||"pageview",349 sd:c.colorDepth&&screen.colorDepth?screen.colorDepth+"-bits":void 0,dr:e.referrer||350 void 0,dt:e.title,dl:e.location.origin+e.location.pathname+e.location.search,ul:c.language?351 (f.language||"").toLowerCase():void 0,de:c.characterSet?e.characterSet:void 0,352 sr:c.screenSize?(a.screen||{}).width+"x"+(a.screen||{}).height:void 0,vp:c.screenSize&&353 a.visualViewport?(a.visualViewport||{}).width+"x"+(a.visualViewport||{}).height:void 0,354 ec:s||void 0,ea:t||void 0,el:u||void 0,ev:v||void 0,exd:w||void 0,exf:"undefined"!=typeof x&&355 !1==!!x?0:void 0});if(f.sendBeacon)f.sendBeacon(z,A);else{var y=new XMLHttpRequest;356 y.open("POST",z,!0),y.send(A)}};d.pushState=function(r){return"function"==typeof d.onpushstate&&357 d.onpushstate({state:r}),setTimeout(n,c.delay||10),i.apply(d,arguments)},n(),358 a.ma={trackEvent:function o(r,s,t,u){return n("event",r,s,t,u)},359 trackException:function q(r,s){return n("exception",null,null,null,null,r,s)}}})360 (window,"'.$lightweight_ga['tracking_id'].'",{';352 h=encodeURIComponent,i=d.pushState,k=function(){return Math.random().toString(36)}, 353 l=function(){return g.cid||(g.cid=k()),g.cid},m=function(r){var s=[];for(var t in r) 354 r.hasOwnProperty(t)&&void 0!==r[t]&&s.push(h(t)+"="+h(r[t]));return s.join("&")}, 355 n=function(r,s,t,u,v,w,x){var z="https://www.google-analytics.com/collect", 356 A=m({v:"1",ds:"web",aip:c.anonymizeIp?1:void 0,tid:b,cid:l(),t:r||"pageview", 357 sd:c.colorDepth&&screen.colorDepth?screen.colorDepth+"-bits":void 0,dr:e.referrer|| 358 void 0,dt:e.title,dl:e.location.origin+e.location.pathname+e.location.search,ul:c.language? 359 (f.language||"").toLowerCase():void 0,de:c.characterSet?e.characterSet:void 0, 360 sr:c.screenSize?(a.screen||{}).width+"x"+(a.screen||{}).height:void 0,vp:c.screenSize&& 361 a.visualViewport?(a.visualViewport||{}).width+"x"+(a.visualViewport||{}).height:void 0, 362 ec:s||void 0,ea:t||void 0,el:u||void 0,ev:v||void 0,exd:w||void 0,exf:"undefined"!=typeof x&& 363 !1==!!x?0:void 0});if(f.sendBeacon)f.sendBeacon(z,A);else{var y=new XMLHttpRequest; 364 y.open("POST",z,!0),y.send(A)}};d.pushState=function(r){return"function"==typeof d.onpushstate&& 365 d.onpushstate({state:r}),setTimeout(n,c.delay||10),i.apply(d,arguments)},n(), 366 a.ma={trackEvent:function o(r,s,t,u){return n("event",r,s,t,u)}, 367 trackException:function q(r,s){return n("exception",null,null,null,null,r,s)}}}) 368 (window,"'.$lightweight_ga['tracking_id'].'",{'; 361 369 362 370 if(!empty($lightweight_ga['anonymize_ip']) && $lightweight_ga['anonymize_ip'] == "checked") { -
lightweight-google-analytics/trunk/readme.txt
r2970054 r3058404 4 4 Tags: Google Analytics, Analytics, Google Analytics Plugin, WordPress analytics 5 5 Requires at least: 5.0 6 Tested up to: 6. 36 Tested up to: 6.5 7 7 Requires PHP: 7.0 8 Stable tag: 1.4. 28 Stable tag: 1.4.3 9 9 License: GPLv3 10 10 License URI: http://www.gnu.org/licenses/gpl.html … … 50 50 == Changelog == 51 51 52 = 1.4.3 = 53 * Tested up to WordPress 6.5. 54 * Upgraded minimal analytics tracking scripts. 55 52 56 = 1.4.2 = 53 57 * Tested up to WordPress 6.3.
Note: See TracChangeset
for help on using the changeset viewer.