Google Analytics - Version 2.0.6

Version Description

  • 14-Oct-2019
  • Fix : extra validation for POST variables.
  • Fix : Pages tab shows correct percentage values.
Download this release

Release Info

Developer amribrahim
Plugin Icon 128x128 Google Analytics
Version 2.0.6
Comparing to
See all releases

Code changes from version 2.0.5 to 2.0.6

core/lrgawidget.class.php CHANGED
@@ -310,9 +310,10 @@ class lrgawidget{
310
  }
311
 
312
  private function preparePagesOutput(&$item){
313
- $item[0] = array($item[0],$item[1]);
314
  $item[1] = $item[2];
315
  unset($item[2]);
 
316
  }
317
 
318
  private function convertDate(&$item){
310
  }
311
 
312
  private function preparePagesOutput(&$item){
313
+ $item[0] = array(htmlspecialchars($item[0]),htmlspecialchars($item[1]));
314
  $item[1] = $item[2];
315
  unset($item[2]);
316
+ $item = array_values($item);
317
  }
318
 
319
  private function convertDate(&$item){
lara-google-analytics.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
 
3
  /*
4
- Plugin Name: Google Analytics
5
  Plugin URI: https://www.xtraorbit.com/wordpress-google-analytics-dashboard-widget/
6
  Description: Full width Google Analytics dashboard widget for Wordpress admin interface, which also inserts latest Google Analytics tracking code to your pages.
7
- Version: 2.0.5
8
  Author: Amr M. Ibrahim
9
  Author URI: https://www.xtraorbit.com/
10
  License: GPL2
11
  */
12
 
13
- define ("lrgawidget_plugin_version", "2.0.5");
14
- define ("lrgawidget_plugin_scripts_version", "205");
15
  define ("lrgawidget_plugin_prefiex", "lrgalite-");
16
  define ("lrgawidget_plugin_dist_dir", plugin_dir_url( __FILE__ ).'dist/');
17
  define ("lrgawidget_plugin_plugins_dir", plugin_dir_url( __FILE__ ).'dist/plugins/');
@@ -38,6 +38,10 @@ add_action( 'wp_ajax_lrgawidget_getPages', 'lrgawidget_callback' );
38
 
39
  add_action( 'wp_head', 'lrgawidget_ga_code');
40
 
 
 
 
 
41
  function lrgawidget_enqueue($hook) {
42
  if ( 'index.php' != $hook || !current_user_can('manage_options')) {
43
  return;
@@ -81,10 +85,11 @@ function lrgawidget_callback() {
81
  $lrperm = lrgawidget_internal_permissions();
82
  $lrdata = array_map ( 'htmlspecialchars' , $_POST );
83
  $modifiedAction = explode("_", $lrdata['action']);
84
- $lrdata['action'] = $modifiedAction[1];
85
 
86
  if ($lrdata['action'] == "setProfileID"){
87
- if ( (isset($lrdata['enable_universal_tracking'])) && !empty($lrdata['property_id'])){
 
88
  update_option('lrgawidget_property_id', $lrdata['property_id']);
89
  }else{
90
  delete_option('lrgawidget_property_id');
@@ -95,8 +100,11 @@ function lrgawidget_callback() {
95
  }
96
 
97
  if ($lrdata['action'] == "hideShowWidget"){
98
- update_user_option( $user_id, 'lrgawidget_hideShowWidget', $lrdata['wstate'] );
99
- lrgawidget_jsonOutput();
 
 
 
100
  };
101
 
102
 
@@ -118,8 +126,8 @@ function lrga_welcome_panel() {
118
  }
119
 
120
  function lrgawidget_ga_code(){
121
- $lrgawidget_property_id = get_option('lrgawidget_property_id',"");
122
- if (!current_user_can('edit_posts') && !empty($lrgawidget_property_id) ) {
123
  ?>
124
 
125
  <!-- Google Analytics by Lara - https://www.xtraorbit.com/wordpress-google-analytics-dashboard-widget/ -->
@@ -128,7 +136,6 @@ function lrgawidget_ga_code(){
128
  window.dataLayer = window.dataLayer || [];
129
  function gtag(){dataLayer.push(arguments);}
130
  gtag('js', new Date());
131
-
132
  gtag('config', '<?php echo $lrgawidget_property_id ?>', { 'anonymize_ip': true });
133
  </script>
134
 
1
  <?php
2
 
3
  /*
4
+ Plugin Name: Lara's Google Analytics
5
  Plugin URI: https://www.xtraorbit.com/wordpress-google-analytics-dashboard-widget/
6
  Description: Full width Google Analytics dashboard widget for Wordpress admin interface, which also inserts latest Google Analytics tracking code to your pages.
7
+ Version: 2.0.6
8
  Author: Amr M. Ibrahim
9
  Author URI: https://www.xtraorbit.com/
10
  License: GPL2
11
  */
12
 
13
+ define ("lrgawidget_plugin_version", "2.0.6");
14
+ define ("lrgawidget_plugin_scripts_version", "206");
15
  define ("lrgawidget_plugin_prefiex", "lrgalite-");
16
  define ("lrgawidget_plugin_dist_dir", plugin_dir_url( __FILE__ ).'dist/');
17
  define ("lrgawidget_plugin_plugins_dir", plugin_dir_url( __FILE__ ).'dist/plugins/');
38
 
39
  add_action( 'wp_head', 'lrgawidget_ga_code');
40
 
41
+ function lrgawidget_is_analytics($str){
42
+ return (bool) preg_match('/^ua-\d{4,20}(-\d{1,10})?$/i', $str);
43
+ }
44
+
45
  function lrgawidget_enqueue($hook) {
46
  if ( 'index.php' != $hook || !current_user_can('manage_options')) {
47
  return;
85
  $lrperm = lrgawidget_internal_permissions();
86
  $lrdata = array_map ( 'htmlspecialchars' , $_POST );
87
  $modifiedAction = explode("_", $lrdata['action']);
88
+ $lrdata['action'] = sanitize_text_field($modifiedAction[1]);
89
 
90
  if ($lrdata['action'] == "setProfileID"){
91
+ $lrdata['property_id'] = sanitize_text_field($lrdata['property_id']);
92
+ if ( (isset($lrdata['enable_universal_tracking'])) && !empty($lrdata['property_id']) && lrgawidget_is_analytics($lrdata['property_id']) ){
93
  update_option('lrgawidget_property_id', $lrdata['property_id']);
94
  }else{
95
  delete_option('lrgawidget_property_id');
100
  }
101
 
102
  if ($lrdata['action'] == "hideShowWidget"){
103
+ $lrdata['wstate'] = sanitize_text_field($lrdata['wstate']);
104
+ if ($lrdata['wstate'] == "show" || $lrdata['wstate'] == "hide"){
105
+ update_user_option( $user_id, 'lrgawidget_hideShowWidget', $lrdata['wstate'] );
106
+ lrgawidget_jsonOutput();
107
+ }
108
  };
109
 
110
 
126
  }
127
 
128
  function lrgawidget_ga_code(){
129
+ $lrgawidget_property_id = sanitize_text_field(get_option('lrgawidget_property_id',""));
130
+ if (!current_user_can('edit_posts') && !empty($lrgawidget_property_id) && lrgawidget_is_analytics($lrgawidget_property_id)) {
131
  ?>
132
 
133
  <!-- Google Analytics by Lara - https://www.xtraorbit.com/wordpress-google-analytics-dashboard-widget/ -->
136
  window.dataLayer = window.dataLayer || [];
137
  function gtag(){dataLayer.push(arguments);}
138
  gtag('js', new Date());
 
139
  gtag('config', '<?php echo $lrgawidget_property_id ?>', { 'anonymize_ip': true });
140
  </script>
141
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === Google Analytics ===
2
  Tags: analytics,google analytics,google analytics dashboard,google analytics plugin,google analytics widget
3
  Contributors: amribrahim, laragoogleanalytics
4
  Requires PHP: 5.3.0
5
  Requires at least: 4.0
6
  Tested up to: 5.2.3
7
- Stable tag: 2.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,7 +12,7 @@ Full width Google Analytics dashboard widget for Wordpress admin interface, whic
12
 
13
  == Description ==
14
 
15
- <strong>Google Analytics - by Lara.</strong>
16
 
17
  Adds a full width Google Analytics dashboard widget for WordPress admin interface, and inserts latest Google Analytics tracking code to all your pages.
18
 
@@ -102,4 +102,9 @@ Adds a full width Google Analytics dashboard widget for WordPress admin interfac
102
 
103
  = 2.0.5 =
104
  * 14-Oct-2019
105
- * Fix : validate POST variables.
 
 
 
 
 
1
+ === Lara's Google Analytics ===
2
  Tags: analytics,google analytics,google analytics dashboard,google analytics plugin,google analytics widget
3
  Contributors: amribrahim, laragoogleanalytics
4
  Requires PHP: 5.3.0
5
  Requires at least: 4.0
6
  Tested up to: 5.2.3
7
+ Stable tag: 2.0.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ <strong>Lara's Google Analytics.</strong>
16
 
17
  Adds a full width Google Analytics dashboard widget for WordPress admin interface, and inserts latest Google Analytics tracking code to all your pages.
18
 
102
 
103
  = 2.0.5 =
104
  * 14-Oct-2019
105
+ * Fix : validate POST variables.
106
+
107
+ = 2.0.6 =
108
+ * 14-Oct-2019
109
+ * Fix : extra validation for POST variables.
110
+ * Fix : Pages tab shows correct percentage values.