Google Analytics - Version 2.0.4

Version Description

  • Replaced Bootstrap, should fix most of the issues with Google Sign in
  • Fixed occasional black screen on GA sign
Download this release

Release Info

Developer ShareThis
Plugin Icon wp plugin Google Analytics
Version 2.0.4
Comparing to
See all releases

Code changes from version 2.0.3 to 2.0.4

class/Ga_Admin.php CHANGED
@@ -290,18 +290,6 @@ class Ga_Admin {
290
  ), true );
291
  }
292
 
293
- /**
294
- * Adds Bootstrap scripts.
295
- */
296
- public static function enqueue_bootstrap() {
297
- wp_register_script( GA_NAME . '-bootstrap-js', GA_PLUGIN_URL . '/js/bootstrap.min.js', array(
298
- 'jquery'
299
- ) );
300
- wp_register_style( GA_NAME . '-bootstrap-css', GA_PLUGIN_URL . '/css/bootstrap.min.css', false, null, 'all' );
301
- wp_enqueue_script( GA_NAME . '-bootstrap-js' );
302
- wp_enqueue_style( GA_NAME . '-bootstrap-css' );
303
- }
304
-
305
  /**
306
  * Adds JS scripts for the settings page.
307
  */
@@ -317,7 +305,12 @@ class Ga_Admin {
317
  */
318
  public static function enqueue_ga_css() {
319
  wp_register_style( GA_NAME . '-css', GA_PLUGIN_URL . '/css/' . GA_NAME . '.css', false, null, 'all' );
 
320
  wp_enqueue_style( GA_NAME . '-css' );
 
 
 
 
321
  }
322
 
323
  /**
@@ -351,7 +344,6 @@ class Ga_Admin {
351
  }
352
 
353
  if ( Ga_Helper::is_plugin_page() ) {
354
- self::enqueue_bootstrap();
355
  self::enqueue_ga_scripts();
356
  }
357
  }
@@ -500,10 +492,10 @@ class Ga_Admin {
500
  }
501
 
502
  public static function init_oauth() {
503
- // $code = ! empty( $_GET['code'] ) ? $_GET['code'] : null;
504
  $code = Ga_Helper::get_option( self::GA_OAUTH_AUTH_CODE_OPTION_NAME );
505
 
506
- if ( ! Ga_Helper::is_authorized() && $code ) {
507
  Ga_Helper::update_option( self::GA_OAUTH_AUTH_CODE_OPTION_NAME, "" );
508
 
509
  // Get access token
@@ -514,12 +506,13 @@ class Ga_Admin {
514
  $param = '';
515
  if ( ! self::save_access_token( $response ) ) {
516
  $param = '&err=1';
517
- }
518
- self::api_client()->set_access_token( $response->getData() );
519
 
520
- // Get accounts data
521
- $account_summaries = self::api_client()->call( 'ga_api_account_summaries' );
522
- self::save_ga_account_summaries( $account_summaries->getData() );
 
523
 
524
  wp_redirect( admin_url( Ga_Helper::GA_SETTINGS_PAGE_URL . $param ) );
525
  }
290
  ), true );
291
  }
292
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  /**
294
  * Adds JS scripts for the settings page.
295
  */
305
  */
306
  public static function enqueue_ga_css() {
307
  wp_register_style( GA_NAME . '-css', GA_PLUGIN_URL . '/css/' . GA_NAME . '.css', false, null, 'all' );
308
+ wp_register_style( GA_NAME . '-additional-css', GA_PLUGIN_URL . '/css/ga_additional.css', false, null, 'all' );
309
  wp_enqueue_style( GA_NAME . '-css' );
310
+ wp_enqueue_style( GA_NAME . '-additional-css' );
311
+
312
+ wp_register_style( GA_NAME . '-modal-css', GA_PLUGIN_URL . '/css/ga_modal.css', false, null, 'all' );
313
+ wp_enqueue_style( GA_NAME . '-modal-css' );
314
  }
315
 
316
  /**
344
  }
345
 
346
  if ( Ga_Helper::is_plugin_page() ) {
 
347
  self::enqueue_ga_scripts();
348
  }
349
  }
492
  }
493
 
494
  public static function init_oauth() {
495
+
496
  $code = Ga_Helper::get_option( self::GA_OAUTH_AUTH_CODE_OPTION_NAME );
497
 
498
+ if ( ! Ga_Helper::is_authorized() && ! empty( $code ) ) {
499
  Ga_Helper::update_option( self::GA_OAUTH_AUTH_CODE_OPTION_NAME, "" );
500
 
501
  // Get access token
506
  $param = '';
507
  if ( ! self::save_access_token( $response ) ) {
508
  $param = '&err=1';
509
+ } else {
510
+ self::api_client()->set_access_token( $response->getData() );
511
 
512
+ // Get accounts data
513
+ $account_summaries = self::api_client()->call( 'ga_api_account_summaries' );
514
+ self::save_ga_account_summaries( $account_summaries->getData() );
515
+ }
516
 
517
  wp_redirect( admin_url( Ga_Helper::GA_SETTINGS_PAGE_URL . $param ) );
518
  }
class/Ga_Helper.php CHANGED
@@ -53,7 +53,8 @@ class Ga_Helper {
53
  public static function is_plugin_page() {
54
  $site = get_current_screen();
55
 
56
- return preg_match( '/' . GA_NAME . '/', $site->base );
 
57
  }
58
 
59
  /**
53
  public static function is_plugin_page() {
54
  $site = get_current_screen();
55
 
56
+ return preg_match( '/' . GA_NAME . '/i', $site->base ) || preg_match( '/' . GA_NAME . '/i',
57
+ $_SERVER['REQUEST_URI'] );
58
  }
59
 
60
  /**
css/ga_additional.css ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @-ms-viewport {
2
+ width: device-width;
3
+ }
4
+
5
+ .ga-table {
6
+ border-collapse: collapse;
7
+ border-spacing: 0;
8
+ background-color: transparent;
9
+ width: 100%;
10
+ max-width: 100%;
11
+ margin-bottom: 20px;
12
+ border: 1px solid #dddddd;
13
+ }
14
+
15
+ .ga-table > tbody > tr > th,
16
+ .ga-table > tbody > tr > td {
17
+ padding: 8px;
18
+ line-height: 1.42857143;
19
+ vertical-align: top;
20
+ border: 1px solid #dddddd;
21
+ }
22
+
23
+ .ga-table col[class*="col-"] {
24
+ position: static;
25
+ float: none;
26
+ display: table-column;
27
+ }
28
+
29
+ .ga-table td[class*="col-"],
30
+ .ga-table th[class*="col-"] {
31
+ position: static;
32
+ float: none;
33
+ display: table-cell;
34
+ }
35
+
36
+ .progress {
37
+ overflow: hidden;
38
+ height: 20px;
39
+ margin-bottom: 20px;
40
+ background-color: #f5f5f5;
41
+ border-radius: 4px;
42
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
43
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
44
+ }
45
+
46
+ .progress-bar {
47
+ float: left;
48
+ width: 0%;
49
+ height: 100%;
50
+ font-size: 12px;
51
+ line-height: 20px;
52
+ color: #ffffff;
53
+ text-align: center;
54
+ background-color: #337ab7;
55
+ -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
56
+ box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
57
+ -webkit-transition: width 0.6s ease;
58
+ -o-transition: width 0.6s ease;
59
+ transition: width 0.6s ease;
60
+ }
61
+
62
+ .progress.active .progress-bar,
63
+ .progress-bar.active {
64
+ -webkit-animation: progress-bar-stripes 2s linear infinite;
65
+ -o-animation: progress-bar-stripes 2s linear infinite;
66
+ animation: progress-bar-stripes 2s linear infinite;
67
+ }
68
+
69
+ .ga-panel {
70
+ margin-bottom: 20px;
71
+ background-color: #ffffff;
72
+ border: 1px solid transparent;
73
+ border-radius: 4px;
74
+ -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
75
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
76
+ }
77
+
78
+ .ga-panel-body {
79
+ padding: 15px;
80
+ }
81
+
82
+ .ga-panel-heading {
83
+ padding: 10px 15px;
84
+ border-bottom: 1px solid transparent;
85
+ border-top-right-radius: 3px;
86
+ border-top-left-radius: 3px;
87
+ }
88
+
89
+ .ga-panel-heading > .dropdown .dropdown-toggle {
90
+ color: inherit;
91
+ }
92
+
93
+ .ga-panel-heading > strong {
94
+ font-weight: bold;
95
+ }
96
+
97
+ .ga-panel > .ga-panel-heading + .ga-panel-collapse > .list-group .list-group-item:first-child {
98
+ border-top-right-radius: 0;
99
+ border-top-left-radius: 0;
100
+ }
101
+
102
+ .ga-panel > .ga-table {
103
+ margin-bottom: 0;
104
+ }
105
+
106
+ .ga-panel > .ga-table:first-child {
107
+ border-top-right-radius: 3px;
108
+ border-top-left-radius: 3px;
109
+ }
110
+
111
+ .ga-panel > .ga-table:first-child > tbody:first-child > tr:first-child {
112
+ border-top-left-radius: 3px;
113
+ border-top-right-radius: 3px;
114
+ }
115
+
116
+ .ga-panel > .ga-table:first-child > tbody:first-child > tr:first-child td:first-child {
117
+ border-top-left-radius: 3px;
118
+ border-top-right-radius: 3px;
119
+ }
120
+
121
+ .ga-panel > .ga-table:last-child {
122
+ border-bottom-right-radius: 3px;
123
+ border-bottom-left-radius: 3px;
124
+ }
125
+
126
+ .ga-panel > .ga-table:last-child > tbody:last-child > tr:last-child {
127
+ border-bottom-left-radius: 3px;
128
+ border-bottom-right-radius: 3px;
129
+ }
130
+
131
+ .ga-panel > .ga-table:last-child > tbody:last-child > tr:last-child td:first-child,
132
+ .ga-panel > .ga-table:last-child > tbody:last-child > tr:last-child th:first-child {
133
+ border-bottom-left-radius: 3px;
134
+ border-bottom-right-radius: 3px;
135
+ }
136
+
137
+ .ga-panel > .ga-panel-body + .ga-table,
138
+ .ga-panel > .ga-table + .ga-panel-body {
139
+ border-top: 1px solid #dddddd;
140
+ }
141
+
142
+ .ga-panel > .ga-table > tbody:first-child > tr:first-child th,
143
+ .ga-panel > .ga-table > tbody:first-child > tr:first-child td {
144
+ border-top: 0;
145
+ }
146
+
147
+ .ga-panel > .ga-table {
148
+ border: 0;
149
+ }
150
+
151
+ .ga-panel-default {
152
+ border-color: #dddddd;
153
+ }
154
+
155
+ .ga-panel-default > .ga-panel-heading {
156
+ color: #333333;
157
+ background-color: #dcdcdc;
158
+ border-color: #dddddd;
159
+ }
160
+
161
+ .ga-col-pageviews, .ga-box, .ga-col-progressbar {
162
+ position: relative;
163
+ min-height: 1px;
164
+ padding-left: 15px;
165
+ padding-right: 15px;
166
+ }
167
+
168
+ .ga-col-name {
169
+ width: 20%;
170
+ overflow: hidden;
171
+ text-overflow: ellipsis;
172
+ word-wrap: break-word;
173
+ }
174
+
175
+ .ga-row:before,
176
+ .ga-row:after,
177
+ .ga-panel-body:before,
178
+ .ga-panel-body:after {
179
+ content: " ";
180
+ display: table;
181
+ }
182
+
183
+ .ga-row:after,
184
+ .ga-panel-body:after {
185
+ clear: both;
186
+ }
187
+
188
+ .ga-row {
189
+ margin-left: -15px;
190
+ margin-right: -15px;
191
+ }
192
+
193
+ .ga-col-pageviews, .ga-box, .ga-col-progressbar {
194
+ float: left;
195
+ }
196
+
197
+ .ga-col-pageviews {
198
+ width: 16.66666667%;
199
+ }
200
+
201
+ .ga-col-progressbar {
202
+ width: 41.66666667%;
203
+ }
204
+
205
+ .ga-box-diff {
206
+ font-size: 16px;
207
+ }
208
+
209
+ .ga-box-comparison {
210
+ color: grey;
211
+ font-size: 12px;
212
+ overflow: hidden;
213
+ text-overflow: ellipsis;
214
+ white-space: nowrap;
215
+ }
216
+
217
+ .ga-box-label {
218
+ font-size: 14px;
219
+ overflow: hidden;
220
+ text-overflow: ellipsis;
221
+ white-space: nowrap;
222
+ }
223
+
224
+ .ga-box {
225
+ width: 140px;
226
+ box-sizing: border-box;
227
+ }
228
+
229
+ @media (min-width: 600px) {
230
+ .ga-box {
231
+ width: 25%;
232
+ }
233
+ }
234
+
235
+ @media (min-width: 760px) {
236
+ .ga-box-diff {
237
+ font-size: 24px;
238
+ }
239
+
240
+ .ga-box-comparison {
241
+ font-size: 16px
242
+ }
243
+
244
+ .ga-box-label {
245
+ font-size: 16px
246
+ }
247
+
248
+ }
249
+
250
+ @media screen and (orientation: portrait) and (-webkit-device-pixel-ratio: 3) {
251
+ .ga-col-name {
252
+ max-width: 100px;
253
+ }
254
+
255
+ .ga-chart {
256
+ width: 300px;
257
+ overflow: hidden;
258
+ text-overflow: ellipsis;
259
+ }
260
+ }
261
+
262
+ .ga-source-name {
263
+ color: #337ab7;
264
+ text-decoration: none;
265
+ word-wrap: break-word;
266
+ }
267
+
268
+ .ga-alert {
269
+ padding: 15px;
270
+ margin-bottom: 20px;
271
+ border: 1px solid transparent;
272
+ border-radius: 4px;
273
+ }
274
+
275
+ .ga-alert-warning {
276
+ color: #8a6d3b;
277
+ background-color: #fcf8e3;
278
+ border-color: #faebcc;
279
+ max-width: 95%;
280
+ }
css/ga_modal.css ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ga-modal {
2
+ display: none; /* Hidden by default */
3
+ position: fixed; /* Stay in place */
4
+ z-index: 1; /* Sit on top */
5
+ left: 0;
6
+ top: 0;
7
+ width: 100%; /* Full width */
8
+ height: 100%; /* Full height */
9
+ overflow: auto; /* Enable scroll if needed */
10
+ background-color: rgb(0, 0, 0); /* Fallback color */
11
+ background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */
12
+ }
13
+
14
+ .ga-modal-dialog {
15
+ }
16
+
17
+ .ga-modal-body {
18
+ padding: 15px 0px 15px 16px;
19
+ background-color: #fff;
20
+ }
21
+
22
+ .ga-modal-header {
23
+ padding: 2px 16px;
24
+ background-color: #fff;
25
+ border-bottom: 1px solid #cccccc;
26
+ border-top-left-radius: 4px;
27
+ border-top-right-radius: 4px;
28
+ color: #000;
29
+ }
30
+
31
+ .ga-modal-content {
32
+ position: relative;
33
+ background-color: transparent;
34
+ margin: auto;
35
+ margin-top: 50px;
36
+ padding: 0;
37
+ border: 1px solid #888;
38
+ width: 50%;
39
+ box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
40
+ -webkit-animation-name: animatetop;
41
+ -webkit-animation-duration: 0.4s;
42
+ animation-name: animatetop;
43
+ animation-duration: 0.4s
44
+ }
45
+
46
+ .ga-modal-footer {
47
+ padding: 16px 16px 16px;
48
+ background-color: #fff;
49
+ color: #000;
50
+ border: 1px solid #fff;
51
+ border-bottom-left-radius: 4px;
52
+ border-bottom-right-radius: 4px;
53
+ border-top: 1px solid #cccccc;
54
+ text-align: right;
55
+ }
56
+
57
+ /* The Close Button */
58
+ .ga-close {
59
+ color: #aaa;
60
+ float: right;
61
+ font-size: 24px;
62
+ font-weight: bold;
63
+ }
64
+
65
+ .ga-close:hover,
66
+ .ga-close:focus {
67
+ color: black;
68
+ text-decoration: none;
69
+ cursor: pointer;
70
+ }
71
+
72
+ /* Add Animation */
73
+ @-webkit-keyframes animatetop {
74
+ from {
75
+ top: -300px;
76
+ opacity: 0
77
+ }
78
+ to {
79
+ top: 0;
80
+ opacity: 1
81
+ }
82
+ }
83
+
84
+ @keyframes animatetop {
85
+ from {
86
+ top: -300px;
87
+ opacity: 0
88
+ }
89
+ to {
90
+ top: 0;
91
+ opacity: 1
92
+ }
93
+ }
94
+
95
+ #ga_access_code_tmp {
96
+ width: 80%;
97
+ }
98
+
99
+ @media screen {
100
+
101
+ }
css/googleanalytics.css CHANGED
@@ -4,6 +4,10 @@
4
  margin: 0px auto !important;
5
  margin-top: 10px !important;
6
  margin-right: 0px !important;
 
 
 
 
7
  }
8
 
9
  .ga_container {
4
  margin: 0px auto !important;
5
  margin-top: 10px !important;
6
  margin-right: 0px !important;
7
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
8
+ font-size: 14px;
9
+ line-height: 1.42857143;
10
+ color: #333333;
11
  }
12
 
13
  .ga_container {
googleanalytics.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Google Analytics
5
  * Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
6
  * Description: Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
7
- * Version: 2.0.3
8
  * Author: ShareThis
9
  * Author URI: http://sharethis.com
10
  */
@@ -35,7 +35,7 @@ if ( ! defined( 'GA_MAIN_FILE_PATH' ) ) {
35
  if ( ! defined( 'GA_SHARETHIS_SCRIPTS_INCLUDED' ) ) {
36
  define( 'GA_SHARETHIS_SCRIPTS_INCLUDED', 0 );
37
  }
38
- define( 'GOOGLEANALYTICS_VERSION', '2.0.3' );
39
  include_once GA_PLUGIN_DIR . '/overwrite/ga_overwrite.php';
40
  include_once GA_PLUGIN_DIR . '/class/Ga_Autoloader.php';
41
  Ga_Autoloader::register();
4
  * Plugin Name: Google Analytics
5
  * Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
6
  * Description: Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
7
+ * Version: 2.0.4
8
  * Author: ShareThis
9
  * Author URI: http://sharethis.com
10
  */
35
  if ( ! defined( 'GA_SHARETHIS_SCRIPTS_INCLUDED' ) ) {
36
  define( 'GA_SHARETHIS_SCRIPTS_INCLUDED', 0 );
37
  }
38
+ define( 'GOOGLEANALYTICS_VERSION', '2.0.4' );
39
  include_once GA_PLUGIN_DIR . '/overwrite/ga_overwrite.php';
40
  include_once GA_PLUGIN_DIR . '/class/Ga_Autoloader.php';
41
  Ga_Autoloader::register();
js/googleanalytics_page.js CHANGED
@@ -2,6 +2,10 @@ const GA_ACCESS_CODE_MODAL_ID = "ga_access_code_modal";
2
  const GA_ACCESS_CODE_TMP_ID = "ga_access_code_tmp";
3
  const GA_ACCESS_CODE_ID = "ga_access_code";
4
  const GA_FORM_ID = "ga_form";
 
 
 
 
5
 
6
  (function ($) {
7
 
@@ -10,7 +14,7 @@ const GA_FORM_ID = "ga_form";
10
  authorize: function (e, url) {
11
  e.preventDefault();
12
  ga_popup.url = url;
13
- $('#' + GA_ACCESS_CODE_MODAL_ID).appendTo("body").modal('show');
14
  ga_popup.open();
15
  },
16
  open: function () {
@@ -32,6 +36,15 @@ const GA_FORM_ID = "ga_form";
32
  }
33
  }
34
  };
 
 
 
 
 
 
 
 
 
35
  ga_events = {
36
 
37
  click: function (selector, callback) {
@@ -58,13 +71,12 @@ const GA_FORM_ID = "ga_form";
58
  $('#ga_manually_wrapper').toggle();
59
  },
60
  initModalEvents: function () {
61
- $('#' + GA_ACCESS_CODE_MODAL_ID).on('shown.bs.modal', function () {
62
  $('#' + GA_ACCESS_CODE_TMP_ID).focus();
63
  });
64
 
65
- $('#' + GA_ACCESS_CODE_MODAL_ID).on('hide.bs.modal', function () {
66
- ga_loader.hide();
67
- $('#ga_save_access_code').removeAttr('disabled');
68
  });
69
  }
70
  };
2
  const GA_ACCESS_CODE_TMP_ID = "ga_access_code_tmp";
3
  const GA_ACCESS_CODE_ID = "ga_access_code";
4
  const GA_FORM_ID = "ga_form";
5
+ const GA_MODAL_CLOSE_ID = 'ga_close';
6
+ const GA_MODAL_BTN_CLOSE_ID = 'ga_btn_close';
7
+ const GA_GOOGLE_AUTH_BTN_ID = 'ga_authorize_with_google_button';
8
+ const GA_SAVE_ACCESS_CODE_BTN_ID = 'ga_save_access_code';
9
 
10
  (function ($) {
11
 
14
  authorize: function (e, url) {
15
  e.preventDefault();
16
  ga_popup.url = url;
17
+ $('#' + GA_ACCESS_CODE_MODAL_ID).appendTo("body").show();
18
  ga_popup.open();
19
  },
20
  open: function () {
36
  }
37
  }
38
  };
39
+
40
+ ga_modal = {
41
+ hide: function () {
42
+ $('#' + GA_ACCESS_CODE_MODAL_ID).hide();
43
+ ga_loader.hide();
44
+ $('#' + GA_SAVE_ACCESS_CODE_BTN_ID).removeAttr('disabled');
45
+ }
46
+ };
47
+
48
  ga_events = {
49
 
50
  click: function (selector, callback) {
71
  $('#ga_manually_wrapper').toggle();
72
  },
73
  initModalEvents: function () {
74
+ $('#' + GA_GOOGLE_AUTH_BTN_ID).on('click', function () {
75
  $('#' + GA_ACCESS_CODE_TMP_ID).focus();
76
  });
77
 
78
+ $('#' + GA_MODAL_CLOSE_ID + ', #' + GA_MODAL_BTN_CLOSE_ID).on('click', function () {
79
+ ga_modal.hide();
 
80
  });
81
  }
82
  };
lib/Ga_Lib_Api_Client.php CHANGED
@@ -91,8 +91,16 @@ class Ga_Lib_Api_Client {
91
  }
92
  } catch ( Ga_Lib_Api_Client_Exception $e ) {
93
  $this->add_error( $e );
 
 
94
  } catch ( Ga_Lib_Api_Request_Exception $e ) {
95
  $this->add_error( $e );
 
 
 
 
 
 
96
  }
97
  }
98
 
@@ -235,7 +243,8 @@ class Ga_Lib_Api_Client {
235
  */
236
  public function refresh_access_token( $refresh_token ) {
237
  // Request for a new Access Token
238
- $response = $this->ga_auth_refresh_access_token( $refresh_token );
 
239
  Ga_Admin::save_access_token( $response, $refresh_token );
240
 
241
  // Set new access token
@@ -254,6 +263,8 @@ class Ga_Lib_Api_Client {
254
  $this->check_access_token();
255
  } catch ( Ga_Lib_Api_Client_Exception $e ) {
256
  $this->add_error( $e );
 
 
257
  }
258
  }
259
 
91
  }
92
  } catch ( Ga_Lib_Api_Client_Exception $e ) {
93
  $this->add_error( $e );
94
+
95
+ return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
96
  } catch ( Ga_Lib_Api_Request_Exception $e ) {
97
  $this->add_error( $e );
98
+
99
+ return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
100
+ } catch ( Exception $e ) {
101
+ $this->add_error( $e );
102
+
103
+ return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
104
  }
105
  }
106
 
243
  */
244
  public function refresh_access_token( $refresh_token ) {
245
  // Request for a new Access Token
246
+ $response = $this->call( 'ga_auth_refresh_access_token', array( $refresh_token ) );
247
+
248
  Ga_Admin::save_access_token( $response, $refresh_token );
249
 
250
  // Set new access token
263
  $this->check_access_token();
264
  } catch ( Ga_Lib_Api_Client_Exception $e ) {
265
  $this->add_error( $e );
266
+ } catch ( Exception $e ) {
267
+ $this->add_error( $e );
268
  }
269
  }
270
 
lib/Ga_Lib_Api_Response.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  class Ga_Lib_Api_Response {
4
 
 
 
5
  private $header;
6
  private $body;
7
  private $data;
2
 
3
  class Ga_Lib_Api_Response {
4
 
5
+ public static $empty_response = array( '', '' );
6
+
7
  private $header;
8
  private $body;
9
  private $data;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: ShareThis
3
  Tags: analytics, dashboard, google, google analytics, google analytics plugin, javascript, marketing, pageviews, statistics, stats, tracking, visits, web stats, widget, analytics dashboard, google analytics dashboard, google analytics widget, google analytics dashboard
4
  Requires at least: 3.8
5
  Tested up to: 4.7
6
- Stable tag: 2.0.3
7
 
8
  Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
9
 
@@ -47,6 +47,10 @@ By downloading and installing this plugin you are agreeing to the <a href="http:
47
 
48
  == Changelog ==
49
 
 
 
 
 
50
  = 2.0.3 =
51
  * Reliability improvements for Google Analytics access
52
  * Better connection to Google Analytics API
3
  Tags: analytics, dashboard, google, google analytics, google analytics plugin, javascript, marketing, pageviews, statistics, stats, tracking, visits, web stats, widget, analytics dashboard, google analytics dashboard, google analytics widget, google analytics dashboard
4
  Requires at least: 3.8
5
  Tested up to: 4.7
6
+ Stable tag: 2.0.4
7
 
8
  Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
9
 
47
 
48
  == Changelog ==
49
 
50
+ = 2.0.4 =
51
+ * Replaced Bootstrap, should fix most of the issues with Google Sign in
52
+ * Fixed occasional black screen on GA sign
53
+
54
  = 2.0.3 =
55
  * Reliability improvements for Google Analytics access
56
  * Better connection to Google Analytics API
view/ga_dashboard_widget.php CHANGED
@@ -25,21 +25,21 @@
25
  <div>
26
  <div id="boxes-container">
27
  <div class="ga-box-row">
28
- <?php if ( ! empty( $boxes ) ) : ?>
29
- <?php $iter = 1; ?>
30
- <?php foreach ( $boxes as $k => $v ) : ?>
31
  <div class="ga-box-column ga-box-dashboard">
32
  <div style="color: grey; font-size: 13px;"
33
  id="ga_box_dashboard_label_<?php echo $k; ?>"><?php echo $v['label'] ?></div>
34
  <div style="font-size: 15px;"
35
  id="ga_box_dashboard_value_<?php echo $k; ?>"><?php echo $v['value'] ?></div>
36
  </div>
37
- <?php if ( ( ( $iter ++ ) % 3 ) == 0 ) : ?>
38
  </div>
39
  <div class="ga-box-row">
40
- <?php endif; ?>
41
- <?php endforeach; ?>
42
- <?php endif; ?>
43
  </div>
44
  </div>
45
  </div>
@@ -58,10 +58,10 @@
58
  $arr .= ",";
59
  }
60
  $arr .= "['" . $row['day'] . "'," . $row['current'] . "]";
61
- }
62
 
63
- echo $arr;
64
- ?>];
65
 
66
  ga_dashboard.init(dataArr);
67
  ga_dashboard.events(dataArr);
25
  <div>
26
  <div id="boxes-container">
27
  <div class="ga-box-row">
28
+ <?php if ( ! empty( $boxes ) ) : ?>
29
+ <?php $iter = 1; ?>
30
+ <?php foreach ( $boxes as $k => $v ) : ?>
31
  <div class="ga-box-column ga-box-dashboard">
32
  <div style="color: grey; font-size: 13px;"
33
  id="ga_box_dashboard_label_<?php echo $k; ?>"><?php echo $v['label'] ?></div>
34
  <div style="font-size: 15px;"
35
  id="ga_box_dashboard_value_<?php echo $k; ?>"><?php echo $v['value'] ?></div>
36
  </div>
37
+ <?php if ( ( ( $iter ++ ) % 3 ) == 0 ) : ?>
38
  </div>
39
  <div class="ga-box-row">
40
+ <?php endif; ?>
41
+ <?php endforeach; ?>
42
+ <?php endif; ?>
43
  </div>
44
  </div>
45
  </div>
58
  $arr .= ",";
59
  }
60
  $arr .= "['" . $row['day'] . "'," . $row['current'] . "]";
61
+ }
62
 
63
+ echo $arr;
64
+ ?>];
65
 
66
  ga_dashboard.init(dataArr);
67
  ga_dashboard.events(dataArr);
view/ga_oauth_notice.php CHANGED
@@ -1,3 +1,3 @@
1
- <div class="alert alert-warning">
2
  <?php echo $msg; ?>
3
  </div>
1
+ <div class="ga-alert ga-alert-warning">
2
  <?php echo $msg; ?>
3
  </div>
view/page.php CHANGED
@@ -1,22 +1,21 @@
1
- <div id="ga_access_code_modal" class="modal fade" tabindex="-1" role="dialog" style="z-index: 1000000">
2
- <div class="modal-dialog" role="document">
3
- <div class="modal-content">
4
- <div class="modal-header">
5
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
6
- aria-hidden="true">&times;</span></button>
7
- <h4 class="modal-title"><?php _e( 'Please paste the access code obtained from Google below:' ) ?></h4>
8
  </div>
9
- <div class="modal-body">
10
  <label for="ga_access_code"><strong><?php _e( 'Access Code' ); ?></strong>:</label>
11
- &nbsp;<input id="ga_access_code_tmp" type="text" style="width: 350px"
12
  placeholder="<?php _e( 'Paste your access code here' ) ?>"/>
13
  <div class="ga-loader-wrapper">
14
  <div class="ga-loader"></div>
15
  </div>
16
  </div>
17
- <div class="modal-footer">
18
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
19
- <button type="button" class="btn btn-primary"
20
  id="ga_save_access_code"
21
  onclick="ga_popup.saveAccessCode( event )"><?php _e( 'Save Changes' ); ?></button>
22
  </div>
@@ -44,7 +43,7 @@
44
  </label>
45
  </th>
46
  <td <?php echo ( ! Ga_Helper::are_terms_accepted() ) ? 'class="ga-tooltip"' : ''; ?>>
47
- <button id="ga_authorize_with_google_button" class="btn btn-primary"
48
  <?php if ( Ga_Helper::are_terms_accepted() ) : ?>
49
  onclick="ga_popup.authorize( event, '<?php echo esc_attr( $data['popup_url'] ); ?>' )"
50
  <?php endif; ?>
1
+ <div id="ga_access_code_modal" class="ga-modal" tabindex="-1">
2
+ <div class="ga-modal-dialog">
3
+ <div class="ga-modal-content">
4
+ <div class="ga-modal-header">
5
+ <span id="ga_close" class="ga-close">&times;</span>
6
+ <h4 class="ga-modal-title"><?php _e( 'Please paste the access code obtained from Google below:' ) ?></h4>
 
7
  </div>
8
+ <div class="ga-modal-body">
9
  <label for="ga_access_code"><strong><?php _e( 'Access Code' ); ?></strong>:</label>
10
+ &nbsp;<input id="ga_access_code_tmp" type="text"
11
  placeholder="<?php _e( 'Paste your access code here' ) ?>"/>
12
  <div class="ga-loader-wrapper">
13
  <div class="ga-loader"></div>
14
  </div>
15
  </div>
16
+ <div class="ga-modal-footer">
17
+ <button id="ga_btn_close" type="button" class="button"><?php _e( 'Close' ); ?></button>
18
+ <button type="button" class="button-primary"
19
  id="ga_save_access_code"
20
  onclick="ga_popup.saveAccessCode( event )"><?php _e( 'Save Changes' ); ?></button>
21
  </div>
43
  </label>
44
  </th>
45
  <td <?php echo ( ! Ga_Helper::are_terms_accepted() ) ? 'class="ga-tooltip"' : ''; ?>>
46
+ <button id="ga_authorize_with_google_button" class="button-primary"
47
  <?php if ( Ga_Helper::are_terms_accepted() ) : ?>
48
  onclick="ga_popup.authorize( event, '<?php echo esc_attr( $data['popup_url'] ); ?>' )"
49
  <?php endif; ?>
view/stats.php CHANGED
@@ -1,7 +1,7 @@
1
  <div class="wrap ga-wrap" id="ga-stats-container">
2
- <div class="panel panel-default">
3
- <div class="panel-heading"><strong><?php _e( "Pageviews - Last 7 days vs previous 7 days" ) ?></strong></div>
4
- <div class="panel-body ga-chart">
5
  <div id="chart_div" style="width: 100%;"></div>
6
  <div class="ga-loader-wrapper stats-page">
7
  <div class="ga-loader stats-page-loader"></div>
@@ -9,35 +9,36 @@
9
  </div>
10
  </div>
11
 
12
- <div class="panel panel-default">
13
- <div class="panel-heading"><strong><?php _e( "Comparison - Last 7 days vs previous 7 days" ) ?></strong></div>
14
- <div class="panel-body">
15
- <div id="boxes-container">
16
- <div class="row">
17
- <?php if ( ! empty( $boxes ) ) : ?>
18
- <?php foreach ( $boxes as $box ) : ?>
19
- <div class="col-md-3">
20
- <div class="panel panel-default">
21
- <div class="panel-body ga-box-centered">
22
- <div style="font-size: 16px;"><?php echo $box['label'] ?></div>
23
- <div style="color: <?php echo $box['color'] ?>; font-size: 24px;"><?php echo Ga_Helper::format_percent( $box['diff'] ); ?></div>
24
- <div style="color: grey; font-size: 16px;"><?php echo $box['comparison'] ?></div>
25
- </div>
26
  </div>
27
  </div>
28
- <?php endforeach; ?>
29
- <?php endif; ?>
30
- </div>
31
  </div>
32
  </div>
33
  </div>
34
  <?php if ( ! empty( $sources ) ) : ?>
35
- <div class="panel panel-default">
36
- <div class="panel-heading"><strong><?php _e( "Top 5 Traffic Sources for the past 7 days" ) ?></strong></div>
37
- <div class="panel-body">
 
38
 
39
  <div id="table-container">
40
- <table class="table table-bordered">
41
  <tr>
42
  <td colspan="2">
43
  </td>
@@ -49,20 +50,22 @@
49
  </th>
50
  </tr>
51
  <tr>
52
- <td style="width: 20%; font-size: 20px;text-align:center" colspan="2"></td>
53
- <td class="col-md-2" style="text-align: right">
54
  <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
55
  <div style="color: grey; font-size: 10px;">% of
56
  Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
57
- 2, '.', ' ' ) : 100 ); ?>
 
58
  (<?php echo $sources['sum'] ?>)
59
  </div>
60
  </td>
61
- <td class="col-md-5" style="text-align: right">
62
  <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
63
  <div style="color: grey; font-size: 10px;">% of
64
  Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
65
- 2, '.', ' ' ) : 100 ); ?>
 
66
  (<?php echo $sources['sum'] ?>)
67
  </div>
68
  </td>
@@ -70,9 +73,9 @@
70
  <?php foreach ( $sources['rows'] as $key => $source ): ?>
71
  <tr>
72
  <td style="width: 5%;text-align: right"><?php echo $key ?>.</td>
73
- <td style="width: 10%;">
74
  <?php if ( $source['name'] != '(direct) / (none)' ) : ?>
75
- <a href="<?php echo $source['url'] ?>"
76
  target="_blank"><?php echo $source['name'] ?></a>
77
  <?php else: ?>
78
  <?php echo $source['name'] ?>
1
  <div class="wrap ga-wrap" id="ga-stats-container">
2
+ <div class="ga-panel ga-panel-default">
3
+ <div class="ga-panel-heading"><strong><?php _e( "Pageviews - Last 7 days vs previous 7 days" ) ?></strong></div>
4
+ <div class="ga-panel-body ga-chart">
5
  <div id="chart_div" style="width: 100%;"></div>
6
  <div class="ga-loader-wrapper stats-page">
7
  <div class="ga-loader stats-page-loader"></div>
9
  </div>
10
  </div>
11
 
12
+ <div class="ga-panel ga-panel-default">
13
+ <div class="ga-panel-heading"><strong><?php _e( "Comparison - Last 7 days vs previous 7 days" ) ?></strong>
14
+ </div>
15
+ <div class="ga-panel-body">
16
+ <div class="ga-row">
17
+ <?php if ( ! empty( $boxes ) ) : ?>
18
+ <?php foreach ( $boxes as $box ) : ?>
19
+ <div class="ga-box">
20
+ <div class="ga-panel ga-panel-default">
21
+ <div class="ga-panel-body ga-box-centered">
22
+ <div class="ga-box-label"><?php echo $box['label'] ?></div>
23
+ <div class="ga-box-diff"
24
+ style="color: <?php echo $box['color'] ?>;"><?php echo Ga_Helper::format_percent( $box['diff'] ); ?></div>
25
+ <div class="ga-box-comparison"><?php echo $box['comparison'] ?></div>
26
  </div>
27
  </div>
28
+ </div>
29
+ <?php endforeach; ?>
30
+ <?php endif; ?>
31
  </div>
32
  </div>
33
  </div>
34
  <?php if ( ! empty( $sources ) ) : ?>
35
+ <div class="ga-panel ga-panel-default">
36
+ <div class="ga-panel-heading"><strong><?php _e( "Top 5 Traffic Sources for the past 7 days" ) ?></strong>
37
+ </div>
38
+ <div class="ga-panel-body">
39
 
40
  <div id="table-container">
41
+ <table class="ga-table">
42
  <tr>
43
  <td colspan="2">
44
  </td>
50
  </th>
51
  </tr>
52
  <tr>
53
+ <td colspan="2"></td>
54
+ <td class="ga-col-pageviews" style="text-align: right">
55
  <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
56
  <div style="color: grey; font-size: 10px;">% of
57
  Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
58
+ 2, '.', ' ' ) : 100 );
59
+ ?>
60
  (<?php echo $sources['sum'] ?>)
61
  </div>
62
  </td>
63
+ <td class="ga-col-progressbar" style="text-align: right">
64
  <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
65
  <div style="color: grey; font-size: 10px;">% of
66
  Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
67
+ 2, '.', ' ' ) : 100 );
68
+ ?>
69
  (<?php echo $sources['sum'] ?>)
70
  </div>
71
  </td>
73
  <?php foreach ( $sources['rows'] as $key => $source ): ?>
74
  <tr>
75
  <td style="width: 5%;text-align: right"><?php echo $key ?>.</td>
76
+ <td class="ga-col-name">
77
  <?php if ( $source['name'] != '(direct) / (none)' ) : ?>
78
+ <a class="ga-source-name" href="<?php echo $source['url'] ?>"
79
  target="_blank"><?php echo $source['name'] ?></a>
80
  <?php else: ?>
81
  <?php echo $source['name'] ?>