Google Analytics Dashboard for WP (GADWP) - Version 4.4.4

Version Description

  • Bug Fix: end tag missing on error message
  • Bug Fix: additional checks before making a View list request
  • Bug Fix: avoid deleting errors while clearing the cache
  • Bug Fix: PHP notices fix for some requests
  • Bug Fix: PHP notices fix when calling ob_clean on an empty buffer
  • Bug Fix: frontend stats not responsive
  • Enhancement: handle some additional API errors
  • Enhancement: set totals to zero when anonymize stats is enabled
  • Enhancement: auto-cleanup removed; all transients have static identifiers now
  • Enhancement: dump error details to JavaScript Console and throw an alert on invalid responses
  • Enhancement: Italian translation, updated by Leo
Download this release

Release Info

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

Code changes from version 4.4.3 to 4.4.4

Files changed (82) hide show
  1. admin/ajax-actions.php +117 -137
  2. admin/css/ga_dash.css +42 -41
  3. admin/dashboard_widgets.php +413 -391
  4. admin/ga_dash_settings.php +555 -582
  5. config.php +240 -257
  6. front/ajax-actions.php +127 -148
  7. front/css/content_stats.css +8 -8
  8. front/frontend.php +96 -99
  9. front/js/content_stats.js +1 -1
  10. front/tracking.php +53 -62
  11. front/tracking/code-universal.php +28 -37
  12. front/widgets.php +108 -128
  13. gadwp.php +39 -48
  14. install/install.php +119 -123
  15. install/uninstall.php +30 -24
  16. languages/ar.mo +0 -0
  17. languages/ar.po +379 -297
  18. languages/ga-dash-de_DE.mo +0 -0
  19. languages/ga-dash-de_DE.po +381 -299
  20. languages/ga-dash-es_ES.mo +0 -0
  21. languages/ga-dash-es_ES.po +338 -297
  22. languages/ga-dash-fr_FR.mo +0 -0
  23. languages/ga-dash-fr_FR.po +381 -299
  24. languages/ga-dash-hu_HU.mo +0 -0
  25. languages/ga-dash-hu_HU.po +381 -299
  26. languages/ga-dash-it_IT.mo +0 -0
  27. languages/ga-dash-it_IT.po +1104 -1013
  28. languages/ga-dash-pl_PL.mo +0 -0
  29. languages/ga-dash-pl_PL.po +380 -298
  30. languages/ga-dash-pt_BR.mo +0 -0
  31. languages/ga-dash-pt_BR.po +381 -299
  32. languages/ga-dash.pot +309 -283
  33. readme.txt +14 -1
  34. tools/autoload.php +32 -32
  35. tools/gapi.php +811 -896
  36. tools/nprogress/nprogress.css +0 -1
  37. tools/src/Google/Auth/Abstract.php +39 -35
  38. tools/src/Google/Auth/AppIdentity.php +95 -104
  39. tools/src/Google/Auth/AssertionCredentials.php +133 -135
  40. tools/src/Google/Auth/Exception.php +20 -21
  41. tools/src/Google/Auth/LoginTicket.php +74 -68
  42. tools/src/Google/Auth/OAuth2.php +538 -632
  43. tools/src/Google/Auth/Simple.php +62 -63
  44. tools/src/Google/Cache/Abstract.php +57 -52
  45. tools/src/Google/Cache/Apc.php +106 -110
  46. tools/src/Google/Cache/Exception.php +20 -21
  47. tools/src/Google/Cache/File.php +181 -189
  48. tools/src/Google/Cache/Memcache.php +172 -181
  49. tools/src/Google/Cache/Null.php +53 -54
  50. tools/src/Google/Client.php +751 -685
  51. tools/src/Google/Collection.php +91 -95
  52. tools/src/Google/Config.php +440 -413
  53. tools/src/Google/Exception.php +19 -19
  54. tools/src/Google/Http/Batch.php +132 -140
  55. tools/src/Google/Http/CacheParser.php +179 -183
  56. tools/src/Google/Http/MediaFileUpload.php +300 -299
  57. tools/src/Google/Http/REST.php +142 -146
  58. tools/src/Google/Http/Request.php +482 -475
  59. tools/src/Google/IO/Abstract.php +334 -328
  60. tools/src/Google/IO/Curl.php +151 -166
  61. tools/src/Google/IO/Exception.php +20 -21
  62. tools/src/Google/IO/Stream.php +194 -229
  63. tools/src/Google/Logger/Abstract.php +394 -405
  64. tools/src/Google/Logger/Exception.php +20 -21
  65. tools/src/Google/Logger/File.php +143 -155
  66. tools/src/Google/Logger/Null.php +39 -40
  67. tools/src/Google/Logger/Psr.php +91 -90
  68. tools/src/Google/Model.php +279 -280
  69. tools/src/Google/Service.php +39 -38
  70. tools/src/Google/Service/AdSense.php +0 -3585
  71. tools/src/Google/Service/Analytics.php +11018 -9446
  72. tools/src/Google/Service/Exception.php +47 -52
  73. tools/src/Google/Service/Resource.php +234 -241
  74. tools/src/Google/Service/YouTube.php +0 -10456
  75. tools/src/Google/Service/YouTubeAnalytics.php +0 -608
  76. tools/src/Google/Signer/Abstract.php +29 -28
  77. tools/src/Google/Signer/P12.php +77 -89
  78. tools/src/Google/Utils.php +146 -134
  79. tools/src/Google/Utils/URITemplate.php +313 -332
  80. tools/src/Google/Verifier/Abstract.php +30 -29
  81. tools/src/Google/Verifier/Pem.php +76 -72
  82. tools/tools.php +90 -100
admin/ajax-actions.php CHANGED
@@ -7,145 +7,125 @@
7
*/
8
if (! class_exists('GADASH_Backend_Ajax')) {
9
10
- final class GADASH_Backend_Ajax
11
- {
12
-
13
- function __construct()
14
- {
15
- // Backend Widget Realtime action
16
- add_action('wp_ajax_gadashadmin_get_realtime', array(
17
- $this,
18
- 'ajax_adminwidget_realtime'
19
- ));
20
- // Admin Widget get Reports action
21
- add_action('wp_ajax_gadashadmin_get_widgetreports', array(
22
- $this,
23
- 'ajax_adminwidget_reports'
24
- ));
25
- }
26
27
- /**
28
- * Ajax handler for getting reports for Admin Widget
29
- *
30
- * @return string|int
31
- */
32
- function ajax_adminwidget_reports()
33
- {
34
- global $GADASH_Config;
35
-
36
- $projectId = $_REQUEST['projectId'];
37
- $from = $_REQUEST['from'];
38
- $to = $_REQUEST['to'];
39
- $query = $_REQUEST['query'];
40
-
41
- ob_clean();
42
-
43
- if (! isset($_REQUEST['gadashadmin_security_widget_reports']) or ! wp_verify_nonce($_REQUEST['gadashadmin_security_widget_reports'], 'gadashadmin_get_widgetreports')) {
44
- print(json_encode(- 30));
45
- die();
46
- }
47
-
48
- /*
49
- * Include Tools
50
- */
51
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
52
- $tools = new GADASH_Tools();
53
-
54
- if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
55
- print(json_encode(- 31));
56
- die();
57
- }
58
-
59
- if ($GADASH_Config->options['ga_dash_token'] and $projectId and $from and $to) {
60
- include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
61
- global $GADASH_GAPI;
62
- } else {
63
- print(json_encode(- 24));
64
- die();
65
- }
66
-
67
- switch ($query) {
68
- case 'referrers':
69
- print($GADASH_GAPI->get_referrers($projectId, $from, $to));
70
- break;
71
- case 'contentpages':
72
- print($GADASH_GAPI->get_contentpages($projectId, $from, $to));
73
- break;
74
- case 'locations':
75
- print($GADASH_GAPI->get_locations($projectId, $from, $to));
76
- break;
77
- case 'bottomstats':
78
- print(json_encode($GADASH_GAPI->get_bottomstats($projectId, $from, $to)));
79
- break;
80
- case 'trafficchannels':
81
- print($GADASH_GAPI->get_trafficchannels($projectId, $from, $to));
82
- break;
83
- case 'medium':
84
- print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'medium'));
85
- break;
86
- case 'visitorType':
87
- print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'visitorType'));
88
- break;
89
- case 'socialNetwork':
90
- print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'socialNetwork'));
91
- break;
92
- case 'source':
93
- print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'source'));
94
- break;
95
- case 'searches':
96
- print($GADASH_GAPI->get_searches($projectId, $from, $to));
97
- break;
98
- default:
99
- print($GADASH_GAPI->get_mainreport($projectId, $from, $to, $query));
100
- break;
101
- }
102
103
- die();
104
- }
105
-
106
- // Real-Time Request
107
- /**
108
- * Ajax handler for getting realtime analytics data for Admin widget
109
- *
110
- * @return string|int
111
- */
112
- function ajax_adminwidget_realtime()
113
- {
114
- global $GADASH_Config;
115
-
116
- $projectId = $_REQUEST['projectId'];
117
-
118
- ob_clean();
119
-
120
- if (! isset($_REQUEST['gadashadmin_security_widgetrealtime']) or ! wp_verify_nonce($_REQUEST['gadashadmin_security_widgetrealtime'], 'gadashadmin_get_realtime')) {
121
- print(json_encode(- 30));
122
- die();
123
- }
124
-
125
- /*
126
- * Include Tools
127
- */
128
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
129
- $tools = new GADASH_Tools();
130
-
131
- if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
132
- print(json_encode(- 31));
133
- die();
134
- }
135
-
136
- if ($GADASH_Config->options['ga_dash_token'] and $projectId) {
137
- include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
138
- global $GADASH_GAPI;
139
- } else {
140
- print(json_encode(- 24));
141
- die();
142
- }
143
-
144
- print($GADASH_GAPI->gadash_realtime_data($projectId));
145
-
146
- die();
147
- }
148
}
149
}
150
-
151
$GADASH_Backend_Ajax = new GADASH_Backend_Ajax();
7
*/
8
if (! class_exists('GADASH_Backend_Ajax')) {
9
10
+ final class GADASH_Backend_Ajax
11
+ {
12
13
+ function __construct()
14
+ {
15
+ // Backend Widget Realtime action
16
+ add_action('wp_ajax_gadashadmin_get_realtime', array(
17
+ $this,
18
+ 'ajax_adminwidget_realtime'
19
+ ));
20
+ // Admin Widget get Reports action
21
+ add_action('wp_ajax_gadashadmin_get_widgetreports', array(
22
+ $this,
23
+ 'ajax_adminwidget_reports'
24
+ ));
25
+ }
26
27
+ /**
28
+ * Ajax handler for getting reports for Admin Widget
29
+ *
30
+ * @return string|int
31
+ */
32
+ function ajax_adminwidget_reports()
33
+ {
34
+ global $GADASH_Config;
35
+ if (! isset($_REQUEST['gadashadmin_security_widget_reports']) or ! wp_verify_nonce($_REQUEST['gadashadmin_security_widget_reports'], 'gadashadmin_get_widgetreports')) {
36
+ wp_die(- 30);
37
+ }
38
+ $projectId = $_REQUEST['projectId'];
39
+ $from = $_REQUEST['from'];
40
+ $to = $_REQUEST['to'];
41
+ $query = $_REQUEST['query'];
42
+ if (ob_get_length()) {
43
+ ob_clean();
44
+ }
45
+ /*
46
+ * Include Tools
47
+ */
48
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
49
+ $tools = new GADASH_Tools();
50
+ if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
51
+ wp_die(- 31);
52
+ }
53
+ if ($GADASH_Config->options['ga_dash_token'] and $projectId and $from and $to) {
54
+ include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
55
+ global $GADASH_GAPI;
56
+ } else {
57
+ wp_die(- 24);
58
+ }
59
+ switch ($query) {
60
+ case 'referrers':
61
+ print($GADASH_GAPI->get_referrers($projectId, $from, $to));
62
+ break;
63
+ case 'contentpages':
64
+ print($GADASH_GAPI->get_contentpages($projectId, $from, $to));
65
+ break;
66
+ case 'locations':
67
+ print($GADASH_GAPI->get_locations($projectId, $from, $to));
68
+ break;
69
+ case 'bottomstats':
70
+ print(json_encode($GADASH_GAPI->get_bottomstats($projectId, $from, $to)));
71
+ break;
72
+ case 'trafficchannels':
73
+ print($GADASH_GAPI->get_trafficchannels($projectId, $from, $to));
74
+ break;
75
+ case 'medium':
76
+ print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'medium'));
77
+ break;
78
+ case 'visitorType':
79
+ print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'visitorType'));
80
+ break;
81
+ case 'socialNetwork':
82
+ print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'socialNetwork'));
83
+ break;
84
+ case 'source':
85
+ print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'source'));
86
+ break;
87
+ case 'searches':
88
+ print($GADASH_GAPI->get_searches($projectId, $from, $to));
89
+ break;
90
+ default:
91
+ print($GADASH_GAPI->get_mainreport($projectId, $from, $to, $query));
92
+ break;
93
+ }
94
+ wp_die();
95
+ }
96
+ // Real-Time Request
97
+ /**
98
+ * Ajax handler for getting realtime analytics data for Admin widget
99
+ *
100
+ * @return string|int
101
+ */
102
+ function ajax_adminwidget_realtime()
103
+ {
104
+ global $GADASH_Config;
105
+ if (! isset($_REQUEST['gadashadmin_security_widgetrealtime']) or ! wp_verify_nonce($_REQUEST['gadashadmin_security_widgetrealtime'], 'gadashadmin_get_realtime')) {
106
+ wp_die(- 30);
107
+ }
108
+ $projectId = $_REQUEST['projectId'];
109
+ if (ob_get_length()) {
110
+ ob_clean();
111
+ }
112
+ /*
113
+ * Include Tools
114
+ */
115
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
116
+ $tools = new GADASH_Tools();
117
+ if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
118
+ wp_die(- 31);
119
+ }
120
+ if ($GADASH_Config->options['ga_dash_token'] and $projectId) {
121
+ include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
122
+ global $GADASH_GAPI;
123
+ } else {
124
+ wp_die(- 24);
125
+ }
126
+ print($GADASH_GAPI->gadash_realtime_data($projectId));
127
+ wp_die();
128
}
129
+ }
130
}
131
$GADASH_Backend_Ajax = new GADASH_Backend_Ajax();
admin/css/ga_dash.css CHANGED
@@ -1,7 +1,7 @@
1
/* Tab navigation */
2
-
3
- #gadwp-events, #gadwp-custom, #gadwp-advanced, #gadwp-exclude, #gadwp-config{
4
- display:none;
5
}
6
7
/* Options pages */
@@ -36,10 +36,10 @@ td.title label {
36
}
37
38
.gadash-title {
39
- float:left;
40
margin-right: 10px;
41
margin-top: 2px;
42
- clear:left;
43
}
44
45
.gadash-desc {
@@ -51,6 +51,7 @@ td.title label {
51
}
52
53
pre.gadash {
54
}
55
56
pre.log_data {
@@ -189,13 +190,13 @@ td.roles {
189
.gadash-pleft {
190
width: 90%;
191
float: left;
192
- padding-left:5px;
193
}
194
195
.gadash-pright {
196
width: 5%;
197
float: right;
198
- padding-right:5px;
199
}
200
201
#gadash-widget .realtime {
@@ -218,7 +219,7 @@ td.roles {
218
width: 60%;
219
padding: 33px 0;
220
float: left;
221
- text-align:center;
222
}
223
224
.gadash-tdo-right {
@@ -228,15 +229,15 @@ td.roles {
228
font-weight: bold;
229
vertical-align: middle;
230
float: right;
231
- display:table;
232
}
233
234
.gadash-online {
235
font-size: 100px;
236
font-weight: normal;
237
line-height: 1em;
238
- margin:0 auto;
239
- width:80%;
240
}
241
242
.gadash-bigtext {
@@ -249,17 +250,17 @@ td.roles {
249
-webkit-box-shadow: 0px 0px 3px 0px #BBB;
250
box-shadow: 0px 0px 3px 0px #BBB;
251
display: table;
252
- overflow: hidden;
253
}
254
255
- .gadash-bleft{
256
- float:left;
257
- width:80%;
258
}
259
260
- .gadash-bright{
261
- float:right;
262
- width:20%;
263
}
264
265
.gadash-pgdetailsr {
@@ -271,36 +272,37 @@ td.roles {
271
min-width: 250px;
272
}
273
274
- #gadash-mainchart{
275
width: 98%;
276
- height:100%;
277
margin: 10px auto 10px 0;
278
height: 250px;
279
}
280
281
- .gadash-floatwraper{
282
- display:table;
283
- width:100%;
284
- height:100%;
285
}
286
287
- #gadash-trafficmediums, #gadash-traffictype, #gadash-socialnetworks, #gadash-trafficorganic{
288
- width:47%;
289
- margin:10px 0 0 0;
290
height: 200px;
291
}
292
293
- #gadash-trafficmediums, #gadash-trafficorganic{
294
- float:left;
295
}
296
-
297
- #gadash-traffictype, #gadash-socialnetworks{
298
- float:right;
299
}
300
-
301
- #gadash-map, #gadash-prs{
302
width: 98%;
303
- height:100%;
304
margin: 10px auto 10px 0;
305
}
306
@@ -315,11 +317,10 @@ td.roles {
315
}
316
317
/* Admin Widget content */
318
-
319
- #gadash-progressbar{
320
- width:100%;
321
- height:3px;
322
- margin:5px 0 0px 0;
323
}
324
325
.gadash-wrapper {
@@ -359,4 +360,4 @@ td.roles {
359
.gadash-wrapper .inside .small-box {
360
width: 45%;
361
}
362
- }
1
/* Tab navigation */
2
+ #gadwp-events, #gadwp-custom, #gadwp-advanced, #gadwp-exclude,
3
+ #gadwp-config {
4
+ display: none;
5
}
6
7
/* Options pages */
36
}
37
38
.gadash-title {
39
+ float: left;
40
margin-right: 10px;
41
margin-top: 2px;
42
+ clear: left;
43
}
44
45
.gadash-desc {
51
}
52
53
pre.gadash {
54
+
55
}
56
57
pre.log_data {
190
.gadash-pleft {
191
width: 90%;
192
float: left;
193
+ padding-left: 5px;
194
}
195
196
.gadash-pright {
197
width: 5%;
198
float: right;
199
+ padding-right: 5px;
200
}
201
202
#gadash-widget .realtime {
219
width: 60%;
220
padding: 33px 0;
221
float: left;
222
+ text-align: center;
223
}
224
225
.gadash-tdo-right {
229
font-weight: bold;
230
vertical-align: middle;
231
float: right;
232
+ display: table;
233
}
234
235
.gadash-online {
236
font-size: 100px;
237
font-weight: normal;
238
line-height: 1em;
239
+ margin: 0 auto;
240
+ width: 80%;
241
}
242
243
.gadash-bigtext {
250
-webkit-box-shadow: 0px 0px 3px 0px #BBB;
251
box-shadow: 0px 0px 3px 0px #BBB;
252
display: table;
253
+ overflow: hidden;
254
}
255
256
+ .gadash-bleft {
257
+ float: left;
258
+ width: 80%;
259
}
260
261
+ .gadash-bright {
262
+ float: right;
263
+ width: 20%;
264
}
265
266
.gadash-pgdetailsr {
272
min-width: 250px;
273
}
274
275
+ #gadash-mainchart {
276
width: 98%;
277
+ height: 100%;
278
margin: 10px auto 10px 0;
279
height: 250px;
280
}
281
282
+ .gadash-floatwraper {
283
+ display: table;
284
+ width: 100%;
285
+ height: 100%;
286
}
287
288
+ #gadash-trafficmediums, #gadash-traffictype, #gadash-socialnetworks,
289
+ #gadash-trafficorganic {
290
+ width: 47%;
291
+ margin: 10px 0 0 0;
292
height: 200px;
293
}
294
295
+ #gadash-trafficmediums, #gadash-trafficorganic {
296
+ float: left;
297
}
298
+
299
+ #gadash-traffictype, #gadash-socialnetworks {
300
+ float: right;
301
}
302
+
303
+ #gadash-map, #gadash-prs {
304
width: 98%;
305
+ height: 100%;
306
margin: 10px auto 10px 0;
307
}
308
317
}
318
319
/* Admin Widget content */
320
+ #gadash-progressbar {
321
+ width: 100%;
322
+ height: 3px;
323
+ margin: 5px 0 0px 0;
324
}
325
326
.gadash-wrapper {
360
.gadash-wrapper .inside .small-box {
361
width: 45%;
362
}
363
+ }
admin/dashboard_widgets.php CHANGED
@@ -7,297 +7,271 @@
7
*/
8
if (! class_exists('GADASH_Widgets')) {
9
10
- class GADASH_Widgets
11
- {
12
13
- function __construct()
14
- {
15
- global $GADASH_Config;
16
- add_action('wp_dashboard_setup', array(
17
- $this,
18
- 'ga_dash_setup'
19
- ));
20
- // Admin Styles
21
- add_action('admin_enqueue_scripts', array(
22
- $this,
23
- 'ga_dash_admin_enqueue_styles'
24
- ));
25
- // Admin Menu
26
- add_action('admin_menu', array(
27
- $this,
28
- 'ga_dash_admin_actions'
29
- ));
30
- // Network Menu
31
- add_action('network_admin_menu', array(
32
- $this,
33
- 'ga_dash_network_actions'
34
- ));
35
- // Plugin Settings link
36
- add_filter("plugin_action_links_" . plugin_basename($GADASH_Config->plugin_path) . '/gadwp.php', array(
37
- $this,
38
- 'ga_dash_settings_link'
39
- ));
40
- // Add error bubble
41
- add_action('admin_print_scripts', array(
42
- $this,
43
- 'draw_error_bubble'
44
- ), 10000);
45
- }
46
47
- function draw_error_bubble()
48
- {
49
- $bubble_msg = '!';
50
- if (get_transient('ga_dash_gapi_errors')) {
51
- ?>
52
- <script type="text/javascript">
53
jQuery(document).ready(function() {
54
jQuery('#toplevel_page_gadash_settings li > a[href*="page=gadash_errors_debugging"]').append('&nbsp;<span class="awaiting-mod count-1"><span class="pending-count" style="padding:0 7px;"><?php echo $bubble_msg ?></span></span>');
55
});
56
</script>
57
- <?php
58
- }
59
- }
60
-
61
- function ga_dash_admin_actions()
62
- {
63
- global $GADASH_Config;
64
- global $wp_version;
65
-
66
- if (current_user_can('manage_options')) {
67
- include ($GADASH_Config->plugin_path . '/admin/ga_dash_settings.php');
68
-
69
- add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_options', 'gadash_settings', array(
70
- 'GADASH_Settings',
71
- 'general_settings'
72
- ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
73
- add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_options', 'gadash_settings', array(
74
- 'GADASH_Settings',
75
- 'general_settings'
76
- ));
77
- add_submenu_page('gadash_settings', __("Backend Settings", 'ga-dash'), __("Backend Settings", 'ga-dash'), 'manage_options', 'gadash_backend_settings', array(
78
- 'GADASH_Settings',
79
- 'backend_settings'
80
- ));
81
- add_submenu_page('gadash_settings', __("Frontend Settings", 'ga-dash'), __("Frontend Settings", 'ga-dash'), 'manage_options', 'gadash_frontend_settings', array(
82
- 'GADASH_Settings',
83
- 'frontend_settings'
84
- ));
85
- add_submenu_page('gadash_settings', __("Tracking Code", 'ga-dash'), __("Tracking Code", 'ga-dash'), 'manage_options', 'gadash_tracking_settings', array(
86
- 'GADASH_Settings',
87
- 'tracking_settings'
88
- ));
89
- add_submenu_page('gadash_settings', __("Errors & Debug", 'ga-dash'), __("Errors & Debug", 'ga-dash'), 'manage_options', 'gadash_errors_debugging', array(
90
- 'GADASH_Settings',
91
- 'errors_debugging'
92
- ));
93
- }
94
- }
95
96
- function ga_dash_network_actions()
97
- {
98
- global $GADASH_Config;
99
- global $wp_version;
100
-
101
- if (current_user_can('manage_netwrok')) {
102
- include ($GADASH_Config->plugin_path . '/admin/ga_dash_settings.php');
103
-
104
- add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
105
- 'GADASH_Settings',
106
- 'general_settings_network'
107
- ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
108
- add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
109
- 'GADASH_Settings',
110
- 'general_settings_network'
111
- ));
112
- add_submenu_page('gadash_settings', __("Errors & Debug", 'ga-dash'), __("Errors & Debug", 'ga-dash'), 'manage_network', 'gadash_errors_debugging', array(
113
- 'GADASH_Settings',
114
- 'errors_debugging'
115
- ));
116
- }
117
- }
118
119
- /*
120
- * Include styles
121
- */
122
- function ga_dash_admin_enqueue_styles($hook)
123
- {
124
- global $GADASH_Config;
125
- $valid_hooks = array(
126
- 'toplevel_page_gadash_settings',
127
- 'google-analytics_page_gadash_backend_settings',
128
- 'google-analytics_page_gadash_frontend_settings',
129
- 'google-analytics_page_gadash_tracking_settings',
130
- 'google-analytics_page_gadash_errors_debugging'
131
- );
132
-
133
- if (! in_array($hook, $valid_hooks) and 'index.php' != $hook)
134
- return;
135
-
136
- wp_enqueue_style('ga_dash-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.css', NULL, GADWP_CURRENT_VERSION);
137
-
138
- wp_register_style('ga_dash', $GADASH_Config->plugin_url . '/admin/css/ga_dash.css', NULL, GADWP_CURRENT_VERSION);
139
-
140
- wp_enqueue_style('ga_dash');
141
- wp_enqueue_style('wp-color-picker');
142
- wp_enqueue_script('wp-color-picker');
143
- wp_enqueue_script('wp-color-picker-script-handle', plugins_url('js/wp-color-picker-script.js', __FILE__), array(
144
- 'wp-color-picker'
145
- ), false, true);
146
- wp_enqueue_script('gadash-general-settings', plugins_url('js/admin.js', __FILE__), array(
147
- 'jquery'
148
- ), GADWP_CURRENT_VERSION);
149
- if (! wp_script_is('googlejsapi')) {
150
- wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
151
- wp_enqueue_script('googlejsapi');
152
- }
153
- wp_enqueue_script('ga_dash-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.js', array(
154
- 'jquery'
155
- ), GADWP_CURRENT_VERSION);
156
- }
157
158
- function ga_dash_settings_link($links)
159
- {
160
- $settings_link = '<a href="' . get_admin_url(null, 'admin.php?page=gadash_settings') . '">' . __("Settings", 'ga-dash') . '</a>';
161
- array_unshift($links, $settings_link);
162
- return $links;
163
- }
164
165
- function ga_dash_setup()
166
- {
167
- global $GADASH_Config;
168
-
169
- /*
170
- * Include Tools
171
- */
172
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
173
- $tools = new GADASH_Tools();
174
-
175
- if ($tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
176
- wp_add_dashboard_widget('gadash-widget', __("Google Analytics Dashboard", 'ga-dash'), array(
177
- $this,
178
- 'gadash_dashboard_widgets'
179
- ), $control_callback = null);
180
- }
181
- }
182
183
- function gadash_dashboard_widgets()
184
- {
185
- global $GADASH_Config;
186
187
- /*
188
- * Include GAPI
189
- */
190
- if ($GADASH_Config->options['ga_dash_token']) {
191
- include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
192
- global $GADASH_GAPI;
193
- } else {
194
- echo '<p>' . __("This plugin needs an authorization:", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Authorize Plugin", 'ga-dash'), 'secondary') . '</form>';
195
- return;
196
- }
197
-
198
- /*
199
- * Include Tools
200
- */
201
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
202
- $tools = new GADASH_Tools();
203
-
204
- $tools->ga_dash_cleanup_timeouts();
205
-
206
- if (current_user_can('manage_options')) {
207
-
208
- if (isset($_REQUEST['ga_dash_profile_select'])) {
209
- $GADASH_Config->options['ga_dash_tableid'] = $_REQUEST['ga_dash_profile_select'];
210
- }
211
-
212
- $profiles = $GADASH_Config->options['ga_dash_profile_list'];
213
- $profile_switch = '';
214
-
215
- if (is_array($profiles)) {
216
- if (! $GADASH_Config->options['ga_dash_tableid']) {
217
- if ($GADASH_Config->options['ga_dash_tableid_jail']) {
218
- $GADASH_Config->options['ga_dash_tableid'] = $GADASH_Config->options['ga_dash_tableid_jail'];
219
- } else {
220
- $GADASH_Config->options['ga_dash_tableid'] = $tools->guess_default_domain($profiles);
221
- }
222
- } else
223
- if ($GADASH_Config->options['ga_dash_jailadmins'] and $GADASH_Config->options['ga_dash_tableid_jail']) {
224
- $GADASH_Config->options['ga_dash_tableid'] = $GADASH_Config->options['ga_dash_tableid_jail'];
225
- }
226
-
227
- $profile_switch .= '<select id="ga_dash_profile_select" name="ga_dash_profile_select" onchange="this.form.submit()">';
228
- foreach ($profiles as $profile) {
229
- if (! $GADASH_Config->options['ga_dash_tableid']) {
230
- $GADASH_Config->options['ga_dash_tableid'] = $profile[1];
231
- }
232
- if (isset($profile[3])) {
233
- $profile_switch .= '<option value="' . esc_attr($profile[1]) . '" ';
234
- $profile_switch .= selected($profile[1], $GADASH_Config->options['ga_dash_tableid'], false);
235
- $profile_switch .= ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($profile[0]) . '">' . esc_attr($tools->ga_dash_get_profile_domain($profile[3])) . '</option>';
236
- }
237
- }
238
- $profile_switch .= "</select>";
239
- } else {
240
- echo '<p>' . __("Something went wrong while retrieving profiles list.", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("More details", 'ga-dash'), 'secondary') . '</form>';
241
- return;
242
- }
243
- }
244
-
245
- $GADASH_Config->set_plugin_options();
246
-
247
- ?>
248
- <form id="ga-dash" method="POST">
249
- <?php
250
-
251
- if (current_user_can('manage_options')) {
252
- if ($GADASH_Config->options['ga_dash_jailadmins']) {
253
- if ($GADASH_Config->options['ga_dash_tableid_jail']) {
254
- $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
255
- } else {
256
- echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'ga-dash'), 'secondary') . '</form>';
257
- return;
258
- }
259
- } else {
260
- echo $profile_switch;
261
- $projectId = $GADASH_Config->options['ga_dash_tableid'];
262
- }
263
} else {
264
- if ($GADASH_Config->options['ga_dash_tableid_jail']) {
265
- $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
266
- } else {
267
- echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'ga-dash'), 'secondary') . '</form>';
268
- return;
269
- }
270
}
271
-
272
- if (! ($projectId)) {
273
- echo '<p>' . __("Something went wrong while retrieving property data. You need to create and properly configure a Google Analytics account:", 'ga-dash') . '</p> <form action="https://deconf.com/how-to-set-up-google-analytics-on-your-website/" method="POST">' . get_submit_button(__("Find out more!", 'ga-dash'), 'secondary') . '</form>';
274
- return;
275
- } else {
276
- $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
277
- if (isset($profile_info[4])) {
278
- $GADASH_GAPI->timeshift = $profile_info[4];
279
- } else {
280
- $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
281
- }
282
}
283
-
284
- if (isset($_REQUEST['query'])) {
285
- $query = $_REQUEST['query'];
286
- $GADASH_Config->options['ga_dash_default_metric'] = $query;
287
- $GADASH_Config->set_plugin_options();
288
- } else {
289
- $query = isset($GADASH_Config->options['ga_dash_default_metric']) ? $GADASH_Config->options['ga_dash_default_metric'] : 'sessions';
290
}
291
-
292
- if (isset($_REQUEST['period'])) {
293
- $period = $_REQUEST['period'];
294
- $GADASH_Config->options['ga_dash_default_dimension'] = $period;
295
- $GADASH_Config->set_plugin_options();
296
- } else {
297
- $period = isset($GADASH_Config->options['ga_dash_default_dimension']) ? $GADASH_Config->options['ga_dash_default_dimension'] : '30daysAgo';
298
}
299
-
300
- ?>
301
302
<select id="ga_dash_period" name="period" onchange="this.form.submit()">
303
<option value="realtime"
@@ -341,99 +315,85 @@ if (! class_exists('GADASH_Widgets')) {
341
</form>
342
<div id="gadash-progressbar"></div>
343
<?php
344
- switch ($period) {
345
-
346
- case 'today':
347
- $from = 'today';
348
- $to = 'today';
349
- $haxis = 4;
350
- break;
351
-
352
- case 'yesterday':
353
- $from = 'yesterday';
354
- $to = 'yesterday';
355
- $haxis = 4;
356
- break;
357
-
358
- case '7daysAgo':
359
- $from = '7daysAgo';
360
- $to = 'yesterday';
361
- $haxis = 2;
362
- break;
363
-
364
- case '14daysAgo':
365
- $from = '14daysAgo';
366
- $to = 'yesterday';
367
- $haxis = 3;
368
- break;
369
-
370
- case '30daysAgo':
371
- $from = '30daysAgo';
372
- $to = 'yesterday';
373
- $haxis = 5;
374
- break;
375
-
376
- default:
377
- $from = '90daysAgo';
378
- $to = 'yesterday';
379
- $haxis = 16;
380
- break;
381
- }
382
-
383
- if ($query == 'visitBounceRate') {
384
- $formater = "var formatter = new google.visualization.NumberFormat({
385
pattern: '#,##%',
386
fractionDigits: 2
387
});
388
389
formatter.format(data, 1); ";
390
- } else {
391
- $formater = '';
392
- }
393
-
394
- /*
395
- * Include Tools
396
- */
397
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
398
- $tools = new GADASH_Tools();
399
-
400
- if (isset($GADASH_Config->options['ga_dash_style'])) {
401
- $light_color = $tools->colourVariator($GADASH_Config->options['ga_dash_style'], 40);
402
- $dark_color = $tools->colourVariator($GADASH_Config->options['ga_dash_style'], - 20);
403
- $css = "colors:['" . $GADASH_Config->options['ga_dash_style'] . "','" . $tools->colourVariator($GADASH_Config->options['ga_dash_style'], - 20) . "'],";
404
- $color = $GADASH_Config->options['ga_dash_style'];
405
- } else {
406
- $css = "";
407
- $color = "#3366CC";
408
- }
409
-
410
- if ($period == 'realtime') {
411
-
412
- wp_register_style('jquery-ui-tooltip-html', $GADASH_Config->plugin_url . '/realtime/jquery/jquery.ui.tooltip.html.css');
413
- wp_enqueue_style('jquery-ui-tooltip-html');
414
-
415
- if (! wp_script_is('jquery')) {
416
- wp_enqueue_script('jquery');
417
- }
418
- if (! wp_script_is('jquery-ui-tooltip')) {
419
- wp_enqueue_script("jquery-ui-tooltip");
420
- }
421
- if (! wp_script_is('jquery-ui-core')) {
422
- wp_enqueue_script("jquery-ui-core");
423
- }
424
- if (! wp_script_is('jquery-ui-position')) {
425
- wp_enqueue_script("jquery-ui-position");
426
- }
427
- if (! wp_script_is('jquery-ui-position')) {
428
- wp_enqueue_script("jquery-ui-position");
429
- }
430
-
431
- wp_register_script("jquery-ui-tooltip-html", $GADASH_Config->plugin_url . '/realtime/jquery/jquery.ui.tooltip.html.js');
432
- wp_enqueue_script("jquery-ui-tooltip-html");
433
- }
434
-
435
- if ($period == 'realtime') {
436
- ?>
437
<div class="realtime">
438
<div class="gadash-rt-box">
439
<div class='gadash-tdo-left'>
@@ -719,7 +679,7 @@ if (! class_exists('GADASH_Widgets')) {
719
NProgress.configure({ showSpinner: false });
720
NProgress.start();
721
} catch(e) {
722
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border":"1px solid red","border-left":"5px solid red"});
723
jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'ga-dash'); ?>");
724
}
725
npcounter = 0;
@@ -727,8 +687,15 @@ if (! class_exists('GADASH_Widgets')) {
727
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "<?php echo $query; ?>",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
728
729
if (!jQuery.isNumeric(response)){
730
gadash_prs=jQuery.parseJSON(response);
731
- google.setOnLoadCallback(ga_dash_drawprs(gadash_prs));
732
}else{
733
jQuery("#gadash-prs").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
734
jQuery("#gadash-prs").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
@@ -739,8 +706,15 @@ if (! class_exists('GADASH_Widgets')) {
739
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "trafficchannels",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
740
741
if (!jQuery.isNumeric(response)){
742
- gadash_trafficchannels=jQuery.parseJSON(response);
743
- google.setOnLoadCallback(ga_dash_drawtrafficchannels(gadash_trafficchannels));
744
}else{
745
jQuery("#gadash-trafficchannels").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
746
jQuery("#gadash-trafficchannels").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
@@ -802,7 +776,7 @@ if (! class_exists('GADASH_Widgets')) {
802
NProgress.configure({ showSpinner: false });
803
NProgress.start();
804
} catch(e) {
805
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border":"1px solid red","border-left":"5px solid red"});
806
jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'ga-dash'); ?>");
807
}
808
npcounter = 0;
@@ -810,8 +784,15 @@ if (! class_exists('GADASH_Widgets')) {
810
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "medium",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
811
812
if (!jQuery.isNumeric(response)){
813
- gadash_trafficmediums=jQuery.parseJSON(response);
814
- google.setOnLoadCallback(ga_dash_drawtrafficmediums(gadash_trafficmediums));
815
}else{
816
jQuery("#gadash-trafficmediums").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
817
jQuery("#gadash-trafficmediums").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
@@ -834,8 +815,15 @@ if (! class_exists('GADASH_Widgets')) {
834
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "trafficchannels",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
835
836
if (!jQuery.isNumeric(response)){
837
- gadash_trafficchannels=jQuery.parseJSON(response);
838
- google.setOnLoadCallback(ga_dash_drawtrafficchannels(gadash_trafficchannels));
839
}else{
840
jQuery("#gadash-trafficchannels").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
841
jQuery("#gadash-trafficchannels").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
@@ -846,8 +834,15 @@ if (! class_exists('GADASH_Widgets')) {
846
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "socialNetwork",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
847
848
if (!jQuery.isNumeric(response)){
849
- gadash_socialnetworks=jQuery.parseJSON(response);
850
- google.setOnLoadCallback(ga_dash_drawsocialnetworks(gadash_socialnetworks));
851
}else{
852
jQuery("#gadash-socialnetworks").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
853
jQuery("#gadash-socialnetworks").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
@@ -859,8 +854,15 @@ if (! class_exists('GADASH_Widgets')) {
859
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "source",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
860
861
if (!jQuery.isNumeric(response)){
862
- gadash_trafficorganic=jQuery.parseJSON(response);
863
- google.setOnLoadCallback(ga_dash_drawtrafficorganic(gadash_trafficorganic));
864
}else{
865
jQuery("#gadash-trafficorganic").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
866
jQuery("#gadash-trafficorganic").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
@@ -966,7 +968,7 @@ if (! class_exists('GADASH_Widgets')) {
966
NProgress.configure({ showSpinner: false });
967
NProgress.start();
968
} catch(e) {
969
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border":"1px solid red","border-left":"5px solid red"});
970
jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'ga-dash'); ?>");
971
}
972
npcounter = 0;
@@ -974,9 +976,16 @@ if (! class_exists('GADASH_Widgets')) {
974
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "<?php echo $query; ?>",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
975
976
if (!jQuery.isNumeric(response)){
977
- gadash_locations=jQuery.parseJSON(response);
978
- google.setOnLoadCallback(ga_dash_drawmaplocations(gadash_locations));
979
- google.setOnLoadCallback(ga_dash_drawlocations(gadash_locations));
980
}else{
981
jQuery("#gadash-map").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
982
jQuery("#gadash-map").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
@@ -994,9 +1003,9 @@ if (! class_exists('GADASH_Widgets')) {
994
chartArea: {width: '99%',height: '90%'},
995
colors: ['<?php echo $light_color; ?>', '<?php echo $dark_color; ?>'],
996
<?php
997
- $GADASH_GAPI->getcountrycodes();
998
- if ($GADASH_Config->options['ga_target_geomap'] and isset($GADASH_GAPI->country_codes[$GADASH_Config->options['ga_target_geomap']])) {
999
- ?>
1000
region : '<?php echo esc_html($GADASH_Config->options ['ga_target_geomap']); ?>',
1001
displayMode : 'markers',
1002
datalessRegionColor : 'EFEFEF'
@@ -1070,7 +1079,7 @@ if (! class_exists('GADASH_Widgets')) {
1070
NProgress.configure({ showSpinner: false });
1071
NProgress.start();
1072
} catch(e) {
1073
- jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border":"1px solid red","border-left":"5px solid red"});
1074
jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'ga-dash'); ?>");
1075
}
1076
npcounter = 0;
@@ -1078,8 +1087,15 @@ if (! class_exists('GADASH_Widgets')) {
1078
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "<?php echo $query; ?>",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
1079
1080
if (!jQuery.isNumeric(response)){
1081
- gadash_mainchart=jQuery.parseJSON(response);
1082
- google.setOnLoadCallback(ga_dash_drawmainchart(gadash_mainchart));
1083
}else{
1084
jQuery("#gadash-mainchart").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
1085
jQuery("#gadash-mainchart").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
@@ -1090,8 +1106,15 @@ if (! class_exists('GADASH_Widgets')) {
1090
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "bottomstats",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
1091
1092
if (!jQuery.isNumeric(response)){
1093
- gadash_bottomstats=jQuery.parseJSON(response);
1094
- ga_dash_drawbottomstats(gadash_bottomstats);
1095
}else{
1096
jQuery("#gadash-bottomstats").css({"background-color":"#F7F7F7","height":"auto","padding-top":"40px","padding-bottom":"40px","color":"#000","text-align":"center","width": "98%"});
1097
jQuery("#gadash-bottomstats").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
@@ -1127,11 +1150,10 @@ if (! class_exists('GADASH_Widgets')) {
1127
};
1128
</script>
1129
<?php
1130
- }
1131
- }
1132
}
1133
}
1134
-
1135
if (is_admin()) {
1136
- $GADASH_Widgets = new GADASH_Widgets();
1137
}
7
*/
8
if (! class_exists('GADASH_Widgets')) {
9
10
+ class GADASH_Widgets
11
+ {
12
13
+ function __construct()
14
+ {
15
+ global $GADASH_Config;
16
+ add_action('wp_dashboard_setup', array(
17
+ $this,
18
+ 'ga_dash_setup'
19
+ ));
20
+ // Admin Styles
21
+ add_action('admin_enqueue_scripts', array(
22
+ $this,
23
+ 'ga_dash_admin_enqueue_styles'
24
+ ));
25
+ // Admin Menu
26
+ add_action('admin_menu', array(
27
+ $this,
28
+ 'ga_dash_admin_actions'
29
+ ));
30
+ // Network Menu
31
+ add_action('network_admin_menu', array(
32
+ $this,
33
+ 'ga_dash_network_actions'
34
+ ));
35
+ // Plugin Settings link
36
+ add_filter("plugin_action_links_" . plugin_basename($GADASH_Config->plugin_path) . '/gadwp.php', array(
37
+ $this,
38
+ 'ga_dash_settings_link'
39
+ ));
40
+ // Add error bubble
41
+ add_action('admin_print_scripts', array(
42
+ $this,
43
+ 'draw_error_bubble'
44
+ ), 10000);
45
+ }
46
47
+ function draw_error_bubble()
48
+ {
49
+ $bubble_msg = '!';
50
+ if (get_transient('ga_dash_gapi_errors')) {
51
+ ?>
52
+ <script type="text/javascript">
53
jQuery(document).ready(function() {
54
jQuery('#toplevel_page_gadash_settings li > a[href*="page=gadash_errors_debugging"]').append('&nbsp;<span class="awaiting-mod count-1"><span class="pending-count" style="padding:0 7px;"><?php echo $bubble_msg ?></span></span>');
55
});
56
</script>
57
+ <?php
58
+ }
59
+ }
60
61
+ function ga_dash_admin_actions()
62
+ {
63
+ global $GADASH_Config;
64
+ global $wp_version;
65
+ if (current_user_can('manage_options')) {
66
+ include ($GADASH_Config->plugin_path . '/admin/ga_dash_settings.php');
67
+ add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_options', 'gadash_settings', array(
68
+ 'GADASH_Settings',
69
+ 'general_settings'
70
+ ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
71
+ add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_options', 'gadash_settings', array(
72
+ 'GADASH_Settings',
73
+ 'general_settings'
74
+ ));
75
+ add_submenu_page('gadash_settings', __("Backend Settings", 'ga-dash'), __("Backend Settings", 'ga-dash'), 'manage_options', 'gadash_backend_settings', array(
76
+ 'GADASH_Settings',
77
+ 'backend_settings'
78
+ ));
79
+ add_submenu_page('gadash_settings', __("Frontend Settings", 'ga-dash'), __("Frontend Settings", 'ga-dash'), 'manage_options', 'gadash_frontend_settings', array(
80
+ 'GADASH_Settings',
81
+ 'frontend_settings'
82
+ ));
83
+ add_submenu_page('gadash_settings', __("Tracking Code", 'ga-dash'), __("Tracking Code", 'ga-dash'), 'manage_options', 'gadash_tracking_settings', array(
84
+ 'GADASH_Settings',
85
+ 'tracking_settings'
86
+ ));
87
+ add_submenu_page('gadash_settings', __("Errors & Debug", 'ga-dash'), __("Errors & Debug", 'ga-dash'), 'manage_options', 'gadash_errors_debugging', array(
88
+ 'GADASH_Settings',
89
+ 'errors_debugging'
90
+ ));
91
+ }
92
+ }
93
94
+ function ga_dash_network_actions()
95
+ {
96
+ global $GADASH_Config;
97
+ global $wp_version;
98
+ if (current_user_can('manage_netwrok')) {
99
+ include ($GADASH_Config->plugin_path . '/admin/ga_dash_settings.php');
100
+ add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
101
+ 'GADASH_Settings',
102
+ 'general_settings_network'
103
+ ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
104
+ add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
105
+ 'GADASH_Settings',
106
+ 'general_settings_network'
107
+ ));
108
+ add_submenu_page('gadash_settings', __("Errors & Debug", 'ga-dash'), __("Errors & Debug", 'ga-dash'), 'manage_network', 'gadash_errors_debugging', array(
109
+ 'GADASH_Settings',
110
+ 'errors_debugging'
111
+ ));
112
+ }
113
+ }
114
115
+ /*
116
+ * Include styles
117
+ */
118
+ function ga_dash_admin_enqueue_styles($hook)
119
+ {
120
+ global $GADASH_Config;
121
+ $valid_hooks = array(
122
+ 'toplevel_page_gadash_settings',
123
+ 'google-analytics_page_gadash_backend_settings',
124
+ 'google-analytics_page_gadash_frontend_settings',
125
+ 'google-analytics_page_gadash_tracking_settings',
126
+ 'google-analytics_page_gadash_errors_debugging'
127
+ );
128
+ if (! in_array($hook, $valid_hooks) and 'index.php' != $hook)
129
+ return;
130
+ wp_enqueue_style('ga_dash-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.css', NULL, GADWP_CURRENT_VERSION);
131
+ wp_register_style('ga_dash', $GADASH_Config->plugin_url . '/admin/css/ga_dash.css', NULL, GADWP_CURRENT_VERSION);
132
+ wp_enqueue_style('ga_dash');
133
+ wp_enqueue_style('wp-color-picker');
134
+ wp_enqueue_script('wp-color-picker');
135
+ wp_enqueue_script('wp-color-picker-script-handle', plugins_url('js/wp-color-picker-script.js', __FILE__), array(
136
+ 'wp-color-picker'
137
+ ), false, true);
138
+ wp_enqueue_script('gadash-general-settings', plugins_url('js/admin.js', __FILE__), array(
139
+ 'jquery'
140
+ ), GADWP_CURRENT_VERSION);
141
+ if (! wp_script_is('googlejsapi')) {
142
+ wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
143
+ wp_enqueue_script('googlejsapi');
144
+ }
145
+ wp_enqueue_script('ga_dash-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.js', array(
146
+ 'jquery'
147
+ ), GADWP_CURRENT_VERSION);
148
+ }
149
150
+ function ga_dash_settings_link($links)
151
+ {
152
+ $settings_link = '<a href="' . get_admin_url(null, 'admin.php?page=gadash_settings') . '">' . __("Settings", 'ga-dash') . '</a>';
153
+ array_unshift($links, $settings_link);
154
+ return $links;
155
+ }
156
157
+ function ga_dash_setup()
158
+ {
159
+ global $GADASH_Config;
160
+ /*
161
+ * Include Tools
162
+ */
163
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
164
+ $tools = new GADASH_Tools();
165
+ if ($tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
166
+ wp_add_dashboard_widget('gadash-widget', __("Google Analytics Dashboard", 'ga-dash'), array(
167
+ $this,
168
+ 'gadash_dashboard_widgets'
169
+ ), $control_callback = null);
170
+ }
171
+ }
172
173
+ function gadash_dashboard_widgets()
174
+ {
175
+ global $GADASH_Config;
176
+ /*
177
+ * Include GAPI
178
+ */
179
+ if ($GADASH_Config->options['ga_dash_token']) {
180
+ include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
181
+ global $GADASH_GAPI;
182
+ } else {
183
+ echo '<p>' . __("This plugin needs an authorization:", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Authorize Plugin", 'ga-dash'), 'secondary') . '</form>';
184
+ return;
185
+ }
186
+ /*
187
+ * Include Tools
188
+ */
189
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
190
+ $tools = new GADASH_Tools();
191
+ if (current_user_can('manage_options')) {
192
+ if (isset($_REQUEST['ga_dash_profile_select'])) {
193
+ $GADASH_Config->options['ga_dash_tableid'] = $_REQUEST['ga_dash_profile_select'];
194
+ }
195
+ $profiles = $GADASH_Config->options['ga_dash_profile_list'];
196
+ $profile_switch = '';
197
+ if (is_array($profiles)) {
198
+ if (! $GADASH_Config->options['ga_dash_tableid']) {
199
+ if ($GADASH_Config->options['ga_dash_tableid_jail']) {
200
+ $GADASH_Config->options['ga_dash_tableid'] = $GADASH_Config->options['ga_dash_tableid_jail'];
201
} else {
202
+ $GADASH_Config->options['ga_dash_tableid'] = $tools->guess_default_domain($profiles);
203
}
204
+ } else
205
+ if ($GADASH_Config->options['ga_dash_jailadmins'] and $GADASH_Config->options['ga_dash_tableid_jail']) {
206
+ $GADASH_Config->options['ga_dash_tableid'] = $GADASH_Config->options['ga_dash_tableid_jail'];
207
}
208
+ $profile_switch .= '<select id="ga_dash_profile_select" name="ga_dash_profile_select" onchange="this.form.submit()">';
209
+ foreach ($profiles as $profile) {
210
+ if (! $GADASH_Config->options['ga_dash_tableid']) {
211
+ $GADASH_Config->options['ga_dash_tableid'] = $profile[1];
212
}
213
+ if (isset($profile[3])) {
214
+ $profile_switch .= '<option value="' . esc_attr($profile[1]) . '" ';
215
+ $profile_switch .= selected($profile[1], $GADASH_Config->options['ga_dash_tableid'], false);
216
+ $profile_switch .= ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($profile[0]) . '">' . esc_attr($tools->ga_dash_get_profile_domain($profile[3])) . '</option>';
217
}
218
+ }
219
+ $profile_switch .= "</select>";
220
+ } else {
221
+ echo '<p>' . __("Something went wrong while retrieving profiles list.", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("More details", 'ga-dash'), 'secondary') . '</form>';
222
+ return;
223
+ }
224
+ }
225
+ $GADASH_Config->set_plugin_options();
226
+ ?>
227
+ <form id="ga-dash" method="POST">
228
+ <?php
229
+ if (current_user_can('manage_options')) {
230
+ if ($GADASH_Config->options['ga_dash_jailadmins']) {
231
+ if ($GADASH_Config->options['ga_dash_tableid_jail']) {
232
+ $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
233
+ } else {
234
+ echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'ga-dash'), 'secondary') . '</form>';
235
+ return;
236
+ }
237
+ } else {
238
+ echo $profile_switch;
239
+ $projectId = $GADASH_Config->options['ga_dash_tableid'];
240
+ }
241
+ } else {
242
+ if ($GADASH_Config->options['ga_dash_tableid_jail']) {
243
+ $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
244
+ } else {
245
+ echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'ga-dash'), 'secondary') . '</form>';
246
+ return;
247
+ }
248
+ }
249
+ if (! ($projectId)) {
250
+ echo '<p>' . __("Something went wrong while retrieving property data. You need to create and properly configure a Google Analytics account:", 'ga-dash') . '</p> <form action="https://deconf.com/how-to-set-up-google-analytics-on-your-website/" method="POST">' . get_submit_button(__("Find out more!", 'ga-dash'), 'secondary') . '</form>';
251
+ return;
252
+ } else {
253
+ $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
254
+ if (isset($profile_info[4])) {
255
+ $GADASH_GAPI->timeshift = $profile_info[4];
256
+ } else {
257
+ $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
258
+ }
259
+ }
260
+ if (isset($_REQUEST['query'])) {
261
+ $query = $_REQUEST['query'];
262
+ $GADASH_Config->options['ga_dash_default_metric'] = $query;
263
+ $GADASH_Config->set_plugin_options();
264
+ } else {
265
+ $query = isset($GADASH_Config->options['ga_dash_default_metric']) ? $GADASH_Config->options['ga_dash_default_metric'] : 'sessions';
266
+ }
267
+ if (isset($_REQUEST['period'])) {
268
+ $period = $_REQUEST['period'];
269
+ $GADASH_Config->options['ga_dash_default_dimension'] = $period;
270
+ $GADASH_Config->set_plugin_options();
271
+ } else {
272
+ $period = isset($GADASH_Config->options['ga_dash_default_dimension']) ? $GADASH_Config->options['ga_dash_default_dimension'] : '30daysAgo';
273
+ }
274
+ ?>
275
276
<select id="ga_dash_period" name="period" onchange="this.form.submit()">
277
<option value="realtime"
315
</form>
316
<div id="gadash-progressbar"></div>
317
<?php
318
+ switch ($period) {
319
+ case 'today':
320
+ $from = 'today';
321
+ $to = 'today';
322
+ $haxis = 4;
323
+ break;
324
+ case 'yesterday':
325
+ $from = 'yesterday';
326
+ $to = 'yesterday';
327
+ $haxis = 4;
328
+ break;
329
+ case '7daysAgo':
330
+ $from = '7daysAgo';
331
+ $to = 'yesterday';
332
+ $haxis = 2;
333
+ break;
334
+ case '14daysAgo':
335
+ $from = '14daysAgo';
336
+ $to = 'yesterday';
337
+ $haxis = 3;
338
+ break;
339
+ case '30daysAgo':
340
+ $from = '30daysAgo';
341
+ $to = 'yesterday';
342
+ $haxis = 5;
343
+ break;
344
+ default:
345
+ $from = '90daysAgo';
346
+ $to = 'yesterday';
347
+ $haxis = 16;
348
+ break;
349
+ }
350
+ if ($query == 'visitBounceRate') {
351
+ $formater = "var formatter = new google.visualization.NumberFormat({
352
pattern: '#,##%',
353
fractionDigits: 2
354
});
355
356
formatter.format(data, 1); ";
357
+ } else {
358
+ $formater = '';
359
+ }
360
+ /*
361
+ * Include Tools
362
+ */
363
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
364
+ $tools = new GADASH_Tools();
365
+ if (isset($GADASH_Config->options['ga_dash_style'])) {
366
+ $light_color = $tools->colourVariator($GADASH_Config->options['ga_dash_style'], 40);
367
+ $dark_color = $tools->colourVariator($GADASH_Config->options['ga_dash_style'], - 20);
368
+ $css = "colors:['" . $GADASH_Config->options['ga_dash_style'] . "','" . $tools->colourVariator($GADASH_Config->options['ga_dash_style'], - 20) . "'],";
369
+ $color = $GADASH_Config->options['ga_dash_style'];
370
+ } else {
371
+ $css = "";
372
+ $color = "#3366CC";
373
+ }
374
+ if ($period == 'realtime') {
375
+ wp_register_style('jquery-ui-tooltip-html', $GADASH_Config->plugin_url . '/realtime/jquery/jquery.ui.tooltip.html.css');
376
+ wp_enqueue_style('jquery-ui-tooltip-html');
377
+ if (! wp_script_is('jquery')) {
378
+ wp_enqueue_script('jquery');
379
+ }
380
+ if (! wp_script_is('jquery-ui-tooltip')) {
381
+ wp_enqueue_script("jquery-ui-tooltip");
382
+ }
383
+ if (! wp_script_is('jquery-ui-core')) {
384
+ wp_enqueue_script("jquery-ui-core");
385
+ }
386
+ if (! wp_script_is('jquery-ui-position')) {
387
+ wp_enqueue_script("jquery-ui-position");
388
+ }
389
+ if (! wp_script_is('jquery-ui-position')) {
390
+ wp_enqueue_script("jquery-ui-position");
391
+ }
392
+ wp_register_script("jquery-ui-tooltip-html", $GADASH_Config->plugin_url . '/realtime/jquery/jquery.ui.tooltip.html.js');
393
+ wp_enqueue_script("jquery-ui-tooltip-html");
394
+ }
395
+ if ($period == 'realtime') {
396
+ ?>
397
<div class="realtime">
398
<div class="gadash-rt-box">
399
<div class='gadash-tdo-left'>
679
NProgress.configure({ showSpinner: false });
680
NProgress.start();
681
} catch(e) {
682
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
683
jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'ga-dash'); ?>");
684
}
685
npcounter = 0;
687
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "<?php echo $query; ?>",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
688
689
if (!jQuery.isNumeric(response)){
690
+ try{
691
gadash_prs=jQuery.parseJSON(response);
692
+ google.setOnLoadCallback(ga_dash_drawprs(gadash_prs));
693
+ } catch(e) {
694
+ checknpcounter(0);
695
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
696
+ jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'); ?>");
697
+ console.log("\n********************* GADWP Log ********************* \n\n"+response);
698
+ }
699
}else{
700
jQuery("#gadash-prs").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
701
jQuery("#gadash-prs").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
706
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "trafficchannels",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
707
708
if (!jQuery.isNumeric(response)){
709
+ try{
710
+ gadash_trafficchannels=jQuery.parseJSON(response);
711
+ google.setOnLoadCallback(ga_dash_drawtrafficchannels(gadash_trafficchannels));
712
+ } catch(e) {
713
+ checknpcounter(0);
714
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
715
+ jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'); ?>");
716
+ console.log("\n********************* GADWP Log ********************* \n\n"+response);
717
+ }
718
}else{
719
jQuery("#gadash-trafficchannels").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
720
jQuery("#gadash-trafficchannels").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
776
NProgress.configure({ showSpinner: false });
777
NProgress.start();
778
} catch(e) {
779
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
780
jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'ga-dash'); ?>");
781
}
782
npcounter = 0;
784
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "medium",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
785
786
if (!jQuery.isNumeric(response)){
787
+ try{
788
+ gadash_trafficmediums=jQuery.parseJSON(response);
789
+ google.setOnLoadCallback(ga_dash_drawtrafficmediums(gadash_trafficmediums));
790
+ } catch(e) {
791
+ checknpcounter(0);
792
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
793
+ jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'); ?>");
794
+ console.log("\n********************* GADWP Log ********************* \n\n"+response);
795
+ }
796
}else{
797
jQuery("#gadash-trafficmediums").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
798
jQuery("#gadash-trafficmediums").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
815
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "trafficchannels",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
816
817
if (!jQuery.isNumeric(response)){
818
+ try{
819
+ gadash_trafficchannels=jQuery.parseJSON(response);
820
+ google.setOnLoadCallback(ga_dash_drawtrafficchannels(gadash_trafficchannels));
821
+ } catch(e) {
822
+ checknpcounter(0);
823
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
824
+ jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'); ?>");
825
+ console.log("\n********************* GADWP Log ********************* \n\n"+response);
826
+ }
827
}else{
828
jQuery("#gadash-trafficchannels").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
829
jQuery("#gadash-trafficchannels").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
834
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "socialNetwork",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
835
836
if (!jQuery.isNumeric(response)){
837
+ try{
838
+ gadash_socialnetworks=jQuery.parseJSON(response);
839
+ google.setOnLoadCallback(ga_dash_drawsocialnetworks(gadash_socialnetworks));
840
+ } catch(e) {
841
+ checknpcounter(0);
842
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
843
+ jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'); ?>");
844
+ console.log("\n********************* GADWP Log ********************* \n\n"+response);
845
+ }
846
}else{
847
jQuery("#gadash-socialnetworks").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
848
jQuery("#gadash-socialnetworks").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
854
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "source",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
855
856
if (!jQuery.isNumeric(response)){
857
+ try{
858
+ gadash_trafficorganic=jQuery.parseJSON(response);
859
+ google.setOnLoadCallback(ga_dash_drawtrafficorganic(gadash_trafficorganic));
860
+ } catch(e) {
861
+ checknpcounter(0);
862
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
863
+ jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'); ?>");
864
+ console.log("\n********************* GADWP Log ********************* \n\n"+response);
865
+ }
866
}else{
867
jQuery("#gadash-trafficorganic").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
868
jQuery("#gadash-trafficorganic").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
968
NProgress.configure({ showSpinner: false });
969
NProgress.start();
970
} catch(e) {
971
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
972
jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'ga-dash'); ?>");
973
}
974
npcounter = 0;
976
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "<?php echo $query; ?>",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
977
978
if (!jQuery.isNumeric(response)){
979
+ try{
980
+ gadash_locations=jQuery.parseJSON(response);
981
+ google.setOnLoadCallback(ga_dash_drawmaplocations(gadash_locations));
982
+ google.setOnLoadCallback(ga_dash_drawlocations(gadash_locations));
983
+ } catch(e) {
984
+ checknpcounter(0);
985
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
986
+ jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'); ?>");
987
+ console.log("\n********************* GADWP Log ********************* \n\n"+response);
988
+ }
989
}else{
990
jQuery("#gadash-map").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
991
jQuery("#gadash-map").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
1003
chartArea: {width: '99%',height: '90%'},
1004
colors: ['<?php echo $light_color; ?>', '<?php echo $dark_color; ?>'],
1005
<?php
1006
+ $GADASH_GAPI->getcountrycodes();
1007
+ if ($GADASH_Config->options['ga_target_geomap'] and isset($GADASH_GAPI->country_codes[$GADASH_Config->options['ga_target_geomap']])) {
1008
+ ?>
1009
region : '<?php echo esc_html($GADASH_Config->options ['ga_target_geomap']); ?>',
1010
displayMode : 'markers',
1011
datalessRegionColor : 'EFEFEF'
1079
NProgress.configure({ showSpinner: false });
1080
NProgress.start();
1081
} catch(e) {
1082
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
1083
jQuery("#gadash-progressbar").html("<?php _e("A JavaScript Error is blocking plugin resources!", 'ga-dash'); ?>");
1084
}
1085
npcounter = 0;
1087
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "<?php echo $query; ?>",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
1088
1089
if (!jQuery.isNumeric(response)){
1090
+ try{
1091
+ gadash_mainchart=jQuery.parseJSON(response);
1092
+ google.setOnLoadCallback(ga_dash_drawmainchart(gadash_mainchart));
1093
+ } catch(e) {
1094
+ checknpcounter(0);
1095
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
1096
+ jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'); ?>");
1097
+ console.log("\n********************* GADWP Log ********************* \n\n"+response);
1098
+ }
1099
}else{
1100
jQuery("#gadash-mainchart").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
1101
jQuery("#gadash-mainchart").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
1106
jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "bottomstats",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
1107
1108
if (!jQuery.isNumeric(response)){
1109
+ try{
1110
+ gadash_bottomstats=jQuery.parseJSON(response);
1111
+ ga_dash_drawbottomstats(gadash_bottomstats);
1112
+ } catch(e) {
1113
+ checknpcounter(0);
1114
+ jQuery("#gadash-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red"});
1115
+ jQuery("#gadash-progressbar").html("<?php _e("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'); ?>");
1116
+ console.log("\n********************* GADWP Log ********************* \n\n"+response);
1117
+ }
1118
}else{
1119
jQuery("#gadash-bottomstats").css({"background-color":"#F7F7F7","height":"auto","padding-top":"40px","padding-bottom":"40px","color":"#000","text-align":"center","width": "98%"});
1120
jQuery("#gadash-bottomstats").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
1150
};
1151
</script>
1152
<?php
1153
+ }
1154
}
1155
+ }
1156
}
1157
if (is_admin()) {
1158
+ $GADASH_Widgets = new GADASH_Widgets();
1159
}
admin/ga_dash_settings.php CHANGED
@@ -9,86 +9,86 @@
9
final class GADASH_Settings
10
{
11
12
- private static function set_get_options($who)
13
- {
14
- global $GADASH_Config;
15
- $network_settings = false;
16
- $options = $GADASH_Config->options; // Get current options
17
- if (isset($_POST['options']['ga_dash_hidden']) and isset($_POST['options']) and (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) and $who != 'Reset') {
18
- $new_options = $_POST['options'];
19
- if ($who == 'tracking') {
20
- $options['ga_dash_anonim'] = 0;
21
- $options['ga_event_tracking'] = 0;
22
- $options['ga_enhanced_links'] = 0;
23
- $options['ga_dash_remarketing'] = 0;
24
- $options['ga_dash_adsense'] = 0;
25
- $options['ga_event_bouncerate'] = 0;
26
- $options['ga_crossdomain_tracking'] = 0;
27
- $options['ga_aff_tracking'] = 0;
28
- $options['ga_hash_tracking'] = 0;
29
- if (isset($_POST['options']['ga_tracking_code'])) {
30
- $new_options['ga_tracking_code'] = trim($new_options['ga_tracking_code'], "\t");
31
- }
32
- if (empty($new_options['ga_track_exclude'])) {
33
- $new_options['ga_track_exclude'] = array();
34
- }
35
- } else
36
- if ($who == 'backend') {
37
- $options['ga_dash_jailadmins'] = 0;
38
- if (empty($new_options['ga_dash_access_back'])) {
39
- $new_options['ga_dash_access_back'][] = 'administrator';
40
- }
41
- } else
42
- if ($who == 'frontend') {
43
- $options['ga_dash_frontend_stats'] = 0;
44
- $options['ga_dash_frontend_keywords'] = 0;
45
- if (empty($new_options['ga_dash_access_front'])) {
46
- $new_options['ga_dash_access_front'][] = 'administrator';
47
- }
48
- } else
49
- if ($who == 'general') {
50
- $options['ga_dash_userapi'] = 0;
51
- } else
52
- if ($who == 'network') {
53
- $options['ga_dash_userapi'] = 0;
54
- $options['ga_dash_network'] = 0;
55
- $options['ga_dash_excludesa'] = 0;
56
- $network_settings = true;
57
- }
58
- $options = array_merge($options, $new_options);
59
- $GADASH_Config->options = $options;
60
- $GADASH_Config->set_plugin_options($network_settings);
61
}
62
- return $options;
63
}
64
65
- private static function navigation_tabs($tabs)
66
- {
67
- echo '<div id="icon-themes" class="icon32"><br></div>';
68
- echo '<h2 class="nav-tab-wrapper">';
69
- foreach ($tabs as $tab => $name) {
70
- echo "<a class='nav-tab' id='tab-$tab' href='#top#gadwp-$tab'>$name</a>";
71
- }
72
- echo '</h2>';
73
}
74
75
- public static function frontend_settings()
76
- {
77
- global $GADASH_Config;
78
- if (! current_user_can('manage_options')) {
79
- return;
80
- }
81
- $options = self::set_get_options('frontend');
82
- if (isset($_POST['options']['ga_dash_hidden'])) {
83
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
84
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
85
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
86
- }
87
- }
88
- if (! $GADASH_Config->options['ga_dash_tableid_jail'] or ! $GADASH_Config->options['ga_dash_token']) {
89
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash'). "</a> " .__('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
90
- }
91
- ?>
92
<form name="ga_dash_form" method="post"
93
action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
94
<div class="wrap">
@@ -108,18 +108,17 @@ final class GADASH_Settings
108
<td class="roles title"><label for="ga_dash_access_front"><?php _e("Show stats to:", 'ga-dash' ); ?></label></td>
109
<td class="roles">
110
<?php
111
- if (! isset($wp_roles)) {
112
- $wp_roles = new WP_Roles();
113
- }
114
- $i = 0;
115
- ?>
116
- <table>
117
<tr>
118
- <?php
119
- foreach ($wp_roles->role_names as $role => $name) {
120
- if ($role != 'subscriber') {
121
- $i ++;
122
- ?>
123
<td><label> <input
124
type="checkbox" name="options[ga_dash_access_front][]"
125
value="<?php echo $role; ?>"
@@ -127,16 +126,15 @@ final class GADASH_Settings
127
<?php echo $name; ?>
128
</label></td>
129
<?php
130
- }
131
- if ($i % 4 == 0) {
132
- ?>
133
</tr>
134
<tr>
135
<?php
136
- }
137
- }
138
- ?>
139
- </table>
140
</td>
141
</tr>
142
<tr>
@@ -180,29 +178,28 @@ final class GADASH_Settings
180
</tr>
181
</table>
182
<input type="hidden" name="options[ga_dash_hidden]" value="Y">
183
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
184
- </form>
185
<?php
186
- self::output_sidebar();
187
- }
188
189
- public static function backend_settings()
190
- {
191
- global $GADASH_Config;
192
- if (! current_user_can('manage_options')) {
193
- return;
194
- }
195
- $options = self::set_get_options('backend');
196
- if (isset($_POST['options']['ga_dash_hidden'])) {
197
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
198
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
199
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
200
- }
201
- }
202
- if (! $GADASH_Config->options['ga_dash_tableid_jail'] or ! $GADASH_Config->options['ga_dash_token']) {
203
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash'). "</a> " .__('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
204
- }
205
- ?>
206
<form name="ga_dash_form" method="post"
207
action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
208
<div class="wrap">
@@ -222,18 +219,18 @@ final class GADASH_Settings
222
<td class="roles title"><label for="ga_dash_access_back"><?php _e("Show stats to:", 'ga-dash' ); ?></label></td>
223
<td class="roles">
224
<?php
225
- if (! isset($wp_roles)) {
226
- $wp_roles = new WP_Roles();
227
- }
228
- $i = 0;
229
- ?>
230
<table>
231
<tr>
232
<?php
233
- foreach ($wp_roles->role_names as $role => $name) {
234
- if ($role != 'subscriber') {
235
- $i ++;
236
- ?>
237
<td><label> <input
238
type="checkbox" name="options[ga_dash_access_back][]"
239
value="<?php echo $role; ?>"
@@ -241,16 +238,15 @@ final class GADASH_Settings
241
<?php echo $name; ?>
242
</label></td>
243
<?php
244
- }
245
- if ($i % 4 == 0) {
246
- ?>
247
</tr>
248
<tr>
249
<?php
250
- }
251
- }
252
- ?>
253
- </table>
254
</td>
255
</tr>
256
<tr>
@@ -310,60 +306,56 @@ final class GADASH_Settings
310
</tr>
311
</table>
312
<input type="hidden" name="options[ga_dash_hidden]" value="Y">
313
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
314
- </form>
315
<?php
316
- self::output_sidebar();
317
- }
318
319
- public static function tracking_settings()
320
- {
321
- global $GADASH_Config;
322
- /*
323
- * Include Tools
324
- */
325
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
326
- $tools = new GADASH_Tools();
327
- if (! current_user_can('manage_options')) {
328
- return;
329
- }
330
- $options = self::set_get_options('tracking');
331
- if (isset($_POST['options']['ga_dash_hidden'])) {
332
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
333
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
334
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
335
- }
336
- }
337
- if (! $GADASH_Config->options['ga_dash_tableid_jail']) {
338
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash'). "</a> " .__('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
339
- }
340
-
341
- if (!$options['ga_dash_tracking']) {
342
- $message = "<div class='error'><p>" . __("The tracking component is disabled. You should set",'ga-dash')." <strong>". __("Tracking Options",'ga-dash')."</strong> " .__("to",'ga-dash')." <strong>".__("Enabled", 'ga-dash') . "</strong>.</p></div>";
343
- }
344
-
345
- ?>
346
<form name="ga_dash_form" method="post"
347
action="<?php esc_url($_SERVER['REQUEST_URI']); ?>">
348
<div class="wrap">
349
<?php echo "<h2>" . __( "Google Analytics Tracking Code", 'ga-dash' ) . "</h2>"; ?>
350
</div>
351
-
352
<div id="poststuff">
353
<div id="post-body" class="metabox-holder columns-2">
354
<div id="post-body-content">
355
<div class="settings-wrapper">
356
<div class="inside">
357
<?php
358
- $tabs = array(
359
- 'basic' => __("Basic Settings", 'ga-dash'),
360
- 'events' => __("Events Tracking", 'ga-dash'),
361
- 'custom' => __("Custom Definitions", 'ga-dash'),
362
- 'exclude' => __("Exclude Tracking", 'ga-dash'),
363
- 'advanced' => __("Advanced Settings", 'ga-dash')
364
- );
365
- self::navigation_tabs($tabs);
366
- ?>
367
<?php if (isset($message)) echo $message; ?>
368
<div id="gadwp-basic">
369
<table class="options">
@@ -384,15 +376,14 @@ final class GADASH_Settings
384
<tr>
385
<td class="title"></td>
386
<td><?php
387
- $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $GADASH_Config->options['ga_dash_tableid_jail']);
388
- echo '<pre>' . __("View Name:", 'ga-dash') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'ga-dash') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'ga-dash') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'ga-dash') . "\t" . esc_html($profile_info[5]) . '</pre>';
389
- ?></td>
390
</tr>
391
<?php }?>
392
<tr>
393
<td colspan="2"><hr><?php echo "<h2>" . __( "Basic Tracking", 'ga-dash' ) . "</h2>"; ?></td>
394
</tr>
395
-
396
<tr>
397
<td class="title"><label for="ga_dash_tracking_type"><?php _e("Tracking Type:", 'ga-dash' ); ?></label></td>
398
<td><select id="ga_dash_tracking_type"
@@ -635,16 +626,16 @@ final class GADASH_Settings
635
<td class="roles title"><label for="ga_track_exclude"><?php _e("Exclude tracking for:", 'ga-dash' ); ?></label></td>
636
<td class="roles">
637
<?php
638
- if (! isset($wp_roles)) {
639
- $wp_roles = new WP_Roles();
640
- }
641
- $i = 0;
642
- ?> <table>
643
<tr>
644
<?php
645
- foreach ($wp_roles->role_names as $role => $name) {
646
- $i ++;
647
- ?>
648
<td><label> <input type="checkbox"
649
name="options[ga_track_exclude][]"
650
value="<?php echo $role; ?>"
@@ -652,14 +643,14 @@ final class GADASH_Settings
652
<?php echo $name; ?>
653
</label></td>
654
<?php
655
- if ($i % 4 == 0) {
656
- ?>
657
</tr>
658
<tr>
659
<?php
660
- }
661
- }
662
- ?>
663
</table>
664
</td>
665
</tr>
@@ -676,25 +667,22 @@ final class GADASH_Settings
676
</tr>
677
</table>
678
<input type="hidden" name="options[ga_dash_hidden]" value="Y">
679
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
680
- </form>
681
<?php
682
- self::output_sidebar();
683
- }
684
-
685
- public static function errors_debugging()
686
- {
687
- global $GADASH_Config;
688
- if (! current_user_can('manage_options')) {
689
- return;
690
- }
691
- $options = self::set_get_options('frontend');
692
-
693
- if (! $GADASH_Config->options['ga_dash_tableid_jail'] or ! $GADASH_Config->options['ga_dash_token']) {
694
- $message = "<div class='error'><p><strong>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash'). "</a> " .__('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
695
- }
696
- ?>
697
698
<div class="wrap">
699
<?php echo "<h2>" . __( "Google Analytics Errors & Debugging", 'ga-dash' ) . "</h2>"; ?>
700
</div>
@@ -705,29 +693,29 @@ final class GADASH_Settings
705
<div class="inside">
706
<?php if (isset($message)) echo $message; ?>
707
<?php
708
- $tabs = array(
709
- 'errors' => __("Errors & Details", 'ga-dash'),
710
- 'config' => __("Plugin Settings", 'ga-dash')
711
- );
712
- self::navigation_tabs($tabs);
713
- ?>
714
<div id="gadwp-errors">
715
<table class="options">
716
<tr>
717
<td>
718
<?php echo __("For errors and/or other issues please check",'ga-dash')." <a href='https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=errors_screen&utm_campaign=gadwp' target='_blank'>". __("the plugin documentation page",'ga-dash')."</a> ".__("and related tutorials",'ga-dash').".";?>
719
</td>
720
- </tr>
721
<tr>
722
<td><?php echo "<h2>" . __( "Last Error detected", 'ga-dash' ) . "</h2>"; ?></td>
723
</tr>
724
<tr>
725
<td>
726
<?php
727
- $errors = esc_html(print_r(get_transient('gadash_lasterror'), true)) ? esc_html(print_r(get_transient('gadash_lasterror'), true)) : __("None", 'ga-dash');
728
- echo '<pre class="log_data">Last Error: ';
729
- echo $errors;
730
- ?></pre>
731
</td>
732
</tr>
733
<tr>
@@ -736,14 +724,12 @@ final class GADASH_Settings
736
<tr>
737
<td>
738
<?php
739
- echo '<pre class="log_data">Error Details: ';
740
- $error_details = esc_html(print_r(get_transient('ga_dash_gapi_errors'), true)) ? "\n" . esc_html(print_r(get_transient('ga_dash_gapi_errors'), true)) : __("None", 'ga-dash');
741
- echo $error_details;
742
- ?></pre><br />
743
<hr>
744
</td>
745
-
746
-
747
<tr>
748
749
</table>
@@ -755,139 +741,135 @@ final class GADASH_Settings
755
</tr>
756
<tr>
757
<td><pre class="log_data"><?php
758
- $anonim = $GADASH_Config->options;
759
- $anonim['wp_version'] = $wp_version;
760
- $anonim['gadwp_version'] = GADWP_CURRENT_VERSION;
761
- if ($anonim['ga_dash_token']) {
762
- $anonim['ga_dash_token'] = 'HIDDEN';
763
- }
764
- if ($anonim['ga_dash_refresh_token']) {
765
- $anonim['ga_dash_refresh_token'] = 'HIDDEN';
766
- }
767
- if ($anonim['ga_dash_clientid']) {
768
- $anonim['ga_dash_clientid'] = 'HIDDEN';
769
- }
770
- if ($anonim['ga_dash_clientsecret']) {
771
- $anonim['ga_dash_clientsecret'] = 'HIDDEN';
772
- }
773
- if ($anonim['ga_dash_apikey']) {
774
- $anonim['ga_dash_apikey'] = 'HIDDEN';
775
- }
776
- echo esc_html(print_r($anonim, true));
777
- ?></pre><br />
778
- <hr></td>
779
</tr>
780
</table>
781
</div>
782
-
783
<?php
784
- self::output_sidebar();
785
- }
786
787
- public static function general_settings()
788
- {
789
- global $GADASH_Config;
790
- global $wp_version;
791
- /*
792
- * Include Tools
793
- */
794
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
795
- $tools = new GADASH_Tools();
796
- if (! current_user_can('manage_options')) {
797
- return;
798
- }
799
- $options = self::set_get_options('general');
800
- /*
801
- * Include GAPI
802
- */
803
- 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:', "ga-dash") . ' <a href="https://deconf.com/ask/question/ga-dashboard-absolutely-empty-general-settings#answer-770">Library conflicts between WordPress plugins</a></p></div>';
804
- include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
805
- global $GADASH_GAPI;
806
- echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
807
- if (isset($_POST['ga_dash_code'])) {
808
- if (! stripos('x' . $_POST['ga_dash_code'], 'UA-', 1) == 1) {
809
- try {
810
- $GADASH_GAPI->client->authenticate($_POST['ga_dash_code']);
811
- $GADASH_Config->options['ga_dash_token'] = $GADASH_GAPI->client->getAccessToken();
812
- $google_token = json_decode($GADASH_GAPI->client->getAccessToken());
813
- $GADASH_Config->options['ga_dash_refresh_token'] = $google_token->refresh_token;
814
- $GADASH_Config->set_plugin_options();
815
- $message = "<div class='updated'><p>" . __("Plugin authorization succeeded.", 'ga-dash') . "</p></div>";
816
- $options = self::set_get_options('general');
817
- delete_transient('ga_dash_gapi_errors');
818
- } catch (Google_IO_Exception $e) {
819
- set_transient('gadash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e), $GADASH_GAPI->error_timeout);
820
- return false;
821
- } catch (Google_Service_Exception $e) {
822
- set_transient('gadash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html("(" . $e->getCode() . ") " . $e->getMessage()), $GADASH_GAPI->error_timeout);
823
- set_transient('ga_dash_gapi_errors', $e->getErrors(), $GADASH_GAPI->error_timeout);
824
- return $e->getCode();
825
- } catch (Exception $e) {
826
- set_transient('gadash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e) . "\nResponseHttpCode:" . $e->getCode(), $GADASH_GAPI->error_timeout);
827
- $GADASH_GAPI->ga_dash_reset_token(false);
828
- }
829
- } else {
830
- $message = "<div class='error'><p>" . __("The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'ga-dash') . ".</p></div>";
831
- }
832
- }
833
-
834
- if ($GADASH_GAPI->client->getAccessToken()) {
835
- if ($GADASH_Config->options['ga_dash_profile_list']) {
836
- $profiles = $GADASH_Config->options['ga_dash_profile_list'];
837
- } else {
838
- $profiles = $GADASH_GAPI->refresh_profiles();
839
- }
840
- if ($profiles) {
841
- $GADASH_Config->options['ga_dash_profile_list'] = $profiles;
842
- if (! $GADASH_Config->options['ga_dash_tableid_jail']) {
843
- $profile = $tools->guess_default_domain($profiles);
844
- $GADASH_Config->options['ga_dash_tableid_jail'] = $profile;
845
- $GADASH_Config->options['ga_dash_tableid'] = $profile;
846
- }
847
- $GADASH_Config->set_plugin_options();
848
- $options = self::set_get_options('general');
849
- }
850
- }
851
-
852
- if (isset($_POST['Clear'])) {
853
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
854
- $tools->ga_dash_clear_cache();
855
- $message = "<div class='updated'><p>" . __("Cleared Cache.", 'ga-dash') . "</p></div>";
856
- } else {
857
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
858
- }
859
- }
860
- if (isset($_POST['Reset'])) {
861
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
862
- $GADASH_GAPI->ga_dash_reset_token(true);
863
- $tools->ga_dash_clear_cache();
864
- $message = "<div class='updated'><p>" . __("Token Reseted and Revoked.", 'ga-dash') . "</p></div>";
865
- $options = self::set_get_options('Reset');
866
- } else {
867
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
868
- }
869
- }
870
-
871
- if (isset($_POST['options']['ga_dash_hidden']) and ! isset($_POST['Clear']) and ! isset($_POST['Reset'])) {
872
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
873
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
874
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
875
- }
876
}
877
- if (isset($_POST['Hide'])) {
878
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
879
- $message = "<div class='updated'><p>" . __("All other domains/properties were removed.", 'ga-dash') . "</p></div>";
880
- $lock_profile = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $GADASH_Config->options['ga_dash_tableid_jail']);
881
- $GADASH_Config->options['ga_dash_profile_list'] = array(
882
- $lock_profile
883
- );
884
- $options = self::set_get_options('general');
885
- } else {
886
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
887
- }
888
}
889
-
890
- ?>
891
<div class="wrap">
892
<?php echo "<h2>" . __( "Google Analytics Settings", 'ga-dash' ) . "</h2>"; ?><hr>
893
</div>
@@ -896,19 +878,17 @@ final class GADASH_Settings
896
<div id="post-body-content">
897
<div class="settings-wrapper">
898
<div class="inside">
899
-
900
- if ($GADASH_GAPI->gapi_errors_handler()) {
901
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash'). "</a> " .__('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
902
- }
903
-
904
- if (isset($_POST['Authorize'])) {
905
- $tools->ga_dash_clear_cache();
906
- $GADASH_GAPI->token_request();
907
- echo "<div class='updated'><p>" . __("Use the red link (see below) to generate and get your access code!", 'ga-dash') . "</p></div>";
908
- } else {
909
- if (isset($message))
910
- echo $message;
911
- ?>
912
<form name="ga_dash_form" method="post"
913
action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
914
<input type="hidden" name="options[ga_dash_hidden]" value="Y">
@@ -923,8 +903,8 @@ final class GADASH_Settings
923
</td>
924
</tr>
925
<?php
926
- if (! $options['ga_dash_token'] or $options['ga_dash_userapi']) {
927
- ?>
928
<tr>
929
<td colspan="2" class="info"><input
930
name="options[ga_dash_userapi]" type="checkbox"
@@ -934,9 +914,9 @@ final class GADASH_Settings
934
<?php echo ($options['ga_dash_network'])?'disabled="disabled"':''; ?> /><?php _e ( " use your own API Project credentials", 'ga-dash' );?>
935
</td>
936
</tr>
937
- }
938
- if ($options['ga_dash_userapi']) {
939
- ?>
940
<tr>
941
<td class="title"><label for="options[ga_dash_apikey]"><?php _e("API Key:", 'ga-dash'); ?></label>
942
</td>
@@ -963,11 +943,11 @@ final class GADASH_Settings
963
</td>
964
</tr>
965
<?php
966
- }
967
- ?>
968
<?php
969
- if ($options['ga_dash_token']) {
970
- ?>
971
<tr>
972
<td colspan="2"><input type="submit" name="Reset"
973
class="button button-secondary"
@@ -989,41 +969,41 @@ final class GADASH_Settings
989
<?php disabled(is_array($options['ga_dash_profile_list']), false); ?>
990
name="options[ga_dash_tableid_jail]">
991
<?php
992
- if (is_array($options['ga_dash_profile_list'])) {
993
- foreach ($options['ga_dash_profile_list'] as $items) {
994
- if ($items[3]) {
995
- echo '<option value="' . esc_attr($items[1]) . '" ' . selected($items[1], $options['ga_dash_tableid_jail']);
996
- echo ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($items[0]) . '">' . esc_html($tools->ga_dash_get_profile_domain($items[3])) . ' &#8658; ' . esc_attr($items[0]) . '</option>';
997
- }
998
- }
999
- } else {
1000
- echo '<option value="">' . __("Property not found", 'ga-dash') . '</option>';
1001
- }
1002
- ?>
1003
</select>
1004
- if (count($options['ga_dash_profile_list']) > 1) {
1005
- _e("and/or hide all other domains", 'ga-dash');
1006
- ?>
1007
<input type="submit" name="Hide" class="button button-secondary"
1008
value="<?php _e( "Hide Now", 'ga-dash' ); ?>" />
1009
<?php
1010
- }
1011
- ?>
1012
</td>
1013
</tr>
1014
<?php
1015
- if ($options['ga_dash_tableid_jail']) {
1016
- ?>
1017
<tr>
1018
<td class="title"></td>
1019
<td><?php
1020
- $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $GADASH_Config->options['ga_dash_tableid_jail']);
1021
- echo '<pre>' . __("View Name:", 'ga-dash') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'ga-dash') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'ga-dash') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'ga-dash') . "\t" . esc_html($profile_info[5]) . '</pre>';
1022
- ?></td>
1023
</tr>
1024
<?php
1025
- }
1026
- ?>
1027
<td class="title"><label for="ga_dash_style"><?php _e("Theme Color:", 'ga-dash' ); ?></label></td>
1028
<td><input type="text" id="ga_dash_style"
1029
class="ga_dash_style" name="options[ga_dash_style]"
@@ -1044,8 +1024,8 @@ final class GADASH_Settings
1044
name="Submit" class="button button-primary"
1045
value="<?php _e('Save Changes', 'ga-dash' ) ?>" /></td>
1046
</tr>
1047
- } else {
1048
- ?>
1049
<tr>
1050
<td colspan="2"><hr></td>
1051
</tr>
@@ -1064,137 +1044,134 @@ final class GADASH_Settings
1064
</table>
1065
</form>
1066
<?php
1067
- self::output_sidebar();
1068
- return;
1069
- }
1070
- ?>
1071
- </form>
1072
- }
1073
self::output_sidebar();
1074
}
1075
- // Network Settings
1076
- public static function general_settings_network()
1077
- {
1078
- global $GADASH_Config;
1079
- global $wp_version;
1080
- /*
1081
- * Include Tools
1082
- */
1083
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
1084
- $tools = new GADASH_Tools();
1085
- if (! current_user_can('manage_network_options')) {
1086
- return;
1087
- }
1088
- $options = self::set_get_options('network');
1089
- /*
1090
- * Include GAPI
1091
- */
1092
- 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:', "ga-dash") . ' <a href="https://deconf.com/ask/question/ga-dashboard-absolutely-empty-general-settings#answer-770">Library conflicts between WordPress plugins</a></p></div>';
1093
- include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
1094
- global $GADASH_GAPI;
1095
- echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
1096
- if (isset($_POST['ga_dash_code'])) {
1097
- if (! stripos('x' . $_POST['ga_dash_code'], 'UA-', 1) == 1) {
1098
- try {
1099
- $GADASH_GAPI->client->authenticate($_POST['ga_dash_code']);
1100
- $GADASH_Config->options['ga_dash_token'] = $GADASH_GAPI->client->getAccessToken();
1101
- $google_token = json_decode($GADASH_GAPI->client->getAccessToken());
1102
- $GADASH_Config->options['ga_dash_refresh_token'] = $google_token->refresh_token;
1103
- $GADASH_Config->set_plugin_options(true);
1104
- $message = "<div class='updated'><p>" . __("Plugin authorization succeeded.", 'ga-dash') . "</p></div>";
1105
- $options = self::set_get_options('network');
1106
- if (is_multisite()) { // Cleanup errors on the entire network
1107
- foreach (wp_get_sites(array( 'limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) {
1108
- switch_to_blog($blog['blog_id']);
1109
- delete_transient('ga_dash_gapi_errors');
1110
- restore_current_blog();
1111
- }
1112
- } else {
1113
- delete_transient('ga_dash_gapi_errors');
1114
- }
1115
- } catch (Google_IO_Exception $e) {
1116
- set_transient('gadash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e), $GADASH_GAPI->error_timeout);
1117
- return false;
1118
- } catch (Google_Service_Exception $e) {
1119
- set_transient('gadash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html("(" . $e->getCode() . ") " . $e->getMessage()), $GADASH_GAPI->error_timeout);
1120
- set_transient('ga_dash_gapi_errors', $e->getErrors(), $GADASH_GAPI->error_timeout);
1121
- return $e->getCode();
1122
- } catch (Exception $e) {
1123
- set_transient('gadash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e) . "\nResponseHttpCode:" . $e->getCode(), $GADASH_GAPI->error_timeout);
1124
- $GADASH_GAPI->ga_dash_reset_token(false);
1125
- }
1126
- } else {
1127
- $message = "<div class='error'><p>" . __("The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'ga-dash') . ".</p></div>";
1128
- }
1129
- }
1130
-
1131
- if (isset($_POST['Refresh'])) {
1132
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1133
- $GADASH_Config->options['ga_dash_profile_list'] = '';
1134
- $message = "<div class='updated'><p>" . __("Properties refreshed.", 'ga-dash') . "</p></div>";
1135
- $options = self::set_get_options('network');
1136
- } else {
1137
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1138
- }
1139
- }
1140
-
1141
- if ($GADASH_GAPI->client->getAccessToken()) {
1142
- if ($GADASH_Config->options['ga_dash_profile_list']) {
1143
- $profiles = $GADASH_Config->options['ga_dash_profile_list'];
1144
- } else {
1145
- $profiles = $GADASH_GAPI->refresh_profiles();
1146
- }
1147
- if ($profiles) {
1148
- $GADASH_Config->options['ga_dash_profile_list'] = $profiles;
1149
- if (isset($GADASH_Config->options['ga_dash_tableid_jail']) and ! $GADASH_Config->options['ga_dash_tableid_jail']) {
1150
- $profile = $tools->guess_default_domain($profiles);
1151
- $GADASH_Config->options['ga_dash_tableid_jail'] = $profile;
1152
- $GADASH_Config->options['ga_dash_tableid'] = $profile;
1153
- }
1154
- $GADASH_Config->set_plugin_options(true);
1155
- $options = self::set_get_options('network');
1156
- }
1157
- }
1158
-
1159
- if (isset($_POST['Clear'])) {
1160
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1161
- $tools->ga_dash_clear_cache();
1162
- $message = "<div class='updated'><p>" . __("Cleared Cache.", 'ga-dash') . "</p></div>";
1163
- } else {
1164
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1165
- }
1166
- }
1167
- if (isset($_POST['Reset'])) {
1168
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1169
- $GADASH_GAPI->ga_dash_reset_token(true);
1170
- $tools->ga_dash_clear_cache();
1171
- $message = "<div class='updated'><p>" . __("Token Reseted and Revoked.", 'ga-dash') . "</p></div>";
1172
- $options = self::set_get_options('Reset');
1173
- } else {
1174
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1175
- }
1176
- }
1177
-
1178
- if (isset($_POST['options']['ga_dash_hidden']) and ! isset($_POST['Clear']) and ! isset($_POST['Reset']) and ! isset($_POST['Refresh'])) {
1179
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
1180
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
1181
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1182
}
1183
}
1184
- if (isset($_POST['Hide'])) {
1185
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1186
- $message = "<div class='updated'><p>" . __("All other domains/properties were removed.", 'ga-dash') . "</p></div>";
1187
- $lock_profile = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $GADASH_Config->options['ga_dash_tableid_jail']);
1188
- $GADASH_Config->options['ga_dash_profile_list'] = array(
1189
- $lock_profile
1190
- );
1191
- $options = self::set_get_options('network');
1192
- } else {
1193
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1194
- }
1195
}
1196
-
1197
- ?>
1198
<div class="wrap">
1199
<?php echo "<h2>" . __( "Google Analytics Settings", 'ga-dash' ) . "</h2>"; ?><hr>
1200
</div>
@@ -1203,17 +1180,17 @@ final class GADASH_Settings
1203
<div id="post-body-content">
1204
<div class="settings-wrapper">
1205
<div class="inside">
1206
- if ($GADASH_GAPI->gapi_errors_handler()) {
1207
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash'). "</a> " .__('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
1208
- }
1209
- if (isset($_POST['Authorize'])) {
1210
- $tools->ga_dash_clear_cache();
1211
- $GADASH_GAPI->token_request();
1212
- echo "<div class='updated'><p>" . __("Use the red link (see below) to generate and get your access code!", 'ga-dash') . "</p></div>";
1213
- } else {
1214
- if (isset($message))
1215
- echo $message;
1216
- ?>
1217
<form name="ga_dash_form" method="post"
1218
action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1219
<input type="hidden" name="options[ga_dash_hidden]"
@@ -1252,8 +1229,8 @@ final class GADASH_Settings
1252
</td>
1253
</tr>
1254
<?php
1255
- if (! $options['ga_dash_token'] or $options['ga_dash_userapi']) {
1256
- ?>
1257
<tr>
1258
<td colspan="2" class="info"><input
1259
name="options[ga_dash_userapi]" type="checkbox"
@@ -1262,9 +1239,9 @@ final class GADASH_Settings
1262
onchange="this.form.submit()" /><?php _e ( " use your own API Project credentials", 'ga-dash' );?>
1263
</td>
1264
</tr>
1265
- }
1266
- if ($options['ga_dash_userapi']) {
1267
- ?>
1268
<tr>
1269
<td class="title"><label for="options[ga_dash_apikey]"><?php _e("API Key:", 'ga-dash'); ?></label>
1270
</td>
@@ -1294,11 +1271,11 @@ final class GADASH_Settings
1294
</td>
1295
</tr>
1296
<?php
1297
- }
1298
- ?>
1299
<?php
1300
- if ($options['ga_dash_token']) {
1301
- ?>
1302
<tr>
1303
<td colspan="2"><input type="submit" name="Reset"
1304
class="button button-secondary"
@@ -1317,11 +1294,13 @@ final class GADASH_Settings
1317
<td colspan="2"><?php echo "<h2>" . __( "Properties/Views Settings", 'ga-dash' ) . "</h2>"; ?></td>
1318
</tr>
1319
<?php
1320
- if (isset($options['ga_dash_tableid_network'])) {
1321
- $options['ga_dash_tableid_network'] = json_decode(json_encode($options['ga_dash_tableid_network']), FALSE);
1322
- }
1323
- foreach (wp_get_sites(array( 'limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) {
1324
- ?>
1325
<tr>
1326
<td class="title-select"><label
1327
for="ga_dash_tableid_network"><?php echo '<strong>'.$blog['domain'].$blog['path'].'</strong>: ';?></label></td>
@@ -1329,22 +1308,22 @@ final class GADASH_Settings
1329
<?php disabled(is_array($options['ga_dash_profile_list']),false);?>
1330
name="options[ga_dash_tableid_network][<?php echo $blog['blog_id'];?>]">
1331
<?php
1332
- if (is_array($options['ga_dash_profile_list'])) {
1333
- foreach ($options['ga_dash_profile_list'] as $items) {
1334
- if ($items[3]) {
1335
- echo '<option value="' . esc_attr($items[1]) . '" ' . selected($items[1], isset($options['ga_dash_tableid_network']->$blog['blog_id']) ? $options['ga_dash_tableid_network']->$blog['blog_id'] : '');
1336
- echo ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($items[0]) . '">' . $tools->ga_dash_get_profile_domain($items[3]) . ' &#8658; ' . esc_attr($items[0]) . '</option>';
1337
- }
1338
- }
1339