Google Analytics Dashboard for WP (GADWP) - Version 4.9.2

Version Description

In case of errors refresh your page or clear your browser cache, as a first step. The Frontend Widget can be re-enabled from Appearance -> Widgets screen.

=

Download this release

Release Info

Developer deconf
Plugin Icon 128x128 Google Analytics Dashboard for WP (GADWP)
Version 4.9.2
Comparing to
See all releases

Code changes from version 4.9.1.2 to 4.9.2

admin/ajax-actions-ui.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- /**
3
- * Author: Alin Marcu
4
- * Author URI: http://deconf.com
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- // Exit if accessed directly
10
- if ( ! defined( 'ABSPATH' ) )
11
- exit();
12
-
13
- if ( ! class_exists( 'GADWP_UI_Ajax' ) ) {
14
-
15
- final class GADWP_UI_Ajax {
16
-
17
- public function __construct() {
18
- if ( current_user_can( 'manage_options' ) ) {
19
- // Admin Widget action
20
- add_action( 'wp_ajax_gadwp_dismiss_notices', array( $this, 'ajax_dismiss_notices' ) );
21
- }
22
- }
23
-
24
- /**
25
- * Ajax handler for dismissing Admin notices
26
- *
27
- * @return json|int
28
- */
29
- public function ajax_dismiss_notices() {
30
- if ( ! isset( $_POST['gadwp_security_dismiss_notices'] ) || ! wp_verify_nonce( $_POST['gadwp_security_dismiss_notices'], 'gadwp_dismiss_notices' ) ) {
31
- wp_die( - 30 );
32
- }
33
-
34
- if ( !current_user_can( 'manage_options' ) ) {
35
- wp_die( - 31 );
36
- }
37
-
38
- delete_option( 'gadwp_got_updated' );
39
-
40
- wp_send_json( 1 );
41
- }
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/ajax-actions.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  /**
3
  * Author: Alin Marcu
4
- * Author URI: http://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -18,11 +19,15 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
18
 
19
  public function __construct() {
20
  $this->gadwp = GADWP();
21
-
22
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) {
23
  // Items action
24
  add_action( 'wp_ajax_gadwp_backend_item_reports', array( $this, 'ajax_item_reports' ) );
25
  }
 
 
 
 
26
  }
27
 
28
  /**
@@ -50,7 +55,7 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
50
  if ( ob_get_length() ) {
51
  ob_clean();
52
  }
53
-
54
  if ( ! ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) ) {
55
  wp_die( - 31 );
56
  }
@@ -70,40 +75,59 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
70
  } else {
71
  $this->gadwp->gapi_controller->timeshift = (int) current_time( 'timestamp' ) - time();
72
  }
73
-
74
  if ( $filter_id ) {
75
  $uri_parts = explode( '/', get_permalink( $filter_id ), 4 );
76
-
77
  if ( isset( $uri_parts[3] ) ) {
78
  $uri = '/' . $uri_parts[3];
79
  } else {
80
  wp_die( - 25 );
81
  }
82
-
83
  // allow URL correction before sending an API request
84
  $filter = apply_filters( 'gadwp_backenditem_uri', $uri );
85
-
86
  $lastchar = substr( $filter, - 1 );
87
-
88
  if ( isset( $profile_info[6] ) && $profile_info[6] && $lastchar == '/' ) {
89
  $filter = $filter . $profile_info[6];
90
  }
91
-
92
  // Encode URL
93
  $filter = rawurlencode( rawurldecode( $filter ) );
94
  } else {
95
  $filter = false;
96
  }
97
-
98
  $queries = explode( ',', $query );
99
-
100
  $results = array();
101
-
102
  foreach ( $queries as $value ) {
103
  $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter );
104
  }
105
-
106
  wp_send_json( $results );
107
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
  }
1
  <?php
2
  /**
3
  * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
+
23
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) {
24
  // Items action
25
  add_action( 'wp_ajax_gadwp_backend_item_reports', array( $this, 'ajax_item_reports' ) );
26
  }
27
+ if ( current_user_can( 'manage_options' ) ) {
28
+ // Admin Widget action
29
+ add_action( 'wp_ajax_gadwp_dismiss_notices', array( $this, 'ajax_dismiss_notices' ) );
30
+ }
31
  }
32
 
33
  /**
55
  if ( ob_get_length() ) {
56
  ob_clean();
57
  }
58
+
59
  if ( ! ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) ) {
60
  wp_die( - 31 );
61
  }
75
  } else {
76
  $this->gadwp->gapi_controller->timeshift = (int) current_time( 'timestamp' ) - time();
77
  }
78
+
79
  if ( $filter_id ) {
80
  $uri_parts = explode( '/', get_permalink( $filter_id ), 4 );
81
+
82
  if ( isset( $uri_parts[3] ) ) {
83
  $uri = '/' . $uri_parts[3];
84
  } else {
85
  wp_die( - 25 );
86
  }
87
+
88
  // allow URL correction before sending an API request
89
  $filter = apply_filters( 'gadwp_backenditem_uri', $uri );
90
+
91
  $lastchar = substr( $filter, - 1 );
92
+
93
  if ( isset( $profile_info[6] ) && $profile_info[6] && $lastchar == '/' ) {
94
  $filter = $filter . $profile_info[6];
95
  }
96
+
97
  // Encode URL
98
  $filter = rawurlencode( rawurldecode( $filter ) );
99
  } else {
100
  $filter = false;
101
  }
102
+
103
  $queries = explode( ',', $query );
104
+
105
  $results = array();
106
+
107
  foreach ( $queries as $value ) {
108
  $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter );
109
  }
110
+
111
  wp_send_json( $results );
112
  }
113
+
114
+ /**
115
+ * Ajax handler for dismissing Admin notices
116
+ *
117
+ * @return json|int
118
+ */
119
+ public function ajax_dismiss_notices() {
120
+ if ( ! isset( $_POST['gadwp_security_dismiss_notices'] ) || ! wp_verify_nonce( $_POST['gadwp_security_dismiss_notices'], 'gadwp_dismiss_notices' ) ) {
121
+ wp_die( - 30 );
122
+ }
123
+
124
+ if ( ! current_user_can( 'manage_options' ) ) {
125
+ wp_die( - 31 );
126
+ }
127
+
128
+ delete_option( 'gadwp_got_updated' );
129
+
130
+ wp_die();
131
+ }
132
  }
133
  }
admin/css/admin-widgets.css CHANGED
@@ -1,4 +1,10 @@
1
- /* Admin Widget & Real-Time Stats*/
 
 
 
 
 
 
2
 
3
  /* Real-Time content */
4
  .gadwp-pline {
@@ -25,7 +31,7 @@
25
  padding-right: 5px;
26
  }
27
 
28
- [id^=gadwp-realtime] {
29
  margin: 10px 0 0 0;
30
  width: 100%;
31
  }
@@ -98,7 +104,7 @@
98
  min-width: 250px;
99
  }
100
 
101
- [id^=gadwp-mainchart] {
102
  width: 98%;
103
  height: 100%;
104
  margin: 10px auto 10px 0;
@@ -111,21 +117,22 @@
111
  height: 100%;
112
  }
113
 
114
- [id^=gadwp-trafficmediums], [id^=gadwp-traffictype], [id^=gadwp-socialnetworks], [id^=gadwp-trafficorganic] {
115
  width: 47%;
116
  margin: 10px 0 0 0;
117
  height: 200px;
 
118
  }
119
 
120
- [id^=gadwp-trafficmediums], [id^=gadwp-trafficorganic] {
121
  float: left;
122
  }
123
 
124
- [id^=gadwp-traffictype], [id^=gadwp-socialnetworks] {
125
  float: right;
126
  }
127
 
128
- [id^=gadwp-locations], [id^=gadwp-prs] {
129
  width: 98%;
130
  height: 100%;
131
  margin: 10px auto 10px 0;
@@ -136,17 +143,17 @@
136
  }
137
 
138
  /* Admin Widget content */
139
- [id^=gadwp-progressbar] {
140
  width: 100%;
141
  height: 3px;
142
  margin: 5px 0 0px 0;
143
  }
144
 
145
- .gadwp-wrapper {
146
  width: 100%;
147
  }
148
 
149
- .gadwp-wrapper .inside {
150
  display: table;
151
  margin: 0 auto;
152
  padding: 0px;
@@ -170,7 +177,7 @@
170
  margin: 0px 0px 0px 0px;
171
  text-overflow: ellipsis;
172
  overflow: hidden;
173
- white-space: nowrap;
174
  }
175
 
176
  #gadwp-widget .inside .small-box p {
@@ -179,7 +186,7 @@
179
  }
180
 
181
  @media screen and (max-width: 410px) {
182
- .gadwp-wrapper .inside .small-box {
183
  width: 45%;
184
  }
185
  }
1
+ /**
2
+ * Author: Alin Marcu
3
+ * Author URI: https://deconf.com
4
+ * Copyright 2013 Alin Marcu
5
+ * License: GPLv2 or later
6
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
+ */
8
 
9
  /* Real-Time content */
10
  .gadwp-pline {
31
  padding-right: 5px;
32
  }
33
 
34
+ [id^=gadwp-realtime-] {
35
  margin: 10px 0 0 0;
36
  width: 100%;
37
  }
104
  min-width: 250px;
105
  }
106
 
107
+ [id^=gadwp-areachart-] {
108
  width: 98%;
109
  height: 100%;
110
  margin: 10px auto 10px 0;
117
  height: 100%;
118
  }
119
 
120
+ [id^=gadwp-piechart-].halfsize {
121
  width: 47%;
122
  margin: 10px 0 0 0;
123
  height: 200px;
124
+ float: left;
125
  }
126
 
127
+ [id^=gadwp-piechart-].floatleft {
128
  float: left;
129
  }
130
 
131
+ [id^=gadwp-piechart-].floatright {
132
  float: right;
133
  }
134
 
135
+ [id^=gadwp-tablechart-], [id^=gadwp-tablechart-] {
136
  width: 98%;
137
  height: 100%;
138
  margin: 10px auto 10px 0;
143
  }
144
 
145
  /* Admin Widget content */
146
+ [id^=gadwp-progressbar-] {
147
  width: 100%;
148
  height: 3px;
149
  margin: 5px 0 0px 0;
150
  }
151
 
152
+ [id^=gadwp-bottomstats-] {
153
  width: 100%;
154
  }
155
 
156
+ [id^=gadwp-bottomstats-] .inside {
157
  display: table;
158
  margin: 0 auto;
159
  padding: 0px;
177
  margin: 0px 0px 0px 0px;
178
  text-overflow: ellipsis;
179
  overflow: hidden;
180
+ white-space: nowrap;
181
  }
182
 
183
  #gadwp-widget .inside .small-box p {
186
  }
187
 
188
  @media screen and (max-width: 410px) {
189
+ [id^=gadwp-bottomstats-] .inside .small-box {
190
  width: 45%;
191
  }
192
  }
admin/css/gadwp.css CHANGED
@@ -1,6 +1,13 @@
 
 
 
 
 
 
 
 
1
  /* Tab navigation */
2
- #gadwp-events, #gadwp-custom, #gadwp-advanced, #gadwp-exclude,
3
- #gadwp-config {
4
  display: none;
5
  }
6
 
@@ -72,12 +79,11 @@ td.gadwp-settings-roles {
72
  font-weight: normal;
73
  padding: 0;
74
  margin: 20px 0 15px 0;
75
-
76
  }
77
 
78
  #poststuff.gadwp h2.nav-tab-wrapper {
79
- border-bottom: 1px solid #ccc;
80
- padding-bottom: 0;
81
  }
82
 
83
  /* Options pages ON/OFF Switch */
@@ -108,7 +114,7 @@ input.gadwp-settings-switchoo-checkbox {
108
  background: transparent;
109
  border: 1px solid #ddd;
110
  border-radius: 2px;
111
- text-shadow: none;
112
  }
113
 
114
  .gadwp-settings-switchoo-inner {
1
+ /**
2
+ * Author: Alin Marcu
3
+ * Author URI: https://deconf.com
4
+ * Copyright 2013 Alin Marcu
5
+ * License: GPLv2 or later
6
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
+ */
8
+
9
  /* Tab navigation */
10
+ #gadwp-events, #gadwp-custom, #gadwp-advanced, #gadwp-exclude, #gadwp-config {
 
11
  display: none;
12
  }
13
 
79
  font-weight: normal;
80
  padding: 0;
81
  margin: 20px 0 15px 0;
 
82
  }
83
 
84
  #poststuff.gadwp h2.nav-tab-wrapper {
85
+ border-bottom: 1px solid #ccc;
86
+ padding-bottom: 0;
87
  }
88
 
89
  /* Options pages ON/OFF Switch */
114
  background: transparent;
115
  border: 1px solid #ddd;
116
  border-radius: 2px;
117
+ text-shadow: none;
118
  }
119
 
120
  .gadwp-settings-switchoo-inner {
admin/css/item-reports.css CHANGED
@@ -1,3 +1,11 @@
 
 
 
 
 
 
 
 
1
  /* Backend Item Reports */
2
  .column-gadwp_stats {
3
  width: 70px;
@@ -15,31 +23,31 @@
15
  padding-top: 5px;
16
  }
17
 
18
- [id^=gadwp-container] {
19
  width: 480px;
20
  }
21
 
22
- [id^=gadwp-mainchart] {
23
  height: 280px;
24
  }
25
 
26
- [id^=gadwp-progressbar] {
27
  width: 100%;
28
  height: 3px;
29
  margin: 5px 0 0px 0;
30
  }
31
 
32
- .gadwp-wrapper {
33
  width: 100%;
34
  }
35
 
36
- .gadwp-wrapper .inside {
37
  display: table;
38
  margin: 0 auto;
39
  padding: 0px;
40
  }
41
 
42
- .gadwp-wrapper .inside .small-box {
43
  width: 31.2%;
44
  float: left;
45
  margin: 10px 5px 10px 5px;
@@ -50,32 +58,44 @@
50
  box-shadow: 0px 0px 7px 0px #BBB;
51
  }
52
 
53
- .gadwp-wrapper .inside .small-box h3 {
54
- font-family: 'Open Sans', sans-serif;
55
  font-size: 1em;
56
  color: #777;
57
  padding: 0px 5px 0px 5px;
58
  margin: 0px 0px 0px 0px;
59
  text-overflow: ellipsis;
60
  overflow: hidden;
61
- white-space: nowrap;
62
  }
63
 
64
- .gadwp-wrapper .inside .small-box p {
65
  font-size: 1.2em;
66
  margin: 0px 0px 2px 0px;
67
  }
68
 
69
- [id^=gadwp-trafficmediums], [id^=gadwp-traffictype], [id^=gadwp-trafficorganic],
70
- [id^=gadwp-socialnetworks] {
71
- width: 49.6%;
 
 
 
 
 
72
  margin: 10px 0 0 0;
73
- border-right: 1px solid white;
74
  height: 200px;
75
  float: left;
76
  }
77
 
78
- [id^=gadwp-locations], [id^=gadwp-prs] {
 
 
 
 
 
 
 
 
79
  margin: 10px 0 0 0;
80
  }
81
 
@@ -86,19 +106,19 @@
86
  }
87
 
88
  @media screen and (max-width: 500px) {
89
- [id^=gadwp-container] {
90
  width: 410px;
91
  }
92
- .gadwp-wrapper .inside .small-box {
93
  width: 30.8%;
94
  }
95
  }
96
 
97
  @media screen and (max-width: 410px) {
98
- [id^=gadwp-container] {
99
  width: 260px;
100
  }
101
- .gadwp-wrapper .inside .small-box {
102
  width: 46%;
103
  }
104
  }
1
+ /**
2
+ * Author: Alin Marcu
3
+ * Author URI: https://deconf.com
4
+ * Copyright 2013 Alin Marcu
5
+ * License: GPLv2 or later
6
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
+ */
8
+
9
  /* Backend Item Reports */
10
  .column-gadwp_stats {
11
  width: 70px;
23
  padding-top: 5px;
24
  }
25
 
26
+ [id^=gadwp-container-] {
27
  width: 480px;
28
  }
29
 
30
+ [id^=gadwp-areachart-] {
31
  height: 280px;
32
  }
33
 
34
+ [id^=gadwp-progressbar-] {
35
  width: 100%;
36
  height: 3px;
37
  margin: 5px 0 0px 0;
38
  }
39
 
40
+ [id^=gadwp-bottomstats-] {
41
  width: 100%;
42
  }
43
 
44
+ [id^=gadwp-bottomstats-] .inside {
45
  display: table;
46
  margin: 0 auto;
47
  padding: 0px;
48
  }
49
 
50
+ [id^=gadwp-bottomstats-] .inside .small-box {
51
  width: 31.2%;
52
  float: left;
53
  margin: 10px 5px 10px 5px;
58
  box-shadow: 0px 0px 7px 0px #BBB;
59
  }
60
 
61
+ [id^=gadwp-bottomstats-] .inside .small-box h3 {
62
+ font-family: 'Open Sans', sans-serif;
63
  font-size: 1em;
64
  color: #777;
65
  padding: 0px 5px 0px 5px;
66
  margin: 0px 0px 0px 0px;
67
  text-overflow: ellipsis;
68
  overflow: hidden;
69
+ white-space: nowrap;
70
  }
71
 
72
+ [id^=gadwp-bottomstats-] .inside .small-box p {
73
  font-size: 1.2em;
74
  margin: 0px 0px 2px 0px;
75
  }
76
 
77
+ .gadwp-floatwraper {
78
+ display: table;
79
+ width: 100%;
80
+ height: 100%;
81
+ }
82
+
83
+ [id^=gadwp-piechart-].halfsize {
84
+ width: 47%;
85
  margin: 10px 0 0 0;
 
86
  height: 200px;
87
  float: left;
88
  }
89
 
90
+ [id^=gadwp-piechart-].floatleft {
91
+ float: left;
92
+ }
93
+
94
+ [id^=gadwp-piechart-].floatright {
95
+ float: right;
96
+ }
97
+
98
+ [id^=gadwp-tablechart-], [id^=gadwp-tablechart-] {
99
  margin: 10px 0 0 0;
100
  }
101
 
106
  }
107
 
108
  @media screen and (max-width: 500px) {
109
+ [id^=gadwp-container-] {
110
  width: 410px;
111
  }
112
+ [id^=gadwp-bottomstats-] .inside .small-box {
113
  width: 30.8%;
114
  }
115
  }
116
 
117
  @media screen and (max-width: 410px) {
118
+ [id^=gadwp-container-] {
119
  width: 260px;
120
  }
121
+ [id^=gadwp-bottomstats-] .inside .small-box {
122
  width: 46%;
123
  }
124
  }
admin/item-reports.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  /**
3
- * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -18,37 +19,29 @@ if ( ! class_exists( 'GADWP_Backend_Item_Reports' ) ) {
18
 
19
  public function __construct() {
20
  $this->gadwp = GADWP();
21
-
22
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && 1 == $this->gadwp->config->options['backend_item_reports'] ) {
23
  // Add custom column in Posts List
24
- add_filter( 'manage_posts_columns', array(
25
- $this,
26
- 'add_columns' ) );
27
-
28
  // Populate custom column in Posts List
29
- add_action( 'manage_posts_custom_column', array(
30
- $this,
31
- 'add_icons' ), 10, 2 );
32
-
33
  // Add custom column in Pages List
34
- add_filter( 'manage_pages_columns', array(
35
- $this,
36
- 'add_columns' ) );
37
-
38
  // Populate custom column in Pages List
39
- add_action( 'manage_pages_custom_column', array(
40
- $this,
41
- 'add_icons' ), 10, 2 );
42
  }
43
  }
44
 
45
  public function add_icons( $column, $id ) {
46
  global $wp_version;
47
-
48
  if ( $column != 'gadwp_stats' ) {
49
  return;
50
  }
51
-
52
  if ( version_compare( $wp_version, '3.8.0', '>=' ) ) {
53
  echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area"></a>';
54
  } else {
@@ -57,8 +50,7 @@ if ( ! class_exists( 'GADWP_Backend_Item_Reports' ) ) {
57
  }
58
 
59
  public function add_columns( $columns ) {
60
- return array_merge( $columns, array(
61
- 'gadwp_stats' => __( 'Analytics', 'google-analytics-dashboard-for-wp' ) ) );
62
  }
63
  }
64
  }
1
  <?php
2
  /**
3
+ * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
+
23
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && 1 == $this->gadwp->config->options['backend_item_reports'] ) {
24
  // Add custom column in Posts List
25
+ add_filter( 'manage_posts_columns', array( $this, 'add_columns' ) );
26
+
 
 
27
  // Populate custom column in Posts List
28
+ add_action( 'manage_posts_custom_column', array( $this, 'add_icons' ), 10, 2 );
29
+
 
 
30
  // Add custom column in Pages List
31
+ add_filter( 'manage_pages_columns', array( $this, 'add_columns' ) );
32
+
 
 
33
  // Populate custom column in Pages List
34
+ add_action( 'manage_pages_custom_column', array( $this, 'add_icons' ), 10, 2 );
 
 
35
  }
36
  }
37
 
38
  public function add_icons( $column, $id ) {
39
  global $wp_version;
40
+
41
  if ( $column != 'gadwp_stats' ) {
42
  return;
43
  }
44
+
45
  if ( version_compare( $wp_version, '3.8.0', '>=' ) ) {
46
  echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area"></a>';
47
  } else {
50
  }
51
 
52
  public function add_columns( $columns ) {
53
+ return array_merge( $columns, array( 'gadwp_stats' => __( 'Analytics', 'google-analytics-dashboard-for-wp' ) ) );
 
54
  }
55
  }
56
  }
admin/js/ui.js CHANGED
@@ -8,9 +8,7 @@ jQuery( document ).ready( function () {
8
  }
9
 
10
  jQuery( "#gadwp-notice .notice-dismiss" ).click( function () {
11
- jQuery.post( gadwp_ui_data.ajaxurl, gadwp_ui, function ( response ) {
12
- return true;
13
- } );
14
  } );
15
 
16
  if (gadwp_ui_data.ed_bubble != ''){
8
  }
9
 
10
  jQuery( "#gadwp-notice .notice-dismiss" ).click( function () {
11
+ jQuery.post( gadwp_ui_data.ajaxurl, gadwp_ui );
 
 
12
  } );
13
 
14
  if (gadwp_ui_data.ed_bubble != ''){
admin/settings.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Author: Alin Marcu
5
  * Author URI: https://deconf.com
 
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
@@ -35,34 +35,30 @@ final class GADWP_Settings {
35
  if ( empty( $new_options['ga_track_exclude'] ) ) {
36
  $new_options['ga_track_exclude'] = array();
37
  }
38
- } else
39
- if ( $who == 'backend' ) {
40
- $options['switch_profile'] = 0;
41
- $options['backend_item_reports'] = 0;
42
- $options['dashboard_widget'] = 0;
43
- if ( empty( $new_options['ga_dash_access_back'] ) ) {
44
- $new_options['ga_dash_access_back'][] = 'administrator';
45
- }
46
- } else
47
- if ( $who == 'frontend' ) {
48
- $options['frontend_item_reports'] = 0;
49
- if ( empty( $new_options['ga_dash_access_front'] ) ) {
50
- $new_options['ga_dash_access_front'][] = 'administrator';
51
- }
52
- } else
53
- if ( $who == 'general' ) {
54
- $options['ga_dash_userapi'] = 0;
55
- if ( ! is_multisite() ) {
56
- $options['automatic_updates_minorversion'] = 0;
57
- }
58
- } else
59
- if ( $who == 'network' ) {
60
- $options['ga_dash_userapi'] = 0;
61
- $options['ga_dash_network'] = 0;
62
- $options['ga_dash_excludesa'] = 0;
63
- $options['automatic_updates_minorversion'] = 0;
64
- $network_settings = true;
65
- }
66
  $options = array_merge( $options, $new_options );
67
  $gadwp->config->options = $options;
68
  $gadwp->config->set_plugin_options( $network_settings );
@@ -139,6 +135,8 @@ final class GADWP_Settings {
139
 
140
 
141
 
 
 
142
  </table>
143
  </td>
144
  </tr>
@@ -168,6 +166,8 @@ final class GADWP_Settings {
168
 
169
 
170
 
 
 
171
  </form>
172
  <?php
173
  self::output_sidebar();
@@ -215,7 +215,7 @@ final class GADWP_Settings {
215
  <table>
216
  <tr>
217
  <?php
218
-
219
  foreach ( $wp_roles->role_names as $role => $name ) {
220
  if ( $role != 'subscriber' ) {
221
  $i++;
@@ -236,6 +236,8 @@ final class GADWP_Settings {
236
 
237
 
238
 
 
 
239
  </table>
240
  </td>
241
  </tr>
@@ -301,6 +303,8 @@ final class GADWP_Settings {
301
 
302
 
303
 
 
 
304
  </form>
305
  <?php
306
  self::output_sidebar();
@@ -308,7 +312,7 @@ final class GADWP_Settings {
308
 
309
  public static function tracking_settings() {
310
  $gadwp = GADWP();
311
-
312
  if ( ! current_user_can( 'manage_options' ) ) {
313
  return;
314
  }
@@ -336,12 +340,7 @@ final class GADWP_Settings {
336
  <div class="settings-wrapper">
337
  <div class="inside">
338
  <?php
339
- $tabs = array(
340
- 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ),
341
- 'events' => __( "Events Tracking", 'google-analytics-dashboard-for-wp' ),
342
- 'custom' => __( "Custom Definitions", 'google-analytics-dashboard-for-wp' ),
343
- 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ),
344
- 'advanced' => __( "Advanced Settings", 'google-analytics-dashboard-for-wp' ) );
345
  self::navigation_tabs( $tabs );
346
  if ( isset( $message ) )
347
  echo $message;
@@ -602,6 +601,8 @@ final class GADWP_Settings {
602
 
603
 
604
 
 
 
605
  </table>
606
  </td>
607
  </tr>
@@ -620,6 +621,8 @@ final class GADWP_Settings {
620
 
621
 
622
 
 
 
623
  </form>
624
  <?php
625
  self::output_sidebar();
@@ -627,13 +630,13 @@ final class GADWP_Settings {
627
 
628
  public static function errors_debugging() {
629
  global $wp_version;
630
-
631
  $gadwp = GADWP();
632
-
633
  if ( ! current_user_can( 'manage_options' ) ) {
634
  return;
635
  }
636
-
637
  $anonim = $gadwp->config->options;
638
  $anonim['wp_version'] = $wp_version;
639
  $anonim['gadwp_version'] = GADWP_CURRENT_VERSION;
@@ -646,10 +649,6 @@ final class GADWP_Settings {
646
  if ( $anonim['ga_dash_clientsecret'] ) {
647
  $anonim['ga_dash_clientsecret'] = 'HIDDEN';
648
  }
649
- if ( $anonim['ga_dash_apikey'] ) {
650
- $anonim['ga_dash_apikey'] = 'HIDDEN';
651
- }
652
-
653
  $options = self::update_options( 'frontend' );
654
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token'] ) {
655
  $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
@@ -665,9 +664,7 @@ final class GADWP_Settings {
665
  <div class="inside">
666
  <?php if (isset($message)) echo $message; ?>
667
  <?php
668
- $tabs = array(
669
- 'errors' => __( "Errors & Details", 'google-analytics-dashboard-for-wp' ),
670
- 'config' => __( "Plugin Settings", 'google-analytics-dashboard-for-wp' ) );
671
  self::navigation_tabs( $tabs );
672
  ?>
673
  <div id="gadwp-errors">
@@ -680,7 +677,7 @@ final class GADWP_Settings {
680
  <tr>
681
  <td>
682
  <?php
683
- $errors = print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ? esc_html( str_replace( $gadwp->config->access[2], '' , print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) ) : __( "None", 'google-analytics-dashboard-for-wp' );
684
  echo '<pre class="gadwp-settings-logdata">Last Error: ';
685
  echo $errors;
686
  ?></pre>
@@ -693,15 +690,15 @@ final class GADWP_Settings {
693
  <td>
694
  <?php
695
  echo '<pre class="gadwp-settings-logdata">Error Details: ';
696
- $error_details = print_r( GADWP_Tools::get_cache( 'gapi_errors' ), true ) ? "\n" . esc_html( str_replace( $gadwp->config->access[2], '' , print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) ) : __( "None", 'google-analytics-dashboard-for-wp' );
697
  echo $error_details;
698
  ?></pre><br />
699
  <hr>
700
  </td>
701
-
702
-
703
  <tr>
704
-
705
  </table>
706
  </div>
707
  <div id="gadwp-config">
@@ -721,9 +718,9 @@ final class GADWP_Settings {
721
 
722
  public static function general_settings() {
723
  $gadwp = GADWP();
724
-
725
  global $wp_version;
726
-
727
  if ( ! current_user_can( 'manage_options' ) ) {
728
  return;
729
  }
@@ -755,7 +752,7 @@ final class GADWP_Settings {
755
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
756
  $profile = GADWP_Tools::guess_default_domain( $profiles );
757
  $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
758
- //$gadwp->config->options['ga_dash_tableid'] = $profile;
759
  }
760
  $gadwp->config->set_plugin_options();
761
  $options = self::update_options( 'general' );
@@ -813,8 +810,7 @@ final class GADWP_Settings {
813
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
814
  $message = "<div class='updated'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
815
  $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
816
- $gadwp->config->options['ga_dash_profile_list'] = array(
817
- $lock_profile );
818
  $options = self::update_options( 'general' );
819
  } else {
820
  $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
@@ -831,7 +827,7 @@ final class GADWP_Settings {
831
  <div class="settings-wrapper">
832
  <div class="inside">
833
  <?php
834
- if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache('last_error') ) {
835
  $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
836
  }
837
  if ( isset( $_POST['Authorize'] ) ) {
@@ -839,7 +835,7 @@ final class GADWP_Settings {
839
  $gadwp->gapi_controller->token_request();
840
  echo "<div class='updated'><p>" . __( "Use the red link (see below) to generate and get your access code!", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
841
  } else {
842
- if ( isset( $message ) ){
843
  echo $message;
844
  }
845
  ?>
@@ -863,10 +859,6 @@ final class GADWP_Settings {
863
  </td>
864
  </tr>
865
  <?php } if ($options['ga_dash_userapi']) { ?>
866
- <tr>
867
- <td class="gadwp-settings-title"><label for="options[ga_dash_apikey]"><?php _e("API Key:", 'google-analytics-dashboard-for-wp'); ?></label></td>
868
- <td><input type="text" name="options[ga_dash_apikey]" value="<?php echo esc_attr($options['ga_dash_apikey']); ?>" size="40" required="required"></td>
869
- </tr>
870
  <tr>
871
  <td class="gadwp-settings-title"><label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label></td>
872
  <td><input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required"></td>
@@ -982,7 +974,7 @@ final class GADWP_Settings {
982
  public static function general_settings_network() {
983
  $gadwp = GADWP();
984
  global $wp_version;
985
-
986
  if ( ! current_user_can( 'manage_network_options' ) ) {
987
  return;
988
  }
@@ -991,11 +983,11 @@ final class GADWP_Settings {
991
  * Include GAPI
992
  */
993
  echo '<div id="gapi-warning" class="updated"><p>' . __( 'Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', 'google-analytics-dashboard-for-wp' ) . ' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=general_screen&utm_campaign=gadwp">Library conflicts between WordPress plugins</a></p></div>';
994
-
995
  if ( null === $gadwp->gapi_controller ) {
996
  $gadwp->gapi_controller = new GADWP_GAPI_Controller();
997
  }
998
-
999
  echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
1000
  if ( isset( $_POST['ga_dash_code'] ) ) {
1001
  if ( ! stripos( 'x' . $_POST['ga_dash_code'], 'UA-', 1 ) == 1 ) {
@@ -1007,8 +999,7 @@ final class GADWP_Settings {
1007
  $options = self::update_options( 'network' );
1008
  $message = "<div class='updated'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1009
  if ( is_multisite() ) { // Cleanup errors on the entire network
1010
- foreach ( wp_get_sites( array(
1011
- 'limit' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
1012
  switch_to_blog( $blog['blog_id'] );
1013
  GADWP_Tools::delete_cache( 'gapi_errors' );
1014
  restore_current_blog();
@@ -1027,7 +1018,7 @@ final class GADWP_Settings {
1027
  if ( isset( $gadwp->config->options['ga_dash_tableid_jail'] ) && ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
1028
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1029
  $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
1030
- //$gadwp->config->options['ga_dash_tableid'] = $profile;
1031
  }
1032
  $gadwp->config->set_plugin_options( true );
1033
  $options = self::update_options( 'network' );
@@ -1064,7 +1055,7 @@ final class GADWP_Settings {
1064
  if ( isset( $gadwp->config->options['ga_dash_tableid_jail'] ) && ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
1065
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1066
  $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
1067
- //$gadwp->config->options['ga_dash_tableid'] = $profile;
1068
  }
1069
  $gadwp->config->set_plugin_options( true );
1070
  $options = self::update_options( 'network' );
@@ -1102,8 +1093,7 @@ final class GADWP_Settings {
1102
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1103
  $message = "<div class='updated'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1104
  $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
1105
- $gadwp->config->options['ga_dash_profile_list'] = array(
1106
- $lock_profile );
1107
  $options = self::update_options( 'network' );
1108
  } else {
1109
  $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
@@ -1119,7 +1109,7 @@ final class GADWP_Settings {
1119
  <div class="settings-wrapper">
1120
  <div class="inside">
1121
  <?php
1122
- if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache('last_error')) {
1123
  $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
1124
  }
1125
  if ( isset( $_POST['Authorize'] ) ) {
@@ -1127,7 +1117,7 @@ final class GADWP_Settings {
1127
  $gadwp->gapi_controller->token_request();
1128
  echo "<div class='updated'><p>" . __( "Use the red link (see below) to generate and get your access code!", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1129
  } else {
1130
- if ( isset( $message ) ){
1131
  echo $message;
1132
  }
1133
  ?>
@@ -1172,10 +1162,6 @@ final class GADWP_Settings {
1172
  }
1173
  if ( $options['ga_dash_userapi'] ) {
1174
  ?>
1175
- <tr>
1176
- <td class="gadwp-settings-title"><label for="options[ga_dash_apikey]"><?php _e("API Key:", 'google-analytics-dashboard-for-wp'); ?></label></td>
1177
- <td><input type="text" name="options[ga_dash_apikey]" value="<?php echo esc_attr($options['ga_dash_apikey']); ?>" size="40" required="required"></td>
1178
- </tr>
1179
  <tr>
1180
  <td class="gadwp-settings-title"><label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label></td>
1181
  <td><input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required"></td>
@@ -1203,8 +1189,7 @@ final class GADWP_Settings {
1203
  if ( isset( $options['ga_dash_tableid_network'] ) ) {
1204
  $options['ga_dash_tableid_network'] = json_decode( json_encode( $options['ga_dash_tableid_network'] ), false );
1205
  }
1206
- foreach ( wp_get_sites( array(
1207
- 'limit' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
1208
  ?>
1209
  <tr>
1210
  <td class="gadwp-settings-title-s"><label for="ga_dash_tableid_network"><?php echo '<strong>'.$blog['domain'].$blog['path'].'</strong>: ';?></label></td>
@@ -1289,7 +1274,7 @@ final class GADWP_Settings {
1289
 
1290
  public static function output_sidebar() {
1291
  global $wp_version;
1292
-
1293
  $gadwp = GADWP();
1294
  ?>
1295
  </div>
@@ -1311,11 +1296,10 @@ final class GADWP_Settings {
1311
  </h3>
1312
  <div class="inside">
1313
  <div class="gadash-desc">
1314
- <div style="margin-left:-10px;">
1315
- <div class="g-page" data-width="273" data-href="//plus.google.com/+Deconfcom" data-layout="landscape" data-showtagline="false" data-showcoverphoto="false" data-rel="publisher"></div>
1316
- </div>
1317
-
1318
- <script type="text/javascript">
1319
  (function() {
1320
  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
1321
  po.src = 'https://apis.google.com/js/platform.js';
@@ -1325,8 +1309,8 @@ final class GADWP_Settings {
1325
  </div>
1326
  <br />
1327
  <div class="gadash-desc">
1328
- <a href="https://twitter.com/deconfcom" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @deconfcom</a>
1329
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
1330
  </div>
1331
  <br />
1332
  <div class="gadash-title">
1
  <?php
 
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
35
  if ( empty( $new_options['ga_track_exclude'] ) ) {
36
  $new_options['ga_track_exclude'] = array();
37
  }
38
+ } else if ( $who == 'backend' ) {
39
+ $options['switch_profile'] = 0;
40
+ $options['backend_item_reports'] = 0;
41
+ $options['dashboard_widget'] = 0;
42
+ if ( empty( $new_options['ga_dash_access_back'] ) ) {
43
+ $new_options['ga_dash_access_back'][] = 'administrator';
44
+ }
45
+ } else if ( $who == 'frontend' ) {
46
+ $options['frontend_item_reports'] = 0;
47
+ if ( empty( $new_options['ga_dash_access_front'] ) ) {
48
+ $new_options['ga_dash_access_front'][] = 'administrator';
49
+ }
50
+ } else if ( $who == 'general' ) {
51
+ $options['ga_dash_userapi'] = 0;
52
+ if ( ! is_multisite() ) {
53
+ $options['automatic_updates_minorversion'] = 0;
54
+ }
55
+ } else if ( $who == 'network' ) {
56
+ $options['ga_dash_userapi'] = 0;
57
+ $options['ga_dash_network'] = 0;
58
+ $options['ga_dash_excludesa'] = 0;
59
+ $options['automatic_updates_minorversion'] = 0;
60
+ $network_settings = true;
61
+ }
 
 
 
 
62
  $options = array_merge( $options, $new_options );
63
  $gadwp->config->options = $options;
64
  $gadwp->config->set_plugin_options( $network_settings );
135
 
136
 
137
 
138
+
139
+
140
  </table>
141
  </td>
142
  </tr>
166
 
167
 
168
 
169
+
170
+
171
  </form>
172
  <?php
173
  self::output_sidebar();
215
  <table>
216
  <tr>
217
  <?php
218
+
219
  foreach ( $wp_roles->role_names as $role => $name ) {
220
  if ( $role != 'subscriber' ) {
221
  $i++;
236
 
237
 
238
 
239
+
240
+
241
  </table>
242
  </td>
243
  </tr>
303
 
304
 
305
 
306
+
307
+
308
  </form>
309
  <?php
310
  self::output_sidebar();
312
 
313
  public static function tracking_settings() {
314
  $gadwp = GADWP();
315
+
316
  if ( ! current_user_can( 'manage_options' ) ) {
317
  return;
318
  }
340
  <div class="settings-wrapper">
341
  <div class="inside">
342
  <?php
343
+ $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'events' => __( "Events Tracking", 'google-analytics-dashboard-for-wp' ), 'custom' => __( "Custom Definitions", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'advanced' => __( "Advanced Settings", 'google-analytics-dashboard-for-wp' ) );
 
 
 
 
 
344
  self::navigation_tabs( $tabs );
345
  if ( isset( $message ) )
346
  echo $message;
601
 
602
 
603
 
604
+
605
+
606
  </table>
607
  </td>
608
  </tr>
621
 
622
 
623
 
624
+
625
+
626
  </form>
627
  <?php
628
  self::output_sidebar();
630
 
631
  public static function errors_debugging() {
632
  global $wp_version;
633
+
634
  $gadwp = GADWP();
635
+
636
  if ( ! current_user_can( 'manage_options' ) ) {
637
  return;
638
  }
639
+
640
  $anonim = $gadwp->config->options;
641
  $anonim['wp_version'] = $wp_version;
642
  $anonim['gadwp_version'] = GADWP_CURRENT_VERSION;
649
  if ( $anonim['ga_dash_clientsecret'] ) {
650
  $anonim['ga_dash_clientsecret'] = 'HIDDEN';
651
  }
 
 
 
 
652
  $options = self::update_options( 'frontend' );
653
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token'] ) {
654
  $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
664
  <div class="inside">
665
  <?php if (isset($message)) echo $message; ?>
666
  <?php
667
+ $tabs = array( 'errors' => __( "Errors & Details", 'google-analytics-dashboard-for-wp' ), 'config' => __( "Plugin Settings", 'google-analytics-dashboard-for-wp' ) );
 
 
668
  self::navigation_tabs( $tabs );
669
  ?>
670
  <div id="gadwp-errors">
677
  <tr>
678
  <td>
679
  <?php
680
+ $errors = print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ? esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : __( "None", 'google-analytics-dashboard-for-wp' );
681
  echo '<pre class="gadwp-settings-logdata">Last Error: ';
682
  echo $errors;
683
  ?></pre>
690
  <td>
691
  <?php
692
  echo '<pre class="gadwp-settings-logdata">Error Details: ';
693
+ $error_details = print_r( GADWP_Tools::get_cache( 'gapi_errors' ), true ) ? "\n" . esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : __( "None", 'google-analytics-dashboard-for-wp' );
694
  echo $error_details;
695
  ?></pre><br />
696
  <hr>
697
  </td>
698
+
699
+
700
  <tr>
701
+
702
  </table>
703
  </div>
704
  <div id="gadwp-config">
718
 
719
  public static function general_settings() {
720
  $gadwp = GADWP();
721
+
722
  global $wp_version;
723
+
724
  if ( ! current_user_can( 'manage_options' ) ) {
725
  return;
726
  }
752
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
753
  $profile = GADWP_Tools::guess_default_domain( $profiles );
754
  $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
755
+ // $gadwp->config->options['ga_dash_tableid'] = $profile;
756
  }
757
  $gadwp->config->set_plugin_options();
758
  $options = self::update_options( 'general' );
810
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
811
  $message = "<div class='updated'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
812
  $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
813
+ $gadwp->config->options['ga_dash_profile_list'] = array( $lock_profile );
 
814
  $options = self::update_options( 'general' );
815
  } else {
816
  $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
827
  <div class="settings-wrapper">
828
  <div class="inside">
829
  <?php
830
+ if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) {
831
  $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
832
  }
833
  if ( isset( $_POST['Authorize'] ) ) {
835
  $gadwp->gapi_controller->token_request();
836
  echo "<div class='updated'><p>" . __( "Use the red link (see below) to generate and get your access code!", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
837
  } else {
838
+ if ( isset( $message ) ) {
839
  echo $message;
840
  }
841
  ?>
859
  </td>
860
  </tr>
861
  <?php } if ($options['ga_dash_userapi']) { ?>
 
 
 
 
862
  <tr>
863
  <td class="gadwp-settings-title"><label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label></td>
864
  <td><input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required"></td>
974
  public static function general_settings_network() {
975
  $gadwp = GADWP();
976
  global $wp_version;
977
+
978
  if ( ! current_user_can( 'manage_network_options' ) ) {
979
  return;
980
  }
983
  * Include GAPI
984
  */
985
  echo '<div id="gapi-warning" class="updated"><p>' . __( 'Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', 'google-analytics-dashboard-for-wp' ) . ' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=general_screen&utm_campaign=gadwp">Library conflicts between WordPress plugins</a></p></div>';
986
+
987
  if ( null === $gadwp->gapi_controller ) {
988
  $gadwp->gapi_controller = new GADWP_GAPI_Controller();
989
  }
990
+
991
  echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
992
  if ( isset( $_POST['ga_dash_code'] ) ) {
993
  if ( ! stripos( 'x' . $_POST['ga_dash_code'], 'UA-', 1 ) == 1 ) {
999
  $options = self::update_options( 'network' );
1000
  $message = "<div class='updated'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1001
  if ( is_multisite() ) { // Cleanup errors on the entire network
1002
+ foreach ( wp_get_sites( array( 'limit' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
 
1003
  switch_to_blog( $blog['blog_id'] );
1004
  GADWP_Tools::delete_cache( 'gapi_errors' );
1005
  restore_current_blog();
1018
  if ( isset( $gadwp->config->options['ga_dash_tableid_jail'] ) && ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
1019
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1020
  $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
1021
+ // $gadwp->config->options['ga_dash_tableid'] = $profile;
1022
  }
1023
  $gadwp->config->set_plugin_options( true );
1024
  $options = self::update_options( 'network' );
1055
  if ( isset( $gadwp->config->options['ga_dash_tableid_jail'] ) && ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
1056
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1057
  $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
1058
+ // $gadwp->config->options['ga_dash_tableid'] = $profile;
1059
  }
1060
  $gadwp->config->set_plugin_options( true );
1061
  $options = self::update_options( 'network' );
1093
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1094
  $message = "<div class='updated'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1095
  $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
1096
+ $gadwp->config->options['ga_dash_profile_list'] = array( $lock_profile );
 
1097
  $options = self::update_options( 'network' );
1098
  } else {
1099
  $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1109
  <div class="settings-wrapper">
1110
  <div class="inside">
1111
  <?php
1112
+ if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) {
1113
  $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
1114
  }
1115
  if ( isset( $_POST['Authorize'] ) ) {
1117
  $gadwp->gapi_controller->token_request();
1118
  echo "<div class='updated'><p>" . __( "Use the red link (see below) to generate and get your access code!", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1119
  } else {
1120
+ if ( isset( $message ) ) {
1121
  echo $message;
1122
  }
1123
  ?>
1162
  }
1163
  if ( $options['ga_dash_userapi'] ) {
1164
  ?>
 
 
 
 
1165
  <tr>
1166
  <td class="gadwp-settings-title"><label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label></td>
1167
  <td><input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required"></td>
1189
  if ( isset( $options['ga_dash_tableid_network'] ) ) {
1190
  $options['ga_dash_tableid_network'] = json_decode( json_encode( $options['ga_dash_tableid_network'] ), false );
1191
  }
1192
+ foreach ( wp_get_sites( array( 'limit' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
 
1193
  ?>
1194
  <tr>
1195
  <td class="gadwp-settings-title-s"><label for="ga_dash_tableid_network"><?php echo '<strong>'.$blog['domain'].$blog['path'].'</strong>: ';?></label></td>
1274
 
1275
  public static function output_sidebar() {
1276
  global $wp_version;
1277
+
1278
  $gadwp = GADWP();
1279
  ?>
1280
  </div>
1296
  </h3>
1297
  <div class="inside">
1298
  <div class="gadash-desc">
1299
+ <div style="margin-left: -10px;">
1300
+ <div class="g-page" data-width="273" data-href="//plus.google.com/+Deconfcom" data-layout="landscape" data-showtagline="false" data-showcoverphoto="false" data-rel="publisher"></div>
1301
+ </div>
1302
+ <script type="text/javascript">
 
1303
  (function() {
1304
  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
1305
  po.src = 'https://apis.google.com/js/platform.js';
1309
  </div>
1310
  <br />
1311
  <div class="gadash-desc">
1312
+ <a href="https://twitter.com/deconfcom" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @deconfcom</a>
1313
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
1314
  </div>
1315
  <br />
1316
  <div class="gadash-title">
admin/setup.php CHANGED
@@ -2,6 +2,7 @@
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -18,7 +19,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
18
 
19
  public function __construct() {
20
  $this->gadwp = GADWP();
21
-
22
  // Styles & Scripts
23
  add_action( 'admin_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
24
  // Site Menu
@@ -68,30 +69,34 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
68
  */
69
  public function load_styles_scripts( $hook ) {
70
  $new_hook = explode( '_page_', $hook );
71
-
72
  if ( isset( $new_hook[1] ) ) {
73
  $new_hook = '_page_' . $new_hook[1];
74
  } else {
75
  $new_hook = $hook;
76
  }
77
-
 
 
 
 
78
  /*
79
  * GADWP main stylesheet
80
  */
81
  wp_enqueue_style( 'gadwp', GADWP_URL . 'admin/css/gadwp.css', null, GADWP_CURRENT_VERSION );
82
-
83
  /*
84
  * GADWP UI
85
  */
86
-
87
  if ( GADWP_Tools::get_cache( 'gapi_errors' ) ) {
88
  $ed_bubble = '!';
89
  } else {
90
  $ed_bubble = '';
91
  }
92
-
93
  wp_enqueue_script( 'gadwp-backend-ui', plugins_url( 'js/ui.js', __FILE__ ), array( 'jquery' ), GADWP_CURRENT_VERSION, true );
94
-
95
  /* @formatter:off */
96
  wp_localize_script( 'gadwp-backend-ui', 'gadwp_ui_data', array(
97
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
@@ -100,29 +105,29 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
100
  )
101
  );
102
  /* @formatter:on */
103
-
104
- if ( $this->gadwp->config->options['switch_profile'] && count($this->gadwp->config->options['ga_dash_profile_list']) > 1 ) {
105
  $views = array();
106
  foreach ( $this->gadwp->config->options['ga_dash_profile_list'] as $items ) {
107
  if ( $items[3] ) {
108
- $views[$items[1]] = esc_js( GADWP_Tools::strip_protocol( $items[3] ) ); // . ' &#8658; ' . $items[0] );
109
  }
110
  }
111
  } else {
112
  $views = false;
113
  }
114
-
115
  /*
116
  * Main Dashboard Widgets Styles & Scripts
117
  */
118
  $widgets_hooks = array( 'index.php' );
119
-
120
  if ( in_array( $new_hook, $widgets_hooks ) ) {
121
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && $this->gadwp->config->options['dashboard_widget'] ) {
122
-
123
  if ( $this->gadwp->config->options['ga_target_geomap'] ) {
124
  $country_codes = GADWP_Tools::get_countrycodes();
125
- if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ){
126
  $region = $this->gadwp->config->options['ga_target_geomap'];
127
  } else {
128
  $region = false;
@@ -130,27 +135,27 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
130
  } else {
131
  $region = false;
132
  }
133
-
134
  wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
135
-
136
  wp_enqueue_style( 'gadwp-backend-item-reports', GADWP_URL . 'admin/css/admin-widgets.css', null, GADWP_CURRENT_VERSION );
137
-
138
  wp_register_style( 'jquery-ui-tooltip-html', GADWP_URL . 'common/realtime/jquery.ui.tooltip.html.css' );
139
-
140
  wp_enqueue_style( 'jquery-ui-tooltip-html' );
141
-
142
  wp_register_script( 'jquery-ui-tooltip-html', GADWP_URL . 'common/realtime/jquery.ui.tooltip.html.js' );
143
-
144
  if ( ! wp_script_is( 'googlejsapi' ) ) {
145
- wp_register_script( 'googlejsapi', 'https://www.google.com/jsapi' );
146
  }
147
-
148
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
149
-
150
  wp_enqueue_script( 'gadwp-backend-dashboard-reports', GADWP_URL . 'common/js/reports.js', array( 'jquery', 'googlejsapi', 'gadwp-nprogress', 'jquery-ui-tooltip', 'jquery-ui-core', 'jquery-ui-position', 'jquery-ui-tooltip-html' ), GADWP_CURRENT_VERSION );
151
-
152
  /* @formatter:off */
153
- wp_localize_script( 'gadwp-backend-dashboard-reports', 'gadwp_item_data', array(
154
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
155
  'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
156
  'dateList' => array(
@@ -174,14 +179,15 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
174
  'contentpages' => __( "Pages", 'google-analytics-dashboard-for-wp' ),
175
  'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
176
  'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
177
- 'trafficdetails' => __( "Traffic Details", 'google-analytics-dashboard-for-wp' )
 
178
  ),
179
  'i18n' => array(
180
  __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
181
  __( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ),
182
  __( "Visitor Type", 'google-analytics-dashboard-for-wp' ),
183
- __( "Social Networks", 'google-analytics-dashboard-for-wp' ),
184
  __( "Search Engines", 'google-analytics-dashboard-for-wp' ),
 
185
  __( "Sessions", 'google-analytics-dashboard-for-wp' ),
186
  __( "Users", 'google-analytics-dashboard-for-wp' ),
187
  __( "Page Views", 'google-analytics-dashboard-for-wp' ),
@@ -193,16 +199,18 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
193
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
194
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
195
  __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadash_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
196
- ),
197
- 'i18n_realtime' => array(
198
- __( "REFERRALS", 'google-analytics-dashboard-for-wp' ), //0
 
 
199
  __( "KEYWORDS", 'google-analytics-dashboard-for-wp' ),
200
  __( "SOCIAL", 'google-analytics-dashboard-for-wp' ),
201
  __( "CAMPAIGN", 'google-analytics-dashboard-for-wp' ),
202
  __( "DIRECT", 'google-analytics-dashboard-for-wp' ),
203
- __( "NEW", 'google-analytics-dashboard-for-wp' ), //5
204
  ),
205
- 'realtime_maxpages' => $this->gadwp->config->options['ga_realtime_pages'],
206
  'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
207
  'region' => $region,
208
  'language' => get_bloginfo( 'language' ),
@@ -213,17 +221,17 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
213
  /* @formatter:on */
214
  }
215
  }
216
-
217
  /*
218
  * Posts/Pages List Styles & Scripts
219
  */
220
  $contentstats_hooks = array( 'edit.php' );
221
  if ( in_array( $hook, $contentstats_hooks ) ) {
222
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && $this->gadwp->config->options['backend_item_reports'] ) {
223
-
224
  if ( $this->gadwp->config->options['ga_target_geomap'] ) {
225
  $country_codes = GADWP_Tools::get_countrycodes();
226
- if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ){
227
  $region = $this->gadwp->config->options['ga_target_geomap'];
228
  } else {
229
  $region = false;
@@ -231,23 +239,23 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
231
  } else {
232
  $region = false;
233
  }
234
-
235
  wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
236
-
237
  wp_enqueue_style( 'gadwp-backend-item-reports', GADWP_URL . 'admin/css/item-reports.css', null, GADWP_CURRENT_VERSION );
238
-
239
  wp_enqueue_style( "wp-jquery-ui-dialog" );
240
-
241
  if ( ! wp_script_is( 'googlejsapi' ) ) {
242
- wp_register_script( 'googlejsapi', 'https://www.google.com/jsapi' );
243
  }
244
-
245
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
246
-
247
  wp_enqueue_script( 'gadwp-backend-item-reports', GADWP_URL . 'common/js/reports.js', array( 'gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION );
248
-
249
  /* @formatter:off */
250
- wp_localize_script( 'gadwp-backend-item-reports', 'gadwp_item_data', array(
251
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
252
  'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
253
  'dateList' => array(
@@ -269,7 +277,8 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
269
  'locations' => __( "Location", 'google-analytics-dashboard-for-wp' ),
270
  'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
271
  'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
272
- 'trafficdetails' => __( "Traffic Details", 'google-analytics-dashboard-for-wp' )
 
273
  ),
274
  'i18n' => array(
275
  __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
@@ -288,6 +297,10 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
288
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
289
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
290
  __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadash_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
 
 
 
 
291
  ),
292
  'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
293
  'region' => $region,
@@ -299,12 +312,12 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
299
  /* @formatter:on */
300
  }
301
  }
302
-
303
  /*
304
  * Settings Styles & Scripts
305
  */
306
  $settings_hooks = array( '_page_gadash_settings', '_page_gadash_backend_settings', '_page_gadash_frontend_settings', '_page_gadash_tracking_settings', '_page_gadash_errors_debugging' );
307
-
308
  if ( in_array( $new_hook, $settings_hooks ) ) {
309
  wp_enqueue_style( 'wp-color-picker' );
310
  wp_enqueue_script( 'wp-color-picker' );
@@ -330,19 +343,19 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
330
  * Add an admin notice after a manual or atuomatic update
331
  */
332
  function admin_notice() {
333
-
334
  $currentScreen = get_current_screen();
335
-
336
- if ( ! current_user_can( 'manage_options' ) || $currentScreen->base != 'dashboard') {
337
  return;
338
  }
339
-
340
  if ( get_option( 'gadwp_got_updated' ) ) :
341
  ?>
342
- <div id="gadwp-notice" class="notice is-dismissible">
343
- <p><?php echo sprintf( __('Google Analytics Dashboard for WP has been updated to version %s.', 'google-analytics-dashboard-for-wp' ), GADWP_CURRENT_VERSION).' '.sprintf( __('For details, check out %1$s and %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf(' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_notice&utm_medium=link&utm_content=release_notice&utm_campaign=gadwp">%s</a> ', __('the documentation page', 'google-analytics-dashboard-for-wp') ), sprintf(' <a href="%1$s">%2$s</a>', esc_url( get_admin_url( null, 'admin.php?page=gadash_settings' ) ), __('the plugin&#39;s settings page', 'google-analytics-dashboard-for-wp') ) ); ?></p>
344
- </div>
345
- <?php
 
346
  endif;
347
  }
348
  }
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
+
23
  // Styles & Scripts
24
  add_action( 'admin_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
25
  // Site Menu
69
  */
70
  public function load_styles_scripts( $hook ) {
71
  $new_hook = explode( '_page_', $hook );
72
+
73
  if ( isset( $new_hook[1] ) ) {
74
  $new_hook = '_page_' . $new_hook[1];
75
  } else {
76
  $new_hook = $hook;
77
  }
78
+
79
+ $lang = get_bloginfo( 'language' );
80
+ $lang = explode( '-', $lang );
81
+ $lang = $lang[0];
82
+
83
  /*
84
  * GADWP main stylesheet
85
  */
86
  wp_enqueue_style( 'gadwp', GADWP_URL . 'admin/css/gadwp.css', null, GADWP_CURRENT_VERSION );
87
+
88
  /*
89
  * GADWP UI
90
  */
91
+
92
  if ( GADWP_Tools::get_cache( 'gapi_errors' ) ) {
93
  $ed_bubble = '!';
94
  } else {
95
  $ed_bubble = '';
96
  }
97
+
98
  wp_enqueue_script( 'gadwp-backend-ui', plugins_url( 'js/ui.js', __FILE__ ), array( 'jquery' ), GADWP_CURRENT_VERSION, true );
99
+
100
  /* @formatter:off */
101
  wp_localize_script( 'gadwp-backend-ui', 'gadwp_ui_data', array(
102
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
105
  )
106
  );
107
  /* @formatter:on */
108
+
109
+ if ( $this->gadwp->config->options['switch_profile'] && count( $this->gadwp->config->options['ga_dash_profile_list'] ) > 1 ) {
110
  $views = array();
111
  foreach ( $this->gadwp->config->options['ga_dash_profile_list'] as $items ) {
112
  if ( $items[3] ) {
113
+ $views[$items[1]] = esc_js( GADWP_Tools::strip_protocol( $items[3] ) ); // . ' &#8658; ' . $items[0] );
114
  }
115
  }
116
  } else {
117
  $views = false;
118
  }
119
+
120
  /*
121
  * Main Dashboard Widgets Styles & Scripts
122
  */
123
  $widgets_hooks = array( 'index.php' );
124
+
125
  if ( in_array( $new_hook, $widgets_hooks ) ) {
126
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && $this->gadwp->config->options['dashboard_widget'] ) {
127
+
128
  if ( $this->gadwp->config->options['ga_target_geomap'] ) {
129
  $country_codes = GADWP_Tools::get_countrycodes();
130
+ if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
131
  $region = $this->gadwp->config->options['ga_target_geomap'];
132
  } else {
133
  $region = false;
135
  } else {
136
  $region = false;
137
  }
138
+
139
  wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
140
+
141
  wp_enqueue_style( 'gadwp-backend-item-reports', GADWP_URL . 'admin/css/admin-widgets.css', null, GADWP_CURRENT_VERSION );
142
+
143
  wp_register_style( 'jquery-ui-tooltip-html', GADWP_URL . 'common/realtime/jquery.ui.tooltip.html.css' );
144
+
145
  wp_enqueue_style( 'jquery-ui-tooltip-html' );
146
+
147
  wp_register_script( 'jquery-ui-tooltip-html', GADWP_URL . 'common/realtime/jquery.ui.tooltip.html.js' );
148
+
149
  if ( ! wp_script_is( 'googlejsapi' ) ) {
150
+ wp_register_script( 'googlejsapi', 'https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22language%22%3A%22' . $lang . '%22%2C%22packages%22%3A%5B%22corechart%22%2C%20%22table%22%2C%20%22orgchart%22%2C%20%22geochart%22%5D%7D%5D%7D%27', array(), null );
151
  }
152
+
153
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
154
+
155
  wp_enqueue_script( 'gadwp-backend-dashboard-reports', GADWP_URL . 'common/js/reports.js', array( 'jquery', 'googlejsapi', 'gadwp-nprogress', 'jquery-ui-tooltip', 'jquery-ui-core', 'jquery-ui-position', 'jquery-ui-tooltip-html' ), GADWP_CURRENT_VERSION );
156
+
157
  /* @formatter:off */
158
+ wp_localize_script( 'gadwp-backend-dashboard-reports', 'gadwpItemData', array(
159
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
160
  'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
161
  'dateList' => array(
179
  'contentpages' => __( "Pages", 'google-analytics-dashboard-for-wp' ),
180
  'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
181
  'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
182
+ 'trafficdetails' => __( "Traffic", 'google-analytics-dashboard-for-wp' ),
183
+ 'technologydetails' => __( "Technology", 'google-analytics-dashboard-for-wp' ),
184
  ),
185
  'i18n' => array(
186
  __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
187
  __( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ),
188
  __( "Visitor Type", 'google-analytics-dashboard-for-wp' ),
 
189
  __( "Search Engines", 'google-analytics-dashboard-for-wp' ),
190
+ __( "Social Networks", 'google-analytics-dashboard-for-wp' ),
191
  __( "Sessions", 'google-analytics-dashboard-for-wp' ),
192
  __( "Users", 'google-analytics-dashboard-for-wp' ),
193
  __( "Page Views", 'google-analytics-dashboard-for-wp' ),
199
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
200
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
201
  __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadash_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
202
+ __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
203
+ __( "Operating System", 'google-analytics-dashboard-for-wp' ),
204
+ __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
205
+ __( "Mobile Brand", 'google-analytics-dashboard-for-wp' ),
206
+ __( "REFERRALS", 'google-analytics-dashboard-for-wp' ), //20
207
  __( "KEYWORDS", 'google-analytics-dashboard-for-wp' ),
208
  __( "SOCIAL", 'google-analytics-dashboard-for-wp' ),
209
  __( "CAMPAIGN", 'google-analytics-dashboard-for-wp' ),
210
  __( "DIRECT", 'google-analytics-dashboard-for-wp' ),
211
+ __( "NEW", 'google-analytics-dashboard-for-wp' ), //25
212
  ),
213
+ 'rtLimitPages' => $this->gadwp->config->options['ga_realtime_pages'],
214
  'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
215
  'region' => $region,
216
  'language' => get_bloginfo( 'language' ),
221
  /* @formatter:on */
222
  }
223
  }
224
+
225
  /*
226
  * Posts/Pages List Styles & Scripts
227
  */
228
  $contentstats_hooks = array( 'edit.php' );
229
  if ( in_array( $hook, $contentstats_hooks ) ) {
230
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && $this->gadwp->config->options['backend_item_reports'] ) {
231
+
232
  if ( $this->gadwp->config->options['ga_target_geomap'] ) {
233
  $country_codes = GADWP_Tools::get_countrycodes();
234
+ if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
235
  $region = $this->gadwp->config->options['ga_target_geomap'];
236
  } else {
237
  $region = false;
239
  } else {
240
  $region = false;
241
  }
242
+
243
  wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
244
+
245
  wp_enqueue_style( 'gadwp-backend-item-reports', GADWP_URL . 'admin/css/item-reports.css', null, GADWP_CURRENT_VERSION );
246
+
247
  wp_enqueue_style( "wp-jquery-ui-dialog" );
248
+
249
  if ( ! wp_script_is( 'googlejsapi' ) ) {
250
+ wp_register_script( 'googlejsapi', 'https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22language%22%3A%22' . $lang . '%22%2C%22packages%22%3A%5B%22corechart%22%2C%20%22table%22%2C%20%22orgchart%22%2C%20%22geochart%22%5D%7D%5D%7D%27', array(), null );
251
  }
252
+
253
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
254
+
255
  wp_enqueue_script( 'gadwp-backend-item-reports', GADWP_URL . 'common/js/reports.js', array( 'gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION );
256
+
257
  /* @formatter:off */
258
+ wp_localize_script( 'gadwp-backend-item-reports', 'gadwpItemData', array(
259
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
260
  'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
261
  'dateList' => array(
277
  'locations' => __( "Location", 'google-analytics-dashboard-for-wp' ),
278
  'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
279
  'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
280
+ 'trafficdetails' => __( "Traffic", 'google-analytics-dashboard-for-wp' ),
281
+ 'technologydetails' => __( "Technology", 'google-analytics-dashboard-for-wp' ),
282
  ),
283
  'i18n' => array(
284
  __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
297
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
298
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
299
  __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadash_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
300
+ __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
301
+ __( "Operating System", 'google-analytics-dashboard-for-wp' ),
302
+ __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
303
+ __( "Mobile Brand", 'google-analytics-dashboard-for-wp' ),
304
  ),
305
  'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
306
  'region' => $region,
312
  /* @formatter:on */
313
  }
314
  }
315
+
316
  /*
317
  * Settings Styles & Scripts
318
  */
319
  $settings_hooks = array( '_page_gadash_settings', '_page_gadash_backend_settings', '_page_gadash_frontend_settings', '_page_gadash_tracking_settings', '_page_gadash_errors_debugging' );
320
+
321
  if ( in_array( $new_hook, $settings_hooks ) ) {
322
  wp_enqueue_style( 'wp-color-picker' );
323
  wp_enqueue_script( 'wp-color-picker' );
343
  * Add an admin notice after a manual or atuomatic update
344
  */
345
  function admin_notice() {
 
346
  $currentScreen = get_current_screen();
347
+
348
+ if ( ! current_user_can( 'manage_options' ) || $currentScreen->base != 'dashboard' ) {
349
  return;
350
  }
351
+
352
  if ( get_option( 'gadwp_got_updated' ) ) :
353
  ?>
354
+ <div id="gadwp-notice" class="notice is-dismissible">
355
+ <p><?php echo sprintf( __('Google Analytics Dashboard for WP has been updated to version %s.', 'google-analytics-dashboard-for-wp' ), GADWP_CURRENT_VERSION).' '.sprintf( __('For details, check out %1$s and %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf(' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_notice&utm_medium=link&utm_content=release_notice&utm_campaign=gadwp">%s</a> ', __('the documentation page', 'google-analytics-dashboard-for-wp') ), sprintf(' <a href="%1$s">%2$s</a>', esc_url( get_admin_url( null, 'admin.php?page=gadash_settings' ) ), __('the plugin&#39;s settings page', 'google-analytics-dashboard-for-wp') ) ); ?></p>
356
+ </div>
357
+
358
+ <?php
359
  endif;
360
  }
361
  }
admin/widgets.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  /**
3
- * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -29,12 +30,12 @@ if ( ! class_exists( 'GADWP_Backend_Widgets' ) ) {
29
 
30
  public function dashboard_widget() {
31
  $projectId = 0;
32
-
33
  if ( empty( $this->gadwp->config->options['ga_dash_token'] ) ) {
34
  echo '<p>' . __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadash_settings', false ) . '" method="POST">' . get_submit_button( __( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
35
  return;
36
  }
37
-
38
  if ( current_user_can( 'manage_options' ) ) {
39
  if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
40
  $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
@@ -50,12 +51,12 @@ if ( ! class_exists( 'GADWP_Backend_Widgets' ) ) {
50
  return;
51
  }
52
  }
53
-
54
  if ( ! ( $projectId ) ) {
55
  echo '<p>' . __( "Something went wrong while retrieving property data. You need to create and properly configure a Google Analytics account:", 'google-analytics-dashboard-for-wp' ) . '</p> <form action="https://deconf.com/how-to-set-up-google-analytics-on-your-website/" method="POST">' . get_submit_button( __( "Find out more!", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
56
  return;
57
  }
58
-
59
  ?>
60
  <div id="gadwp-window-1"></div>
61
  <?php
1
  <?php
2
  /**
3
+ * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
30
 
31
  public function dashboard_widget() {
32
  $projectId = 0;
33
+
34
  if ( empty( $this->gadwp->config->options['ga_dash_token'] ) ) {
35
  echo '<p>' . __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadash_settings', false ) . '" method="POST">' . get_submit_button( __( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
36
  return;
37
  }
38
+
39
  if ( current_user_can( 'manage_options' ) ) {
40
  if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
41
  $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
51
  return;
52
  }
53
  }
54
+
55
  if ( ! ( $projectId ) ) {
56
  echo '<p>' . __( "Something went wrong while retrieving property data. You need to create and properly configure a Google Analytics account:", 'google-analytics-dashboard-for-wp' ) . '</p> <form action="https://deconf.com/how-to-set-up-google-analytics-on-your-website/" method="POST">' . get_submit_button( __( "Find out more!", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
57
  return;
58
  }
59
+
60
  ?>
61
  <div id="gadwp-window-1"></div>
62
  <?php
common/ajax-actions.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Common_Ajax' ) ) {
15
+
16
+ final class GADWP_Common_Ajax {
17
+
18
+ private $gadwp;
19
+
20
+ public function __construct() {
21
+ $this->gadwp = GADWP();
22
+
23
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) || GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_front'] ) ) {
24
+ add_action( 'wp_ajax_gadwp_set_error', array( $this, 'ajax_set_error' ) );
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Ajax handler for storing JavaScript Errors
30
+ *
31
+ * @return json|int
32
+ */
33
+ public function ajax_set_error() {
34
+ if ( ! isset( $_POST['gadwp_security_set_error'] ) || ! ( wp_verify_nonce( $_POST['gadwp_security_set_error'], 'gadwp_backend_item_reports' ) || wp_verify_nonce( $_POST['gadwp_security_set_error'], 'gadwp_frontend_item_reports' ) ) ) {
35
+ wp_die( - 40 );
36
+ }
37
+
38
+ GADWP_Tools::set_cache( 'last_error', date( 'Y-m-d H:i:s' ) . ': ' . esc_html( $_POST['response'] ), 24 * 60 * 60 );
39
+
40
+ wp_die();
41
+ }
42
+ }
43
+ }
common/js/reports.js CHANGED
@@ -1,8 +1,12 @@
 
 
 
 
1
  "use strict";
2
 
3
- //Get the numeric ID
4
- gadwp_item_data.getID = function ( item ) {
5
- if ( gadwp_item_data.scope == 'admin-item' ) {
6
  if ( typeof item.id == "undefined" ) {
7
  return 0
8
  }
@@ -24,7 +28,7 @@ gadwp_item_data.getID = function ( item ) {
24
  }
25
 
26
  // Get the selector
27
- gadwp_item_data.getSelector = function ( scope ) {
28
  if ( scope == 'admin-item' ) {
29
  return 'a[id^="gadwp-"]';
30
  } else {
@@ -32,10 +36,10 @@ gadwp_item_data.getSelector = function ( scope ) {
32
  }
33
  }
34
 
35
- gadwp_item_data.responsiveDialog = function () {
36
- var dialog;
37
- var wWidth;
38
- var visible = jQuery( ".ui-dialog:visible" );
39
 
40
  // on each visible dialog
41
  visible.each( function () {
@@ -58,38 +62,33 @@ gadwp_item_data.responsiveDialog = function () {
58
  }
59
 
60
  jQuery.fn.extend( {
61
- gadwpItemReport : function ( item_id ) {
62
- var post_data;
63
- var slug = "-" + item_id;
64
- var dialog_title;
65
- var tools = {
66
- set_cookie : function ( name, value ) {
67
- var expires;
68
- var date_item = new Date();
69
-
70
- if ( gadwp_item_data.scope == 'admin-widgets' ) {
71
  name = "gadwp_wg_" + name;
72
  } else {
73
  name = "gadwp_ir_" + name;
74
  }
75
- date_item.setTime( date_item.getTime() + ( 24 * 60 * 60 * 1000 * 7 ) );
76
- expires = "expires=" + date_item.toUTCString();
77
  document.cookie = name + "=" + value + "; " + expires + "; path=/";
78
  },
79
- get_cookie : function ( name ) {
80
- var i = 0;
81
- var cookie;
82
- var cookies_array;
83
- var div;
84
 
85
- if ( gadwp_item_data.scope == 'admin-widgets' ) {
86
  name = "gadwp_wg_" + name + "=";
87
  } else {
88
  name = "gadwp_ir_" + name + "=";
89
  }
90
- cookies_array = document.cookie.split( ';' );
91
- for ( i = 0; i < cookies_array.length; i++ ) {
92
- cookie = cookies_array[ i ];
93
  while ( cookie.charAt( 0 ) == ' ' )
94
  cookie = cookie.substring( 1 );
95
  if ( cookie.indexOf( name ) == 0 )
@@ -104,33 +103,30 @@ jQuery.fn.extend( {
104
  }
105
  }
106
 
107
- var template = {
108
 
109
  addOptions : function ( id, list ) {
110
- var default_metric;
111
- var default_dimension;
112
- var default_view;
113
- var output = [];
114
 
115
  if ( list == false ) {
116
  return;
117
  }
118
 
119
- if ( !tools.get_cookie( 'default_metric' ) || !tools.get_cookie( 'default_dimension' ) ) {
120
- if ( gadwp_item_data.scope == 'admin-widgets' ) {
121
- default_metric = 'sessions';
122
  } else {
123
- default_metric = 'uniquePageviews';
124
  }
125
- default_dimension = '30daysAgo';
126
  } else {
127
- default_metric = tools.get_cookie( 'default_metric' );
128
- default_dimension = tools.get_cookie( 'default_dimension' );
129
- default_view = tools.get_cookie( 'default_view' );
130
  }
131
 
132
  jQuery.each( list, function ( key, value ) {
133
- if ( key == default_metric || key == default_dimension || key == default_view ) {
134
  output.push( '<option value="' + key + '" selected="selected">' + value + '</option>' );
135
  } else {
136
  output.push( '<option value="' + key + '">' + value + '</option>' );
@@ -151,7 +147,7 @@ jQuery.fn.extend( {
151
  }
152
 
153
  tpl = '<div id="gadwp-container' + slug + '">';
154
- if ( gadwp_item_data.viewList != false ) {
155
  tpl += '<select id="gadwp-sel-view' + slug + '"></select>';
156
  }
157
  tpl += '<select id="gadwp-sel-period' + slug + '"></select> ';
@@ -160,33 +156,28 @@ jQuery.fn.extend( {
160
  tpl += '<div id="gadwp-status' + slug + '"></div>';
161
  tpl += '<div id="gadwp-reports' + slug + '"></div>';
162
  tpl += '<div style="text-align:right;width:100%;font-size:0.8em;clear:both;margin-right:5px;margin-top:10px;">';
163
- tpl += gadwp_item_data.i18n[ 14 ];
164
  tpl += ' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=back_report&utm_campaign=gadwp" rel="nofollow" style="text-decoration:none;font-size:1em;">GADWP</a>&nbsp;';
165
  tpl += '</div>';
166
  tpl += '</div>',
167
 
168
  jQuery( '#gadwp-window' + slug ).append( tpl );
169
 
170
- template.addOptions( '#gadwp-sel-view' + slug, gadwp_item_data.viewList );
171
- template.addOptions( '#gadwp-sel-period' + slug, gadwp_item_data.dateList );
172
- template.addOptions( '#gadwp-sel-report' + slug, gadwp_item_data.reportList );
173
 
174
  }
175
  }
176
 
177
- var reports = {
178
- npcounter : 0,
179
- prs : '',
180
- trafficchannels : '',
181
- trafficmediums : '',
182
- traffictype : '',
183
- trafficorganic : '',
184
- socialnetworks : '',
185
- locations : '',
186
- mainchart : '',
187
- bottomstats : '',
188
  realtime : '',
189
- realtime_running : null,
 
190
 
191
  getTitle : function ( scope ) {
192
  if ( scope == 'admin-item' ) {
@@ -207,88 +198,163 @@ jQuery.fn.extend( {
207
  jQuery( "#gadwp-status" + slug ).html( msg );
208
  },
209
 
210
- drawprs : function ( gadwp_prs ) {
211
- var chart_data = google.visualization.arrayToDataTable( gadwp_prs );
212
- var options = {
213
- page : 'enable',
214
- pageSize : 10,
215
- width : '100%',
216
- allowHtml : true
217
- };
218
- var chart = new google.visualization.Table( document.getElementById( 'gadwp-prs' + slug ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
 
220
- chart.draw( chart_data, options );
221
  },
222
 
223
- drawtrafficchannels : function ( gadwp_trafficchannels ) {
224
- var chart_data = google.visualization.arrayToDataTable( gadwp_trafficchannels );
225
- var options = {
226
- allowCollapse : true,
227
- allowHtml : true,
228
- height : '100%'
229
- };
230
- var chart = new google.visualization.OrgChart( document.getElementById( 'gadwp-trafficchannels' + slug ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
- chart.draw( chart_data, options );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  },
234
 
235
- drawtrafficmediums : function ( gadwp_trafficmediums ) {
236
- var chart_data = google.visualization.arrayToDataTable( gadwp_trafficmediums );
237
- var options = {
238
- is3D : false,
239
- tooltipText : 'percentage',
240
- legend : 'none',
241
- chartArea : {
242
- width : '99%',
243
- height : '80%'
244
- },
245
- title : gadwp_item_data.i18n[ 1 ],
246
- colors : gadwp_item_data.colorVariations
247
- };
248
- var chart = new google.visualization.PieChart( document.getElementById( 'gadwp-trafficmediums' + slug ) );
249
 
250
- chart.draw( chart_data, options );
 
 
 
 
 
 
 
 
 
 
 
 
251
  },
252
 
253
- drawtraffictype : function ( gadwp_traffictype ) {
254
- var chart_data = google.visualization.arrayToDataTable( gadwp_traffictype );
255
- var options = {
256
- is3D : false,
257
- tooltipText : 'percentage',
258
- legend : 'none',
259
- chartArea : {
260
- width : '99%',
261
- height : '80%'
262
- },
263
- title : gadwp_item_data.i18n[ 2 ],
264
- colors : gadwp_item_data.colorVariations
265
  };
266
- var chart = new google.visualization.PieChart( document.getElementById( 'gadwp-traffictype' + slug ) );
267
 
268
- chart.draw( chart_data, options );
269
  },
270
 
271
- drawsocialnetworks : function ( gadwp_socialnetworks ) {
272
- var chart_data = google.visualization.arrayToDataTable( gadwp_socialnetworks );
273
- var options = {
274
- is3D : false,
275
- tooltipText : 'percentage',
276
- legend : 'none',
277
- chartArea : {
278
- width : '99%',
279
- height : '80%'
280
- },
281
- title : gadwp_item_data.i18n[ 3 ],
282
- colors : gadwp_item_data.colorVariations
283
  };
284
- var chart = new google.visualization.PieChart( document.getElementById( 'gadwp-socialnetworks' + slug ) );
285
 
286
- chart.draw( chart_data, options );
287
  },
288
 
289
- drawtrafficorganic : function ( gadwp_trafficorganic ) {
290
- var chart_data = google.visualization.arrayToDataTable( gadwp_trafficorganic );
291
- var options = {
 
 
292
  is3D : false,
293
  tooltipText : 'percentage',
294
  legend : 'none',
@@ -296,48 +362,40 @@ jQuery.fn.extend( {
296
  width : '99%',
297
  height : '80%'
298
  },
299
- title : gadwp_item_data.i18n[ 4 ],
300
- colors : gadwp_item_data.colorVariations
 
301
  };
302
- var chart = new google.visualization.PieChart( document.getElementById( 'gadwp-trafficorganic' + slug ) );
303
 
304
- chart.draw( chart_data, options );
305
  },
306
 
307
- drawlocations : function ( gadwp_locations ) {
308
- var chart_data = google.visualization.arrayToDataTable( gadwp_locations );
309
- var options = {
310
- page : 'enable',
311
- pageSize : 10,
312
- width : '100%'
313
- };
314
- var chart = new google.visualization.Table( document.getElementById( 'gadwp-locations' + slug ) );
315
 
316
- chart.draw( chart_data, options );
317
- },
318
-
319
- drawmaplocations : function ( gadwp_locations ) {
320
- var chart_data = google.visualization.arrayToDataTable( gadwp_locations );
321
- var options = {
322
  chartArea : {
323
  width : '99%',
324
  height : '90%'
325
  },
326
- colors : [ gadwp_item_data.colorVariations[ 5 ], gadwp_item_data.colorVariations[ 4 ] ]
327
  }
328
- if ( gadwp_item_data.region ) {
329
- options.region = gadwp_item_data.region;
330
  options.displayMode = 'markers';
331
  options.datalessRegionColor = 'EFEFEF';
332
  }
333
- var chart = new google.visualization.GeoChart( document.getElementById( 'gadwp-map' + slug ) );
334
 
335
- chart.draw( chart_data, options );
336
  },
337
 
338
- drawmainchart : function ( gadwp_mainchart, format ) {
339
- var chart_data = google.visualization.arrayToDataTable( gadwp_mainchart );
340
- var formatter;
 
341
 
342
  if ( format ) {
343
  formatter = new google.visualization.NumberFormat( {
@@ -345,15 +403,15 @@ jQuery.fn.extend( {
345
  fractionDigits : 2
346
  } );
347
 
348
- formatter.format( chart_data, 1 );
349
  }
350
 
351
- var options = {
352
  legend : {
353
  position : 'none'
354
  },
355
  pointSize : 3,
356
- colors : [ gadwp_item_data.colorVariations[ 0 ], gadwp_item_data.colorVariations[ 4 ] ],
357
  chartArea : {
358
  width : '99%',
359
  height : '90%'
@@ -366,44 +424,41 @@ jQuery.fn.extend( {
366
  textPosition : 'none'
367
  }
368
  };
369
- var chart = new google.visualization.AreaChart( document.getElementById( 'gadwp-mainchart' + slug ) );
370
 
371
- chart.draw( chart_data, options );
372
  },
373
 
374
- drawbottomstats : function ( gadwp_bottomstats ) {
375
- jQuery( "#gdsessions" + slug ).text( gadwp_bottomstats[ 0 ] );
376
- jQuery( "#gdusers" + slug ).text( gadwp_bottomstats[ 1 ] );
377
- jQuery( "#gdpageviews" + slug ).text( gadwp_bottomstats[ 2 ] );
378
- jQuery( "#gdbouncerate" + slug ).text( gadwp_bottomstats[ 3 ] + "%" );
379
- jQuery( "#gdorganicsearch" + slug ).text( gadwp_bottomstats[ 4 ] );
380
- jQuery( "#gdpagespervisit" + slug ).text( gadwp_bottomstats[ 5 ] );
381
  },
382
 
383
- rt_onlyUniqueValues : function ( value, index, self ) {
384
  return self.indexOf( value ) === index;
385
  },
386
 
387
- rt_countsessions : function ( gadwp_realtime, searchvalue ) {
388
- var count = 0;
389
- var i = 0;
390
 
391
- for ( i = 0; i < gadwp_realtime[ "rows" ].length; i = i + 1 ) {
392
- if ( jQuery.inArray( searchvalue, gadwp_realtime[ "rows" ][ i ] ) > -1 ) {
393
- count += parseInt( gadwp_realtime[ "rows" ][ i ][ 6 ] );
394
  }
395
  }
396
  return count;
397
  },
398
 
399
- rt_generatetooltip : function ( gadwp_realtime ) {
400
- var count = 0;
401
- var table = "";
402
- var i = 0;
403
 
404
- for ( i = 0; i < gadwp_realtime.length; i = i + 1 ) {
405
- count += parseInt( gadwp_realtime[ i ].count );
406
- table += "<tr><td class='gadwp-pgdetailsl'>" + gadwp_realtime[ i ].value + "</td><td class='gadwp-pgdetailsr'>" + gadwp_realtime[ i ].count + "</td></tr>";
407
  }
408
  ;
409
  if ( count ) {
@@ -413,102 +468,69 @@ jQuery.fn.extend( {
413
  }
414
  },
415
 
416
- rt_pagedetails : function ( gadwp_realtime, searchvalue ) {
417
- var sant;
418
- var i = 0;
419
- var j = 0;
420
- var sum = 0;
421
- var newsum = 0;
422
- var newgadwp_realtime = [];
423
- var countrfr = 0;
424
- var countkwd = 0;
425
- var countdrt = 0;
426
- var countscl = 0;
427
- var countcpg = 0;
428
- var tablerfr = "";
429
- var tablekwd = "";
430
- var tablescl = "";
431
- var tablecpg = "";
432
- var tabledrt = "";
433
- var pagetitle;
434
- var pgstatstable;
435
-
436
- for ( i = 0; i < gadwp_realtime[ "rows" ].length; i = i + 1 ) {
437
- sant = 1;
438
- for ( j = 0; j < newgadwp_realtime.length; j = j + 1 ) {
439
- jQuery.each( gadwp_realtime[ "rows" ][ i ], function () {
440
- sum += parseFloat( this ) || 0;
441
- } );
442
- jQuery.each( newgadwp_realtime[ j ], function () {
443
- newsum += parseFloat( this ) || 0;
444
- } );
445
- if ( sum == newsum ) {
446
- newgadwp_realtime[ j ][ 6 ] = parseInt( newgadwp_realtime[ j ][ 6 ] ) + parseInt( gadwp_realtime[ "rows" ][ i ][ 6 ] );
447
- sant = 0;
448
- }
449
- }
450
- if ( sant ) {
451
- newgadwp_realtime.push( gadwp_realtime[ "rows" ][ i ].slice() );
452
- }
453
- }
454
 
455
- for ( i = 0; i < newgadwp_realtime.length; i = i + 1 ) {
456
- if ( newgadwp_realtime[ i ][ 0 ] == searchvalue ) {
457
- pagetitle = newgadwp_realtime[ i ][ 5 ];
458
 
459
- switch ( newgadwp_realtime[ i ][ 3 ] ) {
460
 
461
  case "REFERRAL":
462
- countrfr += parseInt( newgadwp_realtime[ i ][ 6 ] );
463
- tablerfr += "<tr><td class='gadwp-pgdetailsl'>" + newgadwp_realtime[ i ][ 1 ] + "</td><td class='gadwp-pgdetailsr'>" + newgadwp_realtime[ i ][ 6 ] + "</td></tr>";
464
  break;
465
  case "ORGANIC":
466
- countkwd += parseInt( newgadwp_realtime[ i ][ 6 ] );
467
- tablekwd += "<tr><td class='gadwp-pgdetailsl'>" + newgadwp_realtime[ i ][ 2 ] + "</td><td class='gadwp-pgdetailsr'>" + newgadwp_realtime[ i ][ 6 ] + "</td></tr>";
468
  break;
469
  case "SOCIAL":
470
- countscl += parseInt( newgadwp_realtime[ i ][ 6 ] );
471
- tablescl += "<tr><td class='gadwp-pgdetailsl'>" + newgadwp_realtime[ i ][ 1 ] + "</td><td class='gadwp-pgdetailsr'>" + newgadwp_realtime[ i ][ 6 ] + "</td></tr>";
472
  break;
473
  case "CUSTOM":
474
- countcpg += parseInt( newgadwp_realtime[ i ][ 6 ] );
475
- tablecpg += "<tr><td class='gadwp-pgdetailsl'>" + newgadwp_realtime[ i ][ 1 ] + "</td><td class='gadwp-pgdetailsr'>" + newgadwp_realtime[ i ][ 6 ] + "</td></tr>";
476
  break;
477
  case "DIRECT":
478
- countdrt += parseInt( newgadwp_realtime[ i ][ 6 ] );
479
  break;
480
  }
481
  }
482
  }
483
 
484
  if ( countrfr ) {
485
- tablerfr = "<table><tr><td>" + gadwp_item_data.i18n_realtime[ 0 ] + "(" + countrfr + ")</td></tr>" + tablerfr + "</table><br />";
486
  }
487
  if ( countkwd ) {
488
- tablekwd = "<table><tr><td>" + gadwp_item_data.i18n_realtime[ 1 ] + "(" + countkwd + ")</td></tr>" + tablekwd + "</table><br />";
489
  }
490
  if ( countscl ) {
491
- tablescl = "<table><tr><td>" + gadwp_item_data.i18n_realtime[ 2 ] + "(" + countscl + ")</td></tr>" + tablescl + "</table><br />";
492
  }
493
  if ( countcpg ) {
494
- tablecpg = "<table><tr><td>" + gadwp_item_data.i18n_realtime[ 3 ] + "(" + countcpg + ")</td></tr>" + tablecpg + "</table><br />";
495
  }
496
  if ( countdrt ) {
497
- tabledrt = "<table><tr><td>" + gadwp_item_data.i18n_realtime[ 4 ] + "(" + countdrt + ")</td></tr></table><br />";
498
  }
499
- return ( "<p><center><strong>" + pagetitle + "</strong></center></p>" + tablerfr + tablekwd + tablescl + tablecpg + tabledrt );
500
  },
501
 
502
- rt_refresh : function () {
503
  if ( reports.render.focusFlag ) {
504
- post_data.from = false;
505
- post_data.to = false;
506
- post_data.query = 'realtime';
507
- jQuery.post( gadwp_item_data.ajaxurl, post_data, function ( response ) {
508
  if ( jQuery.isArray( response ) ) {
509
  jQuery( '#gadwp-reports' + slug ).show();
510
  reports.realtime = response[ 0 ];
511
- reports.drawrealtime( reports.realtime );
512
  } else {
513
  reports.throwDebug( response );
514
  }
@@ -519,27 +541,8 @@ jQuery.fn.extend( {
519
  }
520
  },
521
 
522
- drawrealtime : function ( gadwp_realtime ) {
523
- var i = 0;
524
- var pagepath = [];
525
- var referrals = [];
526
- var keywords = [];
527
- var social = [];
528
- var visittype = [];
529
- var custom = [];
530
- var upagepathstats = [];
531
- var upagepath;
532
- var pgstatstable = "";
533
- var ureferralsstats = [];
534
- var ureferrals;
535
- var ukeywordsstats = [];
536
- var ukeywords;
537
- var usocialstats = [];
538
- var usocial;
539
- var ucustomstats = [];
540
- var ucustom;
541
- var uvisittype = [ "REFERRAL", "ORGANIC", "SOCIAL", "CUSTOM" ];
542
- var uvisitortype = [ "DIRECT", "NEW" ];
543
 
544
  jQuery( function () {
545
  jQuery( '#gadwp-widget *' ).tooltip( {
@@ -547,20 +550,20 @@ jQuery.fn.extend( {
547
  } );
548
  } );
549
 
550
- gadwp_realtime = gadwp_realtime[ 0 ];
551
 
552
- if ( jQuery.isNumeric( gadwp_realtime ) || typeof gadwp_realtime === "undefined" ) {
553
- gadwp_realtime = [];
554
- gadwp_realtime[ "totalsForAllResults" ] = []
555
- gadwp_realtime[ "totalsForAllResults" ][ "rt:activeUsers" ] = "0";
556
- gadwp_realtime[ "rows" ] = [];
557
  }
558
 
559
- if ( gadwp_realtime[ "totalsForAllResults" ][ "rt:activeUsers" ] !== document.getElementById( "gadwp-online" ).innerHTML ) {
560
  jQuery( "#gadwp-online" ).fadeOut( "slow" );
561
  jQuery( "#gadwp-online" ).fadeOut( 500 );
562
  jQuery( "#gadwp-online" ).fadeOut( "slow", function () {
563
- if ( ( parseInt( gadwp_realtime[ "totalsForAllResults" ][ "rt:activeUsers" ] ) ) < ( parseInt( document.getElementById( "gadwp-online" ).innerHTML ) ) ) {
564
  jQuery( "#gadwp-online" ).css( {
565
  'background-color' : '#FFE8E8'
566
  } );
@@ -569,7 +572,7 @@ jQuery.fn.extend( {
569
  'background-color' : '#E0FFEC'
570
  } );
571
  }
572
- document.getElementById( "gadwp-online" ).innerHTML = gadwp_realtime[ "totalsForAllResults" ][ "rt:activeUsers" ];
573
  } );
574
  jQuery( "#gadwp-online" ).fadeIn( "slow" );
575
  jQuery( "#gadwp-online" ).fadeIn( 500 );
@@ -580,97 +583,99 @@ jQuery.fn.extend( {
580
  } );
581
  }
582
 
583
- if ( gadwp_realtime[ "totalsForAllResults" ][ "rt:activeUsers" ] == 0 ) {
584
- gadwp_realtime[ "rows" ] = [];
585
  }
586
 
587
- for ( i = 0; i < gadwp_realtime[ "rows" ].length; i = i + 1 ) {
588
- pagepath.push( gadwp_realtime[ "rows" ][ i ][ 0 ] );
589
- if ( gadwp_realtime[ "rows" ][ i ][ 3 ] == "REFERRAL" ) {
590
- referrals.push( gadwp_realtime[ "rows" ][ i ][ 1 ] );
591
  }
592
- if ( gadwp_realtime[ "rows" ][ i ][ 3 ] == "ORGANIC" ) {
593
- keywords.push( gadwp_realtime[ "rows" ][ i ][ 2 ] );
594
  }
595
- if ( gadwp_realtime[ "rows" ][ i ][ 3 ] == "SOCIAL" ) {
596
- social.push( gadwp_realtime[ "rows" ][ i ][ 1 ] );
597
  }
598
- if ( gadwp_realtime[ "rows" ][ i ][ 3 ] == "CUSTOM" ) {
599
- custom.push( gadwp_realtime[ "rows" ][ i ][ 1 ] );
600
  }
601
- visittype.push( gadwp_realtime[ "rows" ][ i ][ 3 ] );
602
  }
603
 
604
- upagepath = pagepath.filter( reports.rt_onlyUniqueValues );
605
- for ( i = 0; i < upagepath.length; i = i + 1 ) {
606
- upagepathstats[ i ] = {
607
- "pagepath" : upagepath[ i ],
608
- "count" : reports.rt_countsessions( gadwp_realtime, upagepath[ i ] )
609
  }
610
  }
611
- upagepathstats.sort( function ( a, b ) {
612
  return b.count - a.count
613
  } );
614
 
615
- pgstatstable = "";
616
- for ( i = 0; i < upagepathstats.length; i = i + 1 ) {
617
- if ( i < gadwp_item_data.realtime_maxpages ) {
618
- pgstatstable += '<div class="gadwp-pline"><div class="gadwp-pleft"><a href="#" data-gadwp="' + reports.rt_pagedetails( gadwp_realtime, upagepathstats[ i ].pagepath ) + '">' + upagepathstats[ i ].pagepath.substring( 0, 70 ) + '</a></div><div class="gadwp-pright">' + upagepathstats[ i ].count + '</div></div>';
619
  }
620
  }
621
- document.getElementById( "gadwp-pages" ).innerHTML = '<br /><div class="gadwp-pg">' + pgstatstable + '</div>';
622
 
623
- ureferrals = referrals.filter( reports.rt_onlyUniqueValues );
624
- for ( i = 0; i < ureferrals.length; i = i + 1 ) {
625
- ureferralsstats[ i ] = {
626
- "value" : ureferrals[ i ],
627
- "count" : reports.rt_countsessions( gadwp_realtime, ureferrals[ i ] )
628
  };
629
  }
630
- ureferralsstats.sort( function ( a, b ) {
631
  return b.count - a.count
632
  } );
633
 
634
- ukeywords = keywords.filter( reports.rt_onlyUniqueValues );
635
- for ( i = 0; i < ukeywords.length; i = i + 1 ) {
636
- ukeywordsstats[ i ] = {
637
- "value" : ukeywords[ i ],
638
- "count" : reports.rt_countsessions( gadwp_realtime, ukeywords[ i ] )
639
  };
640
  }
641
- ukeywordsstats.sort( function ( a, b ) {
642
  return b.count - a.count
643
  } );
644
 
645
- usocial = social.filter( reports.rt_onlyUniqueValues );
646
- for ( i = 0; i < usocial.length; i = i + 1 ) {
647
- usocialstats[ i ] = {
648
- "value" : usocial[ i ],
649
- "count" : reports.rt_countsessions( gadwp_realtime, usocial[ i ] )
650
  };
651
  }
652
- usocialstats.sort( function ( a, b ) {
653
  return b.count - a.count
654
  } );
655
 
656
- ucustom = custom.filter( reports.rt_onlyUniqueValues );
657
- for ( i = 0; i < ucustom.length; i = i + 1 ) {
658
- ucustomstats[ i ] = {
659
- "value" : ucustom[ i ],
660
- "count" : reports.rt_countsessions( gadwp_realtime, ucustom[ i ] )
661
  };
662
  }
663
- ucustomstats.sort( function ( a, b ) {
664
  return b.count - a.count
665
  } );
666
 
667
- document.getElementById( "gadwp-tdo-right" ).innerHTML = '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rt_generatetooltip( ureferralsstats ) + '"><div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 0 ] + '</a></div><div class="gadwp-bright">' + reports.rt_countsessions( gadwp_realtime, uvisittype[ 0 ] ) + '</div></div>';
668
- document.getElementById( "gadwp-tdo-right" ).innerHTML += '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rt_generatetooltip( ukeywordsstats ) + '"><div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 1 ] + '</a></div><div class="gadwp-bright">' + reports.rt_countsessions( gadwp_realtime, uvisittype[ 1 ] ) + '</div></div>';
669
- document.getElementById( "gadwp-tdo-right" ).innerHTML += '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rt_generatetooltip( usocialstats ) + '"><div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 2 ] + '</a></div><div class="gadwp-bright">' + reports.rt_countsessions( gadwp_realtime, uvisittype[ 2 ] ) + '</div></div>';
670
- document.getElementById( "gadwp-tdo-right" ).innerHTML += '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rt_generatetooltip( ucustomstats ) + '"><div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 3 ] + '</a></div><div class="gadwp-bright">' + reports.rt_countsessions( gadwp_realtime, uvisittype[ 3 ] ) + '</div></div>';
 
 
 
671
 
672
- document.getElementById( "gadwp-tdo-right" ).innerHTML += '<div class="gadwp-bigtext"><div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 4 ] + '</div><div class="gadwp-bright">' + reports.rt_countsessions( gadwp_realtime, uvisitortype[ 0 ] ) + '</div></div>';
673
- document.getElementById( "gadwp-tdo-right" ).innerHTML += '<div class="gadwp-bigtext"><div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 5 ] + '</div><div class="gadwp-bright">' + reports.rt_countsessions( gadwp_realtime, uvisitortype[ 1 ] ) + '</div></div>';
674
  },
675
 
676
  throwDebug : function ( response ) {
@@ -682,10 +687,16 @@ jQuery.fn.extend( {
682
  "border-left" : "5px solid red"
683
  } );
684
  if ( response == '-24' ) {
685
- jQuery( "#gadwp-status" + slug ).html( gadwp_item_data.i18n[ 15 ] );
686
  } else {
687
- jQuery( "#gadwp-status" + slug ).html( gadwp_item_data.i18n[ 11 ] );
688
  console.log( "\n********************* GADWP Log ********************* \n\n" + response );
 
 
 
 
 
 
689
  }
690
  },
691
 
@@ -699,24 +710,20 @@ jQuery.fn.extend( {
699
  "text-align" : "center"
700
  } );
701
  if ( response == -21 ) {
702
- jQuery( target ).html( gadwp_item_data.i18n[ 12 ] + ' (' + response + ')' );
703
  } else {
704
- jQuery( target ).html( gadwp_item_data.i18n[ 13 ] + ' (' + response + ')' );
705
  }
706
  },
707
 
708
  render : function ( view, period, query ) {
709
- var projectId;
710
- var from;
711
- var to;
712
- var tpl;
713
- var focusFlag;
714
 
715
  if ( period == 'realtime' ) {
716
  jQuery( '#gadwp-sel-report' + slug ).hide();
717
  } else {
718
  jQuery( '#gadwp-sel-report' + slug ).show();
719
- clearInterval( reports.realtime_running );
720
  }
721
 
722
  jQuery( '#gadwp-status' + slug ).html( '' );
@@ -755,36 +762,36 @@ jQuery.fn.extend( {
755
  break;
756
  }
757
 
758
- tools.set_cookie( 'default_metric', query );
759
- tools.set_cookie( 'default_dimension', period );
760
 
761
  if ( typeof view !== 'undefined' ) {
762
- tools.set_cookie( 'default_view', view );
763
  projectId = view;
764
  } else {
765
  projectId = false;
766
  }
767
 
768
- if ( gadwp_item_data.scope == 'admin-item' ) {
769
- post_data = {
770
  action : 'gadwp_backend_item_reports',
771
- gadwp_security_backend_item_reports : gadwp_item_data.security,
772
  from : from,
773
  to : to,
774
- filter : item_id
775
  }
776
- } else if ( gadwp_item_data.scope == 'front-item' ) {
777
- post_data = {
778
  action : 'gadwp_frontend_item_reports',
779
- gadwp_security_frontend_item_reports : gadwp_item_data.security,
780
  from : from,
781
  to : to,
782
- filter : gadwp_item_data.filter
783
  }
784
  } else {
785
- post_data = {
786
  action : 'gadwp_backend_item_reports',
787
- gadwp_security_backend_item_reports : gadwp_item_data.security,
788
  projectId : projectId,
789
  from : from,
790
  to : to
@@ -792,6 +799,8 @@ jQuery.fn.extend( {
792
  }
793
  if ( period == 'realtime' ) {
794
 
 
 
795
  reports.render.focusFlag = 1;
796
 
797
  jQuery( window ).bind( "focus", function ( event ) {
@@ -807,27 +816,27 @@ jQuery.fn.extend( {
807
  tpl += '</div>';
808
  tpl += '<div class="gadwp-tdo-right" id="gadwp-tdo-right">';
809
  tpl += '<div class="gadwp-bigtext">';
810
- tpl += '<div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 0 ] + '</div>';
811
  tpl += '<div class="gadwp-bright">0</div>';
812
  tpl += '</div>';
813
  tpl += '<div class="gadwp-bigtext">';
814
- tpl += '<div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 1 ] + '</div>';
815
  tpl += '<div class="gadwp-bright">0</div>';
816
  tpl += '</div>';
817
  tpl += '<div class="gadwp-bigtext">';
818
- tpl += '<div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 2 ] + '</div>';
819
  tpl += '<div class="gadwp-bright">0</div>';
820
  tpl += '</div>';
821
  tpl += '<div class="gadwp-bigtext">';
822
- tpl += '<div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 3 ] + '</div>';
823
  tpl += '<div class="gadwp-bright">0</div>';
824
  tpl += '</div>';
825
  tpl += '<div class="gadwp-bigtext">';
826
- tpl += '<div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 4 ] + '</div>';
827
  tpl += '<div class="gadwp-bright">0</div>';
828
  tpl += '</div>';
829
  tpl += '<div class="gadwp-bigtext">';
830
- tpl += '<div class="gadwp-bleft">' + gadwp_item_data.i18n_realtime[ 5 ] + '</div>';
831
  tpl += '<div class="gadwp-bright">0</div>';
832
  tpl += '</div>';
833
  tpl += '</div>';
@@ -839,226 +848,94 @@ jQuery.fn.extend( {
839
 
840
  jQuery( '#gadwp-reports' + slug ).html( tpl );
841
 
842
- reports.rt_refresh( reports.render.focusFlag );
843
 
844
- reports.realtime_running = setInterval( reports.rt_refresh, 55000 );
845
 
846
  } else {
847
  if ( jQuery.inArray( query, [ 'referrers', 'contentpages', 'searches' ] ) > -1 ) {
848
 
849
- tpl = '<div id="gadwp-trafficchannels' + slug + '"></div>';
850
- tpl += '<div id="gadwp-prs' + slug + '"></div>';
 
 
851
 
852
  jQuery( '#gadwp-reports' + slug ).html( tpl );
853
  jQuery( '#gadwp-reports' + slug ).hide();
854
 
855
- post_data.query = 'trafficchannels,' + query;
856
-
857
- jQuery.post( gadwp_item_data.ajaxurl, post_data, function ( response ) {
858
- if ( jQuery.isArray( response ) ) {
859
- if ( !jQuery.isNumeric( response[ 0 ] ) ) {
860
- if ( jQuery.isArray( response[ 0 ] ) ) {
861
- jQuery( '#gadwp-reports' + slug ).show();
862
- reports.trafficchannels = response[ 0 ];
863
- reports.drawtrafficchannels( reports.trafficchannels );
864
- } else {
865
- reports.throwDebug( response[ 0 ] );
866
- }
867
- } else {
868
- jQuery( '#gadwp-reports' + slug ).show();
869
- reports.throwError( '#gadwp-trafficchannels' + slug, response[ 0 ], "125px" );
870
- }
871
-
872
- if ( !jQuery.isNumeric( response[ 1 ] ) ) {
873
- if ( jQuery.isArray( response[ 1 ] ) ) {
874
- reports.prs = response[ 1 ];
875
- reports.drawprs( reports.prs );
876
- } else {
877
- reports.throwDebug( response[ 1 ] );
878
- }
879
- } else {
880
- reports.throwError( '#gadwp-prs' + slug, response[ 1 ], "125px" );
881
- }
882
- } else {
883
- reports.throwDebug( response );
884
- }
885
- NProgress.done();
886
  } );
887
 
888
- } else if ( query == 'trafficdetails' ) {
889
 
890
- tpl = '<div id="gadwp-trafficchannels' + slug + '"></div>';
 
891
  tpl += '<div class="gadwp-floatwraper">';
892
- tpl += '<div id="gadwp-trafficmediums' + slug + '"></div>';
893
- tpl += '<div id="gadwp-traffictype' + slug + '"></div>';
894
  tpl += '</div>';
895
  tpl += '<div class="gadwp-floatwraper">';
896
- tpl += '<div id="gadwp-trafficorganic' + slug + '"></div>';
897
- tpl += '<div id="gadwp-socialnetworks' + slug + '"></div>';
 
898
  tpl += '</div>';
899
 
900
  jQuery( '#gadwp-reports' + slug ).html( tpl );
901
  jQuery( '#gadwp-reports' + slug ).hide();
 
 
 
 
 
 
 
902
 
903
- post_data.query = 'trafficchannels,medium,visitorType,source,socialNetwork';
904
-
905
- jQuery.post( gadwp_item_data.ajaxurl, post_data, function ( response ) {
906
- if ( jQuery.isArray( response ) ) {
907
- if ( !jQuery.isNumeric( response[ 0 ] ) ) {
908
- if ( jQuery.isArray( response[ 0 ] ) ) {
909
- jQuery( '#gadwp-reports' + slug ).show();
910
- reports.trafficchannels = response[ 0 ];
911
- reports.drawtrafficchannels( reports.trafficchannels );
912
- } else {
913
- reports.throwDebug( response[ 0 ] );
914
- }
915
- } else {
916
- jQuery( '#gadwp-reports' + slug ).show();
917
- reports.throwError( '#gadwp-trafficchannels' + slug, response[ 0 ], "125px" );
918
- }
919
-
920
- if ( !jQuery.isNumeric( response[ 1 ] ) ) {
921
- if ( jQuery.isArray( response[ 1 ] ) ) {
922
- jQuery( '#gadwp-reports' + slug ).show();
923
- reports.trafficmediums = response[ 1 ];
924
- reports.drawtrafficmediums( reports.trafficmediums );
925
- } else {
926
- reports.throwDebug( response[ 1 ] );
927
- }
928
- } else {
929
- jQuery( '#gadwp-reports' + slug ).show();
930
- reports.throwError( '#gadwp-trafficmediums' + slug, response[ 1 ], "80px" );
931
- }
932
-
933
- if ( !jQuery.isNumeric( response[ 2 ] ) ) {
934
- if ( jQuery.isArray( response[ 2 ] ) ) {
935
- jQuery( '#gadwp-reports' + slug ).show();
936
- reports.traffictype = response[ 2 ];
937
- reports.drawtraffictype( reports.traffictype );
938
- } else {
939
- reports.throwDebug( response[ 2 ] );
940
- }
941
- } else {
942
- jQuery( '#gadwp-reports' + slug ).show();
943
- reports.throwError( '#gadwp-traffictype' + slug, response[ 2 ], "80px" );
944
- }
945
-
946
- if ( !jQuery.isNumeric( response[ 3 ] ) ) {
947
- if ( jQuery.isArray( response[ 3 ] ) ) {
948
- jQuery( '#gadwp-reports' + slug ).show();
949
- reports.trafficorganic = response[ 3 ];
950
- reports.drawtrafficorganic( reports.trafficorganic );
951
- } else {
952
- reports.throwDebug( response[ 3 ] );
953
- }
954
- } else {
955
- jQuery( '#gadwp-reports' + slug ).show();
956
- reports.throwError( '#gadwp-trafficorganic' + slug, response[ 3 ], "80px" );
957
- }
958
-
959
- if ( !jQuery.isNumeric( response[ 4 ] ) ) {
960
- if ( jQuery.isArray( response[ 4 ] ) ) {
961
- jQuery( '#gadwp-reports' + slug ).show();
962
- reports.socialnetworks = response[ 4 ];
963
- reports.drawsocialnetworks( reports.socialnetworks );
964
- } else {
965
- reports.throwDebug( response[ 4 ] );
966
- }
967
- } else {
968
- jQuery( '#gadwp-reports' + slug ).show();
969
- reports.throwError( '#gadwp-socialnetworks' + slug, response[ 4 ], "80px" );
970
- }
971
- } else {
972
- reports.throwDebug( response );
973
- }
974
- NProgress.done();
975
  } );
976
 
977
  } else if ( query == 'locations' ) {
978
 
979
- tpl = '<div id="gadwp-map' + slug + '"></div>';
980
- tpl += '<div id="gadwp-locations' + slug + '"></div>';
 
 
981
 
982
  jQuery( '#gadwp-reports' + slug ).html( tpl );
983
  jQuery( '#gadwp-reports' + slug ).hide();
984
 
985
- post_data.query = query;
986
-
987
- jQuery.post( gadwp_item_data.ajaxurl, post_data, function ( response ) {
988
- if ( jQuery.isArray( response ) ) {
989
- if ( !jQuery.isNumeric( response[ 0 ] ) ) {
990
- if ( jQuery.isArray( response[ 0 ] ) ) {
991
- jQuery( '#gadwp-reports' + slug ).show();
992
- reports.locations = response[ 0 ];
993
- reports.drawmaplocations( reports.locations );
994
- reports.drawlocations( reports.locations );
995
- } else {
996
- reports.throwDebug( response[ 0 ] );
997
- }
998
- } else {
999
- jQuery( '#gadwp-reports' + slug ).show();
1000
- reports.throwError( '#gadwp-map' + slug, response[ 0 ], "125px" );
1001
- reports.throwError( '#gadwp-locations' + slug, response[ 0 ], "125px" );
1002
- }
1003
- } else {
1004
- reports.throwDebug( response );
1005
- }
1006
- NProgress.done();
1007
  } );
1008
 
1009
  } else {
1010
 
1011
- tpl = '<div id="gadwp-mainchart' + slug + '"></div>';
1012
- tpl += '<div id="gadwp-bottomstats' + slug + '" class="gadwp-wrapper">';
 
1013
  tpl += '<div class="inside">';
1014
- tpl += '<div class="small-box"><h3>' + gadwp_item_data.i18n[ 5 ] + '</h3><p id="gdsessions' + slug + '">&nbsp;</p></div>';
1015
- tpl += '<div class="small-box"><h3>' + gadwp_item_data.i18n[ 6 ] + '</h3><p id="gdusers' + slug + '">&nbsp;</p></div>';
1016
- tpl += '<div class="small-box"><h3>' + gadwp_item_data.i18n[ 7 ] + '</h3><p id="gdpageviews' + slug + '">&nbsp;</p></div>';
1017
- tpl += '<div class="small-box"><h3>' + gadwp_item_data.i18n[ 8 ] + '</h3><p id="gdbouncerate' + slug + '">&nbsp;</p></div>';
1018
- tpl += '<div class="small-box"><h3>' + gadwp_item_data.i18n[ 9 ] + '</h3><p id="gdorganicsearch' + slug + '">&nbsp;</p></div>';
1019
- tpl += '<div class="small-box"><h3>' + gadwp_item_data.i18n[ 10 ] + '</h3><p id="gdpagespervisit' + slug + '">&nbsp;</p></div>';
 
1020
  tpl += '</div>';
1021
  tpl += '</div>';
1022
 
1023
  jQuery( '#gadwp-reports' + slug ).html( tpl );
1024
  jQuery( '#gadwp-reports' + slug ).hide();
1025
 
1026
- post_data.query = query + ',bottomstats';
1027
-
1028
- jQuery.post( gadwp_item_data.ajaxurl, post_data, function ( response ) {
1029
- if ( jQuery.isArray( response ) ) {
1030
- if ( !jQuery.isNumeric( response[ 0 ] ) ) {
1031
- if ( jQuery.isArray( response[ 0 ] ) ) {
1032
- jQuery( '#gadwp-reports' + slug ).show();
1033
- reports.mainchart = response[ 0 ];
1034
- if ( query == 'visitBounceRate' ) {
1035
- reports.drawmainchart( reports.mainchart, true );
1036
- } else {
1037
- reports.drawmainchart( reports.mainchart, false );
1038
- }
1039
- } else {
1040
- reports.throwDebug( response[ 0 ] );
1041
- }
1042
- } else {
1043
- jQuery( '#gadwp-reports' + slug ).show();
1044
- reports.throwError( '#gadwp-mainchart' + slug, response[ 0 ], "125px" );
1045
- }
1046
- if ( !jQuery.isNumeric( response[ 1 ] ) ) {
1047
- if ( jQuery.isArray( response[ 1 ] ) ) {
1048
- jQuery( '#gadwp-reports' + slug ).show();
1049
- reports.bottomstats = response[ 1 ];
1050
- reports.drawbottomstats( reports.bottomstats );
1051
- } else {
1052
- reports.throwDebug( response[ 1 ] );
1053
- }
1054
- } else {
1055
- jQuery( '#gadwp-reports' + slug ).show();
1056
- reports.throwError( '#gadwp-bottomstats' + slug, response[ 1 ], "40px" );
1057
- }
1058
- } else {
1059
- reports.throwDebug( response );
1060
- }
1061
- NProgress.done();
1062
  } );
1063
 
1064
  }
@@ -1068,35 +945,17 @@ jQuery.fn.extend( {
1068
  },
1069
 
1070
  refresh : function () {
1071
- if ( jQuery( '#gadwp-bottomstats' + slug ).length > 0 ) {
1072
- reports.drawbottomstats( reports.bottomstats );
1073
- }
1074
- if ( jQuery( '#gadwp-mainchart' + slug ).length > 0 && jQuery.isArray( reports.mainchart ) ) {
1075
- reports.drawmainchart( reports.mainchart );
1076
- }
1077
- if ( jQuery( '#gadwp-map' + slug ).length > 0 && jQuery.isArray( reports.locations ) ) {
1078
- reports.drawmaplocations( reports.locations );
1079
- }
1080
- if ( jQuery( '#gadwp-locations' + slug ).length > 0 && jQuery.isArray( reports.locations ) ) {
1081
- reports.drawlocations( reports.locations );
1082
  }
1083
- if ( jQuery( '#gadwp-socialnetworks' + slug ).length > 0 && jQuery.isArray( reports.socialnetworks ) ) {
1084
- reports.drawsocialnetworks( reports.socialnetworks );
1085
  }
1086
- if ( jQuery( '#gadwp-trafficorganic' + slug ).length > 0 && jQuery.isArray( reports.trafficorganic ) ) {
1087
- reports.drawtrafficorganic( reports.trafficorganic );
1088
  }
1089
- if ( jQuery( '#gadwp-traffictype' + slug ).length > 0 && jQuery.isArray( reports.traffictype ) ) {
1090
- reports.drawtraffictype( reports.traffictype );
1091
- }
1092
- if ( jQuery( '#gadwp-trafficmediums' + slug ).length > 0 && jQuery.isArray( reports.trafficmediums ) ) {
1093
- reports.drawtrafficmediums( reports.trafficmediums );
1094
- }
1095
- if ( jQuery( '#gadwp-trafficchannels' + slug ).length > 0 && jQuery.isArray( reports.trafficchannels ) ) {
1096
- reports.drawtrafficchannels( reports.trafficchannels );
1097
- }
1098
- if ( jQuery( '#gadwp-prs' + slug ).length > 0 && jQuery.isArray( reports.prs ) ) {
1099
- reports.drawprs( reports.prs );
1100
  }
1101
  },
1102
 
@@ -1117,7 +976,7 @@ jQuery.fn.extend( {
1117
  } );
1118
  NProgress.start();
1119
  } catch ( e ) {
1120
- reports.alertMessage( gadwp_item_data.i18n[ 0 ] );
1121
  }
1122
 
1123
  reports.render( jQuery( '#gadwp-sel-view' + slug ).val(), jQuery( '#gadwp-sel-period' + slug ).val(), jQuery( '#gadwp-sel-report' + slug ).val() );
@@ -1147,7 +1006,7 @@ jQuery.fn.extend( {
1147
  reports.init();
1148
  } );
1149
 
1150
- if ( gadwp_item_data.scope == 'admin-widgets' ) {
1151
  return;
1152
  } else {
1153
  return this.dialog( {
@@ -1158,7 +1017,7 @@ jQuery.fn.extend( {
1158
  fluid : true,
1159
  dialogClass : 'gadwp wp-dialog',
1160
  resizable : false,
1161
- title : reports.getTitle( gadwp_item_data.scope ),
1162
  position : {
1163
  my : "top",
1164
  at : "top+100",
@@ -1169,34 +1028,25 @@ jQuery.fn.extend( {
1169
  }
1170
  } );
1171
 
1172
- google.load( "visualization", "1", {
1173
- packages : [ "corechart", "table", "orgchart" ],
1174
- 'language' : gadwp_item_data.language,
1175
- } );
1176
-
1177
- google.setOnLoadCallback( GADWPLoad );
1178
-
1179
- function GADWPLoad () {
1180
- jQuery( function () {
1181
- if ( gadwp_item_data.scope == 'admin-widgets' ) {
1182
- jQuery( '#gadwp-window-1' ).gadwpItemReport( 1 );
1183
- } else {
1184
- jQuery( gadwp_item_data.getSelector( gadwp_item_data.scope ) ).click( function () {
1185
- if ( !jQuery( "#gadwp-window-" + gadwp_item_data.getID( this ) ).length > 0 ) {
1186
- jQuery( "body" ).append( '<div id="gadwp-window-' + gadwp_item_data.getID( this ) + '"></div>' );
1187
- }
1188
- jQuery( '#gadwp-window-' + gadwp_item_data.getID( this ) ).gadwpItemReport( gadwp_item_data.getID( this ) );
1189
- } );
1190
- }
1191
-
1192
- // on window resize
1193
- jQuery( window ).resize( function () {
1194
- gadwp_item_data.responsiveDialog();
1195
  } );
 
1196
 
1197
- // dialog width larger than viewport
1198
- jQuery( document ).on( "dialogopen", ".ui-dialog", function ( event, ui ) {
1199
- gadwp_item_data.responsiveDialog();
1200
- } );
1201
  } );
1202
- }
 
 
 
 
 
1
+ /**
2
+ * Author: Alin Marcu Author URI: https://deconf.com Copyright 2013 Alin Marcu License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html
3
+ */
4
+
5
  "use strict";
6
 
7
+ // Get the numeric ID
8
+ gadwpItemData.getID = function ( item ) {
9
+ if ( gadwpItemData.scope == 'admin-item' ) {
10
  if ( typeof item.id == "undefined" ) {
11
  return 0
12
  }
28
  }
29
 
30
  // Get the selector
31
+ gadwpItemData.getSelector = function ( scope ) {
32
  if ( scope == 'admin-item' ) {
33
  return 'a[id^="gadwp-"]';
34
  } else {
36
  }
37
  }
38
 
39
+ gadwpItemData.responsiveDialog = function () {
40
+ var dialog, wWidth, visible;
41
+
42
+ visible = jQuery( ".ui-dialog:visible" );
43
 
44
  // on each visible dialog
45
  visible.each( function () {
62
  }
63
 
64
  jQuery.fn.extend( {
65
+ gadwpItemReport : function ( itemId ) {
66
+ var postData, tools, template, reports, refresh, init, slug = "-" + itemId;
67
+
68
+ tools = {
69
+ setCookie : function ( name, value ) {
70
+ var expires, dateItem = new Date();
71
+
72
+ if ( gadwpItemData.scope == 'admin-widgets' ) {
 
 
73
  name = "gadwp_wg_" + name;
74
  } else {
75
  name = "gadwp_ir_" + name;
76
  }
77
+ dateItem.setTime( dateItem.getTime() + ( 24 * 60 * 60 * 1000 * 7 ) );
78
+ expires = "expires=" + dateItem.toUTCString();
79
  document.cookie = name + "=" + value + "; " + expires + "; path=/";
80
  },
81
+ getCookie : function ( name ) {
82
+ var cookie, cookiesArray, div, i = 0;
 
 
 
83
 
84
+ if ( gadwpItemData.scope == 'admin-widgets' ) {
85
  name = "gadwp_wg_" + name + "=";
86
  } else {
87
  name = "gadwp_ir_" + name + "=";
88
  }
89
+ cookiesArray = document.cookie.split( ';' );
90
+ for ( i = 0; i < cookiesArray.length; i++ ) {
91
+ cookie = cookiesArray[ i ];
92
  while ( cookie.charAt( 0 ) == ' ' )
93
  cookie = cookie.substring( 1 );
94
  if ( cookie.indexOf( name ) == 0 )
103
  }
104
  }
105
 
106
+ template = {
107
 
108
  addOptions : function ( id, list ) {
109
+ var defaultMetric, defaultDimension, defaultView, output = [];
 
 
 
110
 
111
  if ( list == false ) {
112
  return;
113
  }
114
 
115
+ if ( !tools.getCookie( 'default_metric' ) || !tools.getCookie( 'default_dimension' ) ) {
116
+ if ( gadwpItemData.scope == 'admin-widgets' ) {
117
+ defaultMetric = 'sessions';
118
  } else {
119
+ defaultMetric = 'uniquePageviews';
120
  }
121
+ defaultDimension = '30daysAgo';
122
  } else {
123
+ defaultMetric = tools.getCookie( 'default_metric' );
124
+ defaultDimension = tools.getCookie( 'default_dimension' );
125
+ defaultView = tools.getCookie( 'default_view' );
126
  }
127
 
128
  jQuery.each( list, function ( key, value ) {
129
+ if ( key == defaultMetric || key == defaultDimension || key == defaultView ) {
130
  output.push( '<option value="' + key + '" selected="selected">' + value + '</option>' );
131
  } else {
132
  output.push( '<option value="' + key + '">' + value + '</option>' );
147
  }
148
 
149
  tpl = '<div id="gadwp-container' + slug + '">';
150
+ if ( gadwpItemData.viewList != false ) {
151
  tpl += '<select id="gadwp-sel-view' + slug + '"></select>';
152
  }
153
  tpl += '<select id="gadwp-sel-period' + slug + '"></select> ';
156
  tpl += '<div id="gadwp-status' + slug + '"></div>';
157
  tpl += '<div id="gadwp-reports' + slug + '"></div>';
158
  tpl += '<div style="text-align:right;width:100%;font-size:0.8em;clear:both;margin-right:5px;margin-top:10px;">';
159
+ tpl += gadwpItemData.i18n[ 14 ];
160
  tpl += ' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=back_report&utm_campaign=gadwp" rel="nofollow" style="text-decoration:none;font-size:1em;">GADWP</a>&nbsp;';
161
  tpl += '</div>';
162
  tpl += '</div>',
163
 
164
  jQuery( '#gadwp-window' + slug ).append( tpl );
165
 
166
+ template.addOptions( '#gadwp-sel-view' + slug, gadwpItemData.viewList );
167
+ template.addOptions( '#gadwp-sel-period' + slug, gadwpItemData.dateList );
168
+ template.addOptions( '#gadwp-sel-report' + slug, gadwpItemData.reportList );
169
 
170
  }
171
  }
172
 
173
+ reports = {
174
+ orgChartTableChartData : '',
175
+ orgChartPieChartsData : '',
176
+ geoChartTableChartData : '',
177
+ areaChartBottomStatsData : '',
 
 
 
 
 
 
178
  realtime : '',
179
+ rtRuns : null,
180
+ i18n : null,
181
 
182
  getTitle : function ( scope ) {
183
  if ( scope == 'admin-item' ) {
198
  jQuery( "#gadwp-status" + slug ).html( msg );
199
  },
200
 
201
+ areaChartBottomStats : function ( response ) {
202
+ reports.areaChartBottomStatsData = response;
203
+ if ( jQuery.isArray( response ) ) {
204
+ if ( !jQuery.isNumeric( response[ 0 ] ) ) {
205
+ if ( jQuery.isArray( response[ 0 ] ) ) {
206
+ jQuery( '#gadwp-reports' + slug ).show();
207
+ if ( postData.query == 'visitBounceRate,bottomstats' ) {
208
+ reports.drawAreaChart( response[ 0 ], true );
209
+ } else {
210
+ reports.drawAreaChart( response[ 0 ], false );
211
+ }
212
+ } else {
213
+ reports.throwDebug( response[ 0 ] );
214
+ }
215
+ } else {
216
+ jQuery( '#gadwp-reports' + slug ).show();
217
+ reports.throwError( '#gadwp-areachart' + slug, response[ 0 ], "125px" );
218
+ }
219
+ if ( !jQuery.isNumeric( response[ 1 ] ) ) {
220
+ if ( jQuery.isArray( response[ 1 ] ) ) {
221
+ jQuery( '#gadwp-reports' + slug ).show();
222
+ reports.drawBottomStats( response[ 1 ] );
223
+ } else {
224
+ reports.throwDebug( response[ 1 ] );
225
+ }
226
+ } else {
227
+ jQuery( '#gadwp-reports' + slug ).show();
228
+ reports.throwError( '#gadwp-bottomstats' + slug, response[ 1 ], "40px" );
229
+ }
230
+ } else {
231
+ reports.throwDebug( response );
232
+ }
233
+ NProgress.done();
234
 
 
235
  },
236
 
237
+ orgChartPieCharts : function ( response ) {
238
+ var i = 0;
239
+ reports.orgChartPieChartsData = response;
240
+ if ( jQuery.isArray( response ) ) {
241
+ if ( !jQuery.isNumeric( response[ 0 ] ) ) {
242
+ if ( jQuery.isArray( response[ 0 ] ) ) {
243
+ jQuery( '#gadwp-reports' + slug ).show();
244
+ reports.drawOrgChart( response[ 0 ] );
245
+ } else {
246
+ reports.throwDebug( response[ 0 ] );
247
+ }
248
+ } else {
249
+ jQuery( '#gadwp-reports' + slug ).show();
250
+ reports.throwError( '#gadwp-orgchart' + slug, response[ 0 ], "125px" );
251
+ }
252
+
253
+ for ( i = 1; i < response.length; i++ ) {
254
+ if ( !jQuery.isNumeric( response[ i ] ) ) {
255
+ if ( jQuery.isArray( response[ i ] ) ) {
256
+ jQuery( '#gadwp-reports' + slug ).show();
257
+ reports.drawPieChart( 'piechart-' + i, response[ i ], reports.i18n[ i ] );
258
+ } else {
259
+ reports.throwDebug( response[ i ] );
260
+ }
261
+ } else {
262
+ jQuery( '#gadwp-reports' + slug ).show();
263
+ reports.throwError( '#gadwp-piechart-' + i + slug, response[ i ], "80px" );
264
+ }
265
+ }
266
+ } else {
267
+ reports.throwDebug( response );
268
+ }
269
+ NProgress.done();
270
+ },
271
 
272
+ geoChartTableChart : function ( response ) {
273
+ reports.geoChartTableChartData = response;
274
+ if ( jQuery.isArray( response ) ) {
275
+ if ( !jQuery.isNumeric( response[ 0 ] ) ) {
276
+ if ( jQuery.isArray( response[ 0 ] ) ) {
277
+ jQuery( '#gadwp-reports' + slug ).show();
278
+ reports.drawGeoChart( response[ 0 ] );
279
+ reports.drawTableChart( response[ 0 ] );
280
+ } else {
281
+ reports.throwDebug( response[ 0 ] );
282
+ }
283
+ } else {
284
+ jQuery( '#gadwp-reports' + slug ).show();
285
+ reports.throwError( '#gadwp-geochart' + slug, response[ 0 ], "125px" );
286
+ reports.throwError( '#gadwp-tablechart' + slug, response[ 0 ], "125px" );
287
+ }
288
+ } else {
289
+ reports.throwDebug( response );
290
+ }
291
+ NProgress.done();
292
  },
293
 
294
+ orgChartTableChart : function ( response ) {
295
+ reports.orgChartTableChartData = response
296
+ if ( jQuery.isArray( response ) ) {
297
+ if ( !jQuery.isNumeric( response[ 0 ] ) ) {
298
+ if ( jQuery.isArray( response[ 0 ] ) ) {
299
+ jQuery( '#gadwp-reports' + slug ).show();
300
+ reports.drawOrgChart( response[ 0 ] );
301
+ } else {
302
+ reports.throwDebug( response[ 0 ] );
303
+ }
304
+ } else {
305
+ jQuery( '#gadwp-reports' + slug ).show();
306
+ reports.throwError( '#gadwp-orgchart' + slug, response[ 0 ], "125px" );
307
+ }
308
 
309
+ if ( !jQuery.isNumeric( response[ 1 ] ) ) {
310
+ if ( jQuery.isArray( response[ 1 ] ) ) {
311
+ reports.drawTableChart( response[ 1 ] );
312
+ } else {
313
+ reports.throwDebug( response[ 1 ] );
314
+ }
315
+ } else {
316
+ reports.throwError( '#gadwp-tablechart' + slug, response[ 1 ], "125px" );
317
+ }
318
+ } else {
319
+ reports.throwDebug( response );
320
+ }
321
+ NProgress.done();
322
  },
323
 
324
+ drawTableChart : function ( data ) {
325
+ var chartData, options, chart;
326
+
327
+ chartData = google.visualization.arrayToDataTable( data );
328
+ options = {
329
+ page : 'enable',
330
+ pageSize : 10,
331
+ width : '100%',
332
+ allowHtml : true
 
 
 
333
  };
334
+ chart = new google.visualization.Table( document.getElementById( 'gadwp-tablechart' + slug ) );
335
 
336
+ chart.draw( chartData, options );
337
  },
338
 
339
+ drawOrgChart : function ( data ) {
340
+ var chartData, options, chart;
341
+
342
+ chartData = google.visualization.arrayToDataTable( data );
343
+ options = {
344
+ allowCollapse : true,
345
+ allowHtml : true,
346
+ height : '100%'
 
 
 
 
347
  };
348
+ chart = new google.visualization.OrgChart( document.getElementById( 'gadwp-orgchart' + slug ) );
349
 
350
+ chart.draw( chartData, options );
351
  },
352
 
353
+ drawPieChart : function ( id, data, title ) {
354
+ var chartData, options, chart;
355
+
356
+ chartData = google.visualization.arrayToDataTable( data );
357
+ options = {
358
  is3D : false,
359
  tooltipText : 'percentage',
360
  legend : 'none',
362
  width : '99%',
363
  height : '80%'
364
  },
365
+ title : title,
366
+ pieSliceText: 'value',
367
+ colors : gadwpItemData.colorVariations
368
  };
369
+ chart = new google.visualization.PieChart( document.getElementById( 'gadwp-' + id + slug ) );
370
 
371
+ chart.draw( chartData, options );
372
  },
373
 
374
+ drawGeoChart : function ( data ) {
375
+ var chartData, options, chart;
 
 
 
 
 
 
376
 
377
+ chartData = google.visualization.arrayToDataTable( data );
378
+ options = {
 
 
 
 
379
  chartArea : {
380
  width : '99%',
381
  height : '90%'
382
  },
383
+ colors : [ gadwpItemData.colorVariations[ 5 ], gadwpItemData.colorVariations[ 4 ] ]
384
  }
385
+ if ( gadwpItemData.region ) {
386
+ options.region = gadwpItemData.region;
387
  options.displayMode = 'markers';
388
  options.datalessRegionColor = 'EFEFEF';
389
  }
390
+ chart = new google.visualization.GeoChart( document.getElementById( 'gadwp-geochart' + slug ) );
391
 
392
+ chart.draw( chartData, options );
393
  },
394
 
395
+ drawAreaChart : function ( data, format ) {
396
+ var chartData, options, chart, formatter;
397
+
398
+ chartData = google.visualization.arrayToDataTable( data );
399
 
400
  if ( format ) {
401
  formatter = new google.visualization.NumberFormat( {
403
  fractionDigits : 2
404
  } );
405
 
406
+ formatter.format( chartData, 1 );
407
  }
408
 
409
+ options = {
410
  legend : {
411
  position : 'none'
412
  },
413
  pointSize : 3,
414
+ colors : [ gadwpItemData.colorVariations[ 0 ], gadwpItemData.colorVariations[ 4 ] ],
415
  chartArea : {
416
  width : '99%',
417
  height : '90%'
424
  textPosition : 'none'
425
  }
426
  };
427
+ chart = new google.visualization.AreaChart( document.getElementById( 'gadwp-areachart' + slug ) );
428
 
429
+ chart.draw( chartData, options );
430
  },
431
 
432
+ drawBottomStats : function ( data ) {
433
+ jQuery( "#gdsessions" + slug ).text( data[ 0 ] );
434
+ jQuery( "#gdusers" + slug ).text( data[ 1 ] );
435
+ jQuery( "#gdpageviews" + slug ).text( data[ 2 ] );
436
+ jQuery( "#gdbouncerate" + slug ).text( data[ 3 ] + "%" );
437
+ jQuery( "#gdorganicsearch" + slug ).text( data[ 4 ] );
438
+ jQuery( "#gdpagespervisit" + slug ).text( data[ 5 ] );
439
  },
440
 
441
+ rtOnlyUniqueValues : function ( value, index, self ) {
442
  return self.indexOf( value ) === index;
443
  },
444
 
445
+ rtCountSessions : function ( rtData, searchValue ) {
446
+ var count = 0, i = 0;
 
447
 
448
+ for ( i = 0; i < rtData[ "rows" ].length; i++ ) {
449
+ if ( jQuery.inArray( searchValue, rtData[ "rows" ][ i ] ) > -1 ) {
450
+ count += parseInt( rtData[ "rows" ][ i ][ 6 ] );
451
  }
452
  }
453
  return count;
454
  },
455
 
456
+ rtGenerateTooltip : function ( rtData ) {
457
+ var count = 0, table = "", i = 0;
 
 
458
 
459
+ for ( i = 0; i < rtData.length; i++ ) {
460
+ count += parseInt( rtData[ i ].count );
461
+ table += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ].value + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ].count + "</td></tr>";
462
  }
463
  ;
464
  if ( count ) {
468
  }
469
  },
470
 
471
+ rtPageDetails : function ( rtData, searchValue ) {
472
+ var sant, pageTitle, pgStatsTable, i = 0, j = 0, sum = 0, newsum = 0, countrfr = 0, countkwd = 0, countdrt = 0, countscl = 0, countcpg = 0, tablerfr = "", tablekwd = "", tablescl = "", tablecpg = "", tabledrt = "";
473
+
474
+ rtData = rtData[ "rows" ];
475
+
476
+ for ( i = 0; i < rtData.length; i++ ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
 
478
+ if ( rtData[ i ][ 0 ] == searchValue ) {
479
+ pageTitle = rtData[ i ][ 5 ];
 
480
 
481
+ switch ( rtData[ i ][ 3 ] ) {
482
 
483
  case "REFERRAL":
484
+ countrfr += parseInt( rtData[ i ][ 6 ] );
485
+ tablerfr += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ][ 1 ] + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ][ 6 ] + "</td></tr>";
486
  break;
487
  case "ORGANIC":
488
+ countkwd += parseInt( rtData[ i ][ 6 ] );
489
+ tablekwd += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ][ 2 ] + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ][ 6 ] + "</td></tr>";
490
  break;
491
  case "SOCIAL":
492
+ countscl += parseInt( rtData[ i ][ 6 ] );
493
+ tablescl += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ][ 1 ] + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ][ 6 ] + "</td></tr>";
494
  break;
495
  case "CUSTOM":
496
+ countcpg += parseInt( rtData[ i ][ 6 ] );
497
+ tablecpg += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ][ 1 ] + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ][ 6 ] + "</td></tr>";
498
  break;
499
  case "DIRECT":
500
+ countdrt += parseInt( rtData[ i ][ 6 ] );
501
  break;
502
  }
503
  }
504
  }
505
 
506
  if ( countrfr ) {
507
+ tablerfr = "<table><tr><td>" + reports.i18n[ 0 ] + "(" + countrfr + ")</td></tr>" + tablerfr + "</table><br />";
508
  }
509
  if ( countkwd ) {
510
+ tablekwd = "<table><tr><td>" + reports.i18n[ 1 ] + "(" + countkwd + ")</td></tr>" + tablekwd + "</table><br />";
511
  }
512
  if ( countscl ) {
513
+ tablescl = "<table><tr><td>" + reports.i18n[ 2 ] + "(" + countscl + ")</td></tr>" + tablescl + "</table><br />";
514
  }
515
  if ( countcpg ) {
516
+ tablecpg = "<table><tr><td>" + reports.i18n[ 3 ] + "(" + countcpg + ")</td></tr>" + tablecpg + "</table><br />";
517
  }
518
  if ( countdrt ) {
519
+ tabledrt = "<table><tr><td>" + reports.i18n[ 4 ] + "(" + countdrt + ")</td></tr></table><br />";
520
  }
521
+ return ( "<p><center><strong>" + pageTitle + "</strong></center></p>" + tablerfr + tablekwd + tablescl + tablecpg + tabledrt );
522
  },
523
 
524
+ rtRefresh : function () {
525
  if ( reports.render.focusFlag ) {
526
+ postData.from = false;
527
+ postData.to = false;
528
+ postData.query = 'realtime';
529
+ jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
530
  if ( jQuery.isArray( response ) ) {
531
  jQuery( '#gadwp-reports' + slug ).show();
532
  reports.realtime = response[ 0 ];
533
+ reports.drawRealtime( reports.realtime );
534
  } else {
535
  reports.throwDebug( response );
536
  }
541
  }
542
  },
543
 
544
+ drawRealtime : function ( rtData ) {
545
+ var rtInfoRight, uPagePath, uReferrals, uKeywords, uSocial, uCustom, i = 0, pagepath = [], referrals = [], keywords = [], social = [], visittype = [], custom = [], uPagePathStats = [], pgStatsTable = "", uReferrals = [], uKeywords = [], uSocial = [], uCustom = [], uVisitType = [ "REFERRAL", "ORGANIC", "SOCIAL", "CUSTOM" ], uVisitorType = [ "DIRECT", "NEW" ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
 
547
  jQuery( function () {
548
  jQuery( '#gadwp-widget *' ).tooltip( {
550
  } );
551
  } );
552
 
553
+ rtData = rtData[ 0 ];
554
 
555
+ if ( jQuery.isNumeric( rtData ) || typeof rtData === "undefined" ) {
556
+ rtData = [];
557
+ rtData[ "totalsForAllResults" ] = []
558
+ rtData[ "totalsForAllResults" ][ "rt:activeUsers" ] = "0";
559
+ rtData[ "rows" ] = [];
560
  }
561
 
562
+ if ( rtData[ "totalsForAllResults" ][ "rt:activeUsers" ] !== document.getElementById( "gadwp-online" ).innerHTML ) {
563
  jQuery( "#gadwp-online" ).fadeOut( "slow" );
564
  jQuery( "#gadwp-online" ).fadeOut( 500 );
565
  jQuery( "#gadwp-online" ).fadeOut( "slow", function () {
566
+ if ( ( parseInt( rtData[ "totalsForAllResults" ][ "rt:activeUsers" ] ) ) < ( parseInt( document.getElementById( "gadwp-online" ).innerHTML ) ) ) {
567
  jQuery( "#gadwp-online" ).css( {
568
  'background-color' : '#FFE8E8'
569
  } );
572
  'background-color' : '#E0FFEC'
573
  } );
574
  }
575
+ document.getElementById( "gadwp-online" ).innerHTML = rtData[ "totalsForAllResults" ][ "rt:activeUsers" ];
576
  } );
577
  jQuery( "#gadwp-online" ).fadeIn( "slow" );
578
  jQuery( "#gadwp-online" ).fadeIn( 500 );
583
  } );
584
  }
585
 
586
+ if ( rtData[ "totalsForAllResults" ][ "rt:activeUsers" ] == 0 ) {
587
+ rtData[ "rows" ] = [];
588
  }
589
 
590
+ for ( i = 0; i < rtData[ "rows" ].length; i++ ) {
591
+ pagepath.push( rtData[ "rows" ][ i ][ 0 ] );
592
+ if ( rtData[ "rows" ][ i ][ 3 ] == "REFERRAL" ) {
593
+ referrals.push( rtData[ "rows" ][ i ][ 1 ] );
594
  }
595
+ if ( rtData[ "rows" ][ i ][ 3 ] == "ORGANIC" ) {
596
+ keywords.push( rtData[ "rows" ][ i ][ 2 ] );
597
  }
598
+ if ( rtData[ "rows" ][ i ][ 3 ] == "SOCIAL" ) {
599
+ social.push( rtData[ "rows" ][ i ][ 1 ] );
600
  }
601
+ if ( rtData[ "rows" ][ i ][ 3 ] == "CUSTOM" ) {
602
+ custom.push( rtData[ "rows" ][ i ][ 1 ] );
603
  }
604
+ visittype.push( rtData[ "rows" ][ i ][ 3 ] );
605
  }
606
 
607
+ uPagePath = pagepath.filter( reports.rtOnlyUniqueValues );
608
+ for ( i = 0; i < uPagePath.length; i++ ) {
609
+ uPagePathStats[ i ] = {
610
+ "pagepath" : uPagePath[ i ],
611
+ "count" : reports.rtCountSessions( rtData, uPagePath[ i ] )
612
  }
613
  }
614
+ uPagePathStats.sort( function ( a, b ) {
615
  return b.count - a.count
616
  } );
617
 
618
+ pgStatsTable = "";
619
+ for ( i = 0; i < uPagePathStats.length; i++ ) {
620
+ if ( i < gadwpItemData.rtLimitPages ) {
621
+ pgStatsTable += '<div class="gadwp-pline"><div class="gadwp-pleft"><a href="#" data-gadwp="' + reports.rtPageDetails( rtData, uPagePathStats[ i ].pagepath ) + '">' + uPagePathStats[ i ].pagepath.substring( 0, 70 ) + '</a></div><div class="gadwp-pright">' + uPagePathStats[ i ].count + '</div></div>';
622
  }
623
  }
624
+ document.getElementById( "gadwp-pages" ).innerHTML = '<br /><div class="gadwp-pg">' + pgStatsTable + '</div>';
625
 
626
+ uReferrals = referrals.filter( reports.rtOnlyUniqueValues );
627
+ for ( i = 0; i < uReferrals.length; i++ ) {
628
+ uReferrals[ i ] = {
629
+ "value" : uReferrals[ i ],
630
+ "count" : reports.rtCountSessions( rtData, uReferrals[ i ] )
631
  };
632
  }
633
+ uReferrals.sort( function ( a, b ) {
634
  return b.count - a.count
635
  } );
636
 
637
+ uKeywords = keywords.filter( reports.rtOnlyUniqueValues );
638
+ for ( i = 0; i < uKeywords.length; i++ ) {
639
+ uKeywords[ i ] = {
640
+ "value" : uKeywords[ i ],
641
+ "count" : reports.rtCountSessions( rtData, uKeywords[ i ] )
642
  };
643
  }
644
+ uKeywords.sort( function ( a, b ) {
645
  return b.count - a.count
646
  } );
647
 
648
+ uSocial = social.filter( reports.rtOnlyUniqueValues );
649
+ for ( i = 0; i < uSocial.length; i++ ) {
650
+ uSocial[ i ] = {
651
+ "value" : uSocial[ i ],
652
+ "count" : reports.rtCountSessions( rtData, uSocial[ i ] )
653
  };
654
  }
655
+ uSocial.sort( function ( a, b ) {
656
  return b.count - a.count
657
  } );
658
 
659
+ uCustom = custom.filter( reports.rtOnlyUniqueValues );
660
+ for ( i = 0; i < uCustom.length; i++ ) {
661
+ uCustom[ i ] = {
662
+ "value" : uCustom[ i ],
663
+ "count" : reports.rtCountSessions( rtData, uCustom[ i ] )
664
  };
665
  }
666
+ uCustom.sort( function ( a, b ) {
667
  return b.count - a.count
668
  } );
669
 
670
+ rtInfoRight = '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rtGenerateTooltip( uReferrals ) + '"><div class="gadwp-bleft">' + reports.i18n[ 0 ] + '</a></div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitType[ 0 ] ) + '</div></div>';
671
+ rtInfoRight += '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rtGenerateTooltip( uKeywords ) + '"><div class="gadwp-bleft">' + reports.i18n[ 1 ] + '</a></div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitType[ 1 ] ) + '</div></div>';
672
+ rtInfoRight += '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rtGenerateTooltip( uSocial ) + '"><div class="gadwp-bleft">' + reports.i18n[ 2 ] + '</a></div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitType[ 2 ] ) + '</div></div>';
673
+ rtInfoRight += '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rtGenerateTooltip( uCustom ) + '"><div class="gadwp-bleft">' + reports.i18n[ 3 ] + '</a></div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitType[ 3 ] ) + '</div></div>';
674
+
675
+ rtInfoRight += '<div class="gadwp-bigtext"><div class="gadwp-bleft">' + reports.i18n[ 4 ] + '</div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitorType[ 0 ] ) + '</div></div>';
676
+ rtInfoRight += '<div class="gadwp-bigtext"><div class="gadwp-bleft">' + reports.i18n[ 5 ] + '</div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitorType[ 1 ] ) + '</div></div>';
677
 
678
+ document.getElementById( "gadwp-tdo-right" ).innerHTML = rtInfoRight;
 
679
  },
680
 
681
  throwDebug : function ( response ) {
687
  "border-left" : "5px solid red"
688
  } );
689
  if ( response == '-24' ) {
690
+ jQuery( "#gadwp-status" + slug ).html( gadwpItemData.i18n[ 15 ] );
691
  } else {
692
+ jQuery( "#gadwp-status" + slug ).html( gadwpItemData.i18n[ 11 ] );
693
  console.log( "\n********************* GADWP Log ********************* \n\n" + response );
694
+ postData = {
695
+ action : 'gadwp_set_error',
696
+ response : response,
697
+ gadwp_security_set_error : gadwpItemData.security,
698
+ }
699
+ jQuery.post( gadwpItemData.ajaxurl, postData );
700
  }
701
  },
702
 
710
  "text-align" : "center"
711
  } );
712
  if ( response == -21 ) {
713
+ jQuery( target ).html( gadwpItemData.i18n[ 12 ] + ' (' + response + ')' );
714
  } else {
715
+ jQuery( target ).html( gadwpItemData.i18n[ 13 ] + ' (' + response + ')' );
716
  }
717
  },
718
 
719
  render : function ( view, period, query ) {
720
+ var projectId, from, to, tpl, focusFlag;
 
 
 
 
721
 
722
  if ( period == 'realtime' ) {
723
  jQuery( '#gadwp-sel-report' + slug ).hide();
724
  } else {
725
  jQuery( '#gadwp-sel-report' + slug ).show();
726
+ clearInterval( reports.rtRuns );
727
  }
728
 
729
  jQuery( '#gadwp-status' + slug ).html( '' );
762
  break;
763
  }
764
 
765
+ tools.setCookie( 'default_metric', query );
766
+ tools.setCookie( 'default_dimension', period );
767
 
768
  if ( typeof view !== 'undefined' ) {
769
+ tools.setCookie( 'default_view', view );
770
  projectId = view;
771
  } else {
772
  projectId = false;
773
  }
774
 
775
+ if ( gadwpItemData.scope == 'admin-item' ) {
776
+ postData = {
777
  action : 'gadwp_backend_item_reports',
778
+ gadwp_security_backend_item_reports : gadwpItemData.security,
779
  from : from,
780
  to : to,
781
+ filter : itemId
782
  }
783
+ } else if ( gadwpItemData.scope == 'front-item' ) {
784
+ postData = {
785
  action : 'gadwp_frontend_item_reports',
786
+ gadwp_security_frontend_item_reports : gadwpItemData.security,
787
  from : from,
788
  to : to,
789
+ filter : gadwpItemData.filter
790
  }
791
  } else {
792
+ postData = {
793
  action : 'gadwp_backend_item_reports',
794
+ gadwp_security_backend_item_reports : gadwpItemData.security,
795
  projectId : projectId,
796
  from : from,
797
  to : to
799
  }
800
  if ( period == 'realtime' ) {
801
 
802
+ reports.i18n = gadwpItemData.i18n.slice( 20, 26 );
803
+
804
  reports.render.focusFlag = 1;
805
 
806
  jQuery( window ).bind( "focus", function ( event ) {
816
  tpl += '</div>';
817
  tpl += '<div class="gadwp-tdo-right" id="gadwp-tdo-right">';
818
  tpl += '<div class="gadwp-bigtext">';
819
+ tpl += '<div class="gadwp-bleft">' + reports.i18n[ 0 ] + '</div>';
820
  tpl += '<div class="gadwp-bright">0</div>';
821
  tpl += '</div>';
822
  tpl += '<div class="gadwp-bigtext">';
823
+ tpl += '<div class="gadwp-bleft">' + reports.i18n[ 1 ] + '</div>';
824
  tpl += '<div class="gadwp-bright">0</div>';
825
  tpl += '</div>';
826
  tpl += '<div class="gadwp-bigtext">';
827
+ tpl += '<div class="gadwp-bleft">' + reports.i18n[ 2 ] + '</div>';
828
  tpl += '<div class="gadwp-bright">0</div>';
829
  tpl += '</div>';
830
  tpl += '<div class="gadwp-bigtext">';
831
+ tpl += '<div class="gadwp-bleft">' + reports.i18n[ 3 ] + '</div>';
832
  tpl += '<div class="gadwp-bright">0</div>';
833
  tpl += '</div>';
834
  tpl += '<div class="gadwp-bigtext">';
835
+ tpl += '<div class="gadwp-bleft">' + reports.i18n[ 4 ] + '</div>';
836
  tpl += '<div class="gadwp-bright">0</div>';
837
  tpl += '</div>';
838
  tpl += '<div class="gadwp-bigtext">';
839
+ tpl += '<div class="gadwp-bleft">' + reports.i18n[ 5 ] + '</div>';
840
  tpl += '<div class="gadwp-bright">0</div>';
841
  tpl += '</div>';
842
  tpl += '</div>';
848
 
849
  jQuery( '#gadwp-reports' + slug ).html( tpl );
850
 
851
+ reports.rtRefresh( reports.render.focusFlag );
852
 
853
+ reports.rtRuns = setInterval( reports.rtRefresh, 55000 );
854
 
855
  } else {
856
  if ( jQuery.inArray( query, [ 'referrers', 'contentpages', 'searches' ] ) > -1 ) {
857
 
858
+ tpl = '<div id="gadwp-orgcharttablechart' + slug + '">';
859
+ tpl += '<div id="gadwp-orgchart' + slug + '"></div>';
860
+ tpl += '<div id="gadwp-tablechart' + slug + '"></div>';
861
+ tpl += '</div>';
862
 
863
  jQuery( '#gadwp-reports' + slug ).html( tpl );
864
  jQuery( '#gadwp-reports' + slug ).hide();
865
 
866
+ postData.query = 'channelGrouping,' + query;
867
+
868
+ jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
869
+ reports.orgChartTableChart( response );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
870
  } );
871
 
872
+ } else if ( query == 'trafficdetails' || query == 'technologydetails' ) {
873
 
874
+ tpl = '<div id="gadwp-orgchartpiecharts' + slug + '">';
875
+ tpl += '<div id="gadwp-orgchart' + slug + '"></div>';
876
  tpl += '<div class="gadwp-floatwraper">';
877
+ tpl += '<div id="gadwp-piechart-1' + slug + '" class="halfsize floatleft"></div>';
878
+ tpl += '<div id="gadwp-piechart-2' + slug + '" class="halfsize floatright"></div>';
879
  tpl += '</div>';
880
  tpl += '<div class="gadwp-floatwraper">';
881
+ tpl += '<div id="gadwp-piechart-3' + slug + '" class="halfsize floatleft"></div>';
882
+ tpl += '<div id="gadwp-piechart-4' + slug + '" class="halfsize floatright"></div>';
883
+ tpl += '</div>';
884
  tpl += '</div>';
885
 
886
  jQuery( '#gadwp-reports' + slug ).html( tpl );
887
  jQuery( '#gadwp-reports' + slug ).hide();
888
+ if ( query == 'trafficdetails' ) {
889
+ postData.query = 'channelGrouping,medium,visitorType,source,socialNetwork';
890
+ reports.i18n = gadwpItemData.i18n.slice( 0, 5 );
891
+ } else {
892
+ reports.i18n = gadwpItemData.i18n.slice( 15, 20 );
893
+ postData.query = 'deviceCategory,browser,operatingSystem,screenResolution,mobileDeviceBranding';
894
+ }
895
 
896
+ jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
897
+ reports.orgChartPieCharts( response )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
898
  } );
899
 
900
  } else if ( query == 'locations' ) {
901
 
902
+ tpl = '<div id="gadwp-geocharttablechart' + slug + '">';
903
+ tpl += '<div id="gadwp-geochart' + slug + '"></div>';
904
+ tpl += '<div id="gadwp-tablechart' + slug + '"></div>';
905
+ tpl += '</div>';
906
 
907
  jQuery( '#gadwp-reports' + slug ).html( tpl );
908
  jQuery( '#gadwp-reports' + slug ).hide();
909
 
910
+ postData.query = query;
911
+
912
+ jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
913
+ reports.geoChartTableChart( response );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
914
  } );
915
 
916
  } else {
917
 
918
+ tpl = '<div id="gadwp-areachartbottomstats' + slug + '">';
919
+ tpl += '<div id="gadwp-areachart' + slug + '"></div>';
920
+ tpl += '<div id="gadwp-bottomstats' + slug + '">';
921
  tpl += '<div class="inside">';
922
+ tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 5 ] + '</h3><p id="gdsessions' + slug + '">&nbsp;</p></div>';
923
+ tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 6 ] + '</h3><p id="gdusers' + slug + '">&nbsp;</p></div>';
924
+ tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 7 ] + '</h3><p id="gdpageviews' + slug + '">&nbsp;</p></div>';
925
+ tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 8 ] + '</h3><p id="gdbouncerate' + slug + '">&nbsp;</p></div>';
926
+ tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 9 ] + '</h3><p id="gdorganicsearch' + slug + '">&nbsp;</p></div>';
927
+ tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 10 ] + '</h3><p id="gdpagespervisit' + slug + '">&nbsp;</p></div>';
928
+ tpl += '</div>';
929
  tpl += '</div>';
930
  tpl += '</div>';
931
 
932
  jQuery( '#gadwp-reports' + slug ).html( tpl );
933
  jQuery( '#gadwp-reports' + slug ).hide();
934
 
935
+ postData.query = query + ',bottomstats';
936
+
937
+ jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
938
+ reports.areaChartBottomStats( response );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
939
  } );
940
 
941
  }
945
  },
946
 
947
  refresh : function () {
948
+ if ( jQuery( '#gadwp-areachartbottomstats' + slug ).length > 0 && jQuery.isArray( reports.areaChartBottomStatsData ) ) {
949
+ reports.areaChartBottomStats( reports.areaChartBottomStatsData );
 
 
 
 
 
 
 
 
 
950
  }
951
+ if ( jQuery( '#gadwp-orgchartpiecharts' + slug ).length > 0 && jQuery.isArray( reports.orgChartPieChartsData ) ) {
952
+ reports.orgChartPieCharts( reports.orgChartPieChartsData );
953
  }
954
+ if ( jQuery( '#gadwp-geocharttablechart' + slug ).length > 0 && jQuery.isArray( reports.geoChartTableChartData ) ) {
955
+ reports.geoChartTableChart( reports.geoChartTableChartData );
956
  }
957
+ if ( jQuery( '#gadwp-orgcharttablechart' + slug ).length > 0 && jQuery.isArray( reports.orgChartTableChartData ) ) {
958
+ reports.orgChartTableChart( reports.orgChartTableChartData );
 
 
 
 
 
 
 
 
 
959
  }
960
  },
961
 
976
  } );
977
  NProgress.start();
978
  } catch ( e ) {
979
+ reports.alertMessage( gadwpItemData.i18n[ 0 ] );
980
  }
981
 
982
  reports.render( jQuery( '#gadwp-sel-view' + slug ).val(), jQuery( '#gadwp-sel-period' + slug ).val(), jQuery( '#gadwp-sel-report' + slug ).val() );
1006
  reports.init();
1007
  } );
1008
 
1009
+ if ( gadwpItemData.scope == 'admin-widgets' ) {
1010
  return;
1011
  } else {
1012
  return this.dialog( {
1017
  fluid : true,
1018
  dialogClass : 'gadwp wp-dialog',
1019
  resizable : false,
1020
+ title : reports.getTitle( gadwpItemData.scope ),
1021
  position : {
1022
  my : "top",
1023
  at : "top+100",
1028
  }
1029
  } );
1030
 
1031
+ jQuery( function () {
1032
+ if ( gadwpItemData.scope == 'admin-widgets' ) {
1033
+ jQuery( '#gadwp-window-1' ).gadwpItemReport( 1 );
1034
+ } else {
1035
+ jQuery( gadwpItemData.getSelector( gadwpItemData.scope ) ).click( function () {
1036
+ if ( !jQuery( "#gadwp-window-" + gadwpItemData.getID( this ) ).length > 0 ) {
1037
+ jQuery( "body" ).append( '<div id="gadwp-window-' + gadwpItemData.getID( this ) + '"></div>' );
1038
+ }
1039
+ jQuery( '#gadwp-window-' + gadwpItemData.getID( this ) ).gadwpItemReport( gadwpItemData.getID( this ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1040
  } );
1041
+ }
1042
 
1043
+ // on window resize
1044
+ jQuery( window ).resize( function () {
1045
+ gadwpItemData.responsiveDialog();
 
1046
  } );
1047
+
1048
+ // dialog width larger than viewport
1049
+ jQuery( document ).on( "dialogopen", ".ui-dialog", function ( event, ui ) {
1050
+ gadwpItemData.responsiveDialog();
1051
+ } );
1052
+ } );
common/nprogress/nprogress.css CHANGED
@@ -52,16 +52,36 @@
52
  position: relative;
53
  }
54
 
55
- .nprogress-custom-parent #nprogress .spinner, .nprogress-custom-parent #nprogress .bar
56
- {
57
  position: absolute;
58
  }
59
 
60
- @-webkit-keyframes nprogress-spinner {
61
- 0% { -webkit-transform: rotate(0deg); }
62
- 100% { -webkit-transform: rotate(360deg); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
- @keyframes nprogress-spinner {
65
- 0% { transform: rotate(0deg); }
66
- 100% { transform: rotate(360deg); }
67
  }
52
  position: relative;
53
  }
54
 
55
+ .nprogress-custom-parent #nprogress .spinner, .nprogress-custom-parent #nprogress .bar {
 
56
  position: absolute;
57
  }
58
 
59
+ @
60
+ -webkit-keyframes nprogress-spinner { 0% {
61
+ -webkit-transform: rotate(0deg);
62
+ }
63
+
64
+ 100%
65
+ {
66
+ -webkit-transform
67
+ :
68
+
69
+ rotate
70
+ (360deg);
71
+
72
+ }
73
+ }
74
+ @
75
+ keyframes nprogress-spinner { 0% {
76
+ transform: rotate(0deg);
77
+ }
78
+ 100%
79
+ {
80
+ transform
81
+ :
82
+
83
+ rotate
84
+ (360deg);
85
+
86
  }
 
 
 
87
  }
common/realtime/jquery.ui.tooltip.html.css CHANGED
@@ -27,16 +27,14 @@ body .ui-tooltip.gadwp {
27
  font-size: 1em;
28
  }
29
 
30
- .ui-widget.gadwp input, .ui-widget.gadwp select, .ui-widget.gadwp textarea, .ui-widget.gadwp button
31
- {
32
  font-family: Verdana, Arial, sans-serif;
33
  font-size: 1em;
34
  }
35
 
36
  .ui-widget-content.gadwp {
37
  border: 1px solid #aaaaaa;
38
- background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50%
39
- repeat-x;
40
  color: #222222;
41
  }
42
 
@@ -46,8 +44,7 @@ body .ui-tooltip.gadwp {
46
 
47
  .gadwp .ui-widget-header {
48
  border: 1px solid #aaaaaa;
49
- background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png)
50
- 50% 50% repeat-x;
51
  color: #222222;
52
  font-weight: bold;
53
  }
27
  font-size: 1em;
28
  }
29
 
30
+ .ui-widget.gadwp input, .ui-widget.gadwp select, .ui-widget.gadwp textarea, .ui-widget.gadwp button {
 
31
  font-family: Verdana, Arial, sans-serif;
32
  font-size: 1em;
33
  }
34
 
35
  .ui-widget-content.gadwp {
36
  border: 1px solid #aaaaaa;
37
+ background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;
 
38
  color: #222222;
39
  }
40
 
44
 
45
  .gadwp .ui-widget-header {
46
  border: 1px solid #aaaaaa;
47
+ background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;
 
48
  color: #222222;
49
  font-weight: bold;
50
  }
config.php CHANGED
@@ -2,6 +2,7 @@
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -67,9 +68,6 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
67
  if ( isset( $options['ga_crossdomain_list'] ) ) {
68
  $options['ga_crossdomain_list'] = sanitize_text_field( $options['ga_crossdomain_list'] );
69
  }
70
- if ( isset( $options['ga_dash_apikey'] ) ) {
71
- $options['ga_dash_apikey'] = sanitize_text_field( $options['ga_dash_apikey'] );
72
- }
73
  if ( isset( $options['ga_dash_clientid'] ) ) {
74
  $options['ga_dash_clientid'] = sanitize_text_field( $options['ga_dash_clientid'] );
75
  }
@@ -142,8 +140,6 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
142
  if ( is_network_admin() ) {
143
  $network_options['ga_dash_profile_list'] = $this->options['ga_dash_profile_list'];
144
  $options['ga_dash_profile_list'] = array();
145
- $network_options['ga_dash_apikey'] = $this->options['ga_dash_apikey'];
146
- $options['ga_dash_apikey'] = '';
147
  $network_options['ga_dash_clientid'] = $this->options['ga_dash_clientid'];
148
  $options['ga_dash_clientid'] = '';
149
  $network_options['ga_dash_clientsecret'] = $this->options['ga_dash_clientsecret'];
@@ -197,7 +193,9 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
197
  $flag = false;
198
 
199
  if ( GADWP_CURRENT_VERSION != get_option( 'gadwp_version' ) ) {
200
-
 
 
201
  $rebuild_token = json_decode( $this->options['ga_dash_token'] ); // v4.8.2
202
  if ( is_object( $rebuild_token ) && ! isset( $rebuild_token->token_type ) ) {
203
  if ( isset( $this->options['ga_dash_refresh_token'] ) ) {
@@ -210,15 +208,8 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
210
  } else {
211
  unset( $this->options['ga_dash_refresh_token'] );
212
  }
213
- GADWP_Tools::unset_cookie( 'default_metric' );
214
- GADWP_Tools::unset_cookie( 'default_dimension' );
215
- GADWP_Tools::unset_cookie( 'default_view' );
216
  GADWP_Tools::clear_cache();
217
- GADWP_Tools::clear_transients(); // 4.8.3 to be removed after a few months
218
- $flag = true;
219
  GADWP_Tools::delete_cache( 'last_error' );
220
- update_option( 'gadwp_version', GADWP_CURRENT_VERSION );
221
- update_option( 'gadwp_got_updated', true );
222
  if ( is_multisite() ) { // Cleanup errors and cookies on the entire network
223
  foreach ( wp_get_sites( array( 'limit' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
224
  switch_to_blog( $blog['blog_id'] );
@@ -228,6 +219,9 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
228
  } else {
229
  GADWP_Tools::delete_cache( 'gapi_errors' );
230
  }
 
 
 
231
  }
232
  if ( ! isset( $this->options['ga_enhanced_links'] ) ) {
233
  $this->options['ga_enhanced_links'] = 0;
@@ -359,6 +353,10 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
359
  unset( $this->options['ga_dash_frontend_keywords'] );
360
  $flag = true;
361
  }
 
 
 
 
362
  if ( isset( $this->options['ga_dash_jailadmins'] ) ) { // v4.7
363
  if ( isset( $this->options['ga_dash_jailadmins'] ) ) {
364
  $this->options['switch_profile'] = 0;
@@ -392,4 +390,4 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
392
  }
393
  }
394
  }
395
- }
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
68
  if ( isset( $options['ga_crossdomain_list'] ) ) {
69
  $options['ga_crossdomain_list'] = sanitize_text_field( $options['ga_crossdomain_list'] );
70
  }
 
 
 
71
  if ( isset( $options['ga_dash_clientid'] ) ) {
72
  $options['ga_dash_clientid'] = sanitize_text_field( $options['ga_dash_clientid'] );
73
  }
140
  if ( is_network_admin() ) {
141
  $network_options['ga_dash_profile_list'] = $this->options['ga_dash_profile_list'];
142
  $options['ga_dash_profile_list'] = array();
 
 
143
  $network_options['ga_dash_clientid'] = $this->options['ga_dash_clientid'];
144
  $options['ga_dash_clientid'] = '';
145
  $network_options['ga_dash_clientsecret'] = $this->options['ga_dash_clientsecret'];
193
  $flag = false;
194
 
195
  if ( GADWP_CURRENT_VERSION != get_option( 'gadwp_version' ) ) {
196
+ $flag = true;
197
+ update_option( 'gadwp_version', GADWP_CURRENT_VERSION );
198
+ update_option( 'gadwp_got_updated', true );
199
  $rebuild_token = json_decode( $this->options['ga_dash_token'] ); // v4.8.2
200
  if ( is_object( $rebuild_token ) && ! isset( $rebuild_token->token_type ) ) {
201
  if ( isset( $this->options['ga_dash_refresh_token'] ) ) {
208
  } else {
209
  unset( $this->options['ga_dash_refresh_token'] );
210
  }
 
 
 
211
  GADWP_Tools::clear_cache();
 
 
212
  GADWP_Tools::delete_cache( 'last_error' );
 
 
213
  if ( is_multisite() ) { // Cleanup errors and cookies on the entire network
214
  foreach ( wp_get_sites( array( 'limit' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
215
  switch_to_blog( $blog['blog_id'] );
219
  } else {
220
  GADWP_Tools::delete_cache( 'gapi_errors' );
221
  }
222
+ GADWP_Tools::unset_cookie( 'default_metric' );
223
+ GADWP_Tools::unset_cookie( 'default_dimension' );
224
+ GADWP_Tools::unset_cookie( 'default_view' );
225
  }
226
  if ( ! isset( $this->options['ga_enhanced_links'] ) ) {
227
  $this->options['ga_enhanced_links'] = 0;
353
  unset( $this->options['ga_dash_frontend_keywords'] );
354
  $flag = true;
355
  }
356
+ if ( isset( $this->options['ga_dash_apikey'] ) ) { // v4.9.1.3
357
+ unset( $this->options['ga_dash_apikey'] );
358
+ $flag = true;
359
+ }
360
  if ( isset( $this->options['ga_dash_jailadmins'] ) ) { // v4.7
361
  if ( isset( $this->options['ga_dash_jailadmins'] ) ) {
362
  $this->options['switch_profile'] = 0;
390
  }
391
  }
392
  }
393
+ }
front/ajax-actions.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  /**
3
- * Author: Alin Marcu
4
- * Author URI: http://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -18,15 +19,15 @@ if ( ! class_exists( 'GADWP_Frontend_Ajax' ) ) {
18
 
19
  public function __construct() {
20
  $this->gadwp = GADWP();
21
-
22
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_front'] ) && $this->gadwp->config->options['frontend_item_reports'] ) {
23
  // Item Reports action
24
  add_action( 'wp_ajax_gadwp_frontend_item_reports', array( $this, 'ajax_item_reports' ) );
25
  }
26
-
27
  // Frontend Widget actions
28
- add_action( 'wp_ajax_gadash_get_frontendwidget_data', array( $this, 'ajax_frontend_widget' ) );
29
- add_action( 'wp_ajax_nopriv_gadash_get_frontendwidget_data', array( $this, 'ajax_frontend_widget' ) );
30
  }
31
 
32
  /**
@@ -35,25 +36,24 @@ if ( ! class_exists( 'GADWP_Frontend_Ajax' ) ) {
35
  * @return string|int
36
  */
37
  public function ajax_item_reports() {
38
-
39
  if ( ! isset( $_POST['gadwp_security_frontend_item_reports'] ) || ! wp_verify_nonce( $_POST['gadwp_security_frontend_item_reports'], 'gadwp_frontend_item_reports' ) ) {
40
  wp_die( - 30 );
41
  }
42
-
43
  $from = $_POST['from'];
44
  $to = $_POST['to'];
45
  $query = $_POST['query'];
46
  $uri = $_POST['filter'];
47
-
48
  $query = $_POST['query'];
49
  if ( ob_get_length() ) {
50
  ob_clean();
51
  }
52
-
53
  if ( ! GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_front'] ) || 0 == $this->gadwp->config->options['frontend_item_reports'] ) {
54
  wp_die( - 31 );
55
  }
56
-
57
  if ( $this->gadwp->config->options['ga_dash_token'] && $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
58
  if ( null === $this->gadwp->gapi_controller ) {
59
  $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
@@ -61,59 +61,57 @@ if ( ! class_exists( 'GADWP_Frontend_Ajax' ) ) {
61
  } else {
62
  wp_die( - 24 );
63
  }
64
-
65
  if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
66
  $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
67
  } else {
68
  wp_die( - 25 );
69
  }
70
-
71
  $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $projectId );
72
-
73
  if ( isset( $profile_info[4] ) ) {
74
  $this->gadwp->gapi_controller->timeshift = $profile_info[4];
75
  } else {
76
  $this->gadwp->gapi_controller->timeshift = (int) current_time( 'timestamp' ) - time();
77
  }
78
-
79
- $uri = '/' . ltrim($uri,'/');
80
-
81
  // allow URL correction before sending an API request
82
  $filter = apply_filters( 'gadwp_frontenditem_uri', $uri );
83
-
84
  $lastchar = substr( $filter, - 1 );
85
-
86
  if ( isset( $profile_info[6] ) && $profile_info[6] && $lastchar == '/' ) {
87
  $filter = $filter . $profile_info[6];
88
  }
89
-
90
  // Encode URL
91
  $filter = rawurlencode( rawurldecode( $filter ) );
92
-
93
  $queries = explode( ',', $query );
94
-
95
  $results = array();
96
-
97
  foreach ( $queries as $value ) {
98
  $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter );
99
  }
100
-
101
  wp_send_json( $results );
102
-
103
  }
104
 
105
-
106
  /**
107
  * Ajax handler for getting analytics data for frontend Widget
108
  *
109
  * @return string|int
110
  */
111
  public function ajax_frontend_widget() {
112
- if ( ! isset( $_POST['gadash_number'] ) || ! isset( $_POST['gadash_optionname'] ) || ! is_active_widget( false, false, 'gadash_frontend_widget' ) ) {
113
  wp_die( - 30 );
114
  }
115
- $widget_index = $_POST['gadash_number'];
116
- $option_name = $_POST['gadash_optionname'];
117
  $options = get_option( $option_name );
118
  if ( isset( $options[$widget_index] ) ) {
119
  $instance = $options[$widget_index];
1
  <?php
2
  /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
+
23
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_front'] ) && $this->gadwp->config->options['frontend_item_reports'] ) {
24
  // Item Reports action
25
  add_action( 'wp_ajax_gadwp_frontend_item_reports', array( $this, 'ajax_item_reports' ) );
26
  }
27
+
28
  // Frontend Widget actions
29
+ add_action( 'wp_ajax_ajax_frontwidget_report', array( $this, 'ajax_frontend_widget' ) );
30
+ add_action( 'wp_ajax_nopriv_ajax_frontwidget_report', array( $this, 'ajax_frontend_widget' ) );
31
  }
32
 
33
  /**
36
  * @return string|int
37
  */
38
  public function ajax_item_reports() {
 
39
  if ( ! isset( $_POST['gadwp_security_frontend_item_reports'] ) || ! wp_verify_nonce( $_POST['gadwp_security_frontend_item_reports'], 'gadwp_frontend_item_reports' ) ) {
40
  wp_die( - 30 );
41
  }
42
+
43
  $from = $_POST['from'];
44
  $to = $_POST['to'];
45
  $query = $_POST['query'];
46
  $uri = $_POST['filter'];
47
+
48
  $query = $_POST['query'];
49
  if ( ob_get_length() ) {
50
  ob_clean();
51
  }
52
+
53
  if ( ! GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_front'] ) || 0 == $this->gadwp->config->options['frontend_item_reports'] ) {
54
  wp_die( - 31 );
55
  }
56
+
57
  if ( $this->gadwp->config->options['ga_dash_token'] && $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
58
  if ( null === $this->gadwp->gapi_controller ) {
59
  $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
61
  } else {
62
  wp_die( - 24 );
63
  }
64
+
65
  if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
66
  $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
67
  } else {
68
  wp_die( - 25 );
69
  }
70
+
71
  $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $projectId );
72
+
73
  if ( isset( $profile_info[4] ) ) {
74
  $this->gadwp->gapi_controller->timeshift = $profile_info[4];
75
  } else {
76
  $this->gadwp->gapi_controller->timeshift = (int) current_time( 'timestamp' ) - time();
77
  }
78
+
79
+ $uri = '/' . ltrim( $uri, '/' );
80
+
81
  // allow URL correction before sending an API request
82
  $filter = apply_filters( 'gadwp_frontenditem_uri', $uri );
83
+
84
  $lastchar = substr( $filter, - 1 );
85
+
86
  if ( isset( $profile_info[6] ) && $profile_info[6] && $lastchar == '/' ) {
87
  $filter = $filter . $profile_info[6];
88
  }
89
+
90
  // Encode URL
91
  $filter = rawurlencode( rawurldecode( $filter ) );
92
+
93
  $queries = explode( ',', $query );
94
+
95
  $results = array();
96
+
97
  foreach ( $queries as $value ) {
98
  $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter );
99
  }
100
+
101
  wp_send_json( $results );
 
102
  }
103
 
 
104
  /**
105
  * Ajax handler for getting analytics data for frontend Widget
106
  *
107
  * @return string|int
108
  */
109
  public function ajax_frontend_widget() {
110
+ if ( ! isset( $_POST['gadwp_number'] ) || ! isset( $_POST['gadwp_optionname'] ) || ! is_active_widget( false, false, 'gadwp-frontwidget-report' ) ) {
111
  wp_die( - 30 );
112
  }
113
+ $widget_index = $_POST['gadwp_number'];
114
+ $option_name = $_POST['gadwp_optionname'];
115
  $options = get_option( $option_name );
116
  if ( isset( $options[$widget_index] ) ) {
117
  $instance = $options[$widget_index];
front/css/item-reports.css CHANGED
@@ -1,3 +1,11 @@
 
 
 
 
 
 
 
 
1
  /* Frontend Item Reports */
2
  .column-gadwp_stats {
3
  width: 70px;
@@ -15,31 +23,31 @@
15
  padding-top: 5px;
16
  }
17
 
18
- [id^=gadwp-container] {
19
  width: 480px;
20
  }
21
 
22
- [id^=gadwp-mainchart] {
23
  height: 280px;
24
  }
25
 
26
- [id^=gadwp-progressbar] {
27
  width: 100%;
28
  height: 3px;
29
  margin: 5px 0 0px 0;
30
  }
31
 
32
- .gadwp-wrapper {
33
  width: 100%;
34
  }
35
 
36
- .gadwp-wrapper .inside {
37
  display: table;
38
  margin: 0 auto;
39
  padding: 0px;
40
  }
41
 
42
- .gadwp-wrapper .inside .small-box {
43
  width: 31.2%;
44
  float: left;
45
  margin: 10px 5px 10px 5px;
@@ -50,52 +58,65 @@
50
  box-shadow: 0px 0px 7px 0px #BBB;
51
  }
52
 
53
- .gadwp-wrapper .inside .small-box h3 {
54
- font-family: 'Open Sans', sans-serif;
55
  font-size: 1em;
56
  color: #777;
57
  padding: 0px 5px 0px 5px;
58
  margin: 0px 0px 0px 0px;
59
  text-overflow: ellipsis;
60
  overflow: hidden;
61
- white-space: nowrap;
62
  }
63
 
64
- .gadwp-wrapper .inside .small-box p {
65
  font-size: 1.2em;
66
  margin: 0px 0px 2px 0px;
67
  }
68
 
69
- [id^=gadwp-trafficmediums], [id^=gadwp-traffictype], [id^=gadwp-trafficorganic], [id^=gadwp-socialnetworks] {
70
- width: 49.6%;
 
 
 
 
 
 
71
  margin: 10px 0 0 0;
72
- border-right: 1px solid white;
73
  height: 200px;
74
  float: left;
75
  }
76
 
77
- [id^=gadwp-locations], [id^=gadwp-prs] {
 
 
 
 
 
 
 
 
78
  margin: 10px 0 0 0;
79
  }
80
 
81
- .ui-dialog.gadwp{
82
  font-family: 'Open Sans', sans-serif;
83
  font-size: 13px;
84
  -webkit-box-sizing: initial;
85
- -moz-box-sizing: initial;
86
  }
87
 
88
- .ui-dialog.gadwp select{
89
  font-family: 'Open Sans', sans-serif;
90
  border: 1px solid #ddd;
91
  font-size: 14px;
92
  background: #fff;
93
  padding: 2px;
94
  color: #333;
95
- width: auto;
96
  }
97
 
98
- .ui-dialog.gadwp table{
99
  margin: auto;
100
  width: auto;
101
  }
@@ -107,37 +128,35 @@
107
  }
108
 
109
  @media screen and (max-width: 500px) {
110
- [id^=gadwp-container] {
111
  width: 410px;
112
  }
113
- .gadwp-wrapper .inside .small-box {
114
  width: 30.8%;
115
  }
116
  }
117
 
118
  @media screen and (max-width: 410px) {
119
- [id^=gadwp-container] {
120
  width: 260px;
121
  }
122
- .gadwp-wrapper .inside .small-box {
123
  width: 46%;
124
  }
125
  }
126
 
127
  /* Toolbar Node (Analytics menu item) */
128
-
129
- #wpadminbar #wp-admin-bar-gadwp-1 > .ab-item:before {
130
  content: '\f239';
131
  top: 2px;
132
  }
133
 
134
- .no-font-face #wpadminbar #wp-admin-bar-gadwp-1 > .ab-item {
135
  text-indent: 0;
136
  }
137
 
138
  @media screen and ( max-width: 782px ) {
139
-
140
- #wpadminbar #wp-admin-bar-gadwp-1 > .ab-item {
141
  text-indent: 100%;
142
  white-space: nowrap;
143
  overflow: hidden;
@@ -146,8 +165,7 @@
146
  color: #999;
147
  position: relative;
148
  }
149
-
150
- #wpadminbar #wp-admin-bar-gadwp-1 > .ab-item:before {
151
  display: block;
152
  text-indent: 0;
153
  font: normal 32px/1 'dashicons';
@@ -158,12 +176,10 @@
158
  -webkit-font-smoothing: antialiased;
159
  -moz-osx-font-smoothing: grayscale;
160
  }
161
-
162
  #wpadminbar li#wp-admin-bar-gadwp-1 {
163
  display: block;
164
  }
165
-
166
  #wpadminbar #wp-admin-bar-gadwp-1 {
167
  position: static;
168
- }
169
  }
1
+ /**
2
+ * Author: Alin Marcu
3
+ * Author URI: https://deconf.com
4
+ * Copyright 2013 Alin Marcu
5
+ * License: GPLv2 or later
6
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
+ */
8
+
9
  /* Frontend Item Reports */
10
  .column-gadwp_stats {
11
  width: 70px;
23
  padding-top: 5px;
24
  }
25
 
26
+ [id^=gadwp-container-] {
27
  width: 480px;
28
  }
29
 
30
+ [id^=gadwp-areachart-] {
31
  height: 280px;
32
  }
33
 
34
+ [id^=gadwp-progressbar-] {
35
  width: 100%;
36
  height: 3px;
37
  margin: 5px 0 0px 0;
38
  }
39
 
40
+ [id^=gadwp-bottomstats-] {
41
  width: 100%;
42
  }
43
 
44
+ [id^=gadwp-bottomstats-] .inside {
45
  display: table;
46
  margin: 0 auto;
47
  padding: 0px;
48
  }
49
 
50
+ [id^=gadwp-bottomstats-] .inside .small-box {
51
  width: 31.2%;
52
  float: left;
53
  margin: 10px 5px 10px 5px;
58
  box-shadow: 0px 0px 7px 0px #BBB;
59
  }
60
 
61
+ [id^=gadwp-bottomstats-] .inside .small-box h3 {
62
+ font-family: 'Open Sans', sans-serif;
63
  font-size: 1em;
64
  color: #777;
65
  padding: 0px 5px 0px 5px;
66
  margin: 0px 0px 0px 0px;
67
  text-overflow: ellipsis;
68
  overflow: hidden;
69
+ white-space: nowrap;
70
  }
71
 
72
+ [id^=gadwp-bottomstats-] .inside .small-box p {
73
  font-size: 1.2em;
74
  margin: 0px 0px 2px 0px;
75
  }
76
 
77
+ .gadwp-floatwraper {
78
+ display: table;
79
+ width: 100%;
80
+ height: 100%;
81
+ }
82
+
83
+ [id^=gadwp-piechart-].halfsize {
84
+ width: 47%;
85
  margin: 10px 0 0 0;
 
86
  height: 200px;
87
  float: left;
88
  }
89
 
90
+ [id^=gadwp-piechart-].floatleft {
91
+ float: left;
92
+ }
93
+
94
+ [id^=gadwp-piechart-].floatright {
95
+ float: right;
96
+ }
97
+
98
+ [id^=gadwp-tablechart-], [id^=gadwp-tablechart-] {
99
  margin: 10px 0 0 0;
100
  }
101
 
102
+ .ui-dialog.gadwp {
103
  font-family: 'Open Sans', sans-serif;
104
  font-size: 13px;
105
  -webkit-box-sizing: initial;
106
+ -moz-box-sizing: initial;
107
  }
108
 
109
+ .ui-dialog.gadwp select {
110
  font-family: 'Open Sans', sans-serif;
111
  border: 1px solid #ddd;
112
  font-size: 14px;
113
  background: #fff;
114
  padding: 2px;
115
  color: #333;
116
+ width: auto;
117
  }
118
 
119
+ .ui-dialog.gadwp table {
120
  margin: auto;
121
  width: auto;
122
  }
128
  }
129
 
130
  @media screen and (max-width: 500px) {
131
+ [id^=gadwp-container-] {
132
  width: 410px;
133
  }
134
+ [id^=gadwp-bottomstats-] .inside .small-box {
135
  width: 30.8%;
136
  }
137
  }
138
 
139
  @media screen and (max-width: 410px) {
140
+ [id^=gadwp-container-] {
141
  width: 260px;
142
  }
143
+ [id^=gadwp-bottomstats-] .inside .small-box {
144
  width: 46%;
145
  }
146
  }
147
 
148
  /* Toolbar Node (Analytics menu item) */
149
+ #wpadminbar #wp-admin-bar-gadwp-1>.ab-item:before {
 
150
  content: '\f239';
151
  top: 2px;
152
  }
153
 
154
+ .no-font-face #wpadminbar #wp-admin-bar-gadwp-1>.ab-item {
155
  text-indent: 0;
156
  }
157
 
158
  @media screen and ( max-width: 782px ) {
159
+ #wpadminbar #wp-admin-bar-gadwp-1>.ab-item {
 
160
  text-indent: 100%;
161
  white-space: nowrap;
162
  overflow: hidden;
165
  color: #999;
166
  position: relative;
167
  }
168
+ #wpadminbar #wp-admin-bar-gadwp-1>.ab-item:before {
 
169
  display: block;
170
  text-indent: 0;
171
  font: normal 32px/1 'dashicons';
176
  -webkit-font-smoothing: antialiased;
177
  -moz-osx-font-smoothing: grayscale;
178
  }
 
179
  #wpadminbar li#wp-admin-bar-gadwp-1 {
180
  display: block;
181
  }
 
182
  #wpadminbar #wp-admin-bar-gadwp-1 {
183
  position: static;
184
+ }
185
  }
front/css/widgets.css CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  #gadwp {
2
  font-family: 'Open Sans', sans-serif;
3
  }
@@ -61,4 +68,8 @@
61
  padding: 10px 0 0 0;
62
  float: left;
63
  font-style: italic;
 
 
 
 
64
  }
1
+ /**
2
+ * Author: Alin Marcu
3
+ * Author URI: https://deconf.com
4
+ * Copyright 2013 Alin Marcu
5
+ * License: GPLv2 or later
6
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
+ */
8
  #gadwp {
9
  font-family: 'Open Sans', sans-serif;
10
  }
68
  padding: 10px 0 0 0;
69
  float: left;
70
  font-style: italic;
71
+ }
72
+
73
+ .widget_gadwp-frontwidget-report h2.widget-title {
74
+ margin-bottom: 0px;
75
  }
front/item-reports.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  /**
3
- * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -18,7 +19,7 @@ if ( ! class_exists( 'GADWP_Frontend_Item_Reports' ) ) {
18
 
19
  public function __construct() {
20
  $this->gadwp = GADWP();
21
-
22
  add_action( 'admin_bar_menu', array( $this, 'custom_adminbar_node' ), 999 );
23
  }
24
 
1
  <?php
2
  /**
3
+ * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
+
23
  add_action( 'admin_bar_menu', array( $this, 'custom_adminbar_node' ), 999 );
24
  }
25
 
front/js/widgets.js CHANGED
@@ -1,5 +1,13 @@
1
- jQuery(window).resize(function(){
2
- if(typeof ga_dash_drawfwidgetsessions == "function" && typeof gadash_widgetsessions!=='undefined' && !jQuery.isNumeric(gadash_widgetsessions)){
3
- ga_dash_drawfwidgetsessions(gadash_widgetsessions);
 
 
 
 
 
 
 
 
4
  }
5
- });
1
+ /**
2
+ * Author: Alin Marcu
3
+ * Author URI: https://deconf.com
4
+ * Copyright 2013 Alin Marcu
5
+ * License: GPLv2 or later
6
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
+ */
8
+
9
+ jQuery( window ).resize( function () {
10
+ if ( typeof gadwp_drawFrontWidgetChart == "function" && typeof gadwpFrontWidgetData !== 'undefined' && !jQuery.isNumeric( gadwpFrontWidgetData ) ) {
11
+ gadwp_drawFrontWidgetChart( gadwpFrontWidgetData );
12
  }
13
+ } );
front/setup.php CHANGED
@@ -2,6 +2,7 @@
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -18,7 +19,7 @@ if ( ! class_exists( 'GADWP_Frontend_Setup' ) ) {
18
 
19
  public function __construct() {
20
  $this->gadwp = GADWP();
21
-
22
  // Styles & Scripts
23
  add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
24
  }
@@ -30,36 +31,38 @@ if ( ! class_exists( 'GADWP_Frontend_Setup' ) ) {
30
  * $hook
31
  */
32
  public function load_styles_scripts() {
33
-
 
 
 
34
  /*
35
  * Item reports Styles & Scripts
36
  */
37
-
38
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_front'] ) && $this->gadwp->config->options['frontend_item_reports'] ) {
39
-
40
  wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
41
-
42
  wp_enqueue_style( 'gadwp-frontend-item-reports', GADWP_URL . 'front/css/item-reports.css', null, GADWP_CURRENT_VERSION );
43
-
44
  $country_codes = GADWP_Tools::get_countrycodes();
45
  if ( $this->gadwp->config->options['ga_target_geomap'] && isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
46
  $region = $this->gadwp->config->options['ga_target_geomap'];
47
  } else {
48
  $region = false;
49
  }
50
-
51
  wp_enqueue_style( "wp-jquery-ui-dialog" );
52
-
53
  if ( ! wp_script_is( 'googlejsapi' ) ) {
54
- wp_register_script( 'googlejsapi', 'https://www.google.com/jsapi' );
55
  }
56
-
57
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
58
-
59
  wp_enqueue_script( 'gadwp-frontend-item-reports', GADWP_URL . 'common/js/reports.js', array( 'gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION );
60
-
61
  /* @formatter:off */
62
- wp_localize_script( 'gadwp-frontend-item-reports', 'gadwp_item_data', array(
63
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
64
  'security' => wp_create_nonce( 'gadwp_frontend_item_reports' ),
65
  'dateList' => array(
@@ -81,14 +84,15 @@ if ( ! class_exists( 'GADWP_Frontend_Setup' ) ) {
81
  'locations' => __( "Location", 'google-analytics-dashboard-for-wp' ),
82
  'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
83
  'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
84
- 'trafficdetails' => __( "Traffic Details", 'google-analytics-dashboard-for-wp' ),
 
85
  ),
86
  'i18n' => array(
87
  __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
88
  __( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ),
89
  __( "Visitor Type", 'google-analytics-dashboard-for-wp' ),
90
- __( "Social Networks", 'google-analytics-dashboard-for-wp' ),
91
  __( "Search Engines", 'google-analytics-dashboard-for-wp' ),
 
92
  __( "Unique Views", 'google-analytics-dashboard-for-wp' ),
93
  __( "Users", 'google-analytics-dashboard-for-wp' ),
94
  __( "Page Views", 'google-analytics-dashboard-for-wp' ),
@@ -100,6 +104,10 @@ if ( ! class_exists( 'GADWP_Frontend_Setup' ) ) {
100
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
101
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
102
  __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <strong>' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</strong>!',
 
 
 
 
103
  ),
104
  'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
105
  'region' => $region,
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
+
23
  // Styles & Scripts
24
  add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
25
  }
31
  * $hook
32
  */
33
  public function load_styles_scripts() {
34
+ $lang = get_bloginfo( 'language' );
35
+ $lang = explode( '-', $lang );
36
+ $lang = $lang[0];
37
+
38
  /*
39
  * Item reports Styles & Scripts
40
  */
 
41
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_front'] ) && $this->gadwp->config->options['frontend_item_reports'] ) {
42
+
43
  wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
44
+
45
  wp_enqueue_style( 'gadwp-frontend-item-reports', GADWP_URL . 'front/css/item-reports.css', null, GADWP_CURRENT_VERSION );
46
+
47
  $country_codes = GADWP_Tools::get_countrycodes();
48
  if ( $this->gadwp->config->options['ga_target_geomap'] && isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
49
  $region = $this->gadwp->config->options['ga_target_geomap'];
50
  } else {
51
  $region = false;
52
  }
53
+
54
  wp_enqueue_style( "wp-jquery-ui-dialog" );
55
+
56
  if ( ! wp_script_is( 'googlejsapi' ) ) {
57
+ wp_register_script( 'googlejsapi', 'https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22language%22%3A%22' . $lang . '%22%2C%22packages%22%3A%5B%22corechart%22%2C%20%22table%22%2C%20%22orgchart%22%2C%20%22geochart%22%5D%7D%5D%7D%27', array(), null );
58
  }
59
+
60
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
61
+
62
  wp_enqueue_script( 'gadwp-frontend-item-reports', GADWP_URL . 'common/js/reports.js', array( 'gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION );
63
+
64
  /* @formatter:off */
65
+ wp_localize_script( 'gadwp-frontend-item-reports', 'gadwpItemData', array(
66
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
67
  'security' => wp_create_nonce( 'gadwp_frontend_item_reports' ),
68
  'dateList' => array(
84
  'locations' => __( "Location", 'google-analytics-dashboard-for-wp' ),
85
  'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
86
  'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
87
+ 'trafficdetails' => __( "Traffic", 'google-analytics-dashboard-for-wp' ),
88
+ 'technologydetails' => __( "Technology", 'google-analytics-dashboard-for-wp' ),
89
  ),
90
  'i18n' => array(
91
  __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
92
  __( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ),
93
  __( "Visitor Type", 'google-analytics-dashboard-for-wp' ),
 
94
  __( "Search Engines", 'google-analytics-dashboard-for-wp' ),
95
+ __( "Social Networks", 'google-analytics-dashboard-for-wp' ),
96
  __( "Unique Views", 'google-analytics-dashboard-for-wp' ),
97
  __( "Users", 'google-analytics-dashboard-for-wp' ),
98
  __( "Page Views", 'google-analytics-dashboard-for-wp' ),
104
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
105
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
106
  __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <strong>' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</strong>!',
107
+ __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
108
+ __( "Operating System", 'google-analytics-dashboard-for-wp' ),
109
+ __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
110
+ __( "Mobile Brand", 'google-analytics-dashboard-for-wp' ),
111
  ),
112
  'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
113
  'region' => $region,
front/tracking.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  /**
3
- * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -19,12 +20,8 @@ if ( ! class_exists( 'GADWP_Tracking' ) ) {
19
  public function __construct() {
20
  $this->gadwp = GADWP();
21
 
22
- add_action( 'wp_head', array(
23
- $this,
24
- 'tracking_code' ), 99 );
25
- add_action( 'wp_enqueue_scripts', array(
26
- $this,
27
- 'load_scripts' ) );
28
  }
29
 
30
  public function load_scripts() {
1
  <?php
2
  /**
3
+ * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
 
23
+ add_action( 'wp_head', array( $this, 'tracking_code' ), 99 );
24
+ add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
 
 
 
 
25
  }
26
 
27
  public function load_scripts() {
front/tracking/code-classic.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  /**
3
- * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
1
  <?php
2
  /**
3
+ * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
front/tracking/code-universal.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  /**
3
- * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -32,17 +33,17 @@ $create_options .= '}';
32
 
33
  $options = "'auto'";
34
  $optionsArray = array();
35
- if ( !empty( $this->gadwp->config->options['ga_cookiedomain'] ) ) {
36
- $optionsArray['cookieDomain'] = $this->gadwp->config->options['ga_cookiedomain'];
37
  }
38
- if ( !empty( $this->gadwp->config->options['ga_cookiename'] ) ) {
39
- $optionsArray['cookieName'] = $this->gadwp->config->options['ga_cookiename'];
40
  }
41
- if ( !empty( $this->gadwp->config->options['ga_cookieexpires'] ) ) {
42
- $optionsArray['cookieExpires'] = (int) $this->gadwp->config->options['ga_cookieexpires'];
43
  }
44
- if (!empty($optionsArray)) {
45
- $options = json_encode($optionsArray);
46
  }
47
  ?>
48
  ga('create', '<?php echo esc_html($profile[2]); ?>', <?php echo $options; ?><?php if ($create_options != '{}') {?>, <?php echo $create_options; }?>);
1
  <?php
2
  /**
3
+ * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
33
 
34
  $options = "'auto'";
35
  $optionsArray = array();
36
+ if ( ! empty( $this->gadwp->config->options['ga_cookiedomain'] ) ) {
37
+ $optionsArray['cookieDomain'] = $this->gadwp->config->options['ga_cookiedomain'];
38
  }
39
+ if ( ! empty( $this->gadwp->config->options['ga_cookiename'] ) ) {
40
+ $optionsArray['cookieName'] = $this->gadwp->config->options['ga_cookiename'];
41
  }
42
+ if ( ! empty( $this->gadwp->config->options['ga_cookieexpires'] ) ) {
43
+ $optionsArray['cookieExpires'] = (int) $this->gadwp->config->options['ga_cookieexpires'];
44
  }
45
+ if ( ! empty( $optionsArray ) ) {
46
+ $options = json_encode( $optionsArray );
47
  }
48
  ?>
49
  ga('create', '<?php echo esc_html($profile[2]); ?>', <?php echo $options; ?><?php if ($create_options != '{}') {?>, <?php echo $create_options; }?>);
front/tracking/events-classic.php CHANGED
@@ -1,4 +1,12 @@
1
  <?php
 
 
 
 
 
 
 
 
2
  // Exit if accessed directly
3
  if ( ! defined( 'ABSPATH' ) )
4
  exit();
1
  <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
  // Exit if accessed directly
11
  if ( ! defined( 'ABSPATH' ) )
12
  exit();
front/tracking/events-universal.php CHANGED
@@ -1,4 +1,12 @@
1
  <?php
 
 
 
 
 
 
 
 
2
  // Exit if accessed directly
3
  if ( ! defined( 'ABSPATH' ) )
4
  exit();
1
  <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
  // Exit if accessed directly
11
  if ( ! defined( 'ABSPATH' ) )
12
  exit();
front/widgets.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Author: Alin Marcu
5
  * Author URI: https://deconf.com
 
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
@@ -17,8 +17,8 @@ final class GADWP_Frontend_Widget extends WP_Widget {
17
 
18
  public function __construct() {
19
  $this->gadwp = GADWP();
20
-
21
- parent::__construct( 'gadash_frontend_widget', __( 'Google Analytics Dashboard', 'google-analytics-dashboard-for-wp' ), array( 'description' => __( "Will display your google analytics stats in a widget", 'google-analytics-dashboard-for-wp' ) ) );
22
  // Frontend Styles
23
  if ( is_active_widget( false, false, $this->id_base, true ) ) {
24
  add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
@@ -26,9 +26,13 @@ final class GADWP_Frontend_Widget extends WP_Widget {
26
  }
27
 
28
  public function load_styles_scripts() {
 
 
 
 
29
  wp_enqueue_style( 'gadwp-front-widget', GADWP_URL . 'front/css/widgets.css', null, GADWP_CURRENT_VERSION );
30
  wp_enqueue_script( 'gadwp-front-widget', GADWP_URL . 'front/js/widgets.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
31
- wp_enqueue_script( 'gadwp-jsapi', 'https://www.google.com/jsapi' );
32
  }
33
 
34
  public function widget( $args, $instance ) {
@@ -39,7 +43,7 @@ final class GADWP_Frontend_Widget extends WP_Widget {
39
  if ( ! empty( $widget_title ) ) {
40
  echo $args['before_title'] . $widget_title . $args['after_title'];
41
  }
42
-
43
  if ( isset( $this->gadwp->config->options['ga_dash_style'] ) ) {
44
  $css = "colors:['" . $this->gadwp->config->options['ga_dash_style'] . "','" . GADWP_Tools::colourVariator( $this->gadwp->config->options['ga_dash_style'], - 20 ) . "'],";
45
  $color = $this->gadwp->config->options['ga_dash_style'];
@@ -54,7 +58,7 @@ final class GADWP_Frontend_Widget extends WP_Widget {
54
  fractionDigits: 2
55
  });
56
 
57
- formatter.format(data, 1); ";
58
  } else {
59
  $formater = '';
60
  }
@@ -84,50 +88,59 @@ final class GADWP_Frontend_Widget extends WP_Widget {
84
  echo '<div id="gadwp-widget"><div id="gadwp-widgettotals"></div></div>';
85
  break;
86
  }
87
- echo '<script type="text/javascript">
88
- jQuery( function () {
89
- jQuery.post("' . admin_url( 'admin-ajax.php' ) . '", {action: "gadash_get_frontendwidget_data",gadash_number: "' . $this->number . '",gadash_optionname: "' . $this->option_name . '"}, function(response){
90
- if (!jQuery.isNumeric(response) && jQuery.isArray(response)){
91
- if (jQuery("#gadwp-widgetchart")[0]){
92
- gadash_widgetsessions=response[0];
93
- google.setOnLoadCallback(ga_dash_drawfwidgetsessions(gadash_widgetsessions));
94
- }
95
- if (jQuery("#gadwp-widgettotals")[0]){
96
- ga_dash_drawtotalsstats(response[1]);
97
- }
98
- }else{
99
- jQuery("#gadwp-widgetchart").css({"background-color":"#F7F7F7","height":"auto","padding-top":"50px","padding-bottom":"50px","color":"#000","text-align":"center"});
100
- jQuery("#gadwp-widgetchart").html("' . __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ) . ' ("+response+")");
101
- }
102
- });});';
103
- echo 'google.load("visualization", "1", {packages:["corechart"], "language" : "'. get_bloginfo( 'language' ) . '"});
104
- function ga_dash_drawfwidgetsessions(response) {
105
- var data = google.visualization.arrayToDataTable(response);
106
- var options = {
107
- legend: {position: "none"},
108
- pointSize: 3,' . $css . '
109
- title: "' . $title . '",
110
- titlePosition: "in",
111
- chartArea: {width: "95%",height:"75%"},
112
- hAxis: { textPosition: "none"},
113
- vAxis: { textPosition: "none", minValue: 0, gridlines: {color: "transparent"}, baselineColor: "transparent"}
114
- }
115
- var chart = new google.visualization.AreaChart(document.getElementById("gadwp-widgetchart"));
116
- ' . $formater . '
117
- chart.draw(data, options);
118
- }
119
- function ga_dash_drawtotalsstats(response) {
120
- if (response == null){
121
- response = 0;
122
- }
123
- jQuery("#gadwp-widgettotals").html("<div class=\"gadwp-left\">' . __( "Period:", 'google-analytics-dashboard-for-wp' ) . '</div> <div class=\"gadwp-right\">' . $periodtext . '</div><div class=\"gadwp-left\">' . __( "Sessions:", 'google-analytics-dashboard-for-wp' ) . '</div> <div class=\"gadwp-right\">"+response+"</div>");
124
- }';
125
- echo '</script>';
126
- if ( $instance['give_credits'] == 1 )
127
- echo '<div style="text-align:right;width:100%;font-size:0.8em;clear:both;margin-right:5px;">' . __( 'generated by', 'google-analytics-dashboard-for-wp' ) . ' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=front_widget&utm_campaign=gadwp" rel="nofollow" style="text-decoration:none;font-size:1em;">GADWP</a>&nbsp;</div>';
 
 
 
 
 
 
 
128
  $widget_content = ob_get_contents();
129
- ob_end_clean();
130
- echo apply_filters( 'widget_html_content', $widget_content );
 
 
131
  echo $args['after_widget'];
132
  echo "\n<!-- END GADWP Widget -->\n";
133
  }
@@ -139,7 +152,7 @@ final class GADWP_Frontend_Widget extends WP_Widget {
139
  $give_credits = ( isset( $instance['give_credits'] ) ? $instance['give_credits'] : 1 );
140
  $anonim = ( isset( $instance['anonim'] ) ? $instance['anonim'] : 0 );
141
  /* @formatter:off */
142
- ?>
143
  <p>
144
  <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( "Title:",'google-analytics-dashboard-for-wp' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $widget_title ); ?>">
145
  </p>
1
  <?php
 
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
17
 
18
  public function __construct() {
19
  $this->gadwp = GADWP();
20
+
21
+ parent::__construct( 'gadwp-frontwidget-report', __( 'Google Analytics Dashboard', 'google-analytics-dashboard-for-wp' ), array( 'description' => __( "Will display your google analytics stats in a widget", 'google-analytics-dashboard-for-wp' ) ) );
22
  // Frontend Styles
23
  if ( is_active_widget( false, false, $this->id_base, true ) ) {
24
  add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_scripts' ) );
26
  }
27
 
28
  public function load_styles_scripts() {
29
+ $lang = get_bloginfo( 'language' );
30
+ $lang = explode( '-', $lang );
31
+ $lang = $lang[0];
32
+
33
  wp_enqueue_style( 'gadwp-front-widget', GADWP_URL . 'front/css/widgets.css', null, GADWP_CURRENT_VERSION );
34
  wp_enqueue_script( 'gadwp-front-widget', GADWP_URL . 'front/js/widgets.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
35
+ wp_enqueue_script( 'googlejsapi', 'https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22visualization%22%2C%22version%22%3A%221%22%2C%22language%22%3A%22' . $lang . '%22%2C%22packages%22%3A%5B%22corechart%22%2C%20%22table%22%2C%20%22orgchart%22%2C%20%22geochart%22%5D%7D%5D%7D%27', array(), null );
36
  }
37
 
38
  public function widget( $args, $instance ) {
43
  if ( ! empty( $widget_title ) ) {
44
  echo $args['before_title'] . $widget_title . $args['after_title'];
45
  }
46
+
47
  if ( isset( $this->gadwp->config->options['ga_dash_style'] ) ) {
48
  $css = "colors:['" . $this->gadwp->config->options['ga_dash_style'] . "','" . GADWP_Tools::colourVariator( $this->gadwp->config->options['ga_dash_style'], - 20 ) . "'],";
49
  $color = $this->gadwp->config->options['ga_dash_style'];
58
  fractionDigits: 2
59
  });
60
 
61
+ formatter.format(data, 1);";
62
  } else {
63
  $formater = '';
64
  }
88
  echo '<div id="gadwp-widget"><div id="gadwp-widgettotals"></div></div>';
89
  break;
90
  }
91
+ ?>
92
+ <script type="text/javascript">
93
+ jQuery( function () {
94
+ jQuery.post("<?php echo admin_url( 'admin-ajax.php' ); ?>", {action: "ajax_frontwidget_report", gadwp_number: "<?php echo $this->number; ?>", gadwp_optionname: "<?php echo $this->option_name; ?>" }, function(response){
95
+ if (!jQuery.isNumeric(response) && jQuery.isArray(response)){
96
+ if (jQuery("#gadwp-widgetchart")[0]){
97
+ gadwpFrontWidgetData = response[0];
98
+ gadwp_drawFrontWidgetChart(gadwpFrontWidgetData);
99
+ }
100
+ if (jQuery("#gadwp-widgettotals")[0]){
101
+ gadwp_drawFrontWidgetTotals(response[1]);
102
+ }
103
+ }else{
104
+ jQuery("#gadwp-widgetchart").css({"background-color":"#F7F7F7","height":"auto","padding-top":"50px","padding-bottom":"50px","color":"#000","text-align":"center"});
105
+ jQuery("#gadwp-widgetchart").html("<?php __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ); ?> ("+response+")");
106
+ }
107
+ });
108
+ });
109
+ function gadwp_drawFrontWidgetChart(response) {
110
+ var data = google.visualization.arrayToDataTable(response);
111
+ var options = {
112
+ legend: { position: "none" },
113
+ pointSize: "3, <?php echo $css; ?>",
114
+ title: "<?php echo $title; ?>",
115
+ titlePosition: "in",
116
+ chartArea: { width: "95%", height: "75%" },
117
+ hAxis: { textPosition: "none"},
118
+ vAxis: { textPosition: "none", minValue: 0, gridlines: { color: "transparent" }, baselineColor: "transparent"}
119
+ }
120
+ var chart = new google.visualization.AreaChart(document.getElementById("gadwp-widgetchart"));
121
+ <?php echo $formater; ?>
122
+ chart.draw(data, options);
123
+ }
124
+ function gadwp_drawFrontWidgetTotals(response) {
125
+ if (response == null){
126
+ response = 0;
127
+ }
128
+ jQuery("#gadwp-widgettotals").html('<div class="gadwp-left"><?php _e( "Period:", 'google-analytics-dashboard-for-wp' ); ?></div> <div class="gadwp-right"><?php echo $periodtext; ?> </div><div class="gadwp-left"><?php _e( "Sessions:", 'google-analytics-dashboard-for-wp' ); ?></div> <div class="gadwp-right">'+response+'</div>');
129
+ }
130
+ </script>
131
+ <?php
132
+ if ( $instance['give_credits'] == 1 ) :
133
+ ?>
134
+ <div style="text-align: right; width: 100%; font-size: 0.8em; clear: both; margin-right: 5px;"><?php _e( 'generated by', 'google-analytics-dashboard-for-wp' ); ?> <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=front_widget&utm_campaign=gadwp" rel="nofollow" style="text-decoration: none; font-size: 1em;">GADWP</a>&nbsp;
135
+ </div>
136
+
137
+ <?php
138
+ endif;
139
  $widget_content = ob_get_contents();
140
+ if ( ob_get_length() ) {
141
+ ob_end_clean();
142
+ }
143
+ echo $widget_content;
144
  echo $args['after_widget'];
145
  echo "\n<!-- END GADWP Widget -->\n";
146
  }
152
  $give_credits = ( isset( $instance['give_credits'] ) ? $instance['give_credits'] : 1 );
153
  $anonim = ( isset( $instance['anonim'] ) ? $instance['anonim'] : 0 );
154
  /* @formatter:off */
155
+ ?>
156
  <p>
157
  <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( "Title:",'google-analytics-dashboard-for-wp' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $widget_title ); ?>">
158
  </p>
gadwp.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: https://deconf.com
5
  * Description: Displays Google Analytics Reports and Real-Time Statistics in your Dashboard. Automatically inserts the tracking code in every page of your website.
6
  * Author: Alin Marcu
7
- * Version: 4.9.1.2
8
  * Author URI: https://deconf.com
9
  * Text Domain: google-analytics-dashboard-for-wp
10
  * Domain Path: /languages
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) )
16
 
17
  // Plugin Version
18
  if ( ! defined( 'GADWP_CURRENT_VERSION' ) ) {
19
- define( 'GADWP_CURRENT_VERSION', '4.9.1.2' );
20
  }
21
 
22
  if ( ! class_exists( 'GADWP_Manager' ) ) {
@@ -29,6 +29,8 @@ if ( ! class_exists( 'GADWP_Manager' ) ) {
29
 
30
  public $frontend_actions = null;
31
 
 
 
32
  public $backend_actions = null;
33
 
34
  public $tracking = null;
@@ -177,9 +179,7 @@ if ( ! class_exists( 'GADWP_Manager' ) ) {
177
  * Load Backend ajax actions
178
  */
179
  include_once ( GADWP_DIR . 'admin/ajax-actions.php' );
180
- include_once ( GADWP_DIR . 'admin/ajax-actions-ui.php' );
181
  self::$instance->backend_actions = new GADWP_Backend_Ajax();
182
- new GADWP_UI_Ajax();
183
  }
184
 
185
  /*
@@ -187,30 +187,35 @@ if ( ! class_exists( 'GADWP_Manager' ) ) {
187
  */
188
  include_once ( GADWP_DIR . 'front/ajax-actions.php' );
189
  self::$instance->frontend_actions = new GADWP_Frontend_Ajax();
190
- } else
191
- if ( GADWP_Tools::check_roles( self::$instance->config->options['ga_dash_access_back'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  /*
193
- * Load Backend Setup
194
  */
195
- include_once ( GADWP_DIR . 'admin/setup.php' );
196
- self::$instance->backend_setup = new GADWP_Backend_Setup();
197
-
198
- if ( self::$instance->config->options['dashboard_widget'] ) {
199
- /*
200
- * Load Backend Widget
201
- */
202
- include_once ( GADWP_DIR . 'admin/widgets.php' );
203
- self::$instance->backend_widgets = new GADWP_Backend_Widgets();
204
- }
205
-
206
- if ( self::$instance->config->options['backend_item_reports'] ) {
207
- /*
208
- * Load Backend Item Reports
209
- */
210
- include_once ( GADWP_DIR . 'admin/item-reports.php' );
211
- self::$instance->backend_item_reports = new GADWP_Backend_Item_Reports();
212
- }
213
  }
 
214
  } else {
215
  if ( GADWP_Tools::check_roles( self::$instance->config->options['ga_dash_access_front'] ) ) {
216
  /*
4
  * Plugin URI: https://deconf.com
5
  * Description: Displays Google Analytics Reports and Real-Time Statistics in your Dashboard. Automatically inserts the tracking code in every page of your website.
6
  * Author: Alin Marcu
7
+ * Version: 4.9.2
8
  * Author URI: https://deconf.com
9
  * Text Domain: google-analytics-dashboard-for-wp
10
  * Domain Path: /languages
16
 
17
  // Plugin Version
18
  if ( ! defined( 'GADWP_CURRENT_VERSION' ) ) {
19
+ define( 'GADWP_CURRENT_VERSION', '4.9.2' );
20
  }
21
 
22
  if ( ! class_exists( 'GADWP_Manager' ) ) {
29
 
30
  public $frontend_actions = null;
31
 
32
+ public $common_actions = null;
33
+
34
  public $backend_actions = null;
35
 
36
  public $tracking = null;
179
  * Load Backend ajax actions
180
  */
181
  include_once ( GADWP_DIR . 'admin/ajax-actions.php' );
 
182
  self::$instance->backend_actions = new GADWP_Backend_Ajax();
 
183
  }
184
 
185
  /*
187
  */
188
  include_once ( GADWP_DIR . 'front/ajax-actions.php' );
189
  self::$instance->frontend_actions = new GADWP_Frontend_Ajax();
190
+
191
+ /*
192
+ * Load Common ajax actions
193
+ */
194
+ include_once ( GADWP_DIR . 'common/ajax-actions.php' );
195
+ self::$instance->common_actions = new GADWP_Common_Ajax();
196
+ } else if ( GADWP_Tools::check_roles( self::$instance->config->options['ga_dash_access_back'] ) ) {
197
+ /*
198
+ * Load Backend Setup
199
+ */
200
+ include_once ( GADWP_DIR . 'admin/setup.php' );
201
+ self::$instance->backend_setup = new GADWP_Backend_Setup();
202
+
203
+ if ( self::$instance->config->options['dashboard_widget'] ) {
204
+ /*
205
+ * Load Backend Widget
206
+ */
207
+ include_once ( GADWP_DIR . 'admin/widgets.php' );
208
+ self::$instance->backend_widgets = new GADWP_Backend_Widgets();
209
+ }
210
+
211
+ if ( self::$instance->config->options['backend_item_reports'] ) {
212
  /*
213
+ * Load Backend Item Reports
214
  */
215
+ include_once ( GADWP_DIR . 'admin/item-reports.php' );
216
+ self::$instance->backend_item_reports = new GADWP_Backend_Item_Reports();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  }
218
+ }
219
  } else {
220
  if ( GADWP_Tools::check_roles( self::$instance->config->options['ga_dash_access_front'] ) ) {
221
  /*
install/install.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Author: Alin Marcu
5
  * Author URI: https://deconf.com
 
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
@@ -16,7 +16,6 @@ class GADWP_Install {
16
  public static function install() {
17
  if ( ! get_option( 'ga_dash_token' ) ) {
18
  $options = array();
19
- $options['ga_dash_apikey'] = '';
20
  $options['ga_dash_clientid'] = '';
21
  $options['ga_dash_clientsecret'] = '';
22
  $options['ga_dash_access_front'][] = 'administrator';
@@ -64,7 +63,6 @@ class GADWP_Install {
64
  $options['ga_cookieexpires'] = '';
65
  } else {
66
  $options = array();
67
- $options['ga_dash_apikey'] = get_option( 'ga_dash_apikey' );
68
  $options['ga_dash_clientid'] = get_option( 'ga_dash_clientid' );
69
  $options['ga_dash_clientsecret'] = get_option( 'ga_dash_clientsecret' );
70
  $options['ga_dash_access'] = get_option( 'ga_dash_access' );
@@ -112,8 +110,7 @@ class GADWP_Install {
112
  $options['ga_cookiedomain'] = '';
113
  $options['ga_cookiename'] = '';
114
  $options['ga_cookieexpires'] = '';
115
-
116
- delete_option( 'ga_dash_apikey' );
117
  delete_option( 'ga_dash_clientid' );
118
  delete_option( 'ga_dash_clientsecret' );
119
  delete_option( 'ga_dash_access' );
1
  <?php
 
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
16
  public static function install() {
17
  if ( ! get_option( 'ga_dash_token' ) ) {
18
  $options = array();
 
19
  $options['ga_dash_clientid'] = '';
20
  $options['ga_dash_clientsecret'] = '';
21
  $options['ga_dash_access_front'][] = 'administrator';
63
  $options['ga_cookieexpires'] = '';
64
  } else {
65
  $options = array();
 
66
  $options['ga_dash_clientid'] = get_option( 'ga_dash_clientid' );
67
  $options['ga_dash_clientsecret'] = get_option( 'ga_dash_clientsecret' );
68
  $options['ga_dash_access'] = get_option( 'ga_dash_access' );
110
  $options['ga_cookiedomain'] = '';
111
  $options['ga_cookiename'] = '';
112
  $options['ga_cookieexpires'] = '';
113
+
 
114
  delete_option( 'ga_dash_clientid' );
115
  delete_option( 'ga_dash_clientsecret' );
116
  delete_option( 'ga_dash_access' );
install/uninstall.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Author: Alin Marcu
5
  * Author URI: https://deconf.com
 
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
1
  <?php
 
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: deconf
3
  Donate link: https://deconf.com/donate/
4
  Tags: google,analytics,google analytics,dashboard,analytics dashboard,google analytics dashboard,google analytics plugin,google analytics widget,tracking,universal google analytics,realtime,multisite,gadwp
5
  Requires at least: 3.5
6
- Tested up to: 4.4
7
- Stable tag: 4.9.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -32,6 +32,7 @@ The Google Analytics reports you need, on your dashboard, in your All Posts and
32
  - Sessions, organic searches, page views, bounce rate analytics reports
33
  - Locations, pages, referrers, keywords analytics reports
34
  - Traffic channels, social networks, traffic mediums, search engines analytics reports
 
35
  - User access control over analytics reports
36
 
37
  = Google Analytics Basic Tracking =
@@ -104,7 +105,7 @@ We are constantly improving Google Analytics Dashboard for WP, sometimes the vid
104
 
105
  = How can I suggest a new feature, contribute or report a bug? =
106
 
107
- You can submit pull requests, feature requests, translations or bug reports on [our GitHub repository](https://github.com/deconf/Google-Analytics-Dashboard-for-WP).
108
 
109
  = Documentation, Tutorials and FAQ =
110
 
@@ -124,14 +125,34 @@ For documentation, tutorials, FAQ and videos check out: [Google Analytics Dashbo
124
 
125
  == Localization ==
126
 
127
- You can translate this plugin on [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/google-analytics-dashboard-for-wp).
128
 
129
  == License ==
130
 
131
  Google Analytics Dashboard for WP it's released under the GPLv2, you can use it free of charge on your personal or commercial website.
132
 
 
 
 
 
 
133
  == Changelog ==
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  = 4.9.1.2 =
136
  - Bug Fix: multiple CSS fixes for frontend widget
137
  - Bug Fix: clean-up output for View selection list
@@ -165,20 +186,4 @@ Google Analytics Dashboard for WP it's released under the GPLv2, you can use it
165
  - Enhancement: force language packs updates for all available languages on a Network
166
  - Enhancement: added View switch capabilities
167
 
168
- = 4.8.3 =
169
- - Enhancement: switching to translate.wordpress.org, you can find [more details here](https://deconf.com/moving-translations-to-wordpress-org/)
170
-
171
- = 4.8.2.1 =
172
- - Bug Fix: blank page on General Settings screen after failing to rebuild the bearer token
173
- - Enhancement: Italian, Portuguese (Brazil), Hungarian, Arabic, Russian, English (Canada), Romanian translations updated
174
- - Enhancement: new Localization section
175
- - Enhancement: small UI updates
176
-
177
- = 4.8.2 =
178
- - Bug Fix: use only unique CSS selectors to avoid conflicts with other plugins
179
- - Bug Fix: don't load unneeded CSS styles on frontend
180
- - Bug Fix: switch to a new custom made cache system to avoid issues with broken transients
181
- - Enhancement: rebuild and roll-back to a bearer token
182
- - Enhancement: Greek translation updated
183
-
184
- The full changelog is [available here](https://deconf.com/changelog-google-analytics-dashboard-for-wp/).
3
  Donate link: https://deconf.com/donate/
4
  Tags: google,analytics,google analytics,dashboard,analytics dashboard,google analytics dashboard,google analytics plugin,google analytics widget,tracking,universal google analytics,realtime,multisite,gadwp
5
  Requires at least: 3.5
6
+ Tested up to: 4.4.1
7
+ Stable tag: 4.9.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
32
  - Sessions, organic searches, page views, bounce rate analytics reports
33
  - Locations, pages, referrers, keywords analytics reports
34
  - Traffic channels, social networks, traffic mediums, search engines analytics reports
35
+ - Device categories, browsers, operating systems, screen resolutions, mobile brands analytics reports
36
  - User access control over analytics reports
37
 
38
  = Google Analytics Basic Tracking =
105
 
106
  = How can I suggest a new feature, contribute or report a bug? =
107
 
108
+ You can submit pull requests, feature requests and bug reports on [our GitHub repository](https://github.com/deconf/Google-Analytics-Dashboard-for-WP).
109
 
110
  = Documentation, Tutorials and FAQ =
111
 
125
 
126
  == Localization ==
127
 
128
+ You can translate Google Analytics Dashboard for WP on [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/google-analytics-dashboard-for-wp).
129
 
130
  == License ==
131
 
132
  Google Analytics Dashboard for WP it's released under the GPLv2, you can use it free of charge on your personal or commercial website.
133
 
134
+ == Upgrade Notice ==
135
+
136
+ = 4.9.2 =
137
+ In case of errors refresh your page or clear your browser cache, as a first step. The Frontend Widget can be re-enabled from Appearance -> Widgets screen.
138
+
139
  == Changelog ==
140
 
141
+ = 4.9.2 =
142
+ * Enhancements:
143
+ * improved loading speed for charts
144
+ * add autoloading for Charts Library to allow dequeue on conflicts
145
+ * removed API Key option, since is not needed anymore
146
+ * display session values in Pie Chart slices
147
+ * improved data accuracy for Pie Charts
148
+
149
+ * Bug Fixes:
150
+ * multiple fixes for frontend widget
151
+ * page title missing in Realtime report
152
+
153
+ * New Features:
154
+ * brand new Technology Reports with details about Device Categories, Browsers, Operating Systems, Screen Resolutions and Device Brands
155
+
156
  = 4.9.1.2 =
157
  - Bug Fix: multiple CSS fixes for frontend widget
158
  - Bug Fix: clean-up output for View selection list
186
  - Enhancement: force language packs updates for all available languages on a Network
187
  - Enhancement: added View switch capabilities
188
 
189
+ The full changelog is [available here](https://deconf.com/changelog-google-analytics-dashboard-for-wp/).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tools/gapi.php CHANGED
@@ -2,6 +2,7 @@
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -26,7 +27,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
26
 
27
  private $gadwp;
28
 
29
- private $access = array( '65556128781.apps.googleusercontent.com', 'Kc7888wgbc_JbeCmApbFjnYpwE' );
30
 
31
  public function __construct() {
32
  $this->gadwp = GADWP();
@@ -51,7 +52,6 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
51
  if ( $this->gadwp->config->options['ga_dash_userapi'] ) {
52
  $this->client->setClientId( $this->gadwp->config->options['ga_dash_clientid'] );
53
  $this->client->setClientSecret( $this->gadwp->config->options['ga_dash_clientsecret'] );
54
- $this->client->setDeveloperKey( $this->gadwp->config->options['ga_dash_apikey'] );
55
  } else {
56
  $this->client->setClientId( $this->access[0] );
57
  $this->client->setClientSecret( $this->access[1] );
@@ -90,7 +90,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
90
  }
91
 
92
  /**
93
- * Handles errors returned by GAPI
94
  *
95
  * @return boolean
96
  */
@@ -139,6 +139,9 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
139
  }
140
  }
141
 
 
 
 
142
  public function token_request() {
143
  $authUrl = $this->client->createAuthUrl();
144
  ?>
@@ -165,7 +168,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
165
  }
166
 
167
  /**
168
- * Retrives all Google Analytics Views with details
169
  *
170
  * @return array
171
  */
@@ -305,7 +308,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
305
  }
306
 
307
  /**
308
- * Analytics data for backend reports (Admin Widget main report)
309
  *
310
  * @param
311
  * $projectId
@@ -315,9 +318,11 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
315
  * $to
316
  * @param
317
  * $query
 
 
318
  * @return array|int
319
  */
320
- private function get_mainreport( $projectId, $from, $to, $query, $filter = '' ) {
321
  switch ( $query ) {
322
  case 'users' :
323
  $title = __( "Users", 'google-analytics-dashboard-for-wp' );
@@ -364,24 +369,29 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
364
  }
365
  } else if ( $from == "365daysAgo" || $from == "1095daysAgo" ) {
366
  foreach ( $data->getRows() as $row ) {
367
- /* translators:
 
368
  * Example: 'F, Y' will become 'November, 2015'
369
- * For details see: http://php.net/manual/en/function.date.php#refsect1-function.date-parameters */
370
- $gadwp_data[] = array( date_i18n( __('F, Y', 'google-analytics-dashboard-for-wp'), strtotime( $row[0] . '01' ) ), round( $row[2], 2 ) );
 
371
  }
372
  } else {
373
  foreach ( $data->getRows() as $row ) {
374
- /* translators:
 
375
  * Example: 'l, F j, Y' will become 'Thusday, November 17, 2015'
376
- * For details see: http://php.net/manual/en/function.date.php#refsect1-function.date-parameters */
 
377
  $gadwp_data[] = array( date_i18n( __( 'l, F j, Y', 'google-analytics-dashboard-for-wp' ), strtotime( $row[0] ) ), round( $row[2], 2 ) );
378
  }
379
  }
 
380
  return $gadwp_data;
381
  }
382
 
383
  /**
384
- * Analytics data for backend reports (bottom stats main report)
385
  *
386
  * @param
387
  * $projectId
@@ -389,6 +399,8 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
389
  * $from
390
  * @param
391
  * $to
 
 
392
  * @return array|int
393
  */
394
  private function get_bottomstats( $projectId, $from, $to, $filter = '' ) {
@@ -425,7 +437,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
425
  }
426
 
427
  /**
428
- * Analytics data for backend reports (contentpages)
429
  *
430
  * @param
431
  * $projectId
@@ -433,6 +445,8 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
433
  * $from
434
  * @param
435
  * $to
 
 
436
  * @return array|int
437
  */
438
  private function get_contentpages( $projectId, $from, $to, $filter = '' ) {
@@ -455,7 +469,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
455
  }
456
 
457
  /**
458
- * Analytics data for backend reports (referrers)
459
  *
460
  * @param
461
  * $projectId
@@ -463,6 +477,8 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
463
  * $from
464
  * @param
465
  * $to
 
 
466
  * @return array|int
467
  */
468
  private function get_referrers( $projectId, $from, $to, $filter = '' ) {
@@ -487,7 +503,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
487
  }
488
 
489
  /**
490
- * Analytics data for backend reports (searches)
491
  *
492
  * @param
493
  * $projectId
@@ -495,6 +511,8 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
495
  * $from
496
  * @param
497
  * $to
 
 
498
  * @return array|int
499
  */
500
  private function get_searches( $projectId, $from, $to, $filter = '' ) {
@@ -520,7 +538,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
520
  }
521
 
522
  /**
523
- * Analytics data for backend reports (location reports)
524
  *
525
  * @param
526
  * $projectId
@@ -528,6 +546,8 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
528
  * $from
529
  * @param
530
  * $to
 
 
531
  * @return array|int
532
  */
533
  private function get_locations( $projectId, $from, $to, $filter = '' ) {
@@ -574,7 +594,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
574
  }
575
 
576
  /**
577
- * Analytics data for backend reports (traffic channels)
578
  *
579
  * @param
580
  * $projectId
@@ -582,31 +602,35 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
582
  * $from
583
  * @param
584
  * $to
 
 
 
 
585
  * @return array|int
586
  */
587
- private function get_trafficchannels( $projectId, $from, $to, $filter = '' ) {
588
  $metrics = 'ga:sessions';
589
- $dimensions = 'ga:channelGrouping';
590
- $options = array( 'dimensions' => $dimensions, 'quotaUser' => $this->managequota . 'p' . $projectId );
591
  if ( $filter ) {
592
  $options['filters'] = 'ga:pagePath==' . $filter;
593
  }
594
- $serial = 'qr8_' . $this->get_serial( $projectId . $from . $filter );
595
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
596
  if ( is_numeric( $data ) ) {
597
  return $data;
598
  }
599
- $title = __( "Channels", 'google-analytics-dashboard-for-wp' );
600
- $gadwp_data = array( array( '<div style="color:black; font-size:1.1em">' . $title . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults']["ga:sessions"] . '</div>', "" ) );
601
  foreach ( $data->getRows() as $row ) {
602
  $shrink = explode( " ", $row[0] );
603
- $gadwp_data[] = array( '<div style="color:black; font-size:1.1em">' . esc_html( $shrink[0] ) . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $row[1] . '</div>', '<div style="color:black; font-size:1.1em">' . $title . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults']["ga:sessions"] . '</div>' );
604
  }
605
  return $gadwp_data;
606
  }
607
 
608
  /**
609
- * Analytics data for backend reports (traffic mediums, type, serach engines, social networks)
610
  *
611
  * @param
612
  * $projectId
@@ -616,21 +640,23 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
616
  * $to
617
  * @param
618
  * $query
 
 
619
  * @return array|int
620
  */
621
- private function get_trafficdetails( $projectId, $from, $to, $query, $filter = '' ) {
622
  $metrics = 'ga:sessions';
623
  $dimensions = 'ga:' . $query;
624
 
625
  if ( $query == 'source' ) {
626
- $options = array( 'dimensions' => $dimensions, 'quotaUser' => $this->managequota . 'p' . $projectId );
627
  if ( $filter ) {
628
  $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set);ga:pagePath==' . $filter;
629
  } else {
630
  $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set)';
631
  }
632
  } else {
633
- $options = array( 'dimensions' => $dimensions, 'quotaUser' => $this->managequota . 'p' . $projectId );
634
  if ( $filter ) {
635
  $options['filters'] = 'ga:' . $query . '!=(not set);ga:pagePath==' . $filter;
636
  } else {
@@ -643,14 +669,28 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
643
  return $data;
644
  }
645
  $gadwp_data = array( array( __( "Type", 'google-analytics-dashboard-for-wp' ), __( "Sessions", 'google-analytics-dashboard-for-wp' ) ) );
 
 
646
  foreach ( $data->getRows() as $row ) {
647
- $gadwp_data[] = array( str_replace( "(none)", "direct", esc_html( $row[0] ) ), (int) $row[1] );
 
 
 
 
 
 
 
 
 
 
 
648
  }
 
649
  return $gadwp_data;
650
  }
651
 
652
  /**
653
- * Analytics data for frontend Widget (chart data and totals)
654
  *
655
  * @param
656
  * $projectId
@@ -687,7 +727,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
687
  }
688
 
689
  /**
690
- * Analytics data for backend reports (Real-Time)
691
  *
692
  * @param
693
  * $projectId
@@ -731,52 +771,61 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
731
  }
732
 
733
  private function map( $map ) {
734
- return str_ireplace( 'map', chr( 112 ), $map );
 
 
 
 
 
 
735
  }
736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
737
  public function get( $projectId, $query, $from = false, $to = false, $filter = '' ) {
738
  if ( empty( $projectId ) || ! is_numeric( $projectId ) ) {
739
  return - 25;
740
  }
741
-
742
- switch ( $query ) {
743
- case 'referrers' :
744
- return $this->get_referrers( $projectId, $from, $to, $filter );
745
- break;
746
- case 'contentpages' :
747
- return $this->get_contentpages( $projectId, $from, $to, $filter );
748
- break;
749
- case 'locations' :
750
- return $this->get_locations( $projectId, $from, $to, $filter );
751
- break;
752
- case 'bottomstats' :
753
- return $this->get_bottomstats( $projectId, $from, $to, $filter );
754
- break;
755
- case 'trafficchannels' :
756
- return $this->get_trafficchannels( $projectId, $from, $to, $filter );
757
- break;
758
- case 'medium' :
759
- return $this->get_trafficdetails( $projectId, $from, $to, 'medium', $filter );
760
- break;
761
- case 'visitorType' :
762
- return $this->get_trafficdetails( $projectId, $from, $to, 'visitorType', $filter );
763
- break;
764
- case 'socialNetwork' :
765
- return $this->get_trafficdetails( $projectId, $from, $to, 'socialNetwork', $filter );
766
- break;
767
- case 'source' :
768
- return $this->get_trafficdetails( $projectId, $from, $to, 'source', $filter );
769
- break;
770
- case 'searches' :
771
- return $this->get_searches( $projectId, $from, $to, $filter );
772
- break;
773
- case 'realtime' :
774
- return $this->get_realtime( $projectId );
775
- break;
776
- default :
777
- return $this->get_mainreport( $projectId, $from, $to, $query, $filter );
778
- break;
779
  }
 
780
  }
781
  }
782
  }
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
27
 
28
  private $gadwp;
29
 
30
+ private $access = array( '65556128672.apps.googleusercontent.com', 'Kc7888wgbc_JbeCmApbFjnYpwE' );
31
 
32
  public function __construct() {
33
  $this->gadwp = GADWP();
52
  if ( $this->gadwp->config->options['ga_dash_userapi'] ) {
53
  $this->client->setClientId( $this->gadwp->config->options['ga_dash_clientid'] );
54
  $this->client->setClientSecret( $this->gadwp->config->options['ga_dash_clientsecret'] );
 
55
  } else {
56
  $this->client->setClientId( $this->access[0] );
57
  $this->client->setClientSecret( $this->access[1] );
90
  }
91
 
92
  /**
93
+ * Handles errors returned by GAPI Library
94
  *
95
  * @return boolean
96
  */
139
  }
140
  }
141
 
142
+ /**
143
+ * Generates and retrieves the Access Code
144
+ */
145
  public function token_request() {
146
  $authUrl = $this->client->createAuthUrl();
147
  ?>
168
  }
169
 
170
  /**
171
+ * Retrieves all Google Analytics Views with details
172
  *
173
  * @return array
174
  */
308
  }
309
 
310
  /**
311
+ * Analytics data for Area Charts (Admin Dashboard Widget report)
312
  *
313
  * @param
314
  * $projectId
318
  * $to
319
  * @param
320
  * $query
321
+ * @param
322
+ * $filter
323
  * @return array|int
324
  */
325
+ private function get_areachart_data( $projectId, $from, $to, $query, $filter = '' ) {
326
  switch ( $query ) {
327
  case 'users' :
328
  $title = __( "Users", 'google-analytics-dashboard-for-wp' );
369
  }
370
  } else if ( $from == "365daysAgo" || $from == "1095daysAgo" ) {
371
  foreach ( $data->getRows() as $row ) {
372
+ /*
373
+ * translators:
374
  * Example: 'F, Y' will become 'November, 2015'
375
+ * For details see: http://php.net/manual/en/function.date.php#refsect1-function.date-parameters
376
+ */
377
+ $gadwp_data[] = array( date_i18n( __( 'F, Y', 'google-analytics-dashboard-for-wp' ), strtotime( $row[0] . '01' ) ), round( $row[2], 2 ) );
378
  }
379
  } else {
380
  foreach ( $data->getRows() as $row ) {
381
+ /*
382
+ * translators:
383
  * Example: 'l, F j, Y' will become 'Thusday, November 17, 2015'
384
+ * For details see: http://php.net/manual/en/function.date.php#refsect1-function.date-parameters
385
+ */
386
  $gadwp_data[] = array( date_i18n( __( 'l, F j, Y', 'google-analytics-dashboard-for-wp' ), strtotime( $row[0] ) ), round( $row[2], 2 ) );
387
  }
388
  }
389
+
390
  return $gadwp_data;
391
  }
392
 
393
  /**
394
+ * Analytics data for Bottom Stats (bottom stats on main report)
395
  *
396
  * @param
397
  * $projectId
399
  * $from
400
  * @param
401
  * $to
402
+ * @param
403
+ * $filter
404
  * @return array|int
405
  */
406
  private function get_bottomstats( $projectId, $from, $to, $filter = '' ) {
437
  }
438
 
439
  /**
440
+ * Analytics data for Org Charts & Table Charts (content pages)
441
  *
442
  * @param
443
  * $projectId
445
  * $from
446
  * @param
447
  * $to
448
+ * @param
449
+ * $filter
450
  * @return array|int
451
  */
452
  private function get_contentpages( $projectId, $from, $to, $filter = '' ) {
469
  }
470
 
471
  /**
472
+ * Analytics data for Org Charts & Table Charts (referrers)
473
  *
474
  * @param
475
  * $projectId
477
  * $from
478
  * @param
479
  * $to
480
+ * @param
481
+ * $filter
482
  * @return array|int
483
  */
484
  private function get_referrers( $projectId, $from, $to, $filter = '' ) {
503
  }
504
 
505
  /**
506
+ * Analytics data for Org Charts & Table Charts (searches)
507
  *
508
  * @param
509
  * $projectId
511
  * $from
512
  * @param
513
  * $to
514
+ * @param
515
+ * $filter
516
  * @return array|int
517
  */
518
  private function get_searches( $projectId, $from, $to, $filter = '' ) {
538
  }
539
 
540
  /**
541
+ * Analytics data for Org Charts & Table Charts (location reports)
542
  *
543
  * @param
544
  * $projectId
546
  * $from
547
  * @param
548
  * $to
549
+ * @param
550
+ * $filter
551
  * @return array|int
552
  */
553
  private function get_locations( $projectId, $from, $to, $filter = '' ) {
594
  }
595
 
596
  /**
597
+ * Analytics data for Org Charts (traffic channels, device categories)
598
  *
599
  * @param
600
  * $projectId
602
  * $from
603
  * @param
604
  * $to
605
+ * @param
606
+ * $query
607
+ * @param
608
+ * $filter
609
  * @return array|int
610
  */
611
+ private function get_orgchart_data( $projectId, $from, $to, $query, $filter = '' ) {
612
  $metrics = 'ga:sessions';
613
+ $dimensions = 'ga:' . $query;
614
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
615
  if ( $filter ) {
616
  $options['filters'] = 'ga:pagePath==' . $filter;
617
  }
618
+ $serial = 'qr8_' . $this->get_serial( $projectId . $from . $query . $filter );
619
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
620
  if ( is_numeric( $data ) ) {
621
  return $data;
622
  }
623
+ $block = ( $query == 'channelGrouping' ) ? __( "Channels", 'google-analytics-dashboard-for-wp' ) : __( "Devices", 'google-analytics-dashboard-for-wp' );
624
+ $gadwp_data = array( array( '<div style="color:black; font-size:1.1em">' . $block . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults']["ga:sessions"] . '</div>', "" ) );
625
  foreach ( $data->getRows() as $row ) {
626
  $shrink = explode( " ", $row[0] );
627
+ $gadwp_data[] = array( '<div style="color:black; font-size:1.1em">' . esc_html( $shrink[0] ) . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $row[1] . '</div>', '<div style="color:black; font-size:1.1em">' . $block . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults']["ga:sessions"] . '</div>' );
628
  }
629
  return $gadwp_data;
630
  }
631
 
632
  /**
633
+ * Analytics data for Pie Charts (traffic mediums, serach engines, social networks, browsers, screen rsolutions, etc.)
634
  *
635
  * @param
636
  * $projectId
640
  * $to
641
  * @param
642
  * $query
643
+ * @param
644
+ * $filter
645
  * @return array|int
646
  */
647
+ private function get_piechart_data( $projectId, $from, $to, $query, $filter = '' ) {
648
  $metrics = 'ga:sessions';
649
  $dimensions = 'ga:' . $query;
650
 
651
  if ( $query == 'source' ) {
652
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
653
  if ( $filter ) {
654
  $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set);ga:pagePath==' . $filter;
655
  } else {
656
  $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set)';
657
  }
658
  } else {
659
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
660
  if ( $filter ) {
661
  $options['filters'] = 'ga:' . $query . '!=(not set);ga:pagePath==' . $filter;
662
  } else {
669
  return $data;
670
  }
671
  $gadwp_data = array( array( __( "Type", 'google-analytics-dashboard-for-wp' ), __( "Sessions", 'google-analytics-dashboard-for-wp' ) ) );
672
+ $i = 0;
673
+ $included = 0;
674
  foreach ( $data->getRows() as $row ) {
675
+ if ( $i < 20 ) {
676
+ $gadwp_data[] = array( str_replace( "(none)", "direct", esc_html( $row[0] ) ), (int) $row[1] );
677
+ $included += $row[1];
678
+ $i++;
679
+ } else {
680
+ break;
681
+ }
682
+ }
683
+ $totals = $data->getTotalsForAllResults();
684
+ $others = $totals['ga:sessions'] - $included;
685
+ if ( $others > 0 ) {
686
+ $gadwp_data[] = array( __( 'Other', 'google-analytics-dashboard-for-wp' ), $others );
687
  }
688
+
689
  return $gadwp_data;
690
  }
691
 
692
  /**
693
+ * Analytics data for Frontend Widget (chart data and totals)
694
  *
695
  * @param
696
  * $projectId
727
  }
728
 
729
  /**
730
+ * Analytics data for Realtime component (the real-time report)
731
  *
732
  * @param
733
  * $projectId
771
  }
772
 
773
  private function map( $map ) {
774
+ $map = explode( '.', $map );
775
+ if ( isset( $map[1] ) ) {
776
+ $map[0] += ord( 'map' );
777
+ return implode( '.', $map );
778
+ } else {
779
+ return str_ireplace( 'map', chr( 112 ), $map[0] );
780
+ }
781
  }
782
 
783
+ /**
784
+ * Handles ajax requests and calls the needed methods
785
+ * @param
786
+ * $projectId
787
+ * @param
788
+ * $query
789
+ * @param
790
+ * $from
791
+ * @param
792
+ * $to
793
+ * @param
794
+ * $filter
795
+ * @return number|Google_Service_Analytics_GaData
796
+ */
797
  public function get( $projectId, $query, $from = false, $to = false, $filter = '' ) {
798
  if ( empty( $projectId ) || ! is_numeric( $projectId ) ) {
799
  return - 25;
800
  }
801
+ if ( in_array( $query, array( 'sessions', 'users', 'organicSearches', 'visitBounceRate', 'pageviews', 'uniquePageviews' ) ) ) {
802
+ return $this->get_areachart_data( $projectId, $from, $to, $query, $filter );
803
+ }
804
+ if ( $query == 'bottomstats' ) {
805
+ return $this->get_bottomstats( $projectId, $from, $to, $filter );
806
+ }
807
+ if ( $query == 'locations' ) {
808
+ return $this->get_locations( $projectId, $from, $to, $filter );
809
+ }
810
+ if ( $query == 'referrers' ) {
811
+ return $this->get_referrers( $projectId, $from, $to, $filter );
812
+ }
813
+ if ( $query == 'contentpages' ) {
814
+ return $this->get_contentpages( $projectId, $from, $to, $filter );
815
+ }
816
+ if ( $query == 'searches' ) {
817
+ return $this->get_searches( $projectId, $from, $to, $filter );
818
+ }
819
+ if ( $query == 'realtime' ) {
820
+ return $this->get_realtime( $projectId );
821
+ }
822
+ if ( $query == 'channelGrouping' || $query == 'deviceCategory' ) {
823
+ return $this->get_orgchart_data( $projectId, $from, $to, $query, $filter );
824
+ }
825
+ if ( in_array( $query, array( 'medium', 'visitorType', 'socialNetwork', 'source', 'browser', 'operatingSystem', 'screenResolution', 'mobileDeviceBranding' ) ) ) {
826
+ return $this->get_piechart_data( $projectId, $from, $to, $query, $filter );
 
 
 
 
 
 
 
 
 
 
 
 
827
  }
828
+ return - 25;
829
  }
830
  }
831
  }
tools/iso3166.php CHANGED
@@ -2,6 +2,7 @@
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -10,6 +11,7 @@
10
  if ( ! defined( 'ABSPATH' ) )
11
  exit();
12
 
 
13
  $country_codes = array(
14
  'AD' => 'Andorra',
15
  'AE' => 'United Arab Emirates',
@@ -249,4 +251,5 @@ $country_codes = array(
249
  'YU' => 'Yugoslavia',
250
  'ZA' => 'South Africa',
251
  'ZM' => 'Zambia',
252
- 'ZW' => 'Zimbabwe' );
 
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
11
  if ( ! defined( 'ABSPATH' ) )
12
  exit();
13
 
14
+ /* @formatter:off */
15
  $country_codes = array(
16
  'AD' => 'Andorra',
17
  'AE' => 'United Arab Emirates',
251
  'YU' => 'Yugoslavia',
252
  'ZA' => 'South Africa',
253
  'ZM' => 'Zambia',
254
+ 'ZW' => 'Zimbabwe' );
255
+ /* @formatter:on */
tools/tools.php CHANGED
@@ -2,6 +2,7 @@
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
 
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
@@ -119,7 +120,7 @@ if ( ! class_exists( 'GADWP_Tools' ) ) {
119
  }
120
 
121
  public static function set_cache( $name, $value, $expiration = 0 ) {
122
- $option = array( 'value' => $value, 'expires' => time() + (int)$expiration );
123
  update_option( 'gadwp_cache_' . $name, $option );
124
  }
125
 
@@ -143,7 +144,7 @@ if ( ! class_exists( 'GADWP_Tools' ) ) {
143
  }
144
 
145
  public static function set_site_cache( $name, $value, $expiration = 0 ) {
146
- $option = array( 'value' => $value, 'expires' => time() + (int)$expiration );
147
  update_site_option( 'gadwp_cache_' . $name, $option );
148
  }
149
 
@@ -165,6 +166,7 @@ if ( ! class_exists( 'GADWP_Tools' ) ) {
165
  return $option['value'];
166
  }
167
  }
 
168
  public static function clear_cache() {
169
  global $wpdb;
170
  $sqlquery = $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'gadwp_cache_qr%%'" );
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
120
  }
121
 
122
  public static function set_cache( $name, $value, $expiration = 0 ) {
123
+ $option = array( 'value' => $value, 'expires' => time() + (int) $expiration );
124
  update_option( 'gadwp_cache_' . $name, $option );
125
  }
126
 
144
  }
145
 
146
  public static function set_site_cache( $name, $value, $expiration = 0 ) {
147
+ $option = array( 'value' => $value, 'expires' => time() + (int) $expiration );
148
  update_site_option( 'gadwp_cache_' . $name, $option );
149
  }
150
 
166
  return $option['value'];
167
  }
168
  }
169
+
170
  public static function clear_cache() {
171
  global $wpdb;
172
  $sqlquery = $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'gadwp_cache_qr%%'" );