Google Analytics Dashboard for WP (GADWP) - Version 4.4

Version Description

  • Bug Fix: frontend reports and widget are not responsive
  • Bug Fix: random notices for today and yesterday reports
  • Enhancement: Italian translation, updated by Leo
  • Enhancement: admin widget responsive design and optimizations
  • Enhancement: added acquisition channel reports
  • Enhancement: added acquisition social networks reports
  • Enhancement: added acquisition search engines reports
  • Enhancement: new location report and countries/cities list table
  • Enhancement: new pages report (removed top 24 limit)
  • Enhancement: new searches report (removed top 24 limit)
  • Enhancement: new referrers report (removed top 24 limit)
  • Enhancement: frontend, per page reports (removed top 24 limit)
  • Enhancement: added campaigns in real-time report/screen
  • Enhancement: asynchronous reports loading and speed improvements
  • Enhancement: code optimization for all frontend and backend features
  • Enhancement: finished the error standardization process; easier debugging
  • Enhancement: GAPI library update
Download this release

Release Info

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

Version 4.4

Files changed (113) hide show
  1. admin/ajax-actions.php +147 -0
  2. admin/css/ga_dash.css +360 -0
  3. admin/dashboard_widgets.php +1043 -0
  4. admin/ga_dash_settings.php +1529 -0
  5. admin/images/clicky.png +0 -0
  6. admin/images/gadash-icon.png +0 -0
  7. admin/images/google-analytics-dashboard.png +0 -0
  8. admin/images/help.png +0 -0
  9. admin/images/mcdn.png +0 -0
  10. admin/images/ssl.png +0 -0
  11. admin/images/star.png +0 -0
  12. admin/images/wp.png +0 -0
  13. admin/js/admin.js +65 -0
  14. admin/js/wp-color-picker-script.js +3 -0
  15. config.php +280 -0
  16. front/ajax-actions.php +162 -0
  17. front/css/content_stats.css +58 -0
  18. front/frontend.php +182 -0
  19. front/js/content_stats.js +1 -0
  20. front/tracking.php +80 -0
  21. front/tracking/code-classic.php +28 -0
  22. front/tracking/code-universal.php +104 -0
  23. front/tracking/events-classic.php +42 -0
  24. front/tracking/events-universal.php +53 -0
  25. front/widgets.php +235 -0
  26. gadwp.php +87 -0
  27. install/install.php +136 -0
  28. install/uninstall.php +37 -0
  29. languages/ar.mo +0 -0
  30. languages/ar.po +987 -0
  31. languages/ga-dash-de_DE.mo +0 -0
  32. languages/ga-dash-de_DE.po +989 -0
  33. languages/ga-dash-es_ES.mo +0 -0
  34. languages/ga-dash-es_ES.po +1094 -0
  35. languages/ga-dash-fr_FR.mo +0 -0
  36. languages/ga-dash-fr_FR.po +996 -0
  37. languages/ga-dash-hu_HU.mo +0 -0
  38. languages/ga-dash-hu_HU.po +995 -0
  39. languages/ga-dash-it_IT.mo +0 -0
  40. languages/ga-dash-it_IT.po +1013 -0
  41. languages/ga-dash-pl_PL.mo +0 -0
  42. languages/ga-dash-pl_PL.po +983 -0
  43. languages/ga-dash-pt_BR.mo +0 -0
  44. languages/ga-dash-pt_BR.po +993 -0
  45. languages/ga-dash.pot +849 -0
  46. readme.txt +533 -0
  47. realtime/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  48. realtime/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  49. realtime/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  50. realtime/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  51. realtime/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  52. realtime/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  53. realtime/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  54. realtime/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  55. realtime/jquery/images/ui-icons_222222_256x240.png +0 -0
  56. realtime/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
  57. realtime/jquery/images/ui-icons_454545_256x240.png +0 -0
  58. realtime/jquery/images/ui-icons_888888_256x240.png +0 -0
  59. realtime/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
  60. realtime/jquery/jquery.ui.tooltip.html.css +57 -0
  61. realtime/jquery/jquery.ui.tooltip.html.js +7 -0
  62. tools/autoload.php +33 -0
  63. tools/gapi.php +971 -0
  64. tools/iso3166.php +247 -0
  65. tools/nprogress/nprogress.css +89 -0
  66. tools/nprogress/nprogress.js +476 -0
  67. tools/src/Google/Auth/Abstract.php +36 -0
  68. tools/src/Google/Auth/AppIdentity.php +105 -0
  69. tools/src/Google/Auth/AssertionCredentials.php +136 -0
  70. tools/src/Google/Auth/Exception.php +22 -0
  71. tools/src/Google/Auth/LoginTicket.php +69 -0
  72. tools/src/Google/Auth/OAuth2.php +633 -0
  73. tools/src/Google/Auth/Simple.php +64 -0
  74. tools/src/Google/Cache/Abstract.php +53 -0
  75. tools/src/Google/Cache/Apc.php +111 -0
  76. tools/src/Google/Cache/Exception.php +22 -0
  77. tools/src/Google/Cache/File.php +190 -0
  78. tools/src/Google/Cache/Memcache.php +182 -0
  79. tools/src/Google/Cache/Null.php +55 -0
  80. tools/src/Google/Client.php +686 -0
  81. tools/src/Google/Collection.php +96 -0
  82. tools/src/Google/Config.php +414 -0
  83. tools/src/Google/Exception.php +20 -0
  84. tools/src/Google/Http/Batch.php +141 -0
  85. tools/src/Google/Http/CacheParser.php +184 -0
  86. tools/src/Google/Http/MediaFileUpload.php +300 -0
  87. tools/src/Google/Http/REST.php +147 -0
  88. tools/src/Google/Http/Request.php +476 -0
  89. tools/src/Google/IO/Abstract.php +329 -0
  90. tools/src/Google/IO/Curl.php +159 -0
  91. tools/src/Google/IO/Exception.php +22 -0
  92. tools/src/Google/IO/Stream.php +230 -0
  93. tools/src/Google/IO/cacerts.pem +2183 -0
  94. tools/src/Google/Logger/Abstract.php +406 -0
  95. tools/src/Google/Logger/Exception.php +22 -0
  96. tools/src/Google/Logger/File.php +156 -0
  97. tools/src/Google/Logger/Null.php +41 -0
  98. tools/src/Google/Logger/Psr.php +91 -0
  99. tools/src/Google/Model.php +281 -0
  100. tools/src/Google/Service.php +39 -0
  101. tools/src/Google/Service/AdSense.php +3585 -0
  102. tools/src/Google/Service/Analytics.php +9447 -0
  103. tools/src/Google/Service/Exception.php +53 -0
  104. tools/src/Google/Service/Resource.php +242 -0
  105. tools/src/Google/Service/YouTube.php +10456 -0
  106. tools/src/Google/Service/YouTubeAnalytics.php +608 -0
  107. tools/src/Google/Signer/Abstract.php +29 -0
  108. tools/src/Google/Signer/P12.php +90 -0
  109. tools/src/Google/Utils.php +135 -0
  110. tools/src/Google/Utils/URITemplate.php +333 -0
  111. tools/src/Google/Verifier/Abstract.php +30 -0
  112. tools/src/Google/Verifier/Pem.php +73 -0
  113. tools/tools.php +124 -0
admin/ajax-actions.php ADDED
@@ -0,0 +1,147 @@
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: http://deconf.com
5
+ * License: GPLv2 or later
6
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
+ */
8
+ 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
+ if (! isset($_REQUEST['gadashadmin_security_widget_reports']) or ! wp_verify_nonce($_REQUEST['gadashadmin_security_widget_reports'], 'gadashadmin_get_widgetreports')) {
42
+ print(json_encode(- 30));
43
+ die();
44
+ }
45
+
46
+ /*
47
+ * Include Tools
48
+ */
49
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
50
+ $tools = new GADASH_Tools();
51
+
52
+ if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
53
+ print(json_encode(- 31));
54
+ die();
55
+ }
56
+
57
+ if ($GADASH_Config->options['ga_dash_token'] and function_exists('curl_version') and $projectId and $from and $to) {
58
+ include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
59
+ global $GADASH_GAPI;
60
+ } else {
61
+ print(json_encode(- 24));
62
+ die();
63
+ }
64
+
65
+ switch ($query) {
66
+ case 'referrers':
67
+ print($GADASH_GAPI->get_referrers($projectId, $from, $to));
68
+ break;
69
+ case 'contentpages':
70
+ print($GADASH_GAPI->get_contentpages($projectId, $from, $to));
71
+ break;
72
+ case 'locations':
73
+ print($GADASH_GAPI->get_locations($projectId, $from, $to));
74
+ break;
75
+ case 'bottomstats':
76
+ print(json_encode($GADASH_GAPI->get_bottomstats($projectId, $from, $to)));
77
+ break;
78
+ case 'trafficchannels':
79
+ print($GADASH_GAPI->get_trafficchannels($projectId, $from, $to));
80
+ break;
81
+ case 'medium':
82
+ print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'medium'));
83
+ break;
84
+ case 'visitorType':
85
+ print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'visitorType'));
86
+ break;
87
+ case 'socialNetwork':
88
+ print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'socialNetwork'));
89
+ break;
90
+ case 'source':
91
+ print($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'source'));
92
+ break;
93
+ case 'searches':
94
+ print($GADASH_GAPI->get_searches($projectId, $from, $to));
95
+ break;
96
+ default:
97
+ print($GADASH_GAPI->get_mainreport($projectId, $from, $to, $query));
98
+ break;
99
+ }
100
+
101
+ die();
102
+ }
103
+
104
+ // Real-Time Request
105
+ /**
106
+ * Ajax handler for getting realtime analytics data for Admin widget
107
+ *
108
+ * @return string|int
109
+ */
110
+ function ajax_adminwidget_realtime()
111
+ {
112
+ global $GADASH_Config;
113
+
114
+ $projectId = $_REQUEST['projectId'];
115
+
116
+ if (! isset($_REQUEST['gadashadmin_security_widgetrealtime']) or ! wp_verify_nonce($_REQUEST['gadashadmin_security_widgetrealtime'], 'gadashadmin_get_realtime')) {
117
+ print(json_encode(- 30));
118
+ die();
119
+ }
120
+
121
+ /*
122
+ * Include Tools
123
+ */
124
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
125
+ $tools = new GADASH_Tools();
126
+
127
+ if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
128
+ print(json_encode(- 31));
129
+ die();
130
+ }
131
+
132
+ if ($GADASH_Config->options['ga_dash_token'] and function_exists('curl_version') and $projectId) {
133
+ include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
134
+ global $GADASH_GAPI;
135
+ } else {
136
+ print(json_encode(- 24));
137
+ die();
138
+ }
139
+
140
+ print($GADASH_GAPI->gadash_realtime_data($projectId));
141
+
142
+ die();
143
+ }
144
+ }
145
+ }
146
+
147
+ $GADASH_Backend_Ajax = new GADASH_Backend_Ajax();
admin/css/ga_dash.css ADDED
@@ -0,0 +1,360 @@
1
+ /* Options pages */
2
+ table.options {
3
+ padding-left: 10px;
4
+ width: 100%;
5
+ }
6
+
7
+ .options td {
8
+ padding: 0px 5px 5px 5px;
9
+ }
10
+
11
+ td.title, td.info {
12
+ width: 130px;
13
+ padding-left: 20px;
14
+ }
15
+
16
+ td.title-select {
17
+ width: 300px;
18
+ }
19
+
20
+ td.debugging {
21
+ width: 150px;
22
+ }
23
+
24
+ td.info {
25
+ padding-bottom: 15px;
26
+ }
27
+
28
+ td.title label {
29
+ font-weight: bold;
30
+ }
31
+
32
+ .gadash-title {
33
+ float:left;
34
+ margin-right: 10px;
35
+ margin-top: 2px;
36
+ clear:left;
37
+ }
38
+
39
+ .gadash-desc {
40
+ font-size: 1em;
41
+ }
42
+
43
+ .gadash-top {
44
+ vertical-align: top;
45
+ }
46
+
47
+ pre.gadash {
48
+ }
49
+
50
+ .show_hide, .log_data {
51
+ display: none;
52
+ }
53
+
54
+ pre.log_data {
55
+ white-space: pre-wrap;
56
+ }
57
+
58
+ td.roles {
59
+ padding-bottom: 15px;
60
+ }
61
+
62
+ #ga_speed_samplerate, #ga_realtime_pages {
63
+ width: 50px;
64
+ }
65
+
66
+ .event-option, .event-option-desc {
67
+ float: left;
68
+ }
69
+
70
+ #gapi-access-code {
71
+ color: red !important;
72
+ }
73
+
74
+ /* Options pages ON/OFF Switch */
75
+ .onoffswitch {
76
+ position: relative;
77
+ width: 55px;
78
+ float: left;
79
+ -webkit-user-select: none;
80
+ -moz-user-select: none;
81
+ -ms-user-select: none;
82
+ }
83
+
84
+ .onoffswitch-checkbox {
85
+ display: none !important;
86
+ }
87
+
88
+ .onoffswitch-label {
89
+ display: block;
90
+ overflow: hidden;
91
+ cursor: pointer;
92
+ border: 2px solid #C9C9C9;
93
+ border-radius: 5px;
94
+ }
95
+
96
+ .onoffswitch-inner {
97
+ width: 200%;
98
+ margin-left: -100%;
99
+ -moz-transition: margin 0.3s ease-in 0s;
100
+ -webkit-transition: margin 0.3s ease-in 0s;
101
+ -o-transition: margin 0.3s ease-in 0s;
102
+ transition: margin 0.3s ease-in 0s;
103
+ }
104
+
105
+ .onoffswitch-inner:before, .onoffswitch-inner:after {
106
+ float: left;
107
+ width: 50%;
108
+ height: 18px;
109
+ padding: 0;
110
+ line-height: 18px;
111
+ font-size: 12px;
112
+ color: white;
113
+ font-family: Trebuchet, Arial, sans-serif;
114
+ font-weight: bold;
115
+ -moz-box-sizing: border-box;
116
+ -webkit-box-sizing: border-box;
117
+ box-sizing: border-box;
118
+ }
119
+
120
+ .onoffswitch-inner:before {
121
+ content: "ON";
122
+ padding-left: 6px;
123
+ background-color: #1269BA;
124
+ color: #FFFFFF;
125
+ }
126
+
127
+ .onoffswitch-inner:after {
128
+ content: "OFF";
129
+ padding-right: 6px;
130
+ background-color: #EEEEEE;
131
+ color: #999999;
132
+ text-align: right;
133
+ }
134
+
135
+ .onoffswitch-switch {
136
+ width: 18px;
137
+ margin: 0px;
138
+ background: #FFFFFF;
139
+ border: 2px solid #C9C9C9;
140
+ border-radius: 5px;
141
+ position: absolute;
142
+ top: 0;
143
+ bottom: 0;
144
+ right: 33px;
145
+ -moz-transition: all 0.3s ease-in 0s;
146
+ -webkit-transition: all 0.3s ease-in 0s;
147
+ -o-transition: all 0.3s ease-in 0s;
148
+ transition: all 0.3s ease-in 0s;
149
+ background-image: -moz-linear-gradient(center top, rgba(0, 0, 0, 0.1) 0%,
150
+ rgba(0, 0, 0, 0) 100%);
151
+ background-image: -webkit-linear-gradient(center top, rgba(0, 0, 0, 0.1)
152
+ 0%, rgba(0, 0, 0, 0) 100%);
153
+ background-image: -o-linear-gradient(center top, rgba(0, 0, 0, 0.1) 0%,
154
+ rgba(0, 0, 0, 0) 100%);
155
+ background-image: linear-gradient(center top, rgba(0, 0, 0, 0.1) 0%,
156
+ rgba(0, 0, 0, 0) 100%);
157
+ }
158
+
159
+ .onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-inner {
160
+ margin-left: 0;
161
+ }
162
+
163
+ .onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-switch {
164
+ right: 0px;
165
+ }
166
+
167
+ .switch-desc {
168
+ float: left;
169
+ margin-left: 10px;
170
+ }
171
+
172
+ /* Admin Widget & Real-Time Stats*/
173
+
174
+ /* Real-Time content */
175
+ .gadash-pline {
176
+ width: 100%;
177
+ margin: 0 0;
178
+ padding: 5px 0 5px 0;
179
+ background: #fff;
180
+ -moz-box-shadow: 0px 0px 3px 0px #BBB;
181
+ -webkit-box-shadow: 0px 0px 3px 0px #BBB;
182
+ box-shadow: 0px 0px 3px 0px #BBB;
183
+ display: table;
184
+ overflow: hidden;
185
+ }
186
+
187
+ .gadash-pleft {
188
+ width: 90%;
189
+ float: left;
190
+ padding-left:5px;
191
+ }
192
+
193
+ .gadash-pright {
194
+ width: 5%;
195
+ float: right;
196
+ padding-right:5px;
197
+ }
198
+
199
+ #gadash-widget .realtime {
200
+ margin: 10px 0 0 0;
201
+ width: 100%;
202
+ }
203
+
204
+ .gadash-rt-box {
205
+ width: 100%;
206
+ margin: 0 0;
207
+ background: #fff;
208
+ text-align: center;
209
+ -moz-box-shadow: 0px 0px 5px 0px #BBB;
210
+ -webkit-box-shadow: 0px 0px 5px 0px #BBB;
211
+ box-shadow: 0px 0px 5px 0px #BBB;
212
+ display: table;
213
+ }
214
+
215
+ .gadash-tdo-left {
216
+ width: 60%;
217
+ padding: 33px 0;
218
+ float: left;
219
+ text-align:center;
220
+ }
221
+
222
+ .gadash-tdo-right {
223
+ width: 35%;
224
+ margin: 0px 10px 0px 0;
225
+ text-align: left;
226
+ font-weight: bold;
227
+ vertical-align: middle;
228
+ float: right;
229
+ display:table;
230
+ }
231
+
232
+ .gadash-online {
233
+ font-size: 100px;
234
+ font-weight: normal;
235
+ line-height: 1em;
236
+ margin:0 auto;
237
+ width:80%;
238
+ }
239
+
240
+ .gadash-bigtext {
241
+ font-size: 14px;
242
+ width: 100%;
243
+ margin: 0 0;
244
+ padding: 5px 5px 5px 5px;
245
+ background: #fff;
246
+ -moz-box-shadow: 0px 0px 3px 0px #BBB;
247
+ -webkit-box-shadow: 0px 0px 3px 0px #BBB;
248
+ box-shadow: 0px 0px 3px 0px #BBB;
249
+ display: table;
250
+ overflow: hidden;
251
+ }
252
+
253
+ .gadash-bleft{
254
+ float:left;
255
+ width:80%;
256
+ }
257
+
258
+ .gadash-bright{
259
+ float:right;
260
+ width:20%;
261
+ }
262
+
263
+ .gadash-pgdetailsr {
264
+ padding-left: 20px;
265
+ text-align: right;
266
+ }
267
+
268
+ .gadash-pgdetailsl {
269
+ min-width: 250px;
270
+ }
271
+
272
+ #gadash-mainchart{
273
+ width: 98%;
274
+ height:100%;
275
+ margin: 10px auto 10px 0;
276
+ height: 250px;
277
+ }
278
+
279
+ .gadash-floatwraper{
280
+ display:table;
281
+ width:100%;
282
+ height:100%;
283
+ }
284
+
285
+ #gadash-trafficmediums, #gadash-traffictype, #gadash-socialnetworks, #gadash-trafficorganic{
286
+ width:47%;
287
+ margin:10px 0 0 0;
288
+ height: 200px;
289
+ }
290
+
291
+ #gadash-trafficmediums, #gadash-trafficorganic{
292
+ float:left;
293
+ }
294
+
295
+ #gadash-traffictype, #gadash-socialnetworks{
296
+ float:right;
297
+ }
298
+
299
+ #gadash-map, #gadash-prs{
300
+ width: 98%;
301
+ height:100%;
302
+ margin: 10px auto 10px 0;
303
+ }
304
+
305
+ #ga_dash_period, #ga_dash_profile_select {
306
+ font-size: 14px !important;
307
+ padding: 1px !important;
308
+ height: 26px !important;
309
+ }
310
+
311
+ #dashboard-widgets-wrap .postbox {
312
+ margin-right: 10px;
313
+ }
314
+
315
+ /* Admin Widget content */
316
+
317
+ #gadash-progressbar{
318
+ width:100%;
319
+ height:3px;
320
+ margin:5px 0 0px 0;
321
+ }
322
+
323
+ .gadash-wrapper {
324
+ width: 100%;
325
+ }
326
+
327
+ .gadash-wrapper .inside {
328
+ display: table;
329
+ margin: 0 auto;
330
+ padding: 0px;
331
+ }
332
+
333
+ .gadash-wrapper .inside .small-box {
334
+ width: 30%;
335
+ float: left;
336
+ margin: 0 5px 10px 5px;
337
+ background: #fff;
338
+ text-align: center;
339
+ -moz-box-shadow: 0px 0px 7px 0px #BBB;
340
+ -webkit-box-shadow: 0px 0px 7px 0px #BBB;
341
+ box-shadow: 0px 0px 7px 0px #BBB;
342
+ }
343
+
344
+ .gadash-wrapper .inside .small-box h3 {
345
+ font-size: 1em;
346
+ color: #777;
347
+ padding: 0px 5px 0px 5px;
348
+ margin: 0px 0px 0px 0px;
349
+ }
350
+
351
+ .gadash-wrapper .inside .small-box p {
352
+ font-size: 1.2em;
353
+ margin: 0px 0px 2px 0px;
354
+ }
355
+
356
+ @media screen and (max-width: 410px) {
357
+ .gadash-wrapper .inside .small-box {
358
+ width: 45%;
359
+ }
360
+ }
admin/dashboard_widgets.php ADDED
@@ -0,0 +1,1043 @@
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * License: GPLv2 or later
6
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
+ */
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
+ }
41
+
42
+ function ga_dash_admin_actions()
43
+ {
44
+ global $GADASH_Config;
45
+ global $wp_version;
46
+
47
+ if (current_user_can('manage_options')) {
48
+ include ($GADASH_Config->plugin_path . '/admin/ga_dash_settings.php');
49
+
50
+ add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_options', 'gadash_settings', array(
51
+ 'GADASH_Settings',
52
+ 'general_settings'
53
+ ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
54
+ add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_options', 'gadash_settings', array(
55
+ 'GADASH_Settings',
56
+ 'general_settings'
57
+ ));
58
+ add_submenu_page('gadash_settings', __("Backend Settings", 'ga-dash'), __("Backend Settings", 'ga-dash'), 'manage_options', 'gadash_backend_settings', array(
59
+ 'GADASH_Settings',
60
+ 'backend_settings'
61
+ ));
62
+ add_submenu_page('gadash_settings', __("Frontend Settings", 'ga-dash'), __("Frontend Settings", 'ga-dash'), 'manage_options', 'gadash_frontend_settings', array(
63
+ 'GADASH_Settings',
64
+ 'frontend_settings'
65
+ ));
66
+ add_submenu_page('gadash_settings', __("Tracking Code", 'ga-dash'), __("Tracking Code", 'ga-dash'), 'manage_options', 'gadash_tracking_settings', array(
67
+ 'GADASH_Settings',
68
+ 'tracking_settings'
69
+ ));
70
+ }
71
+ }
72
+
73
+ function ga_dash_network_actions()
74
+ {
75
+ global $GADASH_Config;
76
+ global $wp_version;
77
+
78
+ if (current_user_can('manage_netwrok')) {
79
+ include ($GADASH_Config->plugin_path . '/admin/ga_dash_settings.php');
80
+
81
+ add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
82
+ 'GADASH_Settings',
83
+ 'general_settings_network'
84
+ ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
85
+ add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
86
+ 'GADASH_Settings',
87
+ 'general_settings_network'
88
+ ));
89
+ }
90
+ }
91
+
92
+ /*
93
+ * Include styles
94
+ */
95
+ function ga_dash_admin_enqueue_styles($hook)
96
+ {
97
+ global $GADASH_Config;
98
+ $valid_hooks = array(
99
+ 'toplevel_page_gadash_settings',
100
+ 'google-analytics_page_gadash_backend_settings',
101
+ 'google-analytics_page_gadash_frontend_settings',
102
+ 'google-analytics_page_gadash_tracking_settings'
103
+ );
104
+
105
+ if (! in_array($hook, $valid_hooks) and 'index.php' != $hook)
106
+ return;
107
+
108
+ wp_enqueue_style('ga_dash-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.css', NULL, GADWP_CURRENT_VERSION);
109
+
110
+ wp_register_style('ga_dash', $GADASH_Config->plugin_url . '/admin/css/ga_dash.css', NULL, GADWP_CURRENT_VERSION);
111
+
112
+ wp_enqueue_style('ga_dash');
113
+ wp_enqueue_style('wp-color-picker');
114
+ wp_enqueue_script('wp-color-picker');
115
+ wp_enqueue_script('wp-color-picker-script-handle', plugins_url('js/wp-color-picker-script.js', __FILE__), array(
116
+ 'wp-color-picker'
117
+ ), false, true);
118
+ wp_enqueue_script('gadash-general-settings', plugins_url('js/admin.js', __FILE__), array(
119
+ 'jquery'
120
+ ), GADWP_CURRENT_VERSION);
121
+ if (! wp_script_is('googlejsapi')) {
122
+ wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
123
+ wp_enqueue_script('googlejsapi');
124
+ }
125
+ wp_enqueue_script('ga_dash-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.js', array(
126
+ 'jquery'
127
+ ), GADWP_CURRENT_VERSION);
128
+ }
129
+
130
+ function ga_dash_settings_link($links)
131
+ {
132
+ $settings_link = '<a href="' . get_admin_url(null, 'admin.php?page=gadash_settings') . '">' . __("Settings", 'ga-dash') . '</a>';
133
+ array_unshift($links, $settings_link);
134
+ return $links;
135
+ }
136
+
137
+ function ga_dash_setup()
138
+ {
139
+ global $GADASH_Config;
140
+
141
+ /*
142
+ * Include Tools
143
+ */
144
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
145
+ $tools = new GADASH_Tools();
146
+
147
+ if ($tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
148
+ wp_add_dashboard_widget('gadash-widget', __("Google Analytics Dashboard", 'ga-dash'), array(
149
+ $this,
150
+ 'gadash_dashboard_widgets'
151
+ ), $control_callback = null);
152
+ }
153
+ }
154
+
155
+ function gadash_dashboard_widgets()
156
+ {
157
+ global $GADASH_Config;
158
+
159
+ /*
160
+ * Include GAPI
161
+ */
162
+ if ($GADASH_Config->options['ga_dash_token'] and function_exists('curl_version')) {
163
+ include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
164
+ global $GADASH_GAPI;
165
+ } else {
166
+ 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>';
167
+ return;
168
+ }
169
+
170
+ /*
171
+ * Include Tools
172
+ */
173
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
174
+ $tools = new GADASH_Tools();
175
+
176
+ $tools->ga_dash_cleanup_timeouts();
177
+
178
+ if (current_user_can('manage_options')) {
179
+
180
+ if (isset($_REQUEST['ga_dash_profile_select'])) {
181
+ $GADASH_Config->options['ga_dash_tableid'] = $_REQUEST['ga_dash_profile_select'];
182
+ }
183
+
184
+ $profiles = $GADASH_Config->options['ga_dash_profile_list'];
185
+ $profile_switch = '';
186
+
187
+ if (is_array($profiles)) {
188
+ if (! $GADASH_Config->options['ga_dash_tableid']) {
189
+ if ($GADASH_Config->options['ga_dash_tableid_jail']) {
190
+ $GADASH_Config->options['ga_dash_tableid'] = $GADASH_Config->options['ga_dash_tableid_jail'];
191
+ } else {
192
+ $GADASH_Config->options['ga_dash_tableid'] = $tools->guess_default_domain($profiles);
193
+ }
194
+ } else
195
+ if ($GADASH_Config->options['ga_dash_jailadmins'] and $GADASH_Config->options['ga_dash_tableid_jail']) {
196
+ $GADASH_Config->options['ga_dash_tableid'] = $GADASH_Config->options['ga_dash_tableid_jail'];
197
+ }
198
+
199
+ $profile_switch .= '<select id="ga_dash_profile_select" name="ga_dash_profile_select" onchange="this.form.submit()">';
200
+ foreach ($profiles as $profile) {
201
+ if (! $GADASH_Config->options['ga_dash_tableid']) {
202
+ $GADASH_Config->options['ga_dash_tableid'] = $profile[1];
203
+ }
204
+ if (isset($profile[3])) {
205
+ $profile_switch .= '<option value="' . esc_attr($profile[1]) . '" ';
206
+ $profile_switch .= selected($profile[1], $GADASH_Config->options['ga_dash_tableid'], false);
207
+ $profile_switch .= ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($profile[0]) . '">' . esc_attr($tools->ga_dash_get_profile_domain($profile[3])) . '</option>';
208
+ }
209
+ }
210
+ $profile_switch .= "</select>";
211
+ } else {
212
+ 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>';
213
+ return;
214
+ }
215
+ }
216
+
217
+ $GADASH_Config->set_plugin_options();
218
+
219
+ ?>
220
+ <form id="ga-dash" method="POST">
221
+ <?php
222
+
223
+ if (current_user_can('manage_options')) {
224
+ if ($GADASH_Config->options['ga_dash_jailadmins']) {
225
+ if ($GADASH_Config->options['ga_dash_tableid_jail']) {
226
+ $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
227
+ } else {
228
+ 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>';
229
+ return;
230
+ }
231
+ } else {
232
+ echo $profile_switch;
233
+ $projectId = $GADASH_Config->options['ga_dash_tableid'];
234
+ }
235
+ } else {
236
+ if ($GADASH_Config->options['ga_dash_tableid_jail']) {
237
+ $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
238
+ } else {
239
+ 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>';
240
+ return;
241
+ }
242
+ }
243
+
244
+ if (! ($projectId)) {
245
+ 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>';
246
+ return;
247
+ } else {
248
+ $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
249
+ if (isset($profile_info[4])) {
250
+ $GADASH_GAPI->timeshift = $profile_info[4];
251
+ } else {
252
+ $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
253
+ }
254
+ }
255
+
256
+ if (isset($_REQUEST['query'])) {
257
+ $query = $_REQUEST['query'];
258
+ $GADASH_Config->options['ga_dash_default_metric'] = $query;
259
+ $GADASH_Config->set_plugin_options();
260
+ } else {
261
+ $query = isset($GADASH_Config->options['ga_dash_default_metric']) ? $GADASH_Config->options['ga_dash_default_metric'] : 'sessions';
262
+ }
263
+
264
+ if (isset($_REQUEST['period'])) {
265
+ $period = $_REQUEST['period'];
266
+ $GADASH_Config->options['ga_dash_default_dimension'] = $period;
267
+ $GADASH_Config->set_plugin_options();
268
+ } else {
269
+ $period = isset($GADASH_Config->options['ga_dash_default_dimension']) ? $GADASH_Config->options['ga_dash_default_dimension'] : '30daysAgo';
270
+ }
271
+
272
+ ?>
273
+
274
+ <select id="ga_dash_period" name="period" onchange="this.form.submit()">
275
+ <option value="realtime"
276
+ <?php selected ( "realtime", $period, true ); ?>><?php _e("Real-Time",'ga-dash'); ?></option>
277
+ <option value="today" <?php selected ( "today", $period, true ); ?>><?php _e("Today",'ga-dash'); ?></option>
278
+ <option value="yesterday"
279
+ <?php selected ( "yesterday", $period, true ); ?>><?php _e("Yesterday",'ga-dash'); ?></option>
280
+ <option value="7daysAgo"
281
+ <?php selected ( "7daysAgo", $period, true ); ?>><?php _e("Last 7 Days",'ga-dash'); ?></option>
282
+ <option value="14daysAgo"
283
+ <?php selected ( "14daysAgo", $period, true ); ?>><?php _e("Last 14 Days",'ga-dash'); ?></option>
284
+ <option value="30daysAgo"
285
+ <?php selected ( "30daysAgo", $period, true ); ?>><?php _e("Last 30 Days",'ga-dash'); ?></option>
286
+ <option value="90daysAgo"
287
+ <?php selected ( "90daysAgo", $period, true ); ?>><?php _e("Last 90 Days",'ga-dash'); ?></option>
288
+ </select>
289
+ <?php if ($period != 'realtime') {?>
290
+ <select id="ga_dash_query" name="query"
291
+ onchange="this.form.submit()">
292
+ <option value="sessions"
293
+ <?php selected ( "sessions", $query, true ); ?>><?php _e("Sessions",'ga-dash'); ?></option>
294
+ <option value="users" <?php selected ( "users", $query, true ); ?>><?php _e("Users",'ga-dash'); ?></option>
295
+ <option value="organicSearches"
296
+ <?php selected ( "organicSearches", $query, true ); ?>><?php _e("Organic",'ga-dash'); ?></option>
297
+ <option value="pageviews"
298
+ <?php selected ( "pageviews", $query, true ); ?>><?php _e("Page Views",'ga-dash'); ?></option>
299
+ <option value="visitBounceRate"
300
+ <?php selected ( "visitBounceRate", $query, true ); ?>><?php _e("Bounce Rate",'ga-dash'); ?></option>
301
+ <option value="locations"
302
+ <?php selected ( "locations", $query, true ); ?>><?php _e("Location",'ga-dash'); ?></option>
303
+ <option value="contentpages"
304
+ <?php selected ( "contentpages", $query, true ); ?>><?php _e("Pages",'ga-dash'); ?></option>
305
+ <option value="referrers"
306
+ <?php selected ( "referrers", $query, true ); ?>><?php _e("Referrers",'ga-dash'); ?></option>
307
+ <option value="searches"
308
+ <?php selected ( "searches", $query, true ); ?>><?php _e("Searches",'ga-dash'); ?></option>
309
+ <option value="trafficdetails"
310
+ <?php selected ( "trafficdetails", $query, true ); ?>><?php _e("Traffic Details",'ga-dash'); ?></option>
311
+ </select>
312
+ <?php }?>
313
+ </form>
314
+ <div id="gadash-progressbar"></div>
315
+ <?php
316
+ switch ($period) {
317
+
318
+ case 'today':
319
+ $from = 'today';
320
+ $to = 'today';
321
+ $haxis = 4;
322
+ break;
323
+
324
+ case 'yesterday':
325
+ $from = 'yesterday';
326
+ $to = 'yesterday';
327
+ $haxis = 4;
328
+ break;
329
+
330
+ case '7daysAgo':
331
+ $from = '7daysAgo';
332
+ $to = 'yesterday';
333
+ $haxis = 2;
334
+ break;
335
+
336
+ case '14daysAgo':
337
+ $from = '14daysAgo';
338
+ $to = 'yesterday';
339
+ $haxis = 3;
340
+ break;
341
+
342
+ case '30daysAgo':
343
+ $from = '30daysAgo';
344
+ $to = 'yesterday';
345
+ $haxis = 5;
346
+ break;
347
+
348
+ default:
349
+ $from = '90daysAgo';
350
+ $to = 'yesterday';
351
+ $haxis = 16;
352
+ break;
353
+ }
354
+
355
+ if ($query == 'visitBounceRate') {
356
+ $formater = "var formatter = new google.visualization.NumberFormat({
357
+ pattern: '#,##%',
358
+ fractionDigits: 2
359
+ });
360
+
361
+ formatter.format(data, 1); ";
362
+ } else {
363
+ $formater = '';
364
+ }
365
+
366
+ /*
367
+ * Include Tools
368
+ */
369
+ include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
370
+ $tools = new GADASH_Tools();
371
+
372
+ if (isset($GADASH_Config->options['ga_dash_style'])) {
373
+ $light_color = $tools->colourVariator($GADASH_Config->options['ga_dash_style'], 40);
374
+ $dark_color = $tools->colourVariator($GADASH_Config->options['ga_dash_style'], - 20);
375
+ $css = "colors:['" . $GADASH_Config->options['ga_dash_style'] . "','" . $tools->colourVariator($GADASH_Config->options['ga_dash_style'], - 20) . "'],";
376
+ $color = $GADASH_Config->options['ga_dash_style'];
377
+ } else {
378
+ $css = "";
379
+ $color = "#3366CC";
380
+ }
381
+
382
+ if ($period == 'realtime') {
383
+
384
+ wp_register_style('jquery-ui-tooltip-html', $GADASH_Config->plugin_url . '/realtime/jquery/jquery.ui.tooltip.html.css');
385
+ wp_enqueue_style('jquery-ui-tooltip-html');
386
+
387
+ if (! wp_script_is('jquery')) {
388
+ wp_enqueue_script('jquery');
389
+ }
390
+ if (! wp_script_is('jquery-ui-tooltip')) {
391
+ wp_enqueue_script("jquery-ui-tooltip");
392
+ }
393
+ if (! wp_script_is('jquery-ui-core')) {
394
+ wp_enqueue_script("jquery-ui-core");
395
+ }
396
+ if (! wp_script_is('jquery-ui-position')) {
397
+ wp_enqueue_script("jquery-ui-position");
398
+ }
399
+ if (! wp_script_is('jquery-ui-position')) {
400
+ wp_enqueue_script("jquery-ui-position");
401
+ }
402
+
403
+ wp_register_script("jquery-ui-tooltip-html", $GADASH_Config->plugin_url . '/realtime/jquery/jquery.ui.tooltip.html.js');
404
+ wp_enqueue_script("jquery-ui-tooltip-html");
405
+ }
406
+
407
+ if ($period == 'realtime') {
408
+ ?>
409
+ <div class="realtime">
410
+ <div class="gadash-rt-box">
411
+ <div class='gadash-tdo-left'>
412
+ <div class='gadash-online' id='gadash-online'>0</div>
413
+ </div>
414
+ <div class='gadash-tdo-right' id='gadash-tdo-right'>
415
+ <div class="gadash-bigtext">
416
+ <div class="gadash-bleft"><?php _e( "REFERRAL", 'ga-dash' );?></div>
417
+ <div class="gadash-bright">0</div>
418
+ </div>
419
+ <div class="gadash-bigtext">
420
+ <div class="gadash-bleft"><?php _e( "ORGANIC", 'ga-dash' );?></div>
421
+ <div class="gadash-bright">0</div>
422
+ </div>
423
+ <div class="gadash-bigtext">
424
+ <div class="gadash-bleft"><?php _e( "SOCIAL", 'ga-dash' );?></div>
425
+ <div class="gadash-bright">0</div>
426
+ </div>
427
+ <div class="gadash-bigtext">
428
+ <div class="gadash-bleft"><?php _e( "CAMPAIGN", 'ga-dash' );?></div>
429
+ <div class="gadash-bright">0</div>
430
+ </div>
431
+ <div class="gadash-bigtext">
432
+ <div class="gadash-bleft"><?php _e( "DIRECT", 'ga-dash' );?></div>
433
+ <div class="gadash-bright">0</div>
434
+ </div>
435
+ <div class="gadash-bigtext">
436
+ <div class="gadash-bleft"><?php _e( "NEW", 'ga-dash' );?></div>
437
+ <div class="gadash-bright">0</div>
438
+ </div>
439
+ </div>
440
+ </div>
441
+ <div>
442
+ <div id='gadash-pages' class='gadash-pages'>&nbsp;</div>
443
+ </div>
444
+ </div>
445
+ <script type="text/javascript">
446
+
447
+ var focusFlag = 1;
448
+
449
+ jQuery(document).ready(function(){
450
+ jQuery(window).bind("focus",function(event){
451
+ focusFlag = 1;
452
+ }).bind("blur", function(event){
453
+ focusFlag = 0;
454
+ });
455
+ });
456
+
457
+ jQuery(function() {
458
+ jQuery( document ).tooltip();
459
+ });
460
+
461
+ function onlyUniqueValues(value, index, self) {
462
+ return self.indexOf(value) === index;
463
+ }
464
+
465
+ function countsessions(data, searchvalue) {
466
+ var count = 0;
467
+ for ( var i = 0; i < data["rows"].length; i = i + 1 ) {
468
+ if (jQuery.inArray(searchvalue, data["rows"][ i ])>-1){
469
+ count += parseInt(data["rows"][ i ][6]);
470
+ }
471
+ }
472
+ return count;
473
+ }
474
+
475
+ function gadash_generatetooltip(data) {
476
+ var count = 0;
477
+ var table = "";
478
+ for ( var i = 0; i < data.length; i = i + 1 ) {
479
+ count += parseInt(data[ i ].count);
480
+ table += "<tr><td class='gadash-pgdetailsl'>"+data[i].value+"</td><td class='gadash-pgdetailsr'>"+data[ i ].count+"</td></tr>";
481
+ };
482
+ if (count){
483
+ return("<table>"+table+"</table>");
484
+ }else{
485
+ return("");
486
+ }
487
+ }
488
+
489
+ function gadash_pagedetails(data, searchvalue) {
490
+ var newdata = [];
491
+ for ( var i = 0; i < data["rows"].length; i = i + 1 ){
492
+ var sant=1;
493
+ for ( var j = 0; j < newdata.length; j = j + 1 ){
494
+ if (data["rows"][i][0]+data["rows"][i][1]+data["rows"][i][2]+data["rows"][i][3]==newdata[j][0]+newdata[j][1]+newdata[j][2]+newdata[j][3]){
495
+ newdata[j][6] = parseInt(newdata[j][6]) + parseInt(data["rows"][i][6]);
496
+ sant = 0;
497
+ }
498
+ }
499
+ if (sant){
500
+ newdata.push(data["rows"][i].slice());
501
+ }
502
+ }
503
+
504
+ var countrfr = 0;
505
+ var countkwd = 0;
506
+ var countdrt = 0;
507
+ var countscl = 0;
508
+ var countcpg = 0;
509
+ var tablerfr = "";
510
+ var tablekwd = "";
511
+ var tablescl = "";
512
+ var tablecpg = "";
513
+ var tabledrt = "";
514
+ for ( var i = 0; i < newdata.length; i = i + 1 ) {
515
+ if (newdata[i][0] == searchvalue){
516
+ var pagetitle = newdata[i][5];
517
+
518
+ switch (newdata[i][3]){
519
+
520
+ case "REFERRAL": countrfr += parseInt(newdata[ i ][6]);
521
+ tablerfr += "<tr><td class='gadash-pgdetailsl'>"+newdata[i][1]+"</td><td class='gadash-pgdetailsr'>"+newdata[ i ][6]+"</td></tr>";
522
+ break;
523
+ case "ORGANIC": countkwd += parseInt(newdata[ i ][6]);
524
+ tablekwd += "<tr><td class='gadash-pgdetailsl'>"+newdata[i][2]+"</td><td class='gadash-pgdetailsr'>"+newdata[ i ][6]+"</td></tr>";
525
+ break;
526
+ case "SOCIAL": countscl += parseInt(newdata[ i ][6]);
527
+ tablescl += "<tr><td class='gadash-pgdetailsl'>"+newdata[i][1]+"</td><td class='gadash-pgdetailsr'>"+newdata[ i ][6]+"</td></tr>";
528
+ break;
529
+ case "CUSTOM": countcpg += parseInt(newdata[ i ][6]);
530
+ tablecpg += "<tr><td class='gadash-pgdetailsl'>"+newdata[i][1]+"</td><td class='gadash-pgdetailsr'>"+newdata[ i ][6]+"</td></tr>";
531
+ break;
532
+ case "DIRECT": countdrt += parseInt(newdata[ i ][6]);
533
+ break;
534
+ };
535
+ };
536
+ };
537
+ if (countrfr){
538
+ tablerfr = "<table><tr><td><?php _e("REFERRALS", 'ga-dash');?> ("+countrfr+")</td></tr>"+tablerfr+"</table><br />";
539
+ }
540
+ if (countkwd){
541
+ tablekwd = "<table><tr><td><?php _e("KEYWORDS", 'ga-dash');?> ("+countkwd+")</td></tr>"+tablekwd+"</table><br />";
542
+ }
543
+ if (countscl){
544
+ tablescl = "<table><tr><td><?php _e("SOCIAL", 'ga-dash');?> ("+countscl+")</td></tr>"+tablescl+"</table><br />";
545
+ }
546
+ if (countcpg){
547
+ tablecpg = "<table><tr><td><?php _e("CAMPAIGN", 'ga-dash');?> ("+countcpg+")</td></tr>"+tablecpg+"</table><br />";
548
+ }
549
+ if (countdrt){
550
+ tabledrt = "<table><tr><td><?php _e("DIRECT", 'ga-dash');?> ("+countdrt+")</td></tr></table><br />";
551
+ }
552
+ return ("<p><center><strong>"+pagetitle+"</strong></center></p>"+tablerfr+tablekwd+tablescl+tablecpg+tabledrt);
553
+ }
554
+
555
+ function online_refresh(){
556
+ if (focusFlag){
557
+
558
+ jQuery.post(ajaxurl, {action: "gadashadmin_get_realtime", projectId: "<?php echo $projectId;?>", gadashadmin_security_widgetrealtime: "<?php echo wp_create_nonce('gadashadmin_get_realtime');?>"}, function(response){
559
+ var data = jQuery.parseJSON(response);
560
+
561
+ if (jQuery.isNumeric(data) || typeof data === "undefined"){
562
+ data = [];
563
+ data["totalsForAllResults"] = []
564
+ data["totalsForAllResults"]["rt:activeUsers"] = "0";
565
+ data["rows"]= [];
566
+ }
567
+
568
+ if (data["totalsForAllResults"]["rt:activeUsers"]!==document.getElementById("gadash-online").innerHTML){
569
+ jQuery("#gadash-online").fadeOut("slow");
570
+ jQuery("#gadash-online").fadeOut(500);
571
+ jQuery("#gadash-online").fadeOut("slow", function() {
572
+ if ((parseInt(data["totalsForAllResults"]["rt:activeUsers"]))<(parseInt(document.getElementById("gadash-online").innerHTML))){
573
+ jQuery("#gadash-online").css({'background-color' : '#FFE8E8'});
574
+ }else{
575
+ jQuery("#gadash-online").css({'background-color' : '#E0FFEC'});
576
+ }
577
+ document.getElementById("gadash-online").innerHTML = data["totalsForAllResults"]["rt:activeUsers"];
578
+ });
579
+ jQuery("#gadash-online").fadeIn("slow");
580
+ jQuery("#gadash-online").fadeIn(500);
581
+ jQuery("#gadash-online").fadeIn("slow", function() {
582
+ jQuery("#gadash-online").css({'background-color' : '#FFFFFF'});
583
+ });
584
+ };
585
+
586
+ if (data["totalsForAllResults"]["rt:activeUsers"] == 0){
587
+ data["rows"]= [];
588
+ };
589
+
590
+ var pagepath = [];
591
+ var referrals = [];
592
+ var keywords = [];
593
+ var social = [];
594
+ var visittype = [];
595
+ var custom = [];
596
+ for ( var i = 0; i < data["rows"].length; i = i + 1 ) {
597
+ pagepath.push( data["rows"][ i ][0] );
598
+ if (data["rows"][i][3]=="REFERRAL"){
599
+ referrals.push( data["rows"][ i ][1] );
600
+ }
601
+ if (data["rows"][i][3]=="ORGANIC"){
602
+ keywords.push( data["rows"][ i ][2] );
603
+ }
604
+ if (data["rows"][i][3]=="SOCIAL"){
605
+ social.push( data["rows"][ i ][1] );
606
+ }
607
+ if (data["rows"][i][3]=="CUSTOM"){
608
+ custom.push( data["rows"][ i ][1] );
609
+ }
610
+ visittype.push( data["rows"][ i ][3] );
611
+ }
612
+
613
+ var upagepathstats = [];
614
+ var upagepath = pagepath.filter(onlyUniqueValues);
615
+ for ( var i = 0; i < upagepath.length; i = i + 1 ) {
616
+ upagepathstats[i]={"pagepath":upagepath[i],"count":countsessions(data,upagepath[i])};
617
+ }
618
+ upagepathstats.sort( function(a,b){ return b.count - a.count } );
619
+
620
+ var pgstatstable = "";
621
+ for ( var i = 0; i < upagepathstats.length; i = i + 1 ) {
622
+ if (i < <?php echo $GADASH_Config->options['ga_realtime_pages']; ?>){
623
+ pgstatstable += '<div class="gadash-pline"><div class="gadash-pleft"><a href="#" title="'+gadash_pagedetails(data, upagepathstats[i].pagepath)+'">'+upagepathstats[i].pagepath.substring(0,70)+'</a></div><div class="gadash-pright">'+upagepathstats[i].count+'</div></div>';
624
+ }
625
+ }
626
+ document.getElementById("gadash-pages").innerHTML='<br /><div class="gadash-pg">'+pgstatstable+'</div>';
627
+
628
+ var ureferralsstats = [];
629
+ var ureferrals = referrals.filter(onlyUniqueValues);
630
+ for ( var i = 0; i < ureferrals.length; i = i + 1 ) {
631
+ ureferralsstats[i]={"value":ureferrals[i],"count":countsessions(data,ureferrals[i])};
632
+ }
633
+ ureferralsstats.sort( function(a,b){ return b.count - a.count } );
634
+
635
+ var ukeywordsstats = [];
636
+ var ukeywords = keywords.filter(onlyUniqueValues);
637
+ for ( var i = 0; i < ukeywords.length; i = i + 1 ) {
638
+ ukeywordsstats[i]={"value":ukeywords[i],"count":countsessions(data,ukeywords[i])};
639
+ }
640
+ ukeywordsstats.sort( function(a,b){ return b.count - a.count } );
641
+
642
+ var usocialstats = [];
643
+ var usocial = social.filter(onlyUniqueValues);
644
+ for ( var i = 0; i < usocial.length; i = i + 1 ) {
645
+ usocialstats[i]={"value":usocial[i],"count":countsessions(data,usocial[i])};
646
+ }
647
+ usocialstats.sort( function(a,b){ return b.count - a.count } );
648
+
649
+ var ucustomstats = [];
650
+ var ucustom = custom.filter(onlyUniqueValues);
651
+ for ( var i = 0; i < ucustom.length; i = i + 1 ) {
652
+ ucustomstats[i]={"value":ucustom[i],"count":countsessions(data,ucustom[i])};
653
+ }
654
+ ucustomstats.sort( function(a,b){ return b.count - a.count } );
655
+
656
+ var uvisittype = ["REFERRAL","ORGANIC","SOCIAL","CUSTOM"];
657
+ document.getElementById("gadash-tdo-right").innerHTML = '<div class="gadash-bigtext"><a href="#" title="'+gadash_generatetooltip(ureferralsstats)+'"><div class="gadash-bleft">'+'<?php _e("REFERRAL", 'ga-dash');?>'+'</a></div><div class="gadash-bright">'+countsessions(data,uvisittype[0])+'</div></div>';
658
+ document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><a href="#" title="'+gadash_generatetooltip(ukeywordsstats)+'"><div class="gadash-bleft">'+'<?php _e("ORGANIC", 'ga-dash');?>'+'</a></div><div class="gadash-bright">'+countsessions(data,uvisittype[1])+'</div></div>';
659
+ document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><a href="#" title="'+gadash_generatetooltip(usocialstats)+'"><div class="gadash-bleft">'+'<?php _e("SOCIAL", 'ga-dash');?>'+'</a></div><div class="gadash-bright">'+countsessions(data,uvisittype[2])+'</div></div>';
660
+ document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><a href="#" title="'+gadash_generatetooltip(ucustomstats)+'"><div class="gadash-bleft">'+'<?php _e("CAMPAIGN", 'ga-dash');?>'+'</a></div><div class="gadash-bright">'+countsessions(data,uvisittype[3])+'</div></div>';
661
+
662
+ var uvisitortype = ["DIRECT","NEW"];
663
+ document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><div class="gadash-bleft">'+'<?php _e("DIRECT", 'ga-dash');?>'+'</div><div class="gadash-bright">'+countsessions(data,uvisitortype[0])+'</div></div>';
664
+ document.getElementById("gadash-tdo-right").innerHTML += '<div class="gadash-bigtext"><div class="gadash-bleft">'+'<?php _e("NEW", 'ga-dash');?>'+'</div><div class="gadash-bright">'+countsessions(data,uvisitortype[1])+'</div></div>';
665
+
666
+ });
667
+ };
668
+ };
669
+ online_refresh();
670
+ setInterval(online_refresh, 60000);
671
+ </script>
672
+ <?php } else if (array_search($query, array('referrers','contentpages','searches')) !== FALSE) {?>
673
+ <div id="gadash-trafficchannels"></div>
674
+ <div id="gadash-prs"></div>
675
+ <script type="text/javascript">
676
+ google.load("visualization", "1", {packages:["table","orgchart"]})
677
+ NProgress.configure({ parent: "#gadash-progressbar" });
678
+ NProgress.configure({ showSpinner: false });
679
+ NProgress.start();
680
+ npcounter = 0;
681
+
682
+ 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){
683
+
684
+ if (!jQuery.isNumeric(response)){
685
+ gadash_prs=jQuery.parseJSON(response);
686
+ google.setOnLoadCallback(ga_dash_drawprs(gadash_prs));
687
+ }else{
688
+ jQuery("#gadash-prs").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
689
+ jQuery("#gadash-prs").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
690
+ checknpcounter(1);
691
+ }
692
+ });
693
+
694
+ 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){
695
+
696
+ if (!jQuery.isNumeric(response)){
697
+ gadash_trafficchannels=jQuery.parseJSON(response);
698
+ google.setOnLoadCallback(ga_dash_drawtrafficchannels(gadash_trafficchannels));
699
+ }else{
700
+ jQuery("#gadash-trafficchannels").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
701
+ jQuery("#gadash-trafficchannels").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
702
+ checknpcounter(1);
703
+ }
704
+ });
705
+
706
+ function ga_dash_drawprs(gadash_prs) {
707
+ var data = google.visualization.arrayToDataTable(gadash_prs);
708
+ var options = {
709
+ page: 'enable',
710
+ pageSize: 10,
711
+ width: '100%',
712
+ allowHtml:true
713
+ };
714
+
715
+ var chart = new google.visualization.Table(document.getElementById('gadash-prs'));
716
+ chart.draw(data, options);
717
+ checknpcounter(1);
718
+ };
719
+
720
+ function ga_dash_drawtrafficchannels(gadash_trafficchannels) {
721
+ var data = google.visualization.arrayToDataTable(gadash_trafficchannels);
722
+ var options = {
723
+ allowCollapse:true,
724
+ allowHtml:true
725
+ };
726
+
727
+ var chart = new google.visualization.OrgChart(document.getElementById('gadash-trafficchannels'));
728
+ chart.draw(data, options);
729
+ checknpcounter(1);
730
+ };
731
+ </script>
732
+ <?php } else if ($query == 'trafficdetails') {?>
733
+ <div id="gadash-trafficchannels"></div>
734
+ <div class="gadash-floatwraper">
735
+ <div id="gadash-trafficmediums"></div>
736
+ <div id="gadash-traffictype"></div>
737
+ </div>
738
+ <div class="gadash-floatwraper">
739
+ <div id="gadash-trafficorganic"></div>
740
+ <div id="gadash-socialnetworks"></div>
741
+ </div>
742
+ <script type="text/javascript">
743
+ google.load("visualization", "1", {packages:["corechart","orgchart"]});
744
+ NProgress.configure({ parent: "#gadash-progressbar" });
745
+ NProgress.configure({ showSpinner: false });
746
+ NProgress.start();
747
+ npcounter = 0;
748
+
749
+ 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){
750
+
751
+ if (!jQuery.isNumeric(response)){
752
+ gadash_trafficmediums=jQuery.parseJSON(response);
753
+ google.setOnLoadCallback(ga_dash_drawtrafficmediums(gadash_trafficmediums));
754
+ }else{
755
+ jQuery("#gadash-trafficmediums").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
756
+ jQuery("#gadash-trafficmediums").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
757
+ checknpcounter(4);
758
+ }
759
+ });
760
+
761
+ jQuery.post(ajaxurl, {action: "gadashadmin_get_widgetreports",projectId: "<?php echo $projectId; ?>",from: "<?php echo $from; ?>",to: "<?php echo $to; ?>",query: "visitorType",gadashadmin_security_widget_reports: "<?php echo wp_create_nonce('gadashadmin_get_widgetreports'); ?>"}, function(response){
762
+
763
+ if (!jQuery.isNumeric(response)){
764
+ gadash_traffictype=jQuery.parseJSON(response);
765
+ google.setOnLoadCallback(ga_dash_drawtraffictype(gadash_traffictype));
766
+ }else{
767
+ jQuery("#gadash-traffictype").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
768
+ jQuery("#gadash-traffictype").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
769
+ checknpcounter(4);
770
+ }
771
+ });
772
+
773
+ 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){
774
+
775
+ if (!jQuery.isNumeric(response)){
776
+ gadash_trafficchannels=jQuery.parseJSON(response);
777
+ google.setOnLoadCallback(ga_dash_drawtrafficchannels(gadash_trafficchannels));
778
+ }else{
779
+ jQuery("#gadash-trafficchannels").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
780
+ jQuery("#gadash-trafficchannels").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
781
+ checknpcounter(4);
782
+ }
783
+ });
784
+
785
+ 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){
786
+
787
+ if (!jQuery.isNumeric(response)){
788
+ gadash_socialnetworks=jQuery.parseJSON(response);
789
+ google.setOnLoadCallback(ga_dash_drawsocialnetworks(gadash_socialnetworks));
790
+ }else{
791
+ jQuery("#gadash-socialnetworks").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
792
+ jQuery("#gadash-socialnetworks").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
793
+ checknpcounter(4);
794
+ }
795
+ });
796
+
797
+
798
+ 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){
799
+
800
+ if (!jQuery.isNumeric(response)){
801
+ gadash_trafficorganic=jQuery.parseJSON(response);
802
+ google.setOnLoadCallback(ga_dash_drawtrafficorganic(gadash_trafficorganic));
803
+ }else{
804
+ jQuery("#gadash-trafficorganic").css({"background-color":"#F7F7F7","height":"auto","padding-top":"80px","padding-bottom":"80px","color":"#000","text-align":"center"});
805
+ jQuery("#gadash-trafficorganic").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
806
+ checknpcounter(4);
807
+ }
808
+ });
809
+
810
+ function ga_dash_drawtrafficmediums(gadash_trafficmediums) {
811
+ var data = google.visualization.arrayToDataTable(gadash_trafficmediums);
812
+ var options = {
813
+ is3D: false,
814
+ tooltipText: 'percentage',
815
+ legend: 'none',
816
+ chartArea: {width: '99%',height: '80%'},
817
+ title: '<?php _e( "Traffic Mediums", 'ga-dash' ); ?>',
818
+ colors:['<?php echo esc_html($GADASH_Config->options ['ga_dash_style']); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], - 10 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], + 20 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], + 10 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], - 20 )); ?>']
819
+ };
820
+
821
+ var chart = new google.visualization.PieChart(document.getElementById('gadash-trafficmediums'));
822
+ chart.draw(data, options);
823
+ checknpcounter(4);
824
+ };
825
+
826
+ function ga_dash_drawtraffictype(gadash_traffictype) {
827
+ var data = google.visualization.arrayToDataTable(gadash_traffictype);
828
+ var options = {
829
+ is3D: false,
830
+ tooltipText: 'percentage',
831
+ legend: 'none',
832
+ chartArea: {width: '99%',height: '80%'},
833
+ title: '<?php _e( "Visitor Type", 'ga-dash' ); ?>',
834
+ colors:['<?php echo esc_html($GADASH_Config->options ['ga_dash_style']); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], - 10 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], + 20 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], + 10 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], - 20 )); ?>']
835
+ };
836
+
837
+ var chart = new google.visualization.PieChart(document.getElementById('gadash-traffictype'));
838
+ chart.draw(data, options);
839
+ checknpcounter(4);
840
+ };
841
+
842
+ function ga_dash_drawsocialnetworks(gadash_socialnetworks) {
843
+ var data = google.visualization.arrayToDataTable(gadash_socialnetworks);
844
+ var options = {
845
+ is3D: false,
846
+ tooltipText: 'percentage',
847
+ legend: 'none',
848
+ chartArea: {width: '99%',height: '80%'},
849
+ title: '<?php _e( "Social Networks", 'ga-dash' ); ?>',
850
+ colors:['<?php echo esc_html($GADASH_Config->options ['ga_dash_style']); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], - 10 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], + 20 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], + 10 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], - 20 )); ?>']
851
+ };
852
+
853
+ var chart = new google.visualization.PieChart(document.getElementById('gadash-socialnetworks'));
854
+ chart.draw(data, options);
855
+ checknpcounter(4);
856
+ };
857
+
858
+ function ga_dash_drawtrafficorganic(gadash_trafficorganic) {
859
+ var data = google.visualization.arrayToDataTable(gadash_trafficorganic);
860
+ var options = {
861
+ is3D: false,
862
+ tooltipText: 'percentage',
863
+ legend: 'none',
864
+ chartArea: {width: '99%',height: '80%'},
865
+ title: '<?php _e( "Search Engines", 'ga-dash' ); ?>',
866
+ colors:['<?php echo esc_html($GADASH_Config->options ['ga_dash_style']); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], - 10 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], + 20 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], + 10 )); ?>','<?php echo esc_html($tools->colourVariator ( $GADASH_Config->options ['ga_dash_style'], - 20 )); ?>']
867
+ };
868
+
869
+ var chart = new google.visualization.PieChart(document.getElementById('gadash-trafficorganic'));
870
+ chart.draw(data, options);
871
+ checknpcounter(4);
872
+ };
873
+
874
+ function ga_dash_drawtrafficchannels(gadash_trafficchannels) {
875
+ var data = google.visualization.arrayToDataTable(gadash_trafficchannels);
876
+ var options = {
877
+ allowCollapse:true,
878
+ allowHtml:true
879
+ };
880
+
881
+ var chart = new google.visualization.OrgChart(document.getElementById('gadash-trafficchannels'));
882
+ chart.draw(data, options);
883
+ checknpcounter(4);
884
+ };
885
+ </script>
886
+ <?php } else if ($query == 'locations') {?>
887
+ <div id="gadash-map"></div>
888
+ <div id="gadash-locations"></div>
889
+ <script type="text/javascript">
890
+ google.load("visualization", "1", {packages:["geochart","table"]});
891
+ NProgress.configure({ parent: "#gadash-progressbar" });
892
+ NProgress.configure({ showSpinner: false });
893
+ NProgress.start();
894
+ npcounter = 0;
895
+
896
+ 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){
897
+
898
+ if (!jQuery.isNumeric(response)){
899
+ gadash_locations=jQuery.parseJSON(response);
900
+ google.setOnLoadCallback(ga_dash_drawmaplocations(gadash_locations));
901
+ google.setOnLoadCallback(ga_dash_drawlocations(gadash_locations));
902
+ }else{
903
+ jQuery("#gadash-map").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
904
+ jQuery("#gadash-map").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
905
+ checknpcounter(1);
906
+ jQuery("#gadash-locations").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
907
+ jQuery("#gadash-locations").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
908
+ checknpcounter(1);
909
+ }
910
+ });
911
+ function ga_dash_drawmaplocations(gadash_locations) {
912
+
913
+ var data = google.visualization.arrayToDataTable(gadash_locations);
914
+
915
+ var options = {
916
+ chartArea: {width: '99%',height: '90%'},
917
+ colors: ['<?php echo $light_color; ?>', '<?php echo $dark_color; ?>'],
918
+ <?php
919
+ $GADASH_GAPI->getcountrycodes();
920
+ if ($GADASH_Config->options['ga_target_geomap'] and isset($GADASH_GAPI->country_codes[$GADASH_Config->options['ga_target_geomap']])) {
921
+ ?>
922
+ region : '<?php echo esc_html($GADASH_Config->options ['ga_target_geomap']); ?>',
923
+ displayMode : 'markers',
924
+ datalessRegionColor : 'EFEFEF'
925
+ <?php } ?>
926
+ }
927
+ var chart = new google.visualization.GeoChart(document.getElementById('gadash-map'));
928
+ chart.draw(data, options);
929
+ checknpcounter(1);
930
+ }
931
+
932
+ function ga_dash_drawlocations(gadash_locations) {
933
+ var data = google.visualization.arrayToDataTable(gadash_locations);
934
+ var options = {
935
+ page: 'enable',
936
+ pageSize: 10,
937
+ width: '100%',
938
+ allowHtml:true
939
+ };
940
+
941
+ var chart = new google.visualization.Table(document.getElementById('gadash-locations'));
942
+ chart.draw(data, options);
943
+ checknpcounter(1);
944
+ };
945
+ </script>
946
+ <?php } else {?>
947
+ <div id="gadash-mainchart"></div>
948
+ <div id="gadash-bottomstats" class="gadash-wrapper">
949
+ <div class="inside">
950
+ <div class="small-box">
951
+ <h3><?php _e( "Sessions", 'ga-dash' );?></h3>
952
+ <p id="gdsessions">&nbsp;</p>
953
+ </div>
954
+ <div class="small-box">
955
+ <h3><?php _e( "Users", 'ga-dash' );?></h3>
956
+ <p id="gdusers">&nbsp;</p>
957
+ </div>
958
+ <div class="small-box">
959
+ <h3><?php _e( "Page Views", 'ga-dash' );?></h3>
960
+ <p id="gdpageviews">&nbsp;</p>
961
+ </div>
962
+ <div class="small-box">
963
+ <h3><?php _e( "Bounce Rate", 'ga-dash' );?></h3>
964
+ <p id="gdbouncerate">&nbsp;</p>
965
+ </div>
966
+ <div class="small-box">
967
+ <h3><?php _e( "Organic Search", 'ga-dash' );?></h3>
968
+ <p id="gdorganicsearch">&nbsp;</p>
969
+ </div>
970
+ <div class="small-box">
971
+ <h3><?php _e( "Pages/Session", 'ga-dash' );?></h3>
972
+ <p id="gdpagespervisit">&nbsp;</p>
973
+ </div>
974
+ </div>
975
+ </div>
976
+ <script type="text/javascript">
977
+
978
+ google.load("visualization", "1", {packages:["corechart"]})
979
+ NProgress.configure({ parent: "#gadash-progressbar" });
980
+ NProgress.configure({ showSpinner: false });
981
+ NProgress.start();
982
+ npcounter = 0;
983
+
984
+ 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){
985
+
986
+ if (!jQuery.isNumeric(response)){
987
+ gadash_mainchart=jQuery.parseJSON(response);
988
+ google.setOnLoadCallback(ga_dash_drawmainchart(gadash_mainchart));
989
+ }else{
990
+ jQuery("#gadash-mainchart").css({"background-color":"#F7F7F7","height":"auto","padding-top":"125px","padding-bottom":"125px","color":"#000","text-align":"center"});
991
+ jQuery("#gadash-mainchart").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
992
+ checknpcounter(1);
993
+ }
994
+ });
995
+
996
+ 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){
997
+
998
+ if (!jQuery.isNumeric(response)){
999
+ gadash_bottomstats=jQuery.parseJSON(response);
1000
+ ga_dash_drawbottomstats(gadash_bottomstats);
1001
+ }else{
1002
+ jQuery("#gadash-bottomstats").css({"background-color":"#F7F7F7","height":"auto","padding-top":"40px","padding-bottom":"40px","color":"#000","text-align":"center","width": "98%"});
1003
+ jQuery("#gadash-bottomstats").html("<?php _e("This report is unavailable", 'ga-dash'); ?> ("+response+")");
1004
+ checknpcounter(1);
1005
+ }
1006
+ });
1007
+
1008
+ function ga_dash_drawbottomstats(gadash_bottomstats) {
1009
+ jQuery("#gadash-bottomstats #gdsessions").text(gadash_bottomstats[0]);
1010
+ jQuery("#gadash-bottomstats #gdusers").text(gadash_bottomstats[1]);
1011
+ jQuery("#gadash-bottomstats #gdpageviews").text(gadash_bottomstats[2]);
1012
+ jQuery("#gadash-bottomstats #gdbouncerate").text(parseFloat(gadash_bottomstats[3]).toFixed(2)+"%");
1013
+ jQuery("#gadash-bottomstats #gdorganicsearch").text(gadash_bottomstats[4]);
1014
+ jQuery("#gadash-bottomstats #gdpagespervisit").text(parseFloat(gadash_bottomstats[5]).toFixed(2));
1015
+ checknpcounter(1);
1016
+ }
1017
+
1018
+ function ga_dash_drawmainchart(gadash_mainchart) {
1019
+
1020
+ var data = google.visualization.arrayToDataTable(gadash_mainchart);
1021
+
1022
+ var options = {
1023
+ legend: {position: 'none'},
1024
+ pointSize: 3,<?php echo $css;?>
1025
+ chartArea: {width: '99%',height: '90%'},
1026
+ vAxis: { textPosition: "in", minValue: 0},
1027
+ hAxis: { textPosition: 'none' }
1028
+ };
1029
+ <?php echo $formater?>
1030
+ var chart = new google.visualization.AreaChart(document.getElementById('gadash-mainchart'));
1031
+ chart.draw(data, options);
1032
+ checknpcounter(1);
1033
+ };
1034
+ </script>
1035
+ <?php
1036
+ }
1037
+ }
1038
+ }
1039
+ }
1040
+
1041
+ if (is_admin()) {
1042
+ $GADASH_Widgets = new GADASH_Widgets();
1043
+ }
admin/ga_dash_settings.php ADDED
@@ -0,0 +1,1529 @@