Google Analytics Dashboard for WP (GADWP) - Version 4.9

Version Description

  • Bug Fix: add an unique class to jQuery UI Tooltips to avoid conflicts
  • Bug Fix: multiple CSS improvements
  • Bug Fix: invalid localized date formats
  • Bug Fix: switching between multisite modes doesn't propagate the new network status on all sites
  • Bug Fix: Location Settings ignored in posts/pages reports
  • Enhancement: unset cookies while revoking the authorization or clearing the cache
  • Enhancement: no more page re-loads on admin dashboard widget when switching between reports
  • Enhancement: unified reporting system with real-time capabilities
  • Enhancement: new tracking options enabling you to customize cookieName, cookieDomain, cookieExpires; props by Martins Sipenko
  • Enhancement: display update notices only to admins and only on dashboard
  • Enhancement: force language packs updates for all available languages on a Network
  • Enhancement: added View switch capabilities
Download this release

Release Info

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

Code changes from version 4.8.3 to 4.9

Files changed (37) hide show
  1. admin/ajax-actions-ui.php +1 -1
  2. admin/ajax-actions.php +34 -76
  3. admin/css/admin-widgets.css +185 -0
  4. admin/css/gadwp.css +22 -203
  5. admin/settings.php +21 -4
  6. admin/setup.php +124 -23
  7. admin/widgets.php +8 -873
  8. common/js/reports.js +1199 -0
  9. common/nprogress/nprogress.css +67 -0
  10. common/nprogress/nprogress.js +476 -0
  11. common/realtime/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  12. common/realtime/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  13. common/realtime/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  14. common/realtime/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  15. common/realtime/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  16. common/realtime/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  17. common/realtime/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  18. common/realtime/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  19. common/realtime/images/ui-icons_222222_256x240.png +0 -0
  20. common/realtime/images/ui-icons_2e83ff_256x240.png +0 -0
  21. common/realtime/images/ui-icons_454545_256x240.png +0 -0
  22. common/realtime/images/ui-icons_888888_256x240.png +0 -0
  23. common/realtime/images/ui-icons_cd0a0a_256x240.png +0 -0
  24. common/realtime/jquery.ui.tooltip.html.css +57 -0
  25. common/realtime/jquery.ui.tooltip.html.js +8 -0
  26. config.php +42 -21
  27. front/ajax-actions.php +9 -9
  28. front/setup.php +6 -5
  29. front/tracking/code-universal.php +17 -2
  30. front/widgets.php +2 -2
  31. gadwp.php +2 -2
  32. install/install.php +6 -3
  33. install/uninstall.php +3 -0
  34. readme.txt +19 -5
  35. tools/gapi.php +27 -25
  36. tools/js/item-reports.js +0 -737
  37. tools/tools.php +6 -15
admin/ajax-actions-ui.php CHANGED
@@ -27,7 +27,7 @@ if ( ! class_exists( 'GADWP_UI_Ajax' ) ) {
27
* @return json|int
28
*/
29
public function ajax_dismiss_notices() {
30
- if ( ! isset( $_REQUEST['gadwp_security_dismiss_notices'] ) || ! wp_verify_nonce( $_REQUEST['gadwp_security_dismiss_notices'], 'gadwp_dismiss_notices' ) ) {
31
wp_die( - 30 );
32
}
33
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
admin/ajax-actions.php CHANGED
@@ -19,12 +19,7 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
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['dashboard_widget'] ) ) {
23
- // Admin Widget action
24
- add_action( 'wp_ajax_gadash_get_widgetreports', array( $this, 'ajax_widget_reports' ) );
25
- }
26
-
27
- if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && ( 1 == $this->gadwp->config->options['backend_item_reports'] ) ) {
28
// Items action
29
add_action( 'wp_ajax_gadwp_backend_item_reports', array( $this, 'ajax_item_reports' ) );
30
}
@@ -36,15 +31,22 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
36
* @return json|int
37
*/
38
public function ajax_item_reports() {
39
- if ( ! isset( $_REQUEST['gadwp_security_backend_item_reports'] ) || ! wp_verify_nonce( $_REQUEST['gadwp_security_backend_item_reports'], 'gadwp_backend_item_reports' ) ) {
40
wp_die( - 30 );
41
}
42
-
43
- $from = $_REQUEST['from'];
44
- $to = $_REQUEST['to'];
45
- $query = $_REQUEST['query'];
46
- $filter_id = $_REQUEST['filter'];
47
-
48
if ( ob_get_length() ) {
49
ob_clean();
50
}
@@ -59,7 +61,9 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
59
} else {
60
wp_die( - 24 );
61
}
62
- $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
63
$profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $projectId );
64
if ( isset( $profile_info[4] ) ) {
65
$this->gadwp->gapi_controller->timeshift = $profile_info[4];
@@ -67,74 +71,28 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
67
$this->gadwp->gapi_controller->timeshift = (int) current_time( 'timestamp' ) - time();
68
}
69
70
- $uri_parts = explode( '/', get_permalink( $filter_id ), 4 );
71
-
72
- if ( isset( $uri_parts[3] ) ) {
73
- $uri = '/' . $uri_parts[3];
74
- } else {
75
- wp_die( - 25 );
76
- }
77
-
78
- // allow URL correction before sending an API request
79
- $filter = apply_filters( 'gadwp_backenditem_uri', $uri );
80
-
81
- $lastchar = substr( $filter, - 1 );
82
-
83
- if ( isset( $profile_info[6] ) && $profile_info[6] && $lastchar == '/' ) {
84
- $filter = $filter . $profile_info[6];
85
- }
86
-
87
- // Encode URL
88
- $filter = rawurlencode( rawurldecode( $filter ) );
89
-
90
- $queries = explode( ',', $query );
91
-
92
- $results = array();
93
-
94
- foreach ( $queries as $value ) {
95
- $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter );
96
- }
97
-
98
- wp_send_json( $results );
99
- }
100
101
- /**
102
- * Ajax handler for Admin Widget
103
- *
104
- * @return json|int
105
- */
106
- public function ajax_widget_reports() {
107
- if ( ! isset( $_REQUEST['gadash_security_widget_reports'] ) || ! wp_verify_nonce( $_REQUEST['gadash_security_widget_reports'], 'gadash_get_widgetreports' ) ) {
108
- wp_die( - 30 );
109
- }
110
-
111
- $projectId = $_REQUEST['projectId'];
112
- $from = $_REQUEST['from'];
113
- $to = $_REQUEST['to'];
114
- $query = $_REQUEST['query'];
115
116
- if ( ob_get_length() ) {
117
- ob_clean();
118
- }
119
120
- if ( ! GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) || 0 == $this->gadwp->config->options['dashboard_widget'] ) {
121
- wp_die( - 31 );
122
- }
123
124
- if ( $this->gadwp->config->options['ga_dash_token'] && $projectId && $from && $to ) {
125
- if ( null === $this->gadwp->gapi_controller ) {
126
- $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
127
}
128
- } else {
129
- wp_die( - 24 );
130
- }
131
132
- $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $projectId );
133
-
134
- if ( isset( $profile_info[4] ) ) {
135
- $this->gadwp->gapi_controller->timeshift = $profile_info[4];
136
} else {
137
- $this->gadwp->gapi_controller->timeshift = (int) current_time( 'timestamp' ) - time();
138
}
139
140
$queries = explode( ',', $query );
@@ -142,7 +100,7 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
142
$results = array();
143
144
foreach ( $queries as $value ) {
145
- $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to );
146
}
147
148
wp_send_json( $results );
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
}
31
* @return json|int
32
*/
33
public function ajax_item_reports() {
34
+ if ( ! isset( $_POST['gadwp_security_backend_item_reports'] ) || ! wp_verify_nonce( $_POST['gadwp_security_backend_item_reports'], 'gadwp_backend_item_reports' ) ) {
35
wp_die( - 30 );
36
}
37
+ if ( isset( $_POST['projectId'] ) && $this->gadwp->config->options['switch_profile'] && $_POST['projectId'] !== 'false' ) {
38
+ $projectId = $_POST['projectId'];
39
+ } else {
40
+ $projectId = false;
41
+ }
42
+ $from = $_POST['from'];
43
+ $to = $_POST['to'];
44
+ $query = $_POST['query'];
45
+ if ( isset( $_POST['filter'] ) ) {
46
+ $filter_id = $_POST['filter'];
47
+ } else {
48
+ $filter_id = false;
49
+ }
50
if ( ob_get_length() ) {
51
ob_clean();
52
}
61
} else {
62
wp_die( - 24 );
63
}
64
+ if ( $projectId == false ) {
65
+ $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
66
+ }
67
$profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $projectId );
68
if ( isset( $profile_info[4] ) ) {
69
$this->gadwp->gapi_controller->timeshift = $profile_info[4];
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 );
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 );
admin/css/admin-widgets.css ADDED
@@ -0,0 +1,185 @@
1
+ /* Admin Widget & Real-Time Stats*/
2
+
3
+ /* Real-Time content */
4
+ .gadwp-pline {
5
+ width: 100%;
6
+ margin: 0 0;
7
+ padding: 5px 0 5px 0;
8
+ background: #fff;
9
+ -moz-box-shadow: 0px 0px 3px 0px #BBB;
10
+ -webkit-box-shadow: 0px 0px 3px 0px #BBB;
11
+ box-shadow: 0px 0px 3px 0px #BBB;
12
+ display: table;
13
+ overflow: hidden;
14
+ }
15
+
16
+ .gadwp-pleft {
17
+ width: 90%;
18
+ float: left;
19
+ padding-left: 5px;
20
+ }
21
+
22
+ .gadwp-pright {
23
+ width: 5%;
24
+ float: right;
25
+ padding-right: 5px;
26
+ }
27
+
28
+ [id^=gadwp-realtime] {
29
+ margin: 10px 0 0 0;
30
+ width: 100%;
31
+ }
32
+
33
+ .gadwp-rt-box {
34
+ width: 100%;
35
+ margin: 0 0;
36
+ background: #fff;
37
+ text-align: center;
38
+ -moz-box-shadow: 0px 0px 5px 0px #BBB;
39
+ -webkit-box-shadow: 0px 0px 5px 0px #BBB;
40
+ box-shadow: 0px 0px 5px 0px #BBB;
41
+ display: table;
42
+ }
43
+
44
+ .gadwp-tdo-left {
45
+ width: 60%;
46
+ padding: 33px 0;
47
+ float: left;
48
+ text-align: center;
49
+ }
50
+
51
+ .gadwp-tdo-right {
52
+ width: 35%;
53
+ margin: 0px 10px 0px 0;
54
+ text-align: left;
55
+ font-weight: bold;
56
+ vertical-align: middle;
57
+ float: right;
58
+ display: table;
59
+ }
60
+
61
+ .gadwp-online {
62
+ font-size: 100px;
63
+ font-weight: normal;
64
+ line-height: 1em;
65
+ margin: 0 auto;
66
+ width: 80%;
67
+ }
68
+
69
+ .gadwp-bigtext {
70
+ font-size: 14px;
71
+ width: 100%;
72
+ margin: 0 0;
73
+ padding: 5px 5px 5px 5px;
74
+ background: #fff;
75
+ -moz-box-shadow: 0px 0px 3px 0px #BBB;
76
+ -webkit-box-shadow: 0px 0px 3px 0px #BBB;
77
+ box-shadow: 0px 0px 3px 0px #BBB;
78
+ display: table;
79
+ overflow: hidden;
80
+ }
81
+
82
+ .gadwp-bleft {
83
+ float: left;
84
+ width: 80%;
85
+ }
86
+
87
+ .gadwp-bright {
88
+ float: right;
89
+ width: 20%;
90
+ }
91
+
92
+ .gadwp-pgdetailsr {
93
+ padding-left: 20px;
94
+ text-align: right;
95
+ }
96
+
97
+ .gadwp-pgdetailsl {
98
+ min-width: 250px;
99
+ }
100
+
101
+ [id^=gadwp-mainchart] {
102
+ width: 98%;
103
+ height: 100%;
104
+ margin: 10px auto 10px 0;
105
+ height: 250px;
106
+ }
107
+
108
+ .gadwp-floatwraper {
109
+ display: table;
110
+ width: 100%;
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;
132
+ }
133
+
134
+ #dashboard-widgets-wrap .postbox {
135
+ margin-right: 10px;
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;
153
+ }
154
+
155
+ .gadwp-wrapper .inside .small-box {
156
+ width: 30%;
157
+ float: left;
158
+ margin: 0 5px 10px 5px;
159
+ background: #fff;
160
+ text-align: center;
161
+ -moz-box-shadow: 0px 0px 7px 0px #BBB;
162
+ -webkit-box-shadow: 0px 0px 7px 0px #BBB;
163
+ box-shadow: 0px 0px 7px 0px #BBB;
164
+ }
165
+
166
+ .gadwp-wrapper .inside .small-box h3 {
167
+ font-size: 1em;
168
+ color: #777;
169
+ padding: 0px 5px 0px 5px;
170
+ margin: 0px 0px 0px 0px;
171
+ text-overflow: ellipsis;
172
+ overflow: hidden;
173
+ white-space: nowrap;
174
+ }
175
+
176
+ .gadwp-wrapper .inside .small-box p {
177
+ font-size: 1.2em;
178
+ margin: 0px 0px 2px 0px;
179
+ }
180
+
181
+ @media screen and (max-width: 410px) {
182
+ .gadwp-wrapper .inside .small-box {
183
+ width: 45%;
184
+ }
185
+ }
admin/css/gadwp.css CHANGED
@@ -68,27 +68,37 @@ td.gadwp-settings-roles {
68
69
#poststuff.gadwp h2 {
70
padding-bottom: 0;
71
}
72
73
/* Options pages ON/OFF Switch */
74
- .gadwp-settings-switchoo {
75
position: relative;
76
width: 50px;
77
float: left;
78
- border: none !important;
79
- padding: 0 !important;
80
- height: 22px !important;
81
- -moz-box-shadow: none !important;
82
- -webkit-box-shadow: none !important;
83
- -o-box-shadow: none !important;
84
- box-shadow: none !important;
85
-webkit-user-select: none;
86
-moz-user-select: none;
87
-ms-user-select: none;
88
}
89
90
- .gadwp-settings-switchoo-checkbox {
91
- display: none !important;
92
}
93
94
.gadwp-settings-switchoo-label {
@@ -98,6 +108,7 @@ td.gadwp-settings-roles {
98
background: transparent;
99
border: 1px solid #ddd;
100
border-radius: 2px;
101
}
102
103
.gadwp-settings-switchoo-inner {
@@ -121,6 +132,7 @@ td.gadwp-settings-roles {
121
height: 22px;
122
line-height: 22px;
123
font-size: 12px;
124
}
125
126
.gadwp-settings-switchoo-inner:before {
@@ -185,197 +197,4 @@ td.gadwp-settings-roles {
185
float: left;
186
margin-left: 10px;
187
line-height: 20px;
188
- }
189
-
190
- /* Admin Widget & Real-Time Stats*/
191
-
192
- /* Real-Time content */
193
- .gadash-pline {
194
- width: 100%;
195
- margin: 0 0;
196
- padding: 5px 0 5px 0;
197
- background: #fff;
198
- -moz-box-shadow: 0px 0px 3px 0px #BBB;
199
- -webkit-box-shadow: 0px 0px 3px 0px #BBB;
200
- box-shadow: 0px 0px 3px 0px #BBB;
201
- display: table;
202
- overflow: hidden;
203
- }
204
-
205
- .gadash-pleft {
206
- width: 90%;
207
- float: left;
208
- padding-left: 5px;
209
- }
210
-
211
- .gadash-pright {
212
- width: 5%;
213
- float: right;
214
- padding-right: 5px;
215
- }
216
-
217
- #gadash-widget .realtime {
218
- margin: 10px 0 0 0;
219
- width: 100%;
220
- }
221
-
222
- .gadash-rt-box {
223
- width: 100%;
224
- margin: 0 0;
225
- background: #fff;
226
- text-align: center;
227
- -moz-box-shadow: 0px 0px 5px 0px #BBB;
228
- -webkit-box-shadow: 0px 0px 5px 0px #BBB;
229
- box-shadow: 0px 0px 5px 0px #BBB;
230
- display: table;
231
- }
232
-
233
- .gadash-tdo-left {
234
- width: 60%;
235
- padding: 33px 0;
236
- float: left;
237
- text-align: center;
238
- }
239
-
240
- .gadash-tdo-right {
241
- width: 35%;
242
- margin: 0px 10px 0px 0;
243
- text-align: left;
244
- font-weight: bold;
245
- vertical-align: middle;
246
- float: right;
247
- display: table;
248
- }
249
-
250
- .gadash-online {
251
- font-size: 100px;
252
- font-weight: normal;
253
- line-height: 1em;
254
- margin: 0 auto;
255
- width: 80%;
256
- }
257
-
258
- .gadash-bigtext {
259
- font-size: 14px;
260
- width: 100%;
261
- margin: 0 0;
262
- padding: 5px 5px 5px 5px;
263
- background: #fff;
264
- -moz-box-shadow: 0px 0px 3px 0px #BBB;
265
- -webkit-box-shadow: 0px 0px 3px 0px #BBB;
266
- box-shadow: 0px 0px 3px 0px #BBB;
267
- display: table;
268
- overflow: hidden;
269
- }
270
-
271
- .gadash-bleft {
272
- float: left;
273
- width: 80%;
274
- }
275
-
276
- .gadash-bright {
277
- float: right;
278
- width: 20%;
279
- }
280
-
281
- .gadash-pgdetailsr {
282
- padding-left: 20px;
283
- text-align: right;
284
- }
285
-
286
- .gadash-pgdetailsl {
287
- min-width: 250px;
288
- }
289
-
290
- #gadash-mainchart {
291
- width: 98%;
292
- height: 100%;
293
- margin: 10px auto 10px 0;
294
- height: 250px;
295
- }
296
-
297
- .gadash-floatwraper {
298
- display: table;
299
- width: 100%;
300
- height: 100%;
301
- }
302
-
303
- #gadash-trafficmediums, #gadash-traffictype, #gadash-socialnetworks,
304
- #gadash-trafficorganic {
305
- width: 47%;
306
- margin: 10px 0 0 0;
307
- height: 200px;
308
- }
309
-
310
- #gadash-trafficmediums, #gadash-trafficorganic {
311
- float: left;
312
- }
313
-
314
- #gadash-traffictype, #gadash-socialnetworks {
315
- float: right;
316
- }
317
-
318
- #gadash-map, #gadash-prs {
319
- width: 98%;
320
- height: 100%;
321
- margin: 10px auto 10px 0;
322
- }
323
-
324
- #ga_dash_period, #ga_dash_profile_select {
325
- font-size: 14px !important;
326
- padding: 1px !important;
327
- height: 26px !important;
328
- }
329
-
330
- #dashboard-widgets-wrap .postbox {
331
- margin-right: 10px;
332
- }
333
-
334
- /* Admin Widget content */
335
- #gadash-progressbar {
336
- width: 100%;
337
- height: 3px;
338
- margin: 5px 0 0px 0;
339
- }
340
-
341
- .gadash-wrapper {
342
- width: 100%;
343
- }
344
-
345
- .gadash-wrapper .inside {
346
- display: table;
347
- margin: 0 auto;
348
- padding: 0px;
349
- }
350
-
351
- .gadash-wrapper .inside .small-box {
352
- width: 30%;
353
- float: left;
354
- margin: 0 5px 10px 5px;
355
- background: #fff;
356
- text-align: center;
357
- -moz-box-shadow: 0px 0px 7px 0px #BBB;
358
- -webkit-box-shadow: 0px 0px 7px 0px #BBB;
359
- box-shadow: 0px 0px 7px 0px #BBB;
360
- }
361
-
362
- .gadash-wrapper .inside .small-box h3 {
363
- font-size: 1em;
364
- color: #777;
365
- padding: 0px 5px 0px 5px;
366
- margin: 0px 0px 0px 0px;
367
- text-overflow: ellipsis;
368
- overflow: hidden;
369
- white-space: nowrap;
370
- }
371
-
372
- .gadash-wrapper .inside .small-box p {
373
- font-size: 1.2em;
374
- margin: 0px 0px 2px 0px;
375
- }
376
-
377
- @media screen and (max-width: 410px) {
378
- .gadash-wrapper .inside .small-box {
379
- width: 45%;
380
- }
381
}
68
69
#poststuff.gadwp h2 {
70
padding-bottom: 0;
71
+ font-size: 19.5px;
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 */
84
+ .button-primary.gadwp-settings-switchoo {
85
position: relative;
86
width: 50px;
87
float: left;
88
+ border: none;
89
+ padding: 0;
90
+ height: 22px;
91
+ -moz-box-shadow: none;
92
+ -webkit-box-shadow: none;
93
+ -o-box-shadow: none;
94
+ box-shadow: none;
95
-webkit-user-select: none;
96
-moz-user-select: none;
97
-ms-user-select: none;
98
}
99
100
+ input.gadwp-settings-switchoo-checkbox {
101
+ display: none;
102
}
103
104
.gadwp-settings-switchoo-label {
108
background: transparent;
109
border: 1px solid #ddd;
110
border-radius: 2px;
111
+ text-shadow: none;
112
}
113
114
.gadwp-settings-switchoo-inner {
132
height: 22px;
133
line-height: 22px;
134
font-size: 12px;
135
+ text-shadow: none;
136
}
137
138
.gadwp-settings-switchoo-inner:before {
197
float: left;
198
margin-left: 10px;
199
line-height: 20px;
200
}
admin/settings.php CHANGED
@@ -71,7 +71,6 @@ final class GADWP_Settings {
71
}
72
73
private static function navigation_tabs( $tabs ) {
74
- echo '<div id="icon-themes" class="icon32"><br></div>';
75
echo '<h2 class="nav-tab-wrapper">';
76
foreach ( $tabs as $tab => $name ) {
77
echo "<a class='nav-tab' id='tab-$tab' href='#top#gadwp-$tab'>$name</a>";
@@ -531,6 +530,9 @@ final class GADWP_Settings {
531
<div class="switch-desc"><?php echo " ".__("enable AdSense account linking", 'google-analytics-dashboard-for-wp' );?></div>
532
</td>
533
</tr>
534
<tr>
535
<td colspan="2" class="gadwp-settings-title">
536
<div class="button-primary gadwp-settings-switchoo">
@@ -546,6 +548,21 @@ final class GADWP_Settings {
546
<td class="gadwp-settings-title"><label for="ga_crossdomain_list"><?php _e("Cross Domains:", 'google-analytics-dashboard-for-wp'); ?></label></td>
547
<td><input type="text" id="ga_crossdomain_list" name="options[ga_crossdomain_list]" value="<?php echo esc_attr($options['ga_crossdomain_list']); ?>" size="50"></td>
548
</tr>
549
</table>
550
</div>
551
<div id="gadwp-exclude">
@@ -738,7 +755,7 @@ final class GADWP_Settings {
738
if ( ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
739
$profile = GADWP_Tools::guess_default_domain( $profiles );
740
$gadwp->config->options['ga_dash_tableid_jail'] = $profile;
741
- $gadwp->config->options['ga_dash_tableid'] = $profile;
742
}
743
$gadwp->config->set_plugin_options();
744
$options = self::update_options( 'general' );
@@ -1010,7 +1027,7 @@ final class GADWP_Settings {
1010
if ( isset( $gadwp->config->options['ga_dash_tableid_jail'] ) && ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
1011
$profile = GADWP_Tools::guess_default_domain( $profiles );
1012
$gadwp->config->options['ga_dash_tableid_jail'] = $profile;
1013
- $gadwp->config->options['ga_dash_tableid'] = $profile;
1014
}
1015
$gadwp->config->set_plugin_options( true );
1016
$options = self::update_options( 'network' );
@@ -1047,7 +1064,7 @@ final class GADWP_Settings {
1047
if ( isset( $gadwp->config->options['ga_dash_tableid_jail'] ) && ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
1048
$profile = GADWP_Tools::guess_default_domain( $profiles );
1049
$gadwp->config->options['ga_dash_tableid_jail'] = $profile;
1050
- $gadwp->config->options['ga_dash_tableid'] = $profile;
1051
}
1052
$gadwp->config->set_plugin_options( true );
1053
$options = self::update_options( 'network' );
71
}
72
73
private static function navigation_tabs( $tabs ) {
74
echo '<h2 class="nav-tab-wrapper">';
75
foreach ( $tabs as $tab => $name ) {
76
echo "<a class='nav-tab' id='tab-$tab' href='#top#gadwp-$tab'>$name</a>";
530
<div class="switch-desc"><?php echo " ".__("enable AdSense account linking", 'google-analytics-dashboard-for-wp' );?></div>
531
</td>
532
</tr>
533
+ <tr>
534
+ <td colspan="2"><?php echo "<h2>" . __( "Cross-domain Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
535
+ </tr>
536
<tr>
537
<td colspan="2" class="gadwp-settings-title">
538
<div class="button-primary gadwp-settings-switchoo">
548
<td class="gadwp-settings-title"><label for="ga_crossdomain_list"><?php _e("Cross Domains:", 'google-analytics-dashboard-for-wp'); ?></label></td>
549
<td><input type="text" id="ga_crossdomain_list" name="options[ga_crossdomain_list]" value="<?php echo esc_attr($options['ga_crossdomain_list']); ?>" size="50"></td>
550
</tr>
551
+ <tr>
552
+ <td colspan="2"><?php echo "<h2>" . __( "Cookie Customization", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
553
+ </tr>
554
+ <tr>
555
+ <td class="gadwp-settings-title"><label for="ga_cookiedomain"><?php _e("Cookie Domain:", 'google-analytics-dashboard-for-wp'); ?></label></td>
556
+ <td><input type="text" id="ga_cookiedomain" name="options[ga_cookiedomain]" value="<?php echo esc_attr($options['ga_cookiedomain']); ?>" size="50"></td>
557
+ </tr>
558
+ <tr>
559
+ <td class="gadwp-settings-title"><label for="ga_cookiename"><?php _e("Cookie Name:", 'google-analytics-dashboard-for-wp'); ?></label></td>
560
+ <td><input type="text" id="ga_cookiename" name="options[ga_cookiename]" value="<?php echo esc_attr($options['ga_cookiename']); ?>" size="50"></td>
561
+ </tr>
562
+ <tr>
563
+ <td class="gadwp-settings-title"><label for="ga_cookieexpires"><?php _e("Cookie Expires:", 'google-analytics-dashboard-for-wp'); ?></label></td>
564
+ <td><input type="text" id="ga_cookieexpires" name="options[ga_cookieexpires]" value="<?php echo esc_attr($options['ga_cookieexpires']); ?>" size="10"> seconds</td>
565
+ </tr>
566
</table>
567
</div>
568
<div id="gadwp-exclude">
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' );
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
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' );
admin/setup.php CHANGED
@@ -90,10 +90,10 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
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' ),
98
'security' => wp_create_nonce( 'gadwp_dismiss_notices' ),
99
'ed_bubble' => $ed_bubble,
@@ -101,24 +101,115 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
101
);
102
/* @formatter:on */
103
104
/*
105
- * Dashboard Widgets Styles & Scripts
106
*/
107
$widgets_hooks = array( 'index.php' );
108
109
if ( in_array( $new_hook, $widgets_hooks ) ) {
110
if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && $this->gadwp->config->options['dashboard_widget'] ) {
111
112
- wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'tools/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
113
114
- wp_enqueue_script( 'gadwp-admin-widgets', plugins_url( 'js/widgets.js', __FILE__ ), array( 'jquery' ), GADWP_CURRENT_VERSION );
115
116
if ( ! wp_script_is( 'googlejsapi' ) ) {
117
wp_register_script( 'googlejsapi', 'https://www.google.com/jsapi' );
118
- wp_enqueue_script( 'googlejsapi' );
119
}
120
121
- wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'tools/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
122
}
123
}
124
@@ -129,30 +220,33 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
129
if ( in_array( $hook, $contentstats_hooks ) ) {
130
if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && $this->gadwp->config->options['backend_item_reports'] ) {
131
132
- wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'tools/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
133
-
134
- wp_enqueue_style( 'gadwp_backend_item_reports', GADWP_URL . 'admin/css/item-reports.css', null, GADWP_CURRENT_VERSION );
135
-
136
- $country_codes = GADWP_Tools::get_countrycodes();
137
-
138
- if ( $this->gadwp->config->options['ga_target_geomap'] && isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
139
- $region = $this->gadwp->config->options['ga_target_geomap'];
140
} else {
141
$region = false;
142
}
143
144
wp_enqueue_style( "wp-jquery-ui-dialog" );
145
146
if ( ! wp_script_is( 'googlejsapi' ) ) {
147
wp_register_script( 'googlejsapi', 'https://www.google.com/jsapi' );
148
}
149
150
- wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'tools/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
151
152
- wp_enqueue_script( 'gadwp_backend_item_reports', GADWP_URL . 'tools/js/item-reports.js', array( 'gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION );
153
154
/* @formatter:off */
155
- wp_localize_script( 'gadwp_backend_item_reports', 'gadwp_item_data', array(
156
'ajaxurl' => admin_url( 'admin-ajax.php' ),
157
'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
158
'dateList' => array(
@@ -197,6 +291,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
197
'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
198
'region' => $region,
199
'language' => get_bloginfo( 'language' ),
200
'scope' => 'admin-item',
201
)
202
);
@@ -234,13 +329,19 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
234
* Add an admin notice after a manual or atuomatic update
235
*/
236
function admin_notice() {
237
if ( get_option( 'gadwp_got_updated' ) ) :
238
?>
239
- <div id="gadwp-notice" class="notice is-dismissible">
240
- <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>
241
- </div>
242
-
243
- <?php
244
endif;
245
}
246
}
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' ),
98
'security' => wp_create_nonce( 'gadwp_dismiss_notices' ),
99
'ed_bubble' => $ed_bubble,
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;
129
+ }
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(
157
+ 'realtime' => __( "Real-Time", 'google-analytics-dashboard-for-wp' ),
158
+ 'today' => __( "Today", 'google-analytics-dashboard-for-wp' ),
159
+ 'yesterday' => __( "Yesterday", 'google-analytics-dashboard-for-wp' ),
160
+ '7daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 7 ),
161
+ '14daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 14 ),
162
+ '30daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 30 ),
163
+ '90daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 90 ),
164
+ '365daysAgo' => sprintf( _n( "%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp' ), __('One', 'google-analytics-dashboard-for-wp') ),
165
+ '1095daysAgo' => sprintf( _n( "%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp' ), __('Three', 'google-analytics-dashboard-for-wp') ),
166
+ ),
167
+ 'reportList' => array(
168
+ 'sessions' => __( "Sessions", 'google-analytics-dashboard-for-wp' ),
169
+ 'users' => __( "Users", 'google-analytics-dashboard-for-wp' ),
170
+ 'organicSearches' => __( "Organic", 'google-analytics-dashboard-for-wp' ),
171
+ 'pageviews' => __( "Page Views", 'google-analytics-dashboard-for-wp' ),
172
+ 'visitBounceRate' => __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
173
+ 'locations' => __( "Location", 'google-analytics-dashboard-for-wp' ),
174
+ 'referrers' => __( "Referrers", 'google-analytics-dashboard-for-wp' ),
175
+ 'searches' => __( "Searches", 'google-analytics-dashboard-for-wp' ),
176
+ 'trafficdetails' => __( "Traffic Details", 'google-analytics-dashboard-for-wp' )
177
+ ),
178
+ 'i18n' => array(
179
+ __( "A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp' ), //0
180
+ __( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ),
181
+ __( "Visitor Type", 'google-analytics-dashboard-for-wp' ),
182
+ __( "Social Networks", 'google-analytics-dashboard-for-wp' ),
183
+ __( "Search Engines", 'google-analytics-dashboard-for-wp' ),
184
+ __( "Sessions", 'google-analytics-dashboard-for-wp' ),
185
+ __( "Users", 'google-analytics-dashboard-for-wp' ),
186
+ __( "Page Views", 'google-analytics-dashboard-for-wp' ),
187
+ __( "Bounce Rate", 'google-analytics-dashboard-for-wp' ),
188
+ __( "Organic Search", 'google-analytics-dashboard-for-wp' ),
189
+ __( "Pages/Session", 'google-analytics-dashboard-for-wp' ),
190
+ __( "Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp' ),
191
+ __( "Not enough data collected", 'google-analytics-dashboard-for-wp' ),
192
+ __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
193
+ __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
194
+ __( "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>.',
195
+ ),
196
+ 'i18n_realtime' => array(
197
+ __( "REFERRALS", 'google-analytics-dashboard-for-wp' ), //0
198
+ __( "KEYWORDS", 'google-analytics-dashboard-for-wp' ),
199
+ __( "SOCIAL", 'google-analytics-dashboard-for-wp' ),
200
+ __( "CAMPAIGN", 'google-analytics-dashboard-for-wp' ),
201
+ __( "DIRECT", 'google-analytics-dashboard-for-wp' ),
202
+ __( "NEW", 'google-analytics-dashboard-for-wp' ), //5
203
+ ),
204
+ 'realtime_maxpages' => $this->gadwp->config->options['ga_realtime_pages'],
205
+ 'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
206
+ 'region' => $region,
207
+ 'language' => get_bloginfo( 'language' ),
208
+ 'viewList' => $views,
209
+ 'scope' => 'admin-widgets',
210
+ )
211
+ );
212
+ /* @formatter:on */
213
}
214
}
215
220
if ( in_array( $hook, $contentstats_hooks ) ) {
221
if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && $this->gadwp->config->options['backend_item_reports'] ) {
222
223
+ if ( $this->gadwp->config->options['ga_target_geomap'] ) {
224
+ $country_codes = GADWP_Tools::get_countrycodes();
225
+ if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ){
226
+ $region = $this->gadwp->config->options['ga_target_geomap'];
227
+ } else {
228
+ $region = false;
229
+ }
230
} else {
231
$region = false;
232
}
233
234
+ wp_enqueue_style( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.css', null, GADWP_CURRENT_VERSION );
235
+
236
+ wp_enqueue_style( 'gadwp-backend-item-reports', GADWP_URL . 'admin/css/item-reports.css', null, GADWP_CURRENT_VERSION );
237
+
238
wp_enqueue_style( "wp-jquery-ui-dialog" );
239
240
if ( ! wp_script_is( 'googlejsapi' ) ) {
241
wp_register_script( 'googlejsapi', 'https://www.google.com/jsapi' );
242
}
243
244
+ wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
245
246
+ wp_enqueue_script( 'gadwp-backend-item-reports', GADWP_URL . 'common/js/reports.js', array( 'gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION );
247
248
/* @formatter:off */
249
+ wp_localize_script( 'gadwp-backend-item-reports', 'gadwp_item_data', array(
250
'ajaxurl' => admin_url( 'admin-ajax.php' ),
251
'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
252
'dateList' => array(
291
'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
292
'region' => $region,
293
'language' => get_bloginfo( 'language' ),
294
+ 'viewList' => false,
295
'scope' => 'admin-item',
296
)
297
);
329
* Add an admin notice after a manual or atuomatic update
330
*/
331
function admin_notice() {
332
+
333
+ $currentScreen = get_current_screen();
334
+
335
+ if ( ! current_user_can( 'manage_options' ) || $currentScreen->base != 'dashboard') {
336
+ return;
337
+ }
338
+
339
if ( get_option( 'gadwp_got_updated' ) ) :
340
?>
341
+ <div id="gadwp-notice" class="notice is-dismissible">
342
+ <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>
343
+ </div>
344
+ <?php
345
endif;
346
}
347
}
admin/widgets.php CHANGED
@@ -24,65 +24,24 @@ if ( ! class_exists( 'GADWP_Backend_Widgets' ) ) {
24
}
25
26
public function add_widget() {
27
- wp_add_dashboard_widget( 'gadash-widget', __( "Google Analytics Dashboard", 'google-analytics-dashboard-for-wp' ), array( $this, 'dashboard_widget' ), $control_callback = null );
28
}
29
30
public function dashboard_widget() {
31
if ( empty( $this->gadwp->config->options['ga_dash_token'] ) ) {
32
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>';
33
return;
34
}
35
36
if ( current_user_can( 'manage_options' ) ) {
37
- if ( isset( $_REQUEST['gadwp_selected_profile'] ) ) {
38
- $this->gadwp->config->options['ga_dash_tableid'] = $_REQUEST['gadwp_selected_profile'];
39
- }
40
- $profiles = $this->gadwp->config->options['ga_dash_profile_list'];
41
- $profile_switch = '';
42
- if ( ! empty( $profiles ) ) {
43
- if ( ! $this->gadwp->config->options['ga_dash_tableid'] ) {
44
- if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
45
- $this->gadwp->config->options['ga_dash_tableid'] = $this->gadwp->config->options['ga_dash_tableid_jail'];
46
- } else {
47
- $this->gadwp->config->options['ga_dash_tableid'] = GADWP_Tools::guess_default_domain( $profiles );
48
- }
49
- } else
50
- if ( $this->gadwp->config->options['switch_profile'] == 0 && $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
51
- $this->gadwp->config->options['ga_dash_tableid'] = $this->gadwp->config->options['ga_dash_tableid_jail'];
52
- }
53
- $profile_switch .= '<select id="gadwp_selected_profile" name="gadwp_selected_profile" onchange="this.form.submit()">';
54
- foreach ( $profiles as $profile ) {
55
- if ( ! $this->gadwp->config->options['ga_dash_tableid'] ) {
56
- $this->gadwp->config->options['ga_dash_tableid'] = $profile[1];
57
- }
58
- if ( isset( $profile[3] ) ) {
59
- $profile_switch .= '<option value="' . esc_attr( $profile[1] ) . '" ';
60
- $profile_switch .= selected( $profile[1], $this->gadwp->config->options['ga_dash_tableid'], false );
61
- $profile_switch .= ' title="' . __( "View Name:", 'google-analytics-dashboard-for-wp' ) . ' ' . esc_attr( $profile[0] ) . '">' . esc_attr( GADWP_Tools::strip_protocol( $profile[3] ) ) . '</option>';
62
- }
63
- }
64
- $profile_switch .= "</select>";
65
} else {
66
- echo '<p>' . __( "Something went wrong while retrieving profiles list.", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadash_settings', false ) . '" method="POST">' . get_submit_button( __( "More details", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
67
return;
68
}
69
- }
70
- $this->gadwp->config->set_plugin_options();
71
- ?>
72
- <form id="ga-dash" method="POST">
73
- <?php
74
- if ( current_user_can( 'manage_options' ) ) {
75
- if ( $this->gadwp->config->options['switch_profile'] == 0 ) {
76
- if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
77
- $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
78
- } else {
79
- echo '<p>' . __( "An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadash_settings', false ) . '" method="POST">' . get_submit_button( __( "Select Domain", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
80
- return;
81
- }
82
- } else {
83
- echo $profile_switch;
84
- $projectId = $this->gadwp->config->options['ga_dash_tableid'];
85
- }
86
} else {
87
if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
88
$projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
@@ -91,839 +50,15 @@ if ( ! class_exists( 'GADWP_Backend_Widgets' ) ) {
91
return;
92
}
93
}
94
if ( ! ( $projectId ) ) {
95
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>';
96
return;
97
}
98
- if ( isset( $_REQUEST['gadwpquery'] ) ) {
99
- $query = $_REQUEST['gadwpquery'];
100
- } else {
101
- $default_metric = GADWP_Tools::get_cookie( 'default_metric' );
102
- $query = $default_metric ? $default_metric : 'sessions';
103
- }
104
- if ( isset( $_REQUEST['gadwpperiod'] ) ) {
105
- $period = $_REQUEST['gadwpperiod'];
106
- } else {
107
- $default_dimension = GADWP_Tools::get_cookie( 'default_dimension' );
108
- $period = $default_dimension ? $default_dimension : '30daysAgo';
109
- }
110
111
?>
112
- <select id="ga_dash_period" name="gadwpperiod" onchange="this.form.submit()">
113
- <option value="realtime" <?php selected ( "realtime", $period, true ); ?>><?php _e("Real-Time",'google-analytics-dashboard-for-wp'); ?></option>
114
- <option value="today" <?php selected ( "today", $period, true ); ?>><?php _e("Today",'google-analytics-dashboard-for-wp'); ?></option>
115
- <option value="yesterday" <?php selected ( "yesterday", $period, true ); ?>><?php _e("Yesterday",'google-analytics-dashboard-for-wp'); ?></option>
116
- <option value="7daysAgo" <?php selected ( "7daysAgo", $period, true ); ?>><?php printf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 7 ); ?></option>
117
- <option value="14daysAgo" <?php selected ( "14daysAgo", $period, true ); ?>><?php printf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 14 ); ?></option>
118
- <option value="30daysAgo" <?php selected ( "30daysAgo", $period, true ); ?>><?php printf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 30 ); ?></option>
119
- <option value="90daysAgo" <?php selected ( "90daysAgo", $period, true ); ?>><?php printf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 90 ); ?></option>
120
- <option value="365daysAgo" <?php selected ( "365daysAgo", $period, true ); ?>><?php printf( _n( "%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp' ), __('One', 'google-analytics-dashboard-for-wp') ); ?></option>
121
- <option value="1095daysAgo" <?php selected ( "1095daysAgo", $period, true ); ?>><?php printf( _n( "%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp' ), __('Three', 'google-analytics-dashboard-for-wp') ); ?></option>
122
- </select>
123
-
124
- <?php if ($period != 'realtime') {?>
125
- <select id="ga_dash_query" name="gadwpquery" onchange="this.form.submit()">
126
- <option value="sessions" <?php selected ( "sessions", $query, true ); ?>><?php _e("Sessions",'google-analytics-dashboard-for-wp'); ?></option>
127
- <option value="users" <?php selected ( "users", $query, true ); ?>><?php _e("Users",'google-analytics-dashboard-for-wp'); ?></option>
128
- <option value="organicSearches" <?php selected ( "organicSearches", $query, true ); ?>><?php _e("Organic",'google-analytics-dashboard-for-wp'); ?></option>
129
- <option value="pageviews" <?php selected ( "pageviews", $query, true ); ?>><?php _e("Page Views",'google-analytics-dashboard-for-wp'); ?></option>
130
- <option value="visitBounceRate" <?php selected ( "visitBounceRate", $query, true ); ?>><?php _e("Bounce Rate",'google-analytics-dashboard-for-wp'); ?></option>
131
- <option value="locations" <?php selected ( "locations", $query, true ); ?>><?php _e("Location",'google-analytics-dashboard-for-wp'); ?></option>
132
- <option value="contentpages" <?php selected ( "contentpages", $query, true ); ?>><?php _e("Pages",'google-analytics-dashboard-for-wp'); ?></option>
133
- <option value="referrers" <?php selected ( "referrers", $query, true ); ?>><?php _e("Referrers",'google-analytics-dashboard-for-wp'); ?></option>
134
- <option value="searches" <?php selected ( "searches", $query, true ); ?>><?php _e("Searches",'google-analytics-dashboard-for-wp'); ?></option>
135
- <option value="trafficdetails" <?php selected ( "trafficdetails", $query, true ); ?>><?php _e("Traffic Details",'google-analytics-dashboard-for-wp'); ?></option>
136
- </select>
137
- <?php }?>
138
- </form>
139
- <div id="gadash-progressbar"></div>
140
- <?php
141
- switch ( $period ) {
142
- case 'today' :
143
- $from = 'today';
144
- $to = 'today';
145
- $haxis = 4;
146
- break;
147
- case 'yesterday' :
148
- $from = 'yesterday';
149
- $to = 'yesterday';
150
- $haxis = 4;
151
- break;
152
- case '7daysAgo' :
153
- $from = '7daysAgo';
154
- $to = 'yesterday';
155
- $haxis = 2;
156
- break;
157
- case '14daysAgo' :
158
- $from = '14daysAgo';
159
- $to = 'yesterday';
160
- $haxis = 3;
161
- break;
162
- case '90daysAgo' :
163
- $from = '90daysAgo';
164
- $to = 'yesterday';
165
- $haxis = 16;
166
- break;
167
- case '365daysAgo' :
168
- $from = '365daysAgo';
169
- $to = 'yesterday';
170
- $haxis = 5;
171
- break;
172
- case '1095daysAgo' :
173
- $from = '1095daysAgo';
174
- $to = 'yesterday';
175
- $haxis = 5;
176
- break;
177
- default :
178
- $from = '30daysAgo';
179
- $to = 'yesterday';
180
- $haxis = 5;
181
- break;
182
- }
183
- if ( $query == 'visitBounceRate' ) {
184
- $formater = "var formatter = new google.visualization.NumberFormat({
185
- suffix: '%',
186
- fractionDigits: 2
187
- });
188
-
189
- formatter.format(data, 1); ";
190
- } else {
191
- $formater = '';
192
- }
193
-
194
- if ( isset( $this->gadwp->config->options['ga_dash_style'] ) ) {
195
- $light_color = GADWP_Tools::colourVariator( $this->gadwp->config->options['ga_dash_style'], 40 );
196
- $dark_color = GADWP_Tools::colourVariator( $this->gadwp->config->options['ga_dash_style'], - 20 );
197
- $css = "colors:['" . $this->gadwp->config->options['ga_dash_style'] . "','" . GADWP_Tools::colourVariator( $this->gadwp->config->options['ga_dash_style'], - 20 ) . "'],";
198
- $color = $this->gadwp->config->options['ga_dash_style'];
199
- } else {
200
- $css = "";
201
- $color = "#3366CC";
202
- }
203
- if ( $period == 'realtime' ) {
204
- wp_register_style( 'jquery-ui-tooltip-html', GADWP_URL . 'realtime/jquery/jquery.ui.tooltip.html.css' );
205
- wp_enqueue_style( 'jquery-ui-tooltip-html' );
206
- if ( ! wp_script_is( 'jquery' ) ) {
207
- wp_enqueue_script( 'jquery' );
208
- }
209
- if ( ! wp_script_is( 'jquery-ui-tooltip' ) ) {
210
- wp_enqueue_script( "jquery-ui-tooltip" );
211
- }
212
- if ( ! wp_script_is( 'jquery-ui-core' ) ) {
213
- wp_enqueue_script( "jquery-ui-core" );
214
- }
215
- if ( ! wp_script_is( 'jquery-ui-position' ) ) {
216
- wp_enqueue_script( "jquery-ui-position" );
217
- }
218
- if ( ! wp_script_is( 'jquery-ui-position' ) ) {
219
- wp_enqueue_script( "jquery-ui-position" );
220
- }
221
- wp_register_script( "jquery-ui-tooltip-html", GADWP_URL . 'realtime/jquery/jquery.ui.tooltip.html.js' );
222
- wp_enqueue_script( "jquery-ui-tooltip-html" );
223
- }
224
- if ( $period == 'realtime' ) {
225
- ?>
226
- <div class="realtime">
227
- <div class="gadash-rt-box">
228
- <div class='gadash-tdo-left'>
229
- <div class='gadash-online' id='gadash-online'>0</div>
230
- </div>
231
- <div class='gadash-tdo-right' id='gadash-tdo-right'>
232
- <div class="gadash-bigtext">
233
- <div class="gadash-bleft"><?php _e( "REFERRAL", 'google-analytics-dashboard-for-wp' );?></div>
234
- <div class="gadash-bright">0</div>
235
- </div>
236
- <div class="gadash-bigtext">
237
- <div class="gadash-bleft"><?php _e( "ORGANIC", 'google-analytics-dashboard-for-wp' );?></div>
238
- <div class="gadash-bright">0</div>
239
- </div>
240
- <div class="gadash-bigtext">
241
- <div class="gadash-bleft"><?php _e( "SOCIAL", 'google-analytics-dashboard-for-wp' );?></div>
242
- <div class="gadash-bright">0</div>
243
- </div>
244
- <div class="gadash-bigtext">
245
- <div class="gadash-bleft"><?php _e( "CAMPAIGN", 'google-analytics-dashboard-for-wp' );?></div>
246
- <div class="gadash-bright">0</div>
247
- </div>
248
- <div class="gadash-bigtext">
249
- <div class="gadash-bleft"><?php _e( "DIRECT", 'google-analytics-dashboard-for-wp' );?></div>
250
- <div class="gadash-bright">0</div>
251
- </div>
252
- <div class="gadash-bigtext">
253
- <div class="gadash-bleft"><?php _e( "NEW", 'google-analytics-dashboard-for-wp' );?></div>
254
- <div class="gadash-bright">0</div>
255
- </div>
256
- </div>
257
- </div>
258
- <div>
259
- <div id='gadash-pages' class='gadash-pages'>&nbsp;</div>
260
- </div>
261
- </div>
262
- <script type="text/javascript">
263
-
264
- var focusFlag = 1;
265
-
266
- jQuery(document).ready(function(){
267
- jQuery(window).bind("focus",function(event){
268
- focusFlag = 1;
269
- }).bind("blur", function(event){
270
- focusFlag = 0;
271
- });
272
- });
273
-
274
- jQuery(function() {
275
- jQuery('#gadash-widget *').tooltip();
276
- });
277
-
278
- function onlyUniqueValues(value, index, self) {
279
- return self.indexOf(value) === index;
280
- }
281
-
282
- function countsessions(data, searchvalue) {
283
- var count = 0;
284
- for ( var i = 0; i < data["rows"].length; i = i + 1 ) {
285
- if (jQuery.inArray(searchvalue, data["rows"][ i ])>-1){
286
- count += parseInt(data["rows"][ i ][6]);
287
- }
288
- }
289
- return count;
290
- }
291
-
292
- function gadash_generatetooltip(data) {
293
- var count = 0;
294
- var table = "";
295
- for ( var i = 0; i < data.length; i = i + 1 ) {
296
- count += parseInt(data[ i ].count);
297
- table += "<tr><td class='gadash-pgdetailsl'>"+data[i].value+"</td><td class='gadash-pgdetailsr'>"+data[ i ].count+"</td></tr>";
298
- };
299
- if (count){
300
- return("<table>"+table+"</table>");
301
- }else{
302
- return("");
303
- }
304
- }
305
-
306
- function gadash_pagedetails(data, searchvalue) {
307
- var newdata = [];
308
- for ( var i = 0; i < data["rows"].length; i = i + 1 ){
309
- var sant=1;
310
- for ( var j = 0; j < newdata.length; j = j + 1 ){
311
- if (data["rows"][i][0]+data["rows"][i][1]+data["rows"][i][2]+data["rows"][i][3]==newdata[j][0]+newdata[j][1]+newdata[j][2]+newdata[j][3]){
312
- newdata[j][6] = parseInt(newdata[j][6]) + parseInt(data["rows"][i][6]);
313
- sant = 0;
314
- }
315
- }
316
- if (sant){
317
- newdata.push(data["rows"][i].slice());
318
- }
319
- }
320
-
321
- var countrfr = 0;
322
- var countkwd = 0;
323
- var countdrt = 0;
324
- var countscl = 0;
325
- var countcpg = 0;
326
- var tablerfr = "";
327
- var tablekwd = "";
328
- var tablescl = "";
329
- var tablecpg = "";
330
- var tabledrt = "";
331
- for ( var i = 0; i < newdata.length; i = i + 1 ) {
332
- if (newdata[i][0] == searchvalue){
333
- var pagetitle = newdata[i][5];
334
-
335
- switch (newdata[i][3]){
336
-
337
- case "REFERRAL": countrfr += parseInt(newdata[ i ][6]);
338
- tablerfr += "<tr><td class='gadash-pgdetailsl'>"+newdata[i][1]+"</td><td class='gadash-pgdetailsr'>"+newdata[ i ][6]+"</td></tr>";
339
- break;
340
- case "ORGANIC": countkwd += parseInt(newdata[ i ][6]);
341
- tablekwd += "<tr><td class='gadash-pgdetailsl'>"+newdata[i][2]+"</td><td class='gadash-pgdetailsr'>"+newdata[ i ][6]+"</td></tr>";
342
- break;
343
- case "SOCIAL": countscl += parseInt(newdata[ i ][6]);
344
- tablescl += "<tr><td class='gadash-pgdetailsl'>"+newdata[i][1]+"</td><td class='gadash-pgdetailsr'>"+newdata[ i ][6]+"</td></tr>";
345
- break;
346
- case "CUSTOM": countcpg += parseInt(newdata[ i ][6]);
347
- tablecpg += "<tr><td class='gadash-pgdetailsl'>"+newdata[i][1]+"</td><td class='gadash-pgdetailsr'>"+newdata[ i ][6]+"</td></tr>";
348
- break;
349
- case "DIRECT": countdrt += parseInt(newdata[ i ][6]);
350
- break;
351
- };
352
- };
353
- };
354
- if (countrfr){
355
- tablerfr = "<table><tr><td><?php _e("REFERRALS", 'google-analytics-dashboard-for-wp');?> ("+countrfr+")</td></tr>"+tablerfr+"</table><br />";
356
- }
357
- if (countkwd){
358
- tablekwd = "<table><tr><td><?php _e("KEYWORDS", 'google-analytics-dashboard-for-wp');?> ("+countkwd+")</td></tr>"+tablekwd+"</table><br />";
359
- }
360
- if (countscl){
361
- tablescl = "<table><tr><td><?php _e("SOCIAL", 'google-analytics-dashboard-for-wp');?> ("+countscl+")</td></tr>"+tablescl+"</table><br />";
362
- }
363
- if (countcpg){
364
- tablecpg = "<table><tr><td><?php _e("CAMPAIGN", 'google-analytics-dashboard-for-wp');?> ("+countcpg+")</td></tr>"+tablecpg+"</table><br />";
365
- }
366
- if (countdrt){
367
- tabledrt = "<table><tr><td><?php _e("DIRECT", 'google-analytics-dashboard-for-wp');?> ("+countdrt+")</td></tr></table><br />";
368
- }
369
- return ("<p><center><strong>"+pagetitle+"</strong></center></p>"+tablerfr+tablekwd+tablescl+tablecpg+tabledrt);
370
- }
371
-
372
- function online_refresh(){
373
- if (focusFlag){
374
-
375
- jQuery.post(ajaxurl, {action: "gadash_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: false,to: false,query: "realtime",gadash_security_widget_reports: "<?php echo wp_create_nonce('gadash_get_widgetreports'); ?>"}, function(results){
376
-
377
- data = results[0];
378
-
379
- if (jQuery.isNumeric(data) || typeof data === "undefined"){
380
- data = [];
381
- data["totalsForAllResults"] = []
382
- data["totalsForAllResults"]["rt:activeUsers"] = "0";
383
- data["rows"]= [];
384
- }
385
-
386
- if (data["totalsForAllResults"]["rt:activeUsers"]!==document.getElementById("gadash-online").innerHTML){
387
- jQuery("#gadash-online").fadeOut("slow");
388
- jQuery("#gadash-online").fadeOut(500);
389
- jQuery("#gadash-online").fadeOut("slow", function() {
390
- if ((parseInt(data["totalsForAllResults"]["rt:activeUsers"]))<(parseInt(document.getElementById("gadash-online").innerHTML))){
391
- jQuery("#gadash-online").css({'background-color' : '#FFE8E8'});
392
- }else{
393
- jQuery("#gadash-online").css({'background-color' : '#E0FFEC'});
394
- }
395
- document.getElementById("gadash-online").innerHTML = data["totalsForAllResults"]["rt:activeUsers"];
396
- });
397
- jQuery("#gadash-online").fadeIn("slow");
398
- jQuery("#gadash-online").fadeIn(500);
399
- jQuery("#gadash-online").fadeIn("slow", function() {
400
- jQuery("#gadash-online").css({'background-color' : '#FFFFFF'});
401
- });
402
- };
403
-
404
- if (data["totalsForAllResults"]["rt:activeUsers"] == 0){
405
- data["rows"]= [];
406
- };
407
-
408
- var pagepath = [];
409
- var referrals = [];
410
- var keywords = [];
411
- var social = [];
412
- var visittype = [];
413
- var custom = [];
414
- for ( var i = 0; i < data["rows"].length; i = i + 1 ) {
415
- pagepath.push( data["rows"][ i ][0] );
416
- if (data["rows"][i][3]=="REFERRAL"){
417
- referrals.push( data["rows"][ i ][1] );
418
- }
419
- if (data["rows"][i][3]=="ORGANIC"){
420
- keywords.push( data["rows"][ i ][2] );
421
- }
422
- if (data["rows"][i][3]=="SOCIAL"){
423
- social.push( data["rows"][ i ][1] );
424
- }
425
- if (data["rows"][i][3]=="CUSTOM"){
426
- custom.push( data["rows"][ i ][1] );
427
- }
428
- visittype.push( data["rows"][ i ][3] );
429
- }
430
-
431
- var upagepathstats = [];
432
- var upagepath = pagepath.filter(onlyUniqueValues);
433
- for ( var i = 0; i < upagepath.length; i = i + 1 ) {
434
- upagepathstats[i]={"pagepath":upagepath[i],"count":countsessions(data,upagepath[i])};
435
- }
436
- upagepathstats.sort( function(a,b){ return b.count - a.count } );
437
-
438
- var pgstatstable = "";
439
- for ( var i = 0; i < upagepathstats.length; i = i + 1 ) {
440
- if (i < <?php echo $this->gadwp->config->options['ga_realtime_pages']; ?>){
441
- pgstatstable += '<div class="gadash-pline"><div class="gadash-pleft"><a href="#" data-tooltip="'+gadash_pagedetails(data, upagepathstats[i].pagepath)+'">'+upagepathstats[i].pagepath.substring(0,70)+'</a></div><div class="gadash-pright">'+upagepathstats[i].count+'</div></div>';
442
- }
443
- }
444
- document.getElementById("gadash-pages").innerHTML='<br /><div class="gadash-pg">'+pgstatstable+'</div>';
445
-
446
- var ureferralsstats = [];
447
- var ureferrals = referrals.filter(onlyUniqueValues);
448
- for ( var i = 0; i < ureferrals.length; i = i + 1 ) {
449
- ureferralsstats[i]={"value":ureferrals[i],"count":countsessions(data,ureferrals[i])};
450
- }
451
- ureferralsstats.sort( function(a,b){ return b.count - a.count } );
452
-
453
- var ukeywordsstats = [];
454
- var ukeywords = keywords.filter(onlyUniqueValues);
455
- for ( var i = 0; i < ukeywords.length; i = i + 1 ) {
456
- ukeywordsstats[i]={"value":ukeywords[i],"count":countsessions(data,ukeywords[i])};
457
- }
458
- ukeywordsstats.sort( function(a,b){ return b.count - a.count } );
459
-
460
- var usocialstats = [];
461
- var usocial = social.filter(onlyUniqueValues);
462
- for ( var i = 0; i < usocial.length; i = i + 1 ) {
463
- usocialstats[i]={"value":usocial[i],"count":countsessions(data,usocial[i])};
464
- }
465
- usocialstats.sort( function(a,b){ return b.count - a.count } );
466
-
467
- var ucustomstats = [];
468
- var ucustom = custom.filter(onlyUniqueValues);
469
- for ( var i = 0; i < ucustom.length; i = i + 1 ) {
470
- ucustomstats[i]={"value":ucustom[i],"count":countsessions(data,ucustom[i])};
471
- }
472
- ucustomstats.sort( function(a,b){ return b.count - a.count } );
473
-
474
- var uvisittype = ["REFERRAL","ORGANIC","SOCIAL","CUSTOM"];
475
- document.getElementById("gadash-tdo-right").innerHTML = '<div class="gadash-bigtext"><a href="#" data-tooltip="'+gadash_generatetooltip(ureferralsstats)+'"><div class="gadash-bleft">'+'<?php _e("REFERRAL", 'google-analytics-dashboard-for-wp');?>'+'</a></div><div class="gadash-bright">'+countsessions(data,uvisittype[0])+'</div></div>';
476
- document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><a href="#" data-tooltip="'+gadash_generatetooltip(ukeywordsstats)+'"><div class="gadash-bleft">'+'<?php _e("ORGANIC", 'google-analytics-dashboard-for-wp');?>'+'</a></div><div class="gadash-bright">'+countsessions(data,uvisittype[1])+'</div></div>';
477
- document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><a href="#" data-tooltip="'+gadash_generatetooltip(usocialstats)+'"><div class="gadash-bleft">'+'<?php _e("SOCIAL", 'google-analytics-dashboard-for-wp');?>'+'</a></div><div class="gadash-bright">'+countsessions(data,uvisittype[2])+'</div></div>';
478
- document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><a href="#" data-tooltip="'+gadash_generatetooltip(ucustomstats)+'"><div class="gadash-bleft">'+'<?php _e("CAMPAIGN", 'google-analytics-dashboard-for-wp');?>'+'</a></div><div class="gadash-bright">'+countsessions(data,uvisittype[3])+'</div></div>';
479
-
480
- var uvisitortype = ["DIRECT","NEW"];
481
- document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><div class="gadash-bleft">'+'<?php _e("DIRECT", 'google-analytics-dashboard-for-wp');?>'+'</div><div class="gadash-bright">'+countsessions(data,uvisitortype[0])+'</div></div>';
482
- document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><div class="gadash-bleft">'+'<?php _e("NEW", 'google-analytics-dashboard-for-wp');?>'+'</div><div class="gadash-bright">'+countsessions(data,uvisitortype[1])+'</div></div>';
483
-
484
- });
485
- };
486
- };
487
- online_refresh();
488
- setInterval(online_refresh, 60000);
489
- </script>
490
- <?php } else if (array_search($query, array('referrers','contentpages','searches')) !== false) {?>
491
- <div id="gadash-trafficchannels"></div>
492
- <div id="gadash-prs"></div>
493
- <script type="text/javascript">
494
- google.load("visualization", "1", {packages:["table","orgchart"]});
495
-
496
- try {
497
- NProgress.configure({ parent: "#gadash-progressbar" });
498
- NProgress.configure({ showSpinner: false });
499
- NProgress.start();
500
- } catch(e) {
501
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
502
- jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp'); ?>");
503
- }
504
-
505
- jQuery.post(ajaxurl, {action: "gadash_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "<?php echo 'trafficchannels,' . $query; ?>",gadash_security_widget_reports: "<?php echo wp_create_nonce('gadash_get_widgetreports'); ?>"}, function(response){
506
- if ( jQuery.isArray( response ) ) {
507
-
508
- if (!jQuery.isNumeric(response[0])){
509
- if (jQuery.isArray(response[0])){
510
- gadash_trafficchannels=response[0];
511
- google.setOnLoadCallback(ga_dash_drawtrafficchannels(gadash_trafficchannels));
512
- } else {
513
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
514
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
515
- console.log("\n********************* GADWP Log ********************* \n\n"+response[0]);
516
- }
517
- }else{
518
- jQuery("#gadash-trafficchannels").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
519
- jQuery("#gadash-trafficchannels").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[0]+")");
520
- }
521
-
522
- if (!jQuery.isNumeric(response[1])){
523
- if (jQuery.isArray(response[1])){
524
- gadash_prs=response[1];
525
- google.setOnLoadCallback(ga_dash_drawprs(gadash_prs));
526
- } else {
527
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
528
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
529
- console.log("\n********************* GADWP Log ********************* \n\n"+response[1]);
530
- }
531
- }else{
532
- jQuery("#gadash-prs").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
533
- jQuery("#gadash-prs").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[1]+")");
534
- }
535
-
536
- }else{
537
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
538
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
539
- console.log("\n********************* GADWP Log ********************* \n\n"+response);
540
- }
541
- NProgress.done();
542
- });
543
-
544
- function ga_dash_drawprs(gadash_prs) {
545
- var data = google.visualization.arrayToDataTable(gadash_prs);
546
- var options = {
547
- page: 'enable',
548
- pageSize: 10,
549
- width: '100%',
550
- allowHtml: true
551
- };
552
-
553
- var chart = new google.visualization.Table(document.getElementById('gadash-prs'));
554
- chart.draw(data, options);
555
- };
556
-
557
- function ga_dash_drawtrafficchannels(gadash_trafficchannels) {
558
- var data = google.visualization.arrayToDataTable(gadash_trafficchannels);
559
- var options = {
560
- allowCollapse:true,
561
- allowHtml:true
562
- };
563
-
564
- var chart = new google.visualization.OrgChart(document.getElementById('gadash-trafficchannels'));
565
- chart.draw(data, options);
566
- };
567
- </script>
568
- <?php } else if ($query == 'trafficdetails') {?>
569
- <div id="gadash-trafficchannels"></div>
570
- <div class="gadash-floatwraper">
571
- <div id="gadash-trafficmediums"></div>
572
- <div id="gadash-traffictype"></div>
573
- </div>
574
- <div class="gadash-floatwraper">
575
- <div id="gadash-trafficorganic"></div>
576
- <div id="gadash-socialnetworks"></div>
577
- </div>
578
- <script type="text/javascript">
579
- google.load("visualization", "1", {packages:["corechart","orgchart"]});
580
-
581
- try {
582
- NProgress.configure({ parent: "#gadash-progressbar" });
583
- NProgress.configure({ showSpinner: false });
584
- NProgress.start();
585
- } catch(e) {
586
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
587
- jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp'); ?>");
588
- }
589
-
590
- jQuery.post(ajaxurl, {action: "gadash_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "trafficchannels,medium,visitorType,source,socialNetwork",gadash_security_widget_reports: "<?php echo wp_create_nonce('gadash_get_widgetreports'); ?>"}, function(response){
591
- if ( jQuery.isArray( response ) ) {
592
-
593
- if (!jQuery.isNumeric(response[0])){
594
- if (jQuery.isArray(response[0])){
595
- gadash_trafficchannels=response[0];
596
- google.setOnLoadCallback(ga_dash_drawtrafficchannels(gadash_trafficchannels));
597
- } else {
598
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
599
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
600
- console.log("\n********************* GADWP Log ********************* \n\n"+response[0]);
601
- }
602
- }else{
603
- jQuery("#gadash-trafficchannels").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
604
- jQuery("#gadash-trafficchannels").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[0]+")");
605
- }
606
-
607
- if (!jQuery.isNumeric(response[1])){
608
- if (jQuery.isArray(response[1])){
609
- gadash_trafficmediums=response[1];
610
- google.setOnLoadCallback(ga_dash_drawtrafficmediums(gadash_trafficmediums));
611
- } else {
612
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
613
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
614
- console.log("\n********************* GADWP Log ********************* \n\n"+response[1]);
615
- }
616
- }else{
617
- jQuery("#gadash-trafficmediums").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
618
- jQuery("#gadash-trafficmediums").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[1]+")");
619
- }
620
-
621
- if (!jQuery.isNumeric(response[2])){
622
- if (jQuery.isArray(response[2])){
623
- gadash_traffictype=response[2];
624
- google.setOnLoadCallback(ga_dash_drawtraffictype(gadash_traffictype));
625
- } else {
626
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
627
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
628
- console.log("\n********************* GADWP Log ********************* \n\n"+response[2]);
629
- }
630
- }else{
631
- jQuery("#gadash-traffictype").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
632
- jQuery("#gadash-traffictype").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[2]+")");
633
- }
634
-
635
- if (!jQuery.isNumeric(response[3])){
636
- if (jQuery.isArray(response[3])){
637
- gadash_trafficorganic=response[3];
638
- google.setOnLoadCallback(ga_dash_drawtrafficorganic(gadash_trafficorganic));
639
- } else {
640
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
641
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
642
- console.log("\n********************* GADWP Log ********************* \n\n"+response[3]);
643
- }
644
- }else{
645
- jQuery("#gadash-trafficorganic").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
646
- jQuery("#gadash-trafficorganic").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[3]+")");
647
- }
648
-
649
- if (!jQuery.isNumeric(response[4])){
650
- if (jQuery.isArray(response[4])){
651
- gadash_socialnetworks=response[4];
652
- google.setOnLoadCallback(ga_dash_drawsocialnetworks(gadash_socialnetworks));
653
- } else {
654
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
655
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
656
- console.log("\n********************* GADWP Log ********************* \n\n"+response[4]);
657
- }
658
- }else{
659
- jQuery("#gadash-socialnetworks").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
660
- jQuery("#gadash-socialnetworks").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[4]+")");
661
- }
662
-
663
- }else{
664
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
665
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
666
- console.log("\n********************* GADWP Log ********************* \n\n"+response);
667
- }
668
- NProgress.done();
669
- });
670
-
671
- function ga_dash_drawtrafficmediums(gadash_trafficmediums) {
672
- var data = google.visualization.arrayToDataTable(gadash_trafficmediums);
673
- var options = {
674
- is3D: false,
675
- tooltipText: 'percentage',
676
- legend: 'none',
677
- chartArea: {width: '99%',height: '80%'},
678
- title: '<?php _e( "Traffic Mediums", 'google-analytics-dashboard-for-wp' ); ?>',
679
- colors:['<?php echo esc_html($this->gadwp->config->options ['ga_dash_style']); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], - 10 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], + 20 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], + 10 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], - 20 )); ?>']
680
- };
681
-
682
- var chart = new google.visualization.PieChart(document.getElementById('gadash-trafficmediums'));
683
- chart.draw(data, options);
684
- };
685
-
686
- function ga_dash_drawtraffictype(gadash_traffictype) {
687
- var data = google.visualization.arrayToDataTable(gadash_traffictype);
688
- var options = {
689
- is3D: false,
690
- tooltipText: 'percentage',
691
- legend: 'none',
692
- chartArea: {width: '99%',height: '80%'},
693
- title: '<?php _e( "Visitor Type", 'google-analytics-dashboard-for-wp' ); ?>',
694
- colors:['<?php echo esc_html($this->gadwp->config->options ['ga_dash_style']); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], - 10 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], + 20 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], + 10 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], - 20 )); ?>']
695
- };
696
-
697
- var chart = new google.visualization.PieChart(document.getElementById('gadash-traffictype'));
698
- chart.draw(data, options);
699
- };
700
-
701
- function ga_dash_drawsocialnetworks(gadash_socialnetworks) {
702
- var data = google.visualization.arrayToDataTable(gadash_socialnetworks);
703
- var options = {
704
- is3D: false,
705
- tooltipText: 'percentage',
706
- legend: 'none',
707
- chartArea: {width: '99%',height: '80%'},
708
- title: '<?php _e( "Social Networks", 'google-analytics-dashboard-for-wp' ); ?>',
709
- colors:['<?php echo esc_html($this->gadwp->config->options ['ga_dash_style']); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], - 10 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], + 20 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], + 10 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], - 20 )); ?>']
710
- };
711
-
712
- var chart = new google.visualization.PieChart(document.getElementById('gadash-socialnetworks'));
713
- chart.draw(data, options);
714
- };
715
-
716
- function ga_dash_drawtrafficorganic(gadash_trafficorganic) {
717
- var data = google.visualization.arrayToDataTable(gadash_trafficorganic);
718
- var options = {
719
- is3D: false,
720
- tooltipText: 'percentage',
721
- legend: 'none',
722
- chartArea: {width: '99%',height: '80%'},
723
- title: '<?php _e( "Search Engines", 'google-analytics-dashboard-for-wp' ); ?>',
724
- colors:['<?php echo esc_html($this->gadwp->config->options ['ga_dash_style']); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], - 10 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], + 20 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], + 10 )); ?>','<?php echo esc_html(GADWP_Tools::colourVariator ( $this->gadwp->config->options ['ga_dash_style'], - 20 )); ?>']
725
- };
726
-
727
- var chart = new google.visualization.PieChart(document.getElementById('gadash-trafficorganic'));
728
- chart.draw(data, options);
729
- };
730
-
731
- function ga_dash_drawtrafficchannels(gadash_trafficchannels) {
732
- var data = google.visualization.arrayToDataTable(gadash_trafficchannels);
733
- var options = {
734
- allowCollapse:true,
735
- allowHtml:true
736
- };
737
-
738
- var chart = new google.visualization.OrgChart(document.getElementById('gadash-trafficchannels'));
739
- chart.draw(data, options);
740
- };
741
- </script>
742
- <?php } else if ($query == 'locations') {?>
743
- <div id="gadash-map"></div>
744
- <div id="gadash-locations"></div>
745
- <script type="text/javascript">
746
- google.load("visualization", "1", {packages:["geochart","table"]});
747
-
748
- try {
749
- NProgress.configure({ parent: "#gadash-progressbar" });
750
- NProgress.configure({ showSpinner: false });
751
- NProgress.start();
752
- } catch(e) {
753
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
754
- jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp'); ?>");
755
- }
756
-
757
- jQuery.post(ajaxurl, {action: "gadash_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "<?php echo $query; ?>",gadash_security_widget_reports: "<?php echo wp_create_nonce('gadash_get_widgetreports'); ?>"}, function(response){
758
-
759
- if ( jQuery.isArray( response ) ) {
760
- if (!jQuery.isNumeric(response[0])){
761
- if (jQuery.isArray(response[0])){
762
- gadash_locations=response[0];
763
- google.setOnLoadCallback(ga_dash_drawmaplocations(gadash_locations));
764
- google.setOnLoadCallback(ga_dash_drawlocations(gadash_locations));
765
- } else {
766
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
767
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
768
- console.log("\n********************* GADWP Log ********************* \n\n"+response[0]);
769
- }
770
- }else{
771
- jQuery("#gadash-map").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
772
- jQuery("#gadash-map").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[0]+")");
773
- jQuery("#gadash-locations").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
774
- jQuery("#gadash-locations").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[0]+")");
775
- }
776
-
777
- }else{
778
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
779
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
780
- console.log("\n********************* GADWP Log ********************* \n\n"+response);
781
- }
782
- NProgress.done();
783
- });
784
-
785
- function ga_dash_drawmaplocations(gadash_locations) {
786
-
787
- var data = google.visualization.arrayToDataTable(gadash_locations);
788
-
789
- var options = {
790
- chartArea: {width: '99%',height: '90%'},
791
- colors: ['<?php echo $light_color; ?>', '<?php echo $dark_color; ?>'],
792
- <?php
793
-
794
- $country_codes = GADWP_Tools::get_countrycodes();
795
- if ( $this->gadwp->config->options['ga_target_geomap'] && isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
796
- ?>
797
- region : '<?php echo esc_html($this->gadwp->config->options ['ga_target_geomap']); ?>',
798
- displayMode : 'markers',
799
- datalessRegionColor : 'EFEFEF'
800
- <?php } ?>
801
- }
802
- var chart = new google.visualization.GeoChart(document.getElementById('gadash-map'));
803
- chart.draw(data, options);
804
- }
805
-
806
- function ga_dash_drawlocations(gadash_locations) {
807
- var data = google.visualization.arrayToDataTable(gadash_locations);
808
- var options = {
809
- page: 'enable',
810
- pageSize: 10,
811
- width: '100%'
812
- };
813
-
814
- var chart = new google.visualization.Table(document.getElementById('gadash-locations'));
815
- chart.draw(data, options);
816
- };
817
- </script>
818
- <?php } else {?>
819
- <div id="gadash-mainchart"></div>
820
- <div id="gadash-bottomstats" class="gadash-wrapper">
821
- <div class="inside">
822
- <div class="small-box">
823
- <h3><?php _e( "Sessions", 'google-analytics-dashboard-for-wp' );?></h3>
824
- <p id="gdsessions">&nbsp;</p>
825
- </div>
826
- <div class="small-box">
827
- <h3><?php _e( "Users", 'google-analytics-dashboard-for-wp' );?></h3>
828
- <p id="gdusers">&nbsp;</p>
829
- </div>
830
- <div class="small-box">
831
- <h3><?php _e( "Page Views", 'google-analytics-dashboard-for-wp' );?></h3>
832
- <p id="gdpageviews">&nbsp;</p>
833
- </div>
834
- <div class="small-box">
835
- <h3><?php _e( "Bounce Rate", 'google-analytics-dashboard-for-wp' );?></h3>
836
- <p id="gdbouncerate">&nbsp;</p>
837
- </div>
838
- <div class="small-box">
839
- <h3><?php _e( "Organic Search", 'google-analytics-dashboard-for-wp' );?></h3>
840
- <p id="gdorganicsearch">&nbsp;</p>
841
- </div>
842
- <div class="small-box">
843
- <h3><?php _e( "Pages/Session", 'google-analytics-dashboard-for-wp' );?></h3>
844
- <p id="gdpagespervisit">&nbsp;</p>
845
- </div>
846
- </div>
847
- </div>
848
- <script type="text/javascript">
849
-
850
- google.load("visualization", "1", {packages:["corechart"], 'language': '<?php echo get_bloginfo( 'language' ); ?>'});
851
-
852
- try {
853
- NProgress.configure({ parent: "#gadash-progressbar" });
854
- NProgress.configure({ showSpinner: false });
855
- NProgress.start();
856
- } catch(e) {
857
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
858
- jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'google-analytics-dashboard-for-wp'); ?>");
859
- }
860
-
861
- jQuery.post(ajaxurl, {action: "gadash_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "<?php echo $query . ',bottomstats'; ?>",gadash_security_widget_reports: "<?php echo wp_create_nonce('gadash_get_widgetreports'); ?>"}, function(response){
862
- if ( jQuery.isArray( response ) ) {
863
-
864
- if (!jQuery.isNumeric(response[0])){
865
- if (jQuery.isArray(response[0])){
866
- gadash_mainchart=response[0];
867
- google.setOnLoadCallback(ga_dash_drawmainchart(gadash_mainchart));
868
- } else {
869
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
870
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
871
- console.log("\n********************* GADWP Log ********************* \n\n"+response[0]);
872
- }
873
- }else{
874
- jQuery("#gadash-mainchart").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
875
- jQuery("#gadash-mainchart").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[0]+")");
876
- }
877
-
878
- if (!jQuery.isNumeric(response[1])){
879
- if (jQuery.isArray(response[1])){
880
- gadash_bottomstats=response[1];
881
- ga_dash_drawbottomstats(gadash_bottomstats);
882
- } else {
883
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
884
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
885
- console.log("\n********************* GADWP Log ********************* \n\n"+response[1]);
886
- }
887
- }else{
888
- jQuery("#gadash-bottomstats").css({"background-color":"#F7F7F7","height":"auto","padding-top":"40px","padding-bottom":"40px","color":"#000","text-align":"center","width": "98%"});
889
- jQuery("#gadash-bottomstats").html("<?php _e("This report is unavailable", 'google-analytics-dashboard-for-wp'); ?> ("+response[1]+")");
890
- }
891
-
892
- }else{
893
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
894
- jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'google-analytics-dashboard-for-wp'); ?>");
895
- console.log("\n********************* GADWP Log ********************* \n\n"+response);
896
- }
897
- NProgress.done();
898
- });
899
-
900
- function ga_dash_drawbottomstats(gadash_bottomstats) {
901
- jQuery("#gadash-bottomstats #gdsessions").text(gadash_bottomstats[0]);
902
- jQuery("#gadash-bottomstats #gdusers").text(gadash_bottomstats[1]);
903
- jQuery("#gadash-bottomstats #gdpageviews").text(gadash_bottomstats[2]);
904
- jQuery("#gadash-bottomstats #gdbouncerate").text(gadash_bottomstats[3] + "%");
905
- jQuery("#gadash-bottomstats #gdorganicsearch").text(gadash_bottomstats[4]);
906
- jQuery("#gadash-bottomstats #gdpagespervisit").text(gadash_bottomstats[5]);
907
- }
908
-
909
- function ga_dash_drawmainchart(gadash_mainchart) {
910
-
911
- var data = google.visualization.arrayToDataTable(gadash_mainchart);
912
-
913
- var options = {
914
- legend: {position: 'none'},
915
- pointSize: 3,<?php echo $css;?>
916
- chartArea: {width: '99%',height: '90%'},
917
- vAxis: { textPosition: "in", minValue: 0},
918
- hAxis: { textPosition: 'none' }
919
- };
920
- <?php echo $formater?>
921
- var chart = new google.visualization.AreaChart(document.getElementById('gadash-mainchart'));
922
- chart.draw(data, options);
923
- };
924
- </script>
925
<?php
926
- }
927
}
928
}
929
}
24
}
25
26
public function add_widget() {
27
+ wp_add_dashboard_widget( 'gadwp-widget', __( "Google Analytics Dashboard", 'google-analytics-dashboard-for-wp' ), array( $this, 'dashboard_widget' ), $control_callback = null );
28
}
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'];
41
} else {
42
+ echo '<p>' . __( "An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadash_settings', false ) . '" method="POST">' . get_submit_button( __( "Select Domain", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
43
return;
44
}
45
} else {
46
if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
47
$projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
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
62
}
63
}
64
}
common/js/reports.js ADDED
@@ -0,0 +1,1199 @@