Google Analytics for WordPress by MonsterInsights - Version 5.3.3

Version Description

Release Date: March 19th, 2015

  • Several security fixes:
    1. Fix minor XSS issue where admins could XSS each other through an unescaped manual UA field.
    2. Fix stored XSS issue where changing a property's name in Google Analytics to contain malicious JS would allow execution of that JS in the admin as the profile name was not escaped properly.
    3. Fix un-authenticated change of the GA profile list, allowing the previous XSS to become a slightly bigger issue. Issues 2 and 3 combined lead to a DREAD score of 5.
  • Other fixes:
    • Small code style improvements.
    • Throw an error and deactivate if either the PHP SPL or PHP filter libraries aren't loaded.
    • Introduced a filter yst_ga_track_super_admin to allow disabling of super admin tracking on multi-site, defaulting to true.

Big thanks to Jouko Pynnnen for responsibly disclosing security issues #2 and #3.

Download this release

Release Info

Developer omarreiss
Plugin Icon 128x128 Google Analytics for WordPress by MonsterInsights
Version 5.3.3
Comparing to
See all releases

Code changes from version 5.3.2 to 5.3.3

Files changed (41) hide show
  1. README.md +2 -0
  2. admin/class-admin-assets.php +4 -1
  3. admin/class-admin-form.php +33 -23
  4. admin/class-admin-menu.php +18 -14
  5. admin/class-admin.php +79 -57
  6. admin/class-google-analytics.php +16 -8
  7. admin/dashboards/class-admin-dashboards-api-options.php +11 -7
  8. admin/dashboards/class-admin-dashboards-collector.php +41 -31
  9. admin/dashboards/class-admin-dashboards-data.php +11 -7
  10. admin/dashboards/class-admin-dashboards-display.php +15 -8
  11. admin/dashboards/class-admin-dashboards.php +15 -16
  12. admin/dashboards/drivers/class-admin-dashboards-driver-generate.php +10 -2
  13. admin/dashboards/drivers/class-admin-dashboards-driver.php +9 -2
  14. admin/dashboards/drivers/class-admin-dashboards-graph-generate.php +12 -5
  15. admin/dashboards/drivers/class-admin-dashboards-graph.php +7 -0
  16. admin/dashboards/drivers/class-admin-dashboards-table-generate.php +9 -1
  17. admin/dashboards/drivers/class-admin-dashboards-table.php +7 -0
  18. admin/dashboards/views/graph.php +11 -2
  19. admin/dashboards/views/table.php +9 -2
  20. admin/pages/dashboard.php +17 -6
  21. admin/pages/extensions.php +18 -23
  22. admin/pages/settings.php +16 -8
  23. admin/views/content-footer.php +8 -1
  24. frontend/abstract-class-tracking.php +40 -20
  25. frontend/class-frontend.php +9 -2
  26. frontend/class-ga-js.php +24 -11
  27. frontend/class-universal.php +34 -14
  28. frontend/views/tracking-debug.php +7 -0
  29. frontend/views/tracking-ga-js.php +7 -0
  30. frontend/views/tracking-universal.php +17 -10
  31. frontend/views/tracking-usergroup.php +7 -0
  32. googleanalytics.php +87 -30
  33. includes/class-options.php +22 -13
  34. includes/class-settings.php +9 -4
  35. includes/class-utils.php +11 -4
  36. phpcs.xml +14 -0
  37. readme.txt +34 -10
  38. vendor/autoload.php +1 -1
  39. vendor/autoload_52.php +1 -1
  40. vendor/composer/autoload_real.php +4 -4
  41. vendor/composer/autoload_real_52.php +3 -3
README.md CHANGED
@@ -31,6 +31,8 @@ Bugs
31
  ----
32
  If you find an issue, [let us know here](https://github.com/Yoast/google-analytics-for-wordpress/issues/new)!
33
 
 
 
34
  Support
35
  -------
36
  This is a developer's portal for Google Analytics for WordPress by Yoast and should not be used for support. Please visit the
31
  ----
32
  If you find an issue, [let us know here](https://github.com/Yoast/google-analytics-for-wordpress/issues/new)!
33
 
34
+ Please report security issues privately to **security@yoast.com**.
35
+
36
  Support
37
  -------
38
  This is a developer's portal for Google Analytics for WordPress by Yoast and should not be used for support. Please visit the
admin/class-admin-assets.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  /**
4
  * This class is for the backend
@@ -40,7 +44,6 @@ class Yoast_GA_Admin_Assets {
40
  */
41
  public static function enqueue_dashboard_assets() {
42
 
43
- //
44
  wp_enqueue_script( 'ga-admin-dashboard', self::get_asset_path( 'assets/js/yoast_ga_admin_dashboard' ) . self::file_ext( '.js' ), array(), GAWP_VERSION );
45
  wp_enqueue_style( 'ga-admin-dashboard-css', self::get_asset_path( 'assets/css/yoast_ga_admin_dashboard' ) . self::file_ext( '.css' ), array(), GAWP_VERSION );
46
 
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
  /**
8
  * This class is for the backend
44
  */
45
  public static function enqueue_dashboard_assets() {
46
 
 
47
  wp_enqueue_script( 'ga-admin-dashboard', self::get_asset_path( 'assets/js/yoast_ga_admin_dashboard' ) . self::file_ext( '.js' ), array(), GAWP_VERSION );
48
  wp_enqueue_style( 'ga-admin-dashboard-css', self::get_asset_path( 'assets/css/yoast_ga_admin_dashboard' ) . self::file_ext( '.css' ), array(), GAWP_VERSION );
49
 
admin/class-admin-form.php CHANGED
@@ -1,11 +1,17 @@
1
  <?php
 
 
 
 
2
 
3
  /**
4
  * This class is for the backend
5
  */
6
-
7
  class Yoast_GA_Admin_Form {
8
 
 
 
 
9
  private static $form_namespace;
10
 
11
  /**
@@ -44,7 +50,7 @@ class Yoast_GA_Admin_Form {
44
  $output = null;
45
  $output .= '<div class="ga-form ga-form-input">';
46
  $output .= '<input type="submit" name="ga-form-' . $name . '" value="' . $button_label . '" class="button button-primary ga-form-submit" id="yoast-ga-form-submit-' . self::$form_namespace . '"';
47
- if( ! is_null( $onclick ) ){
48
  $output .= ' onclick="' . $onclick . '"';
49
  }
50
  $output .= ' />';
@@ -90,7 +96,8 @@ class Yoast_GA_Admin_Form {
90
  if ( $input_value == 1 ) {
91
  $attributes['checked'] = 'checked';
92
  }
93
- } else {
 
94
  $attributes['value'] = stripslashes( $input_value );
95
  }
96
 
@@ -129,12 +136,13 @@ class Yoast_GA_Admin_Form {
129
 
130
  $select .= '<div class="ga-form ga-form-input">';
131
  if ( ! is_null( $title ) ) {
132
- $select .= self::label( $id, $title, 'select' ); //'<label class="ga-form ga-form-select-label ga-form-label-left" id="yoast-ga-form-label-select-' . self::$form_namespace . '-' . $id . '">' . $title . ':</label>';
133
  }
134
 
135
  if ( $multiple ) {
136
  $select .= '<select multiple name="' . $name . '[]" id="yoast-ga-form-select-' . self::$form_namespace . '-' . $id . '" class="ga-multiple">';
137
- } else {
 
138
  $select .= '<select data-placeholder="' . $empty_text . '" name="' . $name . '" id="yoast-ga-form-select-' . self::$form_namespace . '-' . $id . '">';
139
  if ( ! is_null( $empty_text ) ) {
140
  $select .= '<option></option>';
@@ -146,10 +154,10 @@ class Yoast_GA_Admin_Form {
146
  foreach ( $values as $optgroup => $value ) {
147
  if ( ! empty( $value['items'] ) ) {
148
  $select .= self::create_optgroup( $optgroup, $value, $select_value );
149
- } else {
 
150
  $select .= self::option( $select_value, $value );
151
  }
152
-
153
  }
154
  }
155
  $select .= '</select>';
@@ -207,13 +215,15 @@ class Yoast_GA_Admin_Form {
207
  private static function option( $select_value, $value ) {
208
 
209
  if ( is_array( $select_value ) ) {
210
- if ( in_array( $value['id'], $select_value ) ) {
211
- return '<option value="' . $value['id'] . '" selected="selected">' . stripslashes( $value['name'] ) . '</option>';
212
- } else {
213
- return '<option value="' . $value['id'] . '">' . stripslashes( $value['name'] ) . '</option>';
214
  }
215
- } else {
216
- return '<option value="' . $value['id'] . '" ' . selected( $select_value, $value['id'], false ) . '>' . stripslashes( $value['name'] ) . '</option>';
 
 
 
 
217
  }
218
  }
219
 
@@ -243,10 +253,9 @@ class Yoast_GA_Admin_Form {
243
  public static function parse_optgroups( $values ) {
244
  $optgroups = array();
245
  foreach ( $values as $key => $value ) {
246
- foreach ( $value['items'] AS $subitem ) {
247
- $optgroups[$subitem['name']]['items'] = $subitem['items'];
248
  }
249
-
250
  }
251
 
252
  return $optgroups;
@@ -255,9 +264,9 @@ class Yoast_GA_Admin_Form {
255
  /**
256
  * Creates a label
257
  *
258
- * @param $id
259
- * @param $title
260
- * @param $type
261
  *
262
  * @return string
263
  */
@@ -275,13 +284,14 @@ class Yoast_GA_Admin_Form {
275
  * @return string
276
  */
277
  private static function create_optgroup( $optgroup, $value, $select_value ) {
278
- $optgroup = '<optgroup label="' . $optgroup . '">';
279
 
280
  foreach ( $value['items'] as $option ) {
281
  if ( ! empty( $option['items'] ) ) {
282
 
283
- $optgroup .= self::create_optgroup( $option['name'], $option, $select_value );
284
- } else {
 
285
  $optgroup .= self::option( $select_value, $option );
286
  }
287
  }
@@ -307,7 +317,7 @@ class Yoast_GA_Admin_Form {
307
  }
308
 
309
  // Catch a notice if the option doesn't exist, yet
310
- return ( isset( $options[$name] ) ) ? $options[$name] : '';
311
  }
312
 
313
  /**
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
  /**
8
  * This class is for the backend
9
  */
 
10
  class Yoast_GA_Admin_Form {
11
 
12
+ /**
13
+ * @var string $form_namespace
14
+ */
15
  private static $form_namespace;
16
 
17
  /**
50
  $output = null;
51
  $output .= '<div class="ga-form ga-form-input">';
52
  $output .= '<input type="submit" name="ga-form-' . $name . '" value="' . $button_label . '" class="button button-primary ga-form-submit" id="yoast-ga-form-submit-' . self::$form_namespace . '"';
53
+ if ( ! is_null( $onclick ) ) {
54
  $output .= ' onclick="' . $onclick . '"';
55
  }
56
  $output .= ' />';
96
  if ( $input_value == 1 ) {
97
  $attributes['checked'] = 'checked';
98
  }
99
+ }
100
+ else {
101
  $attributes['value'] = stripslashes( $input_value );
102
  }
103
 
136
 
137
  $select .= '<div class="ga-form ga-form-input">';
138
  if ( ! is_null( $title ) ) {
139
+ $select .= self::label( $id, $title, 'select' ); // '<label class="ga-form ga-form-select-label ga-form-label-left" id="yoast-ga-form-label-select-' . self::$form_namespace . '-' . $id . '">' . $title . ':</label>';
140
  }
141
 
142
  if ( $multiple ) {
143
  $select .= '<select multiple name="' . $name . '[]" id="yoast-ga-form-select-' . self::$form_namespace . '-' . $id . '" class="ga-multiple">';
144
+ }
145
+ else {
146
  $select .= '<select data-placeholder="' . $empty_text . '" name="' . $name . '" id="yoast-ga-form-select-' . self::$form_namespace . '-' . $id . '">';
147
  if ( ! is_null( $empty_text ) ) {
148
  $select .= '<option></option>';
154
  foreach ( $values as $optgroup => $value ) {
155
  if ( ! empty( $value['items'] ) ) {
156
  $select .= self::create_optgroup( $optgroup, $value, $select_value );
157
+ }
158
+ else {
159
  $select .= self::option( $select_value, $value );
160
  }
 
161
  }
162
  }
163
  $select .= '</select>';
215
  private static function option( $select_value, $value ) {
216
 
217
  if ( is_array( $select_value ) ) {
218
+ if ( in_array( esc_attr( $value['id'] ), $select_value ) ) {
219
+ return '<option value="' . esc_attr( $value['id'] ) . '" selected="selected">' . esc_attr( stripslashes( $value['name'] ) ) . '</option>';
 
 
220
  }
221
+ else {
222
+ return '<option value="' . esc_attr( $value['id'] ) . '">' . esc_attr( stripslashes( $value['name'] ) ) . '</option>';
223
+ }
224
+ }
225
+ else {
226
+ return '<option value="' . esc_attr( $value['id'] ) . '" ' . selected( $select_value, $value['id'], false ) . '>' . esc_attr( stripslashes( $value['name'] ) ) . '</option>';
227
  }
228
  }
229
 
253
  public static function parse_optgroups( $values ) {
254
  $optgroups = array();
255
  foreach ( $values as $key => $value ) {
256
+ foreach ( $value['items'] as $subitem ) {
257
+ $optgroups[ $subitem['name'] ]['items'] = $subitem['items'];
258
  }
 
259
  }
260
 
261
  return $optgroups;
264
  /**
265
  * Creates a label
266
  *
267
+ * @param string $id
268
+ * @param string $title
269
+ * @param string $type
270
  *
271
  * @return string
272
  */
284
  * @return string
285
  */
286
  private static function create_optgroup( $optgroup, $value, $select_value ) {
287
+ $optgroup = '<optgroup label="' . esc_attr( $optgroup ) . '">';
288
 
289
  foreach ( $value['items'] as $option ) {
290
  if ( ! empty( $option['items'] ) ) {
291
 
292
+ $optgroup .= self::create_optgroup( esc_attr( $option['name'] ), $option, $select_value );
293
+ }
294
+ else {
295
  $optgroup .= self::option( $select_value, $option );
296
  }
297
  }
317
  }
318
 
319
  // Catch a notice if the option doesn't exist, yet
320
+ return ( isset( $options[ $name ] ) ) ? $options[ $name ] : '';
321
  }
322
 
323
  /**
admin/class-admin-menu.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  /**
4
  * This class is for the backend, extendable for all child classes
@@ -6,16 +10,12 @@
6
  class Yoast_GA_Admin_Menu {
7
 
8
  /**
9
- * The property used for storing target object (class admin)
10
- *
11
- * @var
12
  */
13
  private $target_object;
14
 
15
  /**
16
- * The dashboards disabled bool
17
- *
18
- * @var
19
  */
20
  private $dashboards_disabled;
21
 
@@ -46,7 +46,7 @@ class Yoast_GA_Admin_Menu {
46
  }
47
 
48
  $this->dashboards_disabled = Yoast_GA_Settings::get_instance()->dashboards_disabled();
49
- $this->parent_slug = ( $this->dashboards_disabled ? 'yst_ga_settings' : 'yst_ga_dashboard' );
50
  }
51
 
52
  /**
@@ -92,7 +92,9 @@ class Yoast_GA_Admin_Menu {
92
 
93
  if ( $on_top ) {
94
  $position = $this->get_menu_position_value( 'top' );
95
- } else {
 
 
96
  $position = $this->get_menu_position_value( 'bottom' );
97
  }
98
 
@@ -107,7 +109,7 @@ class Yoast_GA_Admin_Menu {
107
  /**
108
  * Get the top or bottom menu location number
109
  *
110
- * @param $location
111
  *
112
  * @return string
113
  */
@@ -122,8 +124,9 @@ class Yoast_GA_Admin_Menu {
122
  /**
123
  * Prepares an array that can be used to add a submenu page to the Google Analytics for Wordpress menu
124
  *
125
- * @param $submenu_name
126
- * @param $font_color
 
127
  *
128
  * @return array
129
  */
@@ -157,7 +160,7 @@ class Yoast_GA_Admin_Menu {
157
  /**
158
  * Adds a submenu page to the Google Analytics for WordPress menu
159
  *
160
- * @param $submenu_page
161
  */
162
  private function add_submenu_page( $submenu_page ) {
163
  $page = add_submenu_page( $submenu_page['parent_slug'], $submenu_page['page_title'], $submenu_page['menu_title'], $submenu_page['capability'], $submenu_page['menu_slug'], $submenu_page['submenu_function'] );
@@ -188,13 +191,14 @@ class Yoast_GA_Admin_Menu {
188
  * - Settings
189
  * - Extensions
190
  *
191
- * @return array
192
  */
193
  private function add_submenu_pages() {
194
  foreach ( $this->get_submenu_types() as $submenu ) {
195
  if ( isset( $submenu['color'] ) ) {
196
  $submenu_page = $this->prepare_submenu_page( $submenu['label'], $submenu['slug'], $submenu['color'] );
197
- } else {
 
198
  $submenu_page = $this->prepare_submenu_page( $submenu['label'], $submenu['slug'] );
199
  }
200
  $this->add_submenu_page( $submenu_page );
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
  /**
8
  * This class is for the backend, extendable for all child classes
10
  class Yoast_GA_Admin_Menu {
11
 
12
  /**
13
+ * @var object $target_object The property used for storing target object (class admin)
 
 
14
  */
15
  private $target_object;
16
 
17
  /**
18
+ * @var boolean $dashboard_disabled The dashboards disabled bool
 
 
19
  */
20
  private $dashboards_disabled;
21
 
46
  }
47
 
48
  $this->dashboards_disabled = Yoast_GA_Settings::get_instance()->dashboards_disabled();
49
+ $this->parent_slug = ( ( $this->dashboards_disabled ) ? 'yst_ga_settings' : 'yst_ga_dashboard' );
50
  }
51
 
52
  /**
92
 
93
  if ( $on_top ) {
94
  $position = $this->get_menu_position_value( 'top' );
95
+
96
+ }
97
+ else {
98
  $position = $this->get_menu_position_value( 'bottom' );
99
  }
100
 
109
  /**
110
  * Get the top or bottom menu location number
111
  *
112
+ * @param string $location
113
  *
114
  * @return string
115
  */
124
  /**
125
  * Prepares an array that can be used to add a submenu page to the Google Analytics for Wordpress menu
126
  *
127
+ * @param string $submenu_name
128
+ * @param string $submenu_slug
129
+ * @param string $font_color
130
  *
131
  * @return array
132
  */
160
  /**
161
  * Adds a submenu page to the Google Analytics for WordPress menu
162
  *
163
+ * @param array $submenu_page
164
  */
165
  private function add_submenu_page( $submenu_page ) {
166
  $page = add_submenu_page( $submenu_page['parent_slug'], $submenu_page['page_title'], $submenu_page['menu_title'], $submenu_page['capability'], $submenu_page['menu_slug'], $submenu_page['submenu_function'] );
191
  * - Settings
192
  * - Extensions
193
  *
194
+ * @return void
195
  */
196
  private function add_submenu_pages() {
197
  foreach ( $this->get_submenu_types() as $submenu ) {
198
  if ( isset( $submenu['color'] ) ) {
199
  $submenu_page = $this->prepare_submenu_page( $submenu['label'], $submenu['slug'], $submenu['color'] );
200
+ }
201
+ else {
202
  $submenu_page = $this->prepare_submenu_page( $submenu['label'], $submenu['slug'] );
203
  }
204
  $this->add_submenu_page( $submenu_page );
admin/class-admin.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  /**
4
  * This class is for the backend, extendable for all child classes
@@ -6,12 +10,13 @@
6
  class Yoast_GA_Admin extends Yoast_GA_Options {
7
 
8
  /**
9
- * Store the API instance
10
- *
11
- * @var
12
  */
13
  public $api;
14
 
 
 
 
15
  public function __construct() {
16
  parent::__construct();
17
 
@@ -68,7 +73,7 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
68
  /**
69
  * This function saves the settings in the option field and returns a wp success message on success
70
  *
71
- * @param $data
72
  */
73
  public function save_settings( $data ) {
74
 
@@ -79,13 +84,13 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
79
  if ( $key != 'custom_code' && is_string( $value ) ) {
80
  $value = strip_tags( $value );
81
  }
82
- $this->options[$key] = $value;
83
  }
84
  }
85
 
86
  // Check checkboxes, on a uncheck they won't be posted to this function
87
  $defaults = $this->default_ga_values();
88
- foreach ( $defaults[$this->option_prefix] as $option_name => $value ) {
89
  $this->handle_default_setting( $data, $option_name, $value );
90
  }
91
 
@@ -93,14 +98,31 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
93
  $this->options['analytics_profile_code'] = $this->get_ua_code_from_profile( $this->options['analytics_profile'] );
94
  }
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  if ( $this->update_option( $this->options ) ) {
97
  // Success, add a new notification
98
  $this->add_notification( 'ga_notifications', array(
99
  'type' => 'success',
100
  'description' => __( 'Settings saved.', 'google-analytics-for-wordpress' ),
101
  ) );
102
-
103
- } else {
104
  // Fail, add a new notification
105
  $this->add_notification( 'ga_notifications', array(
106
  'type' => 'error',
@@ -108,7 +130,7 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
108
  ) );
109
  }
110
 
111
- #redirect
112
  wp_redirect( admin_url( 'admin.php' ) . '?page=yst_ga_settings#top#' . $data['return_tab'], 301 );
113
  exit;
114
  }
@@ -118,30 +140,26 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
118
  * remove the options for the profiles and the refresh token.
119
  */
120
  public static function ga_deactivation_hook() {
121
- // Remove the refresh token
122
- delete_option( 'yoast-ga-refresh_token' );
123
-
124
- // Remove the ga accounts and response
125
- delete_option( 'yst_ga_accounts' );
126
- delete_option( 'yst_ga_response' );
127
-
128
  }
129
 
130
  /**
131
  * Handle a default setting in GA
132
  *
133
- * @param $data
134
- * @param $option_name
135
- * @param $value
136
  */
137
  private function handle_default_setting( $data, $option_name, $value ) {
138
- if ( ! isset( $data[$option_name] ) ) {
139
  // If no data was passed in, set it to the default.
140
  if ( $value === 1 ) {
141
  // Disable the checkbox for now, use value 0
142
- $this->options[$option_name] = 0;
143
- } else {
144
- $this->options[$option_name] = $value;
 
145
  }
146
  }
147
  }
@@ -149,7 +167,7 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
149
  /**
150
  * Handle the post requests in the admin form of the GA plugin
151
  *
152
- * @param $dashboards
153
  */
154
  private function handle_ga_post_request( $dashboards ) {
155
  if ( ! function_exists( 'wp_verify_nonce' ) ) {
@@ -175,7 +193,7 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
175
  /**
176
  * Is there selected an other property in the settings post? Returns true or false.
177
  *
178
- * @param $post
179
  *
180
  * @return bool
181
  */
@@ -210,7 +228,7 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
210
  /**
211
  * Transform the Profile ID into an helpful UA code
212
  *
213
- * @param $profile_id
214
  *
215
  * @return null
216
  */
@@ -300,19 +318,17 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
300
  add_action( 'yst_ga_custom_dimension_add-dashboards-tab', array( $this, 'premium_promo' ) );
301
  }
302
 
303
- if ( isset( $_GET['page'] ) ) {
304
- switch ( $_GET['page'] ) {
305
- case 'yst_ga_settings':
306
- require_once( $this->plugin_path . 'admin/pages/settings.php' );
307
- break;
308
- case 'yst_ga_extensions':
309
- require_once( $this->plugin_path . 'admin/pages/extensions.php' );
310
- break;
311
- case 'yst_ga_dashboard':
312
- default:
313
- require_once( $this->plugin_path . 'admin/pages/dashboard.php' );
314
- break;
315
- }
316
  }
317
  }
318
 
@@ -329,23 +345,27 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
329
  }
330
 
331
  /**
332
- * Checks if there is a callback or reauth to get token from Google Analytics api
333
  */
334
  private function google_analytics_listener() {
 
 
 
335
 
336
- if ( ! empty( $_POST['google_auth_code'] ) ) {
337
- Yoast_Google_Analytics::get_instance()->authenticate( trim( $_POST['google_auth_code'] ) );
338
- }
339
-
340
-
341
- if ( ! empty ( $_GET['reauth'] ) ) {
342
 
343
- delete_option( 'yst_ga_accounts' );
344
- delete_option( 'yst_ga_response' );
345
-
346
- Yoast_Google_Analytics::get_instance()->authenticate();
347
  }
 
348
 
 
 
 
 
 
 
 
 
349
  }
350
 
351
  /**
@@ -356,7 +376,8 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
356
  private function get_current_profile() {
357
  if ( ! empty( $this->options['analytics_profile'] ) ) {
358
  return $this->options['analytics_profile'];
359
- } else {
 
360
  return null;
361
  }
362
  }
@@ -382,7 +403,7 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
382
  foreach ( $editable_roles as $id => $name ) {
383
  $roles[] = array(
384
  'id' => $id,
385
- 'name' => translate_user_role($name['name']),
386
  );
387
  }
388
 
@@ -408,8 +429,8 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
408
  */
409
  public function get_track_full_url() {
410
  return array(
411
- 0 => array( 'id' => 'domain', 'name' => __( 'Just the domain', 'google-analytics-for-wordpress' ) ),
412
- 1 => array( 'id' => 'full_links', 'name' => __( 'Full links', 'google-analytics-for-wordpress' ) ),
413
  );
414
  }
415
 
@@ -498,8 +519,8 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
498
  /**
499
  * Add a notification to the notification transient
500
  *
501
- * @param $transient_name
502
- * @param $settings
503
  */
504
  private function add_notification( $transient_name, $settings ) {
505
  set_transient( $transient_name, $settings, MINUTE_IN_SECONDS );
@@ -521,7 +542,8 @@ class Yoast_GA_Admin extends Yoast_GA_Options {
521
  $transient['description'],
522
  'updated'
523
  );
524
- } else {
 
525
  add_settings_error(
526
  'yoast_google_analytics',
527
  'yoast_google_analytics',
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
  /**
8
  * This class is for the backend, extendable for all child classes
10
  class Yoast_GA_Admin extends Yoast_GA_Options {
11
 
12
  /**
13
+ * @var boolean $api Store the API instance
 
 
14
  */
15
  public $api;
16
 
17
+ /**
18
+ * Constructor
19
+ */
20
  public function __construct() {
21
  parent::__construct();
22
 
73
  /**
74
  * This function saves the settings in the option field and returns a wp success message on success
75
  *
76
+ * @param array $data
77
  */
78
  public function save_settings( $data ) {
79
 
84
  if ( $key != 'custom_code' && is_string( $value ) ) {
85
  $value = strip_tags( $value );
86
  }
87
+ $this->options[ $key ] = $value;
88
  }
89
  }
90
 
91
  // Check checkboxes, on a uncheck they won't be posted to this function
92
  $defaults = $this->default_ga_values();
93
+ foreach ( $defaults[ $this->option_prefix ] as $option_name => $value ) {
94
  $this->handle_default_setting( $data, $option_name, $value );
95
  }
96
 
98
  $this->options['analytics_profile_code'] = $this->get_ua_code_from_profile( $this->options['analytics_profile'] );
99
  }
100
 
101
+ if ( ! empty( $this->options['manual_ua_code_field'] ) ) {
102
+ $this->options['manual_ua_code_field'] = trim( $this->options['manual_ua_code_field'] );
103
+ // en dash to minus, prevents issue with code copied from web with "fancy" dash
104
+ $this->options['manual_ua_code_field'] = str_replace( '–', '-', $this->options['manual_ua_code_field'] );
105
+
106
+ if ( ! preg_match( '|^UA-\d{4,}-\d+$|', $this->options['manual_ua_code_field'] ) ) {
107
+
108
+ $this->add_notification( 'ga_notifications', array(
109
+ 'type' => 'error',
110
+ 'description' => __( 'The UA code needs to follow UA-XXXXXXXX-X format.', 'google-analytics-for-wordpress' ),
111
+ ) );
112
+
113
+ wp_redirect( admin_url( 'admin.php' ) . '?page=yst_ga_settings#top#' . $data['return_tab'], 301 );
114
+ exit;
115
+ }
116
+ }
117
+
118
  if ( $this->update_option( $this->options ) ) {
119
  // Success, add a new notification
120
  $this->add_notification( 'ga_notifications', array(
121
  'type' => 'success',
122
  'description' => __( 'Settings saved.', 'google-analytics-for-wordpress' ),
123
  ) );
124
+ }
125
+ else {
126
  // Fail, add a new notification
127
  $this->add_notification( 'ga_notifications', array(
128
  'type' => 'error',
130
  ) );
131
  }
132
 
133
+ // redirect
134
  wp_redirect( admin_url( 'admin.php' ) . '?page=yst_ga_settings#top#' . $data['return_tab'], 301 );
135
  exit;
136
  }
140
  * remove the options for the profiles and the refresh token.
141
  */
142
  public static function ga_deactivation_hook() {
143
+ // Remove the refresh token and other API settings
144
+ self::analytics_api_clean_up();
 
 
 
 
 
145
  }
146
 
147
  /**
148
  * Handle a default setting in GA
149
  *
150
+ * @param array $data
151
+ * @param string $option_name
152
+ * @param mixed $value
153
  */
154
  private function handle_default_setting( $data, $option_name, $value ) {
155
+ if ( ! isset( $data[ $option_name ] ) ) {
156
  // If no data was passed in, set it to the default.
157
  if ( $value === 1 ) {
158
  // Disable the checkbox for now, use value 0
159
+ $this->options[ $option_name ] = 0;
160
+ }
161
+ else {
162
+ $this->options[ $option_name ] = $value;
163
  }
164
  }
165
  }
167
  /**
168
  * Handle the post requests in the admin form of the GA plugin
169
  *
170
+ * @param Yoast_GA_Dashboards $dashboards
171
  */
172
  private function handle_ga_post_request( $dashboards ) {
173
  if ( ! function_exists( 'wp_verify_nonce' ) ) {
193
  /**
194
  * Is there selected an other property in the settings post? Returns true or false.
195
  *
196
+ * @param array $post
197
  *
198
  * @return bool
199
  */
228
  /**
229
  * Transform the Profile ID into an helpful UA code
230
  *
231
+ * @param integer $profile_id
232
  *
233
  * @return null
234
  */
318
  add_action( 'yst_ga_custom_dimension_add-dashboards-tab', array( $this, 'premium_promo' ) );
319
  }
320
 
321
+ switch ( filter_input( INPUT_GET, 'page' ) ) {
322
+ case 'yst_ga_settings':
323
+ require_once( $this->plugin_path . 'admin/pages/settings.php' );
324
+ break;
325
+ case 'yst_ga_extensions':
326
+ require_once( $this->plugin_path . 'admin/pages/extensions.php' );
327
+ break;
328
+ case 'yst_ga_dashboard':
329
+ default:
330
+ require_once( $this->plugin_path . 'admin/pages/dashboard.php' );
331
+ break;
 
 
332
  }
333
  }
334
 
345
  }
346
 
347
  /**
348
+ * Checks if there is a callback to get token from Google Analytics API
349
  */
350
  private function google_analytics_listener() {
351
+ $google_auth_code = filter_input( INPUT_POST, 'google_auth_code' );
352
+ if ( $google_auth_code && current_user_can( 'manage_options' ) ) {
353
+ wp_verify_nonce( 'yoast_ga_nonce', 'save_settings' );
354
 
355
+ self::analytics_api_clean_up();
 
 
 
 
 
356
 
357
+ Yoast_Google_Analytics::get_instance()->authenticate( trim( $google_auth_code ) );
 
 
 
358
  }
359
+ }
360
 
361
+ /**
362
+ * Clean up the Analytics API settings
363
+ */
364
+ public static function analytics_api_clean_up() {
365
+ delete_option( 'yoast-ga-refresh_token' );
366
+ delete_option( 'yst_ga_api_call_fail' );
367
+ delete_option( 'yst_ga_last_wp_run' );
368
+ delete_option( 'yst_ga_api' );
369
  }
370
 
371
  /**
376
  private function get_current_profile() {
377
  if ( ! empty( $this->options['analytics_profile'] ) ) {
378
  return $this->options['analytics_profile'];
379
+ }
380
+ else {
381
  return null;
382
  }
383
  }
403
  foreach ( $editable_roles as $id => $name ) {
404
  $roles[] = array(
405
  'id' => $id,
406
+ 'name' => translate_user_role( $name['name'] ),
407
  );
408
  }
409
 
429
  */
430
  public function get_track_full_url() {
431
  return array(
432
+ 0 => array( 'id' => 'domain', 'name' => __( 'Just the domain', 'google-analytics-for-wordpress' ) ),
433
+ 1 => array( 'id' => 'full_links', 'name' => __( 'Full links', 'google-analytics-for-wordpress' ) ),
434
  );
435
  }
436
 
519
  /**
520
  * Add a notification to the notification transient
521
  *
522
+ * @param string $transient_name
523
+ * @param array $settings
524
  */
525
  private function add_notification( $transient_name, $settings ) {
526
  set_transient( $transient_name, $settings, MINUTE_IN_SECONDS );
542
  $transient['description'],
543
  'updated'
544
  );
545
+ }
546
+ else {
547
  add_settings_error(
548
  'yoast_google_analytics',
549
  'yoast_google_analytics',
admin/class-google-analytics.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
2
-
3
-
 
 
 
 
 
 
4
  class Yoast_Google_Analytics {
5
 
6
  /**
@@ -238,7 +244,7 @@ class Yoast_Google_Analytics {
238
  /**
239
  * Format the accounts request
240
  *
241
- * @param $response
242
  *
243
  * @return mixed
244
  */
@@ -254,7 +260,7 @@ class Yoast_Google_Analytics {
254
  $profiles = array();
255
 
256
  foreach ( $item['webProperties'] as $property_key => $property ) {
257
- $profiles[$property_key] = array(
258
  'id' => $property['id'],
259
  'name' => $property['name'],
260
  'items' => array(),
@@ -263,7 +269,7 @@ class Yoast_Google_Analytics {
263
  // Check if profiles is set
264
  if ( isset( $property['profiles'] ) ) {
265
  foreach ( $property['profiles'] as $key => $profile ) {
266
- $profiles[$property_key]['items'][$key] = array_merge(
267
  $profile,
268
  array(
269
  'name' => $profile['name'] . ' (' . $property['id'] . ')',
@@ -274,7 +280,7 @@ class Yoast_Google_Analytics {
274
  }
275
  }
276
 
277
- $accounts[$item['id']] = array(
278
  'id' => $item['id'],
279
  'ua_code' => $property['id'],
280
  'parent_name' => $item['name'],
@@ -300,7 +306,9 @@ class Yoast_Google_Analytics {
300
 
301
  }
302
 
303
-
 
 
304
  class Yoast_Google_Analytics_Notice {
305
 
306
  /**
@@ -344,7 +352,7 @@ class Yoast_Google_Analytics_Notice {
344
  /**
345
  * Showing the given error as an error div
346
  *
347
- * @param $error_message
348
  */
349
  private static function show_error( $error_message ) {
350
  echo '<div class="error"><p>' . $error_message . '</p></div>';
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
+ /**
8
+ * Google Analytics class.
9
+ */
10
  class Yoast_Google_Analytics {
11
 
12
  /**
244
  /**
245
  * Format the accounts request
246
  *
247
+ * @param array $response
248
  *
249
  * @return mixed
250
  */
260
  $profiles = array();
261
 
262
  foreach ( $item['webProperties'] as $property_key => $property ) {
263
+ $profiles[ $property_key ] = array(
264
  'id' => $property['id'],
265
  'name' => $property['name'],
266
  'items' => array(),
269
  // Check if profiles is set
270
  if ( isset( $property['profiles'] ) ) {
271
  foreach ( $property['profiles'] as $key => $profile ) {
272
+ $profiles[ $property_key ]['items'][ $key ] = array_merge(
273
  $profile,
274
  array(
275
  'name' => $profile['name'] . ' (' . $property['id'] . ')',
280
  }
281
  }
282
 
283
+ $accounts[ $item['id'] ] = array(
284
  'id' => $item['id'],
285
  'ua_code' => $property['id'],
286
  'parent_name' => $item['name'],
306
 
307
  }
308
 
309
+ /**
310
+ * Notice class.
311
+ */
312
  class Yoast_Google_Analytics_Notice {
313
 
314
  /**
352
  /**
353
  * Showing the given error as an error div
354
  *
355
+ * @param string $error_message
356
  */
357
  private static function show_error( $error_message ) {
358
  echo '<div class="error"><p>' . $error_message . '</p></div>';
admin/dashboards/class-admin-dashboards-api-options.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
 
 
 
 
2
 
 
 
 
3
  class Yoast_GA_Dashboards_Api_Options {
4
 
5
  /**
@@ -10,16 +17,12 @@ class Yoast_GA_Dashboards_Api_Options {
10
  private static $instance = null;
11
 
12
  /**
13
- * Store the access token
14
- *
15
- * @var
16
  */
17
  private $access_token;
18
 
19
  /**
20
- * Store the options
21
- *
22
- * @var
23
  */
24
  private $options;
25
 
@@ -78,7 +81,8 @@ class Yoast_GA_Dashboards_Api_Options {
78
  public function get_access_token() {
79
  if ( ! empty( $this->access_token ) ) {
80
  return $this->access_token;
81
- } else {
 
82
  return false;
83
  }
84
  }
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
+ /**
8
+ * Dashboards API options.
9
+ */
10
  class Yoast_GA_Dashboards_Api_Options {
11
 
12
  /**
17
  private static $instance = null;
18
 
19
  /**
20
+ * @var string $access_token Store the access token
 
 
21
  */
22
  private $access_token;
23
 
24
  /**
25
+ * @var array $options Store the options
 
 
26
  */
27
  private $options;
28
 
81
  public function get_access_token() {
82
  if ( ! empty( $this->access_token ) ) {
83
  return $this->access_token;
84
+ }
85
+ else {
86
  return false;
87
  }
88
  }
admin/dashboards/class-admin-dashboards-collector.php CHANGED
@@ -1,18 +1,21 @@
1
  <?php
2
-
 
 
 
 
 
 
 
3
  class Yoast_GA_Dashboards_Collector {
4
 
5
  /**
6
- * API storage
7
- *
8
- * @package
9
  */
10
  public $api;
11
 
12
  /**
13
- * Store the active metrics
14
- *
15
- * @var
16
  */
17
  public $active_metrics;
18
 
@@ -31,9 +34,7 @@ class Yoast_GA_Dashboards_Collector {
31
  private $valid_metrics = array();
32
 
33
  /**
34
- * Store the GA Profile ID
35
- *
36
- * @var int
37
  */
38
  public $ga_profile_id;
39
 
@@ -77,8 +78,8 @@ class Yoast_GA_Dashboards_Collector {
77
  if ( is_array( $this->dimensions ) && count( $this->dimensions ) >= 1 ) {
78
  $this->aggregate_dimensions( $this->dimensions );
79
  }
80
-
81
- } else {
82
  // Failure on authenticating, please reauthenticate
83
  }
84
  }
@@ -149,13 +150,13 @@ class Yoast_GA_Dashboards_Collector {
149
  $filter_metrics = $this->get_filter_metrics();
150
 
151
  foreach ( $metrics as $key => $metric_name ) {
152
- if ( isset( $filter_metrics[$metric_name] ) ) {
153
  // Add and set the dimension
154
- $dimension = array( $filter_metrics[$metric_name] );
155
  $this->dimensions = array_merge( $this->dimensions, $dimension );
156
 
157
  // Remove it from the metrics after we've added it into dimensions
158
- unset( $metrics[$key] );
159
  }
160
  }
161
 
@@ -248,10 +249,12 @@ class Yoast_GA_Dashboards_Collector {
248
  if ( isset( $dimension['metric'] ) ) {
249
  if ( isset( $dimension['id'] ) ) {
250
  $this->execute_call( $dimension['metric'], $dates['start'], $dates['end'], 'ga:dimension' . $dimension['id'] );
251
- } elseif ( isset( $dimension['dimension'] ) ) {
 
252
  if ( isset( $dimension['storage_name'] ) ) {
253
  $this->execute_call( $dimension['metric'], $dates['start'], $dates['end'], 'ga:' . $dimension['dimension'], $dimension['storage_name'] );
254
- } else {
 
255
  $this->execute_call( $dimension['metric'], $dates['start'], $dates['end'], 'ga:' . $dimension['dimension'] );
256
  }
257
  }
@@ -263,10 +266,10 @@ class Yoast_GA_Dashboards_Collector {
263
  * Execute an API call to Google Analytics and store the data in the dashboards data class
264
  *
265
  * @param string $metric
266
- * @param string $start_date 2014-10-16
267
- * @param string $end_date 2014-11-20
268
- * @param string $dimensions ga:date
269
- * @param string $storage_name
270
  *
271
  * @return bool
272
  */
@@ -286,7 +289,8 @@ class Yoast_GA_Dashboards_Collector {
286
  update_option( 'yst_ga_last_wp_run', date( 'Y-m-d' ) );
287
 
288
  $response = Yoast_Googleanalytics_Reporting::get_instance()->parse_response( $response, $storage_type, $start_date, $end_date );
289
- } else {
 
290
  // When response is failing, we should count the number of
291
  $this->save_api_failure();
292
 
@@ -295,7 +299,8 @@ class Yoast_GA_Dashboards_Collector {
295
 
296
  if ( strpos( 'ga:date', $dimensions ) !== false ) {
297
  return $this->handle_response( $response, $metric, $dimensions, $start_date, $end_date, 'datelist', $storage_name );
298
- } else {
 
299
  return $this->handle_response( $response, $metric, $dimensions, $start_date, $end_date, 'table', $storage_name );
300
  }
301
  }
@@ -317,7 +322,8 @@ class Yoast_GA_Dashboards_Collector {
317
  private function get_storage_type( $dimensions ) {
318
  if ( strpos( 'ga:date', $dimensions ) !== false ) {
319
  return 'datelist';
320
- } else {
 
321
  return 'table';
322
  }
323
  }
@@ -340,7 +346,8 @@ class Yoast_GA_Dashboards_Collector {
340
 
341
  if ( in_array( $metric, $this->valid_metrics ) ) {
342
  $dimensions = 'ga:date,' . $dimensions;
343
- } elseif ( isset( $filter_metrics[str_replace( 'ga:', '', $dimensions )] ) ) {
 
344
  // Make sure we don't have a ga:date property here
345
  $dimensions = str_replace( 'ga:date', '', $dimensions );
346
  }
@@ -386,7 +393,9 @@ class Yoast_GA_Dashboards_Collector {
386
  * Add a sort direction if we need to (Especially on dimensions which are
387
  * listed in $this->get_filter_metrics())
388
  *
389
- * @param array $params
 
 
390
  *
391
  * @return array
392
  */
@@ -421,14 +430,14 @@ class Yoast_GA_Dashboards_Collector {
421
  $filter_metrics = $this->get_filter_metrics();
422
  $extracted = str_replace( 'ga:', '', str_replace( 'ga:date,', '', $dimensions ) );
423
 
424
- if ( isset( $filter_metrics[$extracted] ) ) {
425
  $name = $extracted;
426
-
427
- } else {
428
  $name = $metric;
429
  }
430
 
431
- if ( $dimensions !== 'ga:date' && ! isset( $filter_metrics[$extracted] ) ) {
432
  $name = str_replace( 'ga:date,', '', $dimensions );
433
  }
434
 
@@ -438,7 +447,8 @@ class Yoast_GA_Dashboards_Collector {
438
  }
439
 
440
  return Yoast_GA_Dashboards_Data::set( $name, $response, strtotime( $start_date ), strtotime( $end_date ), $store_as );
441
- } else {
 
442
  // Failure on API call try to log it
443
  $this->log_error( print_r( $response, true ) );
444
 
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
+ /**
8
+ * Dashboards collector.
9
+ */
10
  class Yoast_GA_Dashboards_Collector {
11
 
12
  /**
13
+ * @var boolean $api API storage
 
 
14
  */
15
  public $api;
16
 
17
  /**
18
+ * @var array $active_metrics Store the active metrics
 
 
19
  */
20
  public $active_metrics;
21
 
34
  private $valid_metrics = array();
35
 
36
  /**
37
+ * @var integer $ga_profile_id Store the GA Profile ID
 
 
38
  */
39
  public $ga_profile_id;
40
 
78
  if ( is_array( $this->dimensions ) && count( $this->dimensions ) >= 1 ) {
79
  $this->aggregate_dimensions( $this->dimensions );
80
  }
81
+ }
82
+ else {
83
  // Failure on authenticating, please reauthenticate
84
  }
85
  }
150
  $filter_metrics = $this->get_filter_metrics();
151
 
152
  foreach ( $metrics as $key => $metric_name ) {
153
+ if ( isset( $filter_metrics[ $metric_name ] ) ) {
154
  // Add and set the dimension
155
+ $dimension = array( $filter_metrics[ $metric_name ] );
156
  $this->dimensions = array_merge( $this->dimensions, $dimension );
157
 
158
  // Remove it from the metrics after we've added it into dimensions
159
+ unset( $metrics[ $key ] );
160
  }
161
  }
162
 
249
  if ( isset( $dimension['metric'] ) ) {
250
  if ( isset( $dimension['id'] ) ) {
251
  $this->execute_call( $dimension['metric'], $dates['start'], $dates['end'], 'ga:dimension' . $dimension['id'] );
252
+ }
253
+ elseif ( isset( $dimension['dimension'] ) ) {
254
  if ( isset( $dimension['storage_name'] ) ) {
255
  $this->execute_call( $dimension['metric'], $dates['start'], $dates['end'], 'ga:' . $dimension['dimension'], $dimension['storage_name'] );
256
+ }
257
+ else {
258
  $this->execute_call( $dimension['metric'], $dates['start'], $dates['end'], 'ga:' . $dimension['dimension'] );
259
  }
260
  }
266
  * Execute an API call to Google Analytics and store the data in the dashboards data class
267
  *
268
  * @param string $metric
269
+ * @param string $start_date 2014-10-16
270
+ * @param string $end_date 2014-11-20
271
+ * @param string $dimensions ga:date
272
+ * @param string $storage_name auto
273
  *
274
  * @return bool
275
  */
289
  update_option( 'yst_ga_last_wp_run', date( 'Y-m-d' ) );
290
 
291
  $response = Yoast_Googleanalytics_Reporting::get_instance()->parse_response( $response, $storage_type, $start_date, $end_date );
292
+ }
293
+ else {
294
  // When response is failing, we should count the number of
295
  $this->save_api_failure();
296
 
299
 
300
  if ( strpos( 'ga:date', $dimensions ) !== false ) {
301
  return $this->handle_response( $response, $metric, $dimensions, $start_date, $end_date, 'datelist', $storage_name );
302
+ }
303
+ else {
304
  return $this->handle_response( $response, $metric, $dimensions, $start_date, $end_date, 'table', $storage_name );
305
  }
306
  }
322
  private function get_storage_type( $dimensions ) {
323
  if ( strpos( 'ga:date', $dimensions ) !== false ) {
324
  return 'datelist';
325
+ }
326
+ else {
327
  return 'table';
328
  }
329
  }
346
 
347
  if ( in_array( $metric, $this->valid_metrics ) ) {
348
  $dimensions = 'ga:date,' . $dimensions;
349
+ }
350
+ elseif ( isset( $filter_metrics[ str_replace( 'ga:', '', $dimensions ) ] ) ) {
351
  // Make sure we don't have a ga:date property here
352
  $dimensions = str_replace( 'ga:date', '', $dimensions );
353
  }
393
  * Add a sort direction if we need to (Especially on dimensions which are
394
  * listed in $this->get_filter_metrics())
395
  *
396
+ * @param array $params
397
+ * @param string $dimensions
398
+ * @param string $metric
399
  *
400
  * @return array
401
  */
430
  $filter_metrics = $this->get_filter_metrics();
431
  $extracted = str_replace( 'ga:', '', str_replace( 'ga:date,', '', $dimensions ) );
432
 
433
+ if ( isset( $filter_metrics[ $extracted ] ) ) {
434
  $name = $extracted;
435
+ }
436
+ else {
437
  $name = $metric;
438
  }
439
 
440
+ if ( $dimensions !== 'ga:date' && ! isset( $filter_metrics[ $extracted ] ) ) {
441
  $name = str_replace( 'ga:date,', '', $dimensions );
442
  }
443
 
447
  }
448
 
449
  return Yoast_GA_Dashboards_Data::set( $name, $response, strtotime( $start_date ), strtotime( $end_date ), $store_as );
450
+ }
451
+ else {
452
  // Failure on API call try to log it
453
  $this->log_error( print_r( $response, true ) );
454
 
admin/dashboards/class-admin-dashboards-data.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  /**
4
  * This class is used to store and get the data of the dashboards. The data is aggregated by
@@ -12,7 +16,7 @@ class Yoast_GA_Dashboards_Data {
12
  /**
13
  * Get a data object
14
  *
15
- * @param $type String
16
  *
17
  * @return array
18
  */
@@ -32,11 +36,11 @@ class Yoast_GA_Dashboards_Data {
32
  /**
33
  * Save a data object
34
  *
35
- * @param $type
36
- * @param $value
37
- * @param $start_date
38
- * @param $end_date
39
- * @param $store_as
40
  *
41
  * @return bool
42
  */
@@ -55,7 +59,7 @@ class Yoast_GA_Dashboards_Data {
55
  /**
56
  * Reset an option of the GA dashboards storage engine
57
  *
58
- * @param $type
59
  *
60
  * @return bool
61
  */
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
  /**
8
  * This class is used to store and get the data of the dashboards. The data is aggregated by
16
  /**
17
  * Get a data object
18
  *
19
+ * @param string $type
20
  *
21
  * @return array
22
  */
36
  /**
37
  * Save a data object
38
  *
39
+ * @param string $type
40
+ * @param array $value
41
+ * @param string $start_date
42
+ * @param string $end_date
43
+ * @param string $store_as
44
  *
45
  * @return bool
46
  */
59
  /**
60
  * Reset an option of the GA dashboards storage engine
61
  *
62
+ * @param string $type
63
  *
64
  * @return bool
65
  */
admin/dashboards/class-admin-dashboards-display.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
2
-
 
 
 
 
 
 
 
3
  class Yoast_GA_Dashboards_Display {
4
 
5
  /**
@@ -45,7 +52,7 @@ class Yoast_GA_Dashboards_Display {
45
  * *Singleton* via the `new` operator from outside of this class.
46
  */
47
  protected function __construct() {
48
- foreach ( $this->dashboard_types AS $dashboard_type ) {
49
  if ( ! $this->driver_exists( $dashboard_type ) ) {
50
  $this->create_driver( $dashboard_type );
51
  }
@@ -67,7 +74,7 @@ class Yoast_GA_Dashboards_Display {
67
  $this->create_driver( $dashboard_type );
68
  }
69
 
70
- return $this->drivers[$dashboard_type];
71
  }
72
 
73
  /**
@@ -88,7 +95,7 @@ class Yoast_GA_Dashboards_Display {
88
  * @param array $dashboards
89
  */
90
  private function register( $dashboards ) {
91
- foreach ( $dashboards AS $dashboard_name => $dashboard_settings ) {
92
  if ( ! empty( $dashboard_settings['type'] ) ) {
93
  $this->driver( $dashboard_settings['type'] )->register( $dashboard_name, $dashboard_settings );
94
  }
@@ -105,7 +112,7 @@ class Yoast_GA_Dashboards_Display {
105
 
106
  $dashboards_to_show = $this->dashboards;
107
 
108
- foreach ( $dashboards_to_show AS $dashboard_name => $dashboard_settings ) {
109
  if ( ! empty( $dashboard_settings['tab'] ) && $dashboard_settings['tab'] === $tab_to_show ) {
110
  $this->driver( $dashboard_settings['type'] )->display( $dashboard_name );
111
  }
@@ -120,17 +127,17 @@ class Yoast_GA_Dashboards_Display {
120
  * @return bool
121
  */
122
  protected function driver_exists( $dashboard_type ) {
123
- return array_key_exists( $dashboard_type, $this->drivers ) && is_object( $this->drivers[$dashboard_type] );
124
  }
125
 
126
  /**
127
  * Creates a driver based on given $dashboard_type
128
  *
129
- * @param $dashboard_type
130
  */
131
  protected function create_driver( $dashboard_type ) {
132
  $driver_class = 'Yoast_GA_Dashboards_' . ucfirst( $dashboard_type );
133
- $this->drivers[$dashboard_type] = new $driver_class();
134
  }
135
 
136
  }
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
+ /**
8
+ * Dashboards display class.
9
+ */
10
  class Yoast_GA_Dashboards_Display {
11
 
12
  /**
52
  * *Singleton* via the `new` operator from outside of this class.
53
  */
54
  protected function __construct() {
55
+ foreach ( $this->dashboard_types as $dashboard_type ) {
56
  if ( ! $this->driver_exists( $dashboard_type ) ) {
57
  $this->create_driver( $dashboard_type );
58
  }
74
  $this->create_driver( $dashboard_type );
75
  }
76
 
77
+ return $this->drivers[ $dashboard_type ];
78
  }
79
 
80
  /**
95
  * @param array $dashboards
96
  */
97
  private function register( $dashboards ) {
98
+ foreach ( $dashboards as $dashboard_name => $dashboard_settings ) {
99
  if ( ! empty( $dashboard_settings['type'] ) ) {
100
  $this->driver( $dashboard_settings['type'] )->register( $dashboard_name, $dashboard_settings );
101
  }
112
 
113
  $dashboards_to_show = $this->dashboards;
114
 
115
+ foreach ( $dashboards_to_show as $dashboard_name => $dashboard_settings ) {
116
  if ( ! empty( $dashboard_settings['tab'] ) && $dashboard_settings['tab'] === $tab_to_show ) {
117
  $this->driver( $dashboard_settings['type'] )->display( $dashboard_name );
118
  }
127
  * @return bool
128
  */
129
  protected function driver_exists( $dashboard_type ) {
130
+ return array_key_exists( $dashboard_type, $this->drivers ) && is_object( $this->drivers[ $dashboard_type ] );
131
  }
132
 
133
  /**
134
  * Creates a driver based on given $dashboard_type
135
  *
136
+ * @param string $dashboard_type
137
  */
138
  protected function create_driver( $dashboard_type ) {
139
  $driver_class = 'Yoast_GA_Dashboards_' . ucfirst( $dashboard_type );
140
+ $this->drivers[ $dashboard_type ] = new $driver_class();
141
  }
142
 
143
  }
admin/dashboards/class-admin-dashboards.php CHANGED
@@ -1,25 +1,26 @@
1
  <?php
2
-
 
 
 
 
 
 
 
3
  class Yoast_GA_Dashboards {
4
 
5
  /**
6
- * Store the data aggregator
7
- *
8
- * @package
9
  */
10
  public $aggregator;
11
 
12
  /**
13
- * Store the Data instance
14
- *
15
- * @package
16
  */
17
  public $data;
18
 
19
  /**
20
- * Store the active metrics
21
- *
22
- * @var
23
  */
24
  public $active_metrics;
25
 
@@ -40,9 +41,7 @@ class Yoast_GA_Dashboards {
40
  private static $instance = null;
41
 
42
  /**
43
- * Store the Dashboards disabled bool
44
- *
45
- * @var bool
46
  */
47
  private $dashboards_disabled;
48
 
@@ -80,7 +79,7 @@ class Yoast_GA_Dashboards {
80
  *
81
  * By hook as filter: $dashboards = apply_filters( 'ga_extend_dashboards', $dashboards);
82
  *
83
- * @param $dashboards
84
  *
85
  * @return mixed
86
  */
@@ -107,7 +106,7 @@ class Yoast_GA_Dashboards {
107
  /**
108
  * Register the dashboard types
109
  *
110
- * @param $types array or singular string
111
  *
112
  * @return bool
113
  */
@@ -235,7 +234,7 @@ class Yoast_GA_Dashboards {
235
  /**
236
  * Validate the registered types of dashboards
237
  *
238
- * @param $types
239
  *
240
  * @return bool
241
  */
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
+ /**
8
+ * Dashboards class.
9
+ */
10
  class Yoast_GA_Dashboards {
11
 
12
  /**
13
+ * @var Yoast_GA_Dashboards_Collector $aggregator Store the data aggregator
 
 
14
  */
15
  public $aggregator;
16
 
17
  /**
18
+ * @var array $data Store the Data instance
 
 
19
  */
20
  public $data;
21
 
22
  /**
23
+ * @var array $active_metrics Store the active metrics
 
 
24
  */
25
  public $active_metrics;
26
 
41
  private static $instance = null;
42
 
43
  /**
44
+ * @var boolean $dashboards_disabled Store the Dashboards disabled bool
 
 
45
  */
46
  private $dashboards_disabled;
47
 
79
  *
80
  * By hook as filter: $dashboards = apply_filters( 'ga_extend_dashboards', $dashboards);
81
  *
82
+ * @param array $dashboards
83
  *
84
  * @return mixed
85
  */
106
  /**
107
  * Register the dashboard types
108
  *
109
+ * @param array|string $types
110
  *
111
  * @return bool
112
  */
234
  /**
235
  * Validate the registered types of dashboards
236
  *
237
+ * @param array $types
238
  *
239
  * @return bool
240
  */
admin/dashboards/drivers/class-admin-dashboards-driver-generate.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
2
-
 
 
 
 
 
 
 
3
  abstract class Yoast_GA_Dashboards_Driver_Generate {
4
 
5
  /**
@@ -89,7 +96,8 @@ abstract class Yoast_GA_Dashboards_Driver_Generate {
89
 
90
  if ( $response != array() && array_key_exists( 'body', $response['value'] ) ) {
91
  $return = $response['value']['body'];
92
- } else {
 
93
  $return = $response;
94
  }
95
 
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
+ /**
8
+ * Base abstract class.
9
+ */
10
  abstract class Yoast_GA_Dashboards_Driver_Generate {
11
 
12
  /**
96
 
97
  if ( $response != array() && array_key_exists( 'body', $response['value'] ) ) {
98
  $return = $response['value']['body'];
99
+ }
100
+ else {
101
  $return = $response;
102
  }
103
 
admin/dashboards/drivers/class-admin-dashboards-driver.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
 
 
 
 
2
 
 
 
 
3
  abstract class Yoast_GA_Dashboards_Driver {
4
 
5
  /**
@@ -54,10 +61,10 @@ abstract class Yoast_GA_Dashboards_Driver {
54
  /**
55
  * Giving the dashboardname to show
56
  *
57
- * @param $dashboard
58
  */
59
  public function display( $dashboard ) {
60
- $settings = $this->dashboards[$dashboard];
61
  require dirname( GAWP_FILE ) . '/admin/dashboards/views/' . $this->dashboard_type . '.php';
62
  }
63
 
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
+ /**
8
+ * Base abstract class.
9
+ */
10
  abstract class Yoast_GA_Dashboards_Driver {
11
 
12
  /**
61
  /**
62
  * Giving the dashboardname to show
63
  *
64
+ * @param string $dashboard
65
  */
66
  public function display( $dashboard ) {
67
+ $settings = $this->dashboards[ $dashboard ];
68
  require dirname( GAWP_FILE ) . '/admin/dashboards/views/' . $this->dashboard_type . '.php';
69
  }
70
 
admin/dashboards/drivers/class-admin-dashboards-graph-generate.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
2
-
 
 
 
 
 
 
 
3
  class Yoast_GA_Dashboards_Graph_Generate extends Yoast_GA_Dashboards_Driver_Generate {
4
 
5
  /**
@@ -60,9 +67,9 @@ class Yoast_GA_Dashboards_Graph_Generate extends Yoast_GA_Dashboards_Driver_Gene
60
  */
61
  protected function filter_google_data( $google_data ) {
62
 
63
- foreach ( $google_data['value'] AS $unix_timestamp => $value ) {
64
  if ( $this->is_date_in_period( $unix_timestamp ) ) {
65
- $return[$unix_timestamp] = $value;
66
  }
67
  }
68
 
@@ -91,7 +98,7 @@ class Yoast_GA_Dashboards_Graph_Generate extends Yoast_GA_Dashboards_Driver_Gene
91
 
92
  $google_data = $this->get_google_data();
93
 
94
- foreach ( $google_data AS $timestamp => $value ) {
95
  $this->add_data( $value );
96
  $this->add_x_mapping( $timestamp );
97
  $this->add_hover_mapping( $timestamp, $value );
@@ -130,7 +137,7 @@ class Yoast_GA_Dashboards_Graph_Generate extends Yoast_GA_Dashboards_Driver_Gene
130
  private function add_x_mapping( $timestamp ) {
131
 
132
  $is_monday = ( 'Mon' === date( 'D', $timestamp ) );
133
- $this->mapping['x'][] = $is_monday ? date( $this->date_field . ' M', $timestamp ) : null;
134
  }
135
 
136
  /**
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
+ /**
8
+ * Graph inherited class.
9
+ */
10
  class Yoast_GA_Dashboards_Graph_Generate extends Yoast_GA_Dashboards_Driver_Generate {
11
 
12
  /**
67
  */
68
  protected function filter_google_data( $google_data ) {
69
 
70
+ foreach ( $google_data['value'] as $unix_timestamp => $value ) {
71
  if ( $this->is_date_in_period( $unix_timestamp ) ) {
72
+ $return[ $unix_timestamp ] = $value;
73
  }
74
  }
75
 
98
 
99
  $google_data = $this->get_google_data();
100
 
101
+ foreach ( $google_data as $timestamp => $value ) {
102
  $this->add_data( $value );
103
  $this->add_x_mapping( $timestamp );
104
  $this->add_hover_mapping( $timestamp, $value );
137
  private function add_x_mapping( $timestamp ) {
138
 
139
  $is_monday = ( 'Mon' === date( 'D', $timestamp ) );
140
+ $this->mapping['x'][] = ( $is_monday ) ? date( $this->date_field . ' M', $timestamp ) : null;
141
  }
142
 
143
  /**
admin/dashboards/drivers/class-admin-dashboards-graph.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
 
 
 
 
2
 
 
 
 
3
  class Yoast_GA_Dashboards_Graph extends Yoast_GA_Dashboards_Driver {
4
 
5
  /**
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
+ /**
8
+ * Dashboards graph inherited class.
9
+ */
10
  class Yoast_GA_Dashboards_Graph extends Yoast_GA_Dashboards_Driver {
11
 
12
  /**
admin/dashboards/drivers/class-admin-dashboards-table-generate.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
 
 
 
 
2
 
 
 
 
3
  class Yoast_GA_Dashboards_Table_Generate extends Yoast_GA_Dashboards_Driver_Generate {
4
 
5
  /**
@@ -51,7 +58,8 @@ class Yoast_GA_Dashboards_Table_Generate extends Yoast_GA_Dashboards_Driver_Gene
51
 
52
  if ( ! empty( $this->dimension_id ) ) {
53
  $this->graph_type = 'ga:dimension' . $this->dimension_id;
54
- } else {
 
55
  $this->graph_type = $this->graph_type;
56
  }
57
  }
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
+ /**
8
+ * Dashboards table inherited class.
9
+ */
10
  class Yoast_GA_Dashboards_Table_Generate extends Yoast_GA_Dashboards_Driver_Generate {
11
 
12
  /**
58
 
59
  if ( ! empty( $this->dimension_id ) ) {
60
  $this->graph_type = 'ga:dimension' . $this->dimension_id;
61
+ }
62
+ else {
63
  $this->graph_type = $this->graph_type;
64
  }
65
  }
admin/dashboards/drivers/class-admin-dashboards-table.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
 
 
 
 
2
 
 
 
 
3
  class Yoast_GA_Dashboards_Table extends Yoast_GA_Dashboards_Driver {
4
 
5
  /**
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
 
7
+ /**
8
+ * Dashboards table inherited class.
9
+ */
10
  class Yoast_GA_Dashboards_Table extends Yoast_GA_Dashboards_Driver {
11
 
12
  /**
admin/dashboards/views/graph.php CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  <div id="graph-<?php echo $dashboard; ?>" class="yoast-dashboard yoast-graph" data-label="<?php echo $settings['title']; ?>" data-percent="<?php echo ! empty( $settings['data-percent'] ); ?>">
2
  <h3>
3
  <span class='alignleft'><?php echo $settings['title']; ?></span>
@@ -9,12 +16,14 @@
9
  <span class='alignright period'><?php echo __( 'Last month', 'google-analytics-for-wordpress' ); ?></span>
10
  </h3>
11
 
12
- <?php if ( empty( $settings['hide_y_axis'] ) ) {
 
13
  echo "<div class='yoast-graph-yaxis'></div >";
14
  } ?>
15
  <div class="yoast-graph-holder"></div>
16
 
17
- <?php if ( empty( $settings['hide_x_axis'] ) ) {
 
18
  echo "<div class='yoast-graph-xaxis'></div >";
19
  } ?>
20
  </div>
1
+ <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
+ ?>
8
  <div id="graph-<?php echo $dashboard; ?>" class="yoast-dashboard yoast-graph" data-label="<?php echo $settings['title']; ?>" data-percent="<?php echo ! empty( $settings['data-percent'] ); ?>">
9
  <h3>
10
  <span class='alignleft'><?php echo $settings['title']; ?></span>
16
  <span class='alignright period'><?php echo __( 'Last month', 'google-analytics-for-wordpress' ); ?></span>
17
  </h3>
18
 
19
+ <?php
20
+ if ( empty( $settings['hide_y_axis'] ) ) {
21
  echo "<div class='yoast-graph-yaxis'></div >";
22
  } ?>
23
  <div class="yoast-graph-holder"></div>
24
 
25
+ <?php
26
+ if ( empty( $settings['hide_x_axis'] ) ) {
27
  echo "<div class='yoast-graph-xaxis'></div >";
28
  } ?>
29
  </div>
admin/dashboards/views/table.php CHANGED
@@ -1,4 +1,11 @@
1
- <div class='yoast-dashboard yoast-data-table' id="table-<?php echo $dashboard; ?>" data-label="<?php echo $settings['title']; ?>" data-dimension="<?php echo (!empty($settings['custom-dimension-id'])) ? $settings['custom-dimension-id'] : ''; ?>">
 
 
 
 
 
 
 
2
  <h3>
3
  <span class='alignleft'><?php echo $settings['title']; ?></span>
4
  <?php
@@ -13,7 +20,7 @@
13
  <table class="widefat fixed stripe">
14
  <thead>
15
  <th><?php echo $settings['title']; ?></th>
16
- <?php foreach($settings['columns'] As $columns) { ?>
17
  <th><?php echo $columns; ?></th>
18
  <?php } ?>
19
  </thead>
1
+ <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
+ ?>
8
+ <div class='yoast-dashboard yoast-data-table' id="table-<?php echo $dashboard; ?>" data-label="<?php echo $settings['title']; ?>" data-dimension="<?php echo ( ! empty( $settings['custom-dimension-id'] ) ) ? $settings['custom-dimension-id'] : ''; ?>">
9
  <h3>
10
  <span class='alignleft'><?php echo $settings['title']; ?></span>
11
  <?php
20
  <table class="widefat fixed stripe">
21
  <thead>
22
  <th><?php echo $settings['title']; ?></th>
23
+ <?php foreach ( $settings['columns'] as $columns ) { ?>
24
  <th><?php echo $columns; ?></th>
25
  <?php } ?>
26
  </thead>
admin/pages/dashboard.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  global $yoast_ga_admin;
3
 
4
  $options_class = Yoast_GA_Options::instance();
@@ -41,7 +46,8 @@ echo $yoast_ga_admin->content_head();
41
  '</a>'
42
  );
43
  echo '</p></div>';
44
- } else if( ! Yoast_Google_Analytics::get_instance()->has_refresh_token() ) {
 
45
  echo '<div class="ga-promote"><p>';
46
  echo sprintf(
47
  __( 'Because we\'ve switched to a newer version of the Google Analytics API, you\'ll need to re-authenticate with Google Analytics. We\'re sorry for the inconvenience. You can %sre-authenticate your Google Analytics profile here%s.', 'google-analytics-for-wordpress' ),
@@ -49,10 +55,12 @@ echo $yoast_ga_admin->content_head();
49
  '</a>'
50
  );
51
  echo '</p></div>';
52
- } else {
 
53
  Yoast_GA_Dashboards_Display::get_instance()->display( 'general' );
54
  }
55
- } else {
 
56
  echo '<div class="ga-promote"><p>';
57
  echo sprintf(
58
  __( 'You have not yet finished setting up Google Analytics for Wordpress by Yoast. Please %sadd your Analytics profile here%s to enable tracking.', 'google-analytics-for-wordpress' ),
@@ -77,7 +85,8 @@ echo $yoast_ga_admin->content_head();
77
  '</a>'
78
  );
79
  echo '</p></div>';
80
- } else if( ! Yoast_Google_Analytics::get_instance()->has_refresh_token() ) {
 
81
  echo '<div class="ga-promote"><p>';
82
  echo sprintf(
83
  __( 'Because we\'ve switched to a newer version of the Google Analytics API, you\'ll need to re-authenticate with Google Analytics. We\'re sorry for the inconvenience. You can %sre-authenticate your Google Analytics profile here%s.', 'google-analytics-for-wordpress' ),
@@ -85,7 +94,8 @@ echo $yoast_ga_admin->content_head();
85
  '</a>'
86
  );
87
  echo '</p></div>';
88
- } else {
 
89
  ?>
90
  <div class="ga-form ga-form-input">
91
  <label class="ga-form ga-form-checkbox-label ga-form-label-left"><?php echo __( 'Select a dimension', 'google-analytics-for-wordpress' ); ?></label>
@@ -95,7 +105,8 @@ echo $yoast_ga_admin->content_head();
95
  <?php
96
  Yoast_GA_Dashboards_Display::get_instance()->display( 'dimensions' );
97
  }
98
- } else {
 
99
  echo '<div class="ga-promote"><p>';
100
  echo sprintf(
101
  __( 'You have not yet finished setting up Google Analytics for Wordpress by Yoast. Please %sadd your Analytics profile here%s to enable tracking.', 'google-analytics-for-wordpress' ),
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
  global $yoast_ga_admin;
8
 
9
  $options_class = Yoast_GA_Options::instance();
46
  '</a>'
47
  );
48
  echo '</p></div>';
49
+ }
50
+ else if ( ! Yoast_Google_Analytics::get_instance()->has_refresh_token() ) {
51
  echo '<div class="ga-promote"><p>';
52
  echo sprintf(
53
  __( 'Because we\'ve switched to a newer version of the Google Analytics API, you\'ll need to re-authenticate with Google Analytics. We\'re sorry for the inconvenience. You can %sre-authenticate your Google Analytics profile here%s.', 'google-analytics-for-wordpress' ),
55
  '</a>'
56
  );
57
  echo '</p></div>';
58
+ }
59
+ else {
60
  Yoast_GA_Dashboards_Display::get_instance()->display( 'general' );
61
  }
62
+ }
63
+ else {
64
  echo '<div class="ga-promote"><p>';
65
  echo sprintf(
66
  __( 'You have not yet finished setting up Google Analytics for Wordpress by Yoast. Please %sadd your Analytics profile here%s to enable tracking.', 'google-analytics-for-wordpress' ),
85
  '</a>'
86
  );
87
  echo '</p></div>';
88
+ }
89
+ else if ( ! Yoast_Google_Analytics::get_instance()->has_refresh_token() ) {
90
  echo '<div class="ga-promote"><p>';
91
  echo sprintf(
92
  __( 'Because we\'ve switched to a newer version of the Google Analytics API, you\'ll need to re-authenticate with Google Analytics. We\'re sorry for the inconvenience. You can %sre-authenticate your Google Analytics profile here%s.', 'google-analytics-for-wordpress' ),
94
  '</a>'
95
  );
96
  echo '</p></div>';
97
+ }
98
+ else {
99
  ?>
100
  <div class="ga-form ga-form-input">
101
  <label class="ga-form ga-form-checkbox-label ga-form-label-left"><?php echo __( 'Select a dimension', 'google-analytics-for-wordpress' ); ?></label>
105
  <?php
106
  Yoast_GA_Dashboards_Display::get_instance()->display( 'dimensions' );
107
  }
108
+ }
109
+ else {
110
  echo '<div class="ga-promote"><p>';
111
  echo sprintf(
112
  __( 'You have not yet finished setting up Google Analytics for Wordpress by Yoast. Please %sadd your Analytics profile here%s to enable tracking.', 'google-analytics-for-wordpress' ),
admin/pages/extensions.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  global $yoast_ga_admin;
3
 
4
  echo $yoast_ga_admin->content_head();
@@ -16,7 +21,7 @@ $extensions = $yoast_ga_admin->get_extensions();
16
  <div class="tabwrapper">
17
  <div id="extensions" class="wpseotab gatab">
18
  <?php
19
- foreach ( $extensions as $name => $extension ) {
20
  if ( 'uninstalled' !== $extension->status ) {
21
  $has_extensions = true;
22
  }
@@ -27,36 +32,26 @@ $extensions = $yoast_ga_admin->get_extensions();
27
  </a>
28
 
29
  <p><?php echo $extension->desc; ?></p>
30
-
31
  <p>
32
- <?php
33
- if ( 'uninstalled' == $extension->status ) {
34
- ?>
35
- <a target="_blank" href="<?php echo $extension->url; ?>#utm_medium=banner&utm_source=gawp-config&utm_campaign=extension-page-banners" class="button-primary"><?php echo __( 'Get this extension', 'google-analytics-for-wordpress'); ?></a>
36
- <?php
37
- } else {
38
- if ( 'inactive' == $extension->status ) {
39
- ?>
40
- <a href="#top#licenses" class="activate-link button-primary"><?php echo __( 'Activate License', 'google-analytics-for-wordpress'); ?></a>
41
- <?php
42
- } else {
43
- ?>
44
- <button class="button-primary installed"><?php echo __( 'Installed', 'google-analytics-for-wordpress'); ?></button>
45
- <?php
46
- }
47
- }
48
- ?>
49
  </p>
50
  </div>
51
- <?php
52
- }
53
- ?>
54
  </div>
55
  <div id="licenses" class="wpseotab gatab">
56
  <?php
57
  if ( ! $has_extensions ) {
58
  echo '<p>' . __( 'You have not installed any extensions for Google Analytics by Yoast, so there are no licenses to activate.', 'google-analytics-for-wordpress' ) . '</p>';
59
- } else {
 
60
  do_action( 'yst_ga_show_license_form' );
61
  }
62
  ?>
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
  global $yoast_ga_admin;
8
 
9
  echo $yoast_ga_admin->content_head();
21
  <div class="tabwrapper">
22
  <div id="extensions" class="wpseotab gatab">
23
  <?php
24
+ foreach ( $extensions as $name => $extension ) :
25
  if ( 'uninstalled' !== $extension->status ) {
26
  $has_extensions = true;
27
  }
32
  </a>
33
 
34
  <p><?php echo $extension->desc; ?></p>
 
35
  <p>
36
+ <?php if ( 'uninstalled' == $extension->status ) : ?>
37
+ <a target="_blank" href="<?php echo $extension->url; ?>#utm_medium=banner&utm_source=gawp-config&utm_campaign=extension-page-banners" class="button-primary"><?php echo __( 'Get this extension', 'google-analytics-for-wordpress' ); ?></a>
38
+ <?php else : ?>
39
+ <?php if ( 'inactive' == $extension->status ) : ?>
40
+ <a href="#top#licenses" class="activate-link button-primary"><?php echo __( 'Activate License', 'google-analytics-for-wordpress' ); ?></a>
41
+ <?php else : ?>
42
+ <button class="button-primary installed"><?php echo __( 'Installed', 'google-analytics-for-wordpress' ); ?></button>
43
+ <?php endif; ?>
44
+ <?php endif; ?>
 
 
 
 
 
 
 
 
45
  </p>
46
  </div>
47
+ <?php endforeach; ?>
 
 
48
  </div>
49
  <div id="licenses" class="wpseotab gatab">
50
  <?php
51
  if ( ! $has_extensions ) {
52
  echo '<p>' . __( 'You have not installed any extensions for Google Analytics by Yoast, so there are no licenses to activate.', 'google-analytics-for-wordpress' ) . '</p>';
53
+ }
54
+ else {
55
  do_action( 'yst_ga_show_license_form' );
56
  }
57
  ?>
admin/pages/settings.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  global $yoast_ga_admin;
3
 
4
  echo $yoast_ga_admin->content_head();
@@ -49,10 +54,11 @@ echo Yoast_GA_Admin_Form::create_form( 'settings' );
49
  echo '</div>';
50
  echo '<div class="ga-form ga-form-input">';
51
  echo '<label class="ga-form ga-form-text-label ga-form-label-left" id="yoast-ga-form-label-text-ga-authwithgoogle">' . __( 'Current UA-profile', 'google-analytics-for-wordpress' ) . '</label>';
52
- echo $yoast_ga_admin->get_tracking_code();
53
  echo '</div>';
54
- } else {
55
- echo Yoast_GA_Admin_Form::select( __('Analytics profile', 'google-analytics-for-wordpress' ), 'analytics_profile', $profiles, null, false, __( 'Select a profile', 'google-analytics-for-wordpress' ) );
 
56
 
57
  echo '<div class="ga-form ga-form-input">';
58
  echo '<label class="ga-form ga-form-text-label ga-form-label-left" id="yoast-ga-form-label-text-ga-authwithgoogle">&nbsp;</label>';
@@ -66,13 +72,15 @@ echo Yoast_GA_Admin_Form::create_form( 'settings' );
66
  echo Yoast_GA_Admin_Form::input( 'text', null, 'google_auth_code', null, null );
67
 
68
  echo '<label class="ga-form ga-form-text-label ga-form-label-left" id="yoast-ga-form-label-text-ga-authwithgoogle-submit">&nbsp;</label>';
69
- echo '<div class="ga-form ga-form-input"><input type="submit" name="ga-form-settings" value="' . __('Save authentication code', 'google-analytics-for-wordpress') . '" class="button button-primary ga-form-submit" id="yoast-ga-form-submit-settings" onclick="yst_closepopupwindow();"></div>';
70
  echo '</div>';
71
- } else {
 
72
  echo '<h3>' . __( 'Cannot connect to Google', 'google-analytics-for-wordpress' ) . '</h3>';
73
  if ( $wp_block_google == false && $check_google_access == false ) {
74
  echo '<p>' . __( 'Your server is blocking requests to Google, to fix this, add <code>*.googleapis.com</code> to the <code>WP_ACCESSIBLE_HOSTS</code> constant in your <em>wp-config.php</em> or ask your webhost to do this.', 'google-analytics-for-wordpress' ) . '</p>';
75
- } else {
 
76
  echo '<p>' . __( 'Your firewall or webhost is blocking requests to Google, please ask your webhost company to fix this.', 'google-analytics-for-wordpress' ) . '</p>';
77
  }
78
  echo '<p>' . __( 'Until this is fixed, you can only use the manual authentication method and cannot use the dashboards feature.', 'google-analytics-for-wordpress' ) . '</p>';
@@ -116,9 +124,9 @@ echo Yoast_GA_Admin_Form::create_form( 'settings' );
116
  echo Yoast_GA_Admin_Form::input( 'text', __( 'Label for those links', 'google-analytics-for-wordpress' ), 'track_internal_as_label', null, 'The label to use for these links, this will be added to where the click came from, so if the label is "aff", the label for a click from the content of an article becomes "outbound-article-aff".' );
117
 
118
  echo Yoast_GA_Admin_Form::input( 'checkbox', __( 'Tag links in RSS feed with campaign variables', 'google-analytics-for-wordpress' ), 'tag_links_in_rss', null, __( 'Do not use this feature if you use FeedBurner, as FeedBurner can do this automatically and better than this plugin can. Check <a href="https://support.google.com/feedburner/answer/165769?hl=en&amp;ref_topic=13075" target="_blank">this help page</a> for info on how to enable this feature in FeedBurner.', 'google-analytics-for-wordpress' ) );
119
- echo Yoast_GA_Admin_Form::input( 'checkbox', __( 'Allow anchor', 'google-analytics-for-wordpress' ), 'allow_anchor', null , sprintf(__( 'This adds a %1$s call to your tracking code, and makes RSS link tagging use a %2$s as well.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking?csw=1#_gat.GA_Tracker_._setAllowAnchor" target="_blank"><code>_setAllowAnchor</code></a>', '<code>#</code>' ));
120
  echo Yoast_GA_Admin_Form::input( 'checkbox', __( 'Add <code>_setAllowLinker</code>', 'google-analytics-for-wordpress' ), 'add_allow_linker', null, sprintf( __( 'This adds a %1$s call to your tracking code, allowing you to use %2$s and related functions.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory?csw=1#_gat.GA_Tracker_._setAllowLinker" target="_blank"><code>_setAllowLinker</code></a>', ' <code>_link</code>' ) );
121
- echo Yoast_GA_Admin_Form::textarea( __( 'Custom code', 'google-analytics-for-wordpress' ), 'custom_code', sprintf( __( 'Not for the average user: this allows you to add a line of code, to be added before the %1$s call.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration#_gat.GA_Tracker_._trackPageview" target="_blank"><code>_trackPageview</code></a>' ) );
122
 
123
  do_action( 'yst_ga_advanced-tab' );
124
  ?>
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
  global $yoast_ga_admin;
8
 
9
  echo $yoast_ga_admin->content_head();
54
  echo '</div>';
55
  echo '<div class="ga-form ga-form-input">';
56
  echo '<label class="ga-form ga-form-text-label ga-form-label-left" id="yoast-ga-form-label-text-ga-authwithgoogle">' . __( 'Current UA-profile', 'google-analytics-for-wordpress' ) . '</label>';
57
+ echo esc_html( $yoast_ga_admin->get_tracking_code() );
58
  echo '</div>';
59
+ }
60
+ else {
61
+ echo Yoast_GA_Admin_Form::select( __( 'Analytics profile', 'google-analytics-for-wordpress' ), 'analytics_profile', $profiles, null, false, __( 'Select a profile', 'google-analytics-for-wordpress' ) );
62
 
63
  echo '<div class="ga-form ga-form-input">';
64
  echo '<label class="ga-form ga-form-text-label ga-form-label-left" id="yoast-ga-form-label-text-ga-authwithgoogle">&nbsp;</label>';
72
  echo Yoast_GA_Admin_Form::input( 'text', null, 'google_auth_code', null, null );
73
 
74
  echo '<label class="ga-form ga-form-text-label ga-form-label-left" id="yoast-ga-form-label-text-ga-authwithgoogle-submit">&nbsp;</label>';
75
+ echo '<div class="ga-form ga-form-input"><input type="submit" name="ga-form-settings" value="' . __( 'Save authentication code', 'google-analytics-for-wordpress' ) . '" class="button button-primary ga-form-submit" id="yoast-ga-form-submit-settings" onclick="yst_closepopupwindow();"></div>';
76
  echo '</div>';
77
+ }
78
+ else {
79
  echo '<h3>' . __( 'Cannot connect to Google', 'google-analytics-for-wordpress' ) . '</h3>';
80
  if ( $wp_block_google == false && $check_google_access == false ) {
81
  echo '<p>' . __( 'Your server is blocking requests to Google, to fix this, add <code>*.googleapis.com</code> to the <code>WP_ACCESSIBLE_HOSTS</code> constant in your <em>wp-config.php</em> or ask your webhost to do this.', 'google-analytics-for-wordpress' ) . '</p>';
82
+ }
83
+ else {
84
  echo '<p>' . __( 'Your firewall or webhost is blocking requests to Google, please ask your webhost company to fix this.', 'google-analytics-for-wordpress' ) . '</p>';
85
  }
86
  echo '<p>' . __( 'Until this is fixed, you can only use the manual authentication method and cannot use the dashboards feature.', 'google-analytics-for-wordpress' ) . '</p>';
124
  echo Yoast_GA_Admin_Form::input( 'text', __( 'Label for those links', 'google-analytics-for-wordpress' ), 'track_internal_as_label', null, 'The label to use for these links, this will be added to where the click came from, so if the label is "aff", the label for a click from the content of an article becomes "outbound-article-aff".' );
125
 
126
  echo Yoast_GA_Admin_Form::input( 'checkbox', __( 'Tag links in RSS feed with campaign variables', 'google-analytics-for-wordpress' ), 'tag_links_in_rss', null, __( 'Do not use this feature if you use FeedBurner, as FeedBurner can do this automatically and better than this plugin can. Check <a href="https://support.google.com/feedburner/answer/165769?hl=en&amp;ref_topic=13075" target="_blank">this help page</a> for info on how to enable this feature in FeedBurner.', 'google-analytics-for-wordpress' ) );
127
+ echo Yoast_GA_Admin_Form::input( 'checkbox', __( 'Allow anchor', 'google-analytics-for-wordpress' ), 'allow_anchor', null, sprintf( __( 'This adds a %1$s call to your tracking code, and makes RSS link tagging use a %2$s as well.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking?csw=1#_gat.GA_Tracker_._setAllowAnchor" target="_blank"><code>_setAllowAnchor</code></a>', '<code>#</code>' ) );
128
  echo Yoast_GA_Admin_Form::input( 'checkbox', __( 'Add <code>_setAllowLinker</code>', 'google-analytics-for-wordpress' ), 'add_allow_linker', null, sprintf( __( 'This adds a %1$s call to your tracking code, allowing you to use %2$s and related functions.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory?csw=1#_gat.GA_Tracker_._setAllowLinker" target="_blank"><code>_setAllowLinker</code></a>', ' <code>_link</code>' ) );
129
+ echo Yoast_GA_Admin_Form::textarea( __( 'Custom code', 'google-analytics-for-wordpress' ), 'custom_code', sprintf( __( 'Not for the average user: this allows you to add a line of code, to be added before the %1$s call.', 'google-analytics-for-wordpress' ), '<a href="https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration#_gat.GA_Tracker_._trackPageview" target="_blank"><code>_trackPageview</code></a>' ) );
130
 
131
  do_action( 'yst_ga_advanced-tab' );
132
  ?>
admin/views/content-footer.php CHANGED
@@ -1,6 +1,13 @@
 
 
 
 
 
 
 
1
  </div>
2
  <div class="yoast-ga-banners">
3
- <?php foreach ( $banners as $item ): ?>
4
  <p><a href="<?php echo $item['url']; ?>" target="_blank">
5
  <img src="<?php echo $item['banner']; ?>" alt="<?php echo $item['title']; ?>" class="yoast-banner" border="0" width="250" />
6
  </a></p>
1
+ <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Admin
5
+ */
6
+
7
+ ?>
8
  </div>
9
  <div class="yoast-ga-banners">
10
+ <?php foreach ( $banners as $item ) : ?>
11
  <p><a href="<?php echo $item['url']; ?>" target="_blank">
12
  <img src="<?php echo $item['banner']; ?>" alt="<?php echo $item['title']; ?>" class="yoast-banner" border="0" width="250" />
13
  </a></p>
frontend/abstract-class-tracking.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  /**
4
  * The basic frontend tracking class for the GA plugin, extendable for the children
@@ -18,8 +22,7 @@ abstract class Yoast_GA_Tracking {
18
  public $options;
19
 
20
  /**
21
- * Should the tracking code be added
22
- * @var bool
23
  */
24
  protected $do_tracking = null;
25
 
@@ -35,8 +38,8 @@ abstract class Yoast_GA_Tracking {
35
  /**
36
  * Output tracking link
37
  *
38
- * @param $label
39
- * @param $matches
40
  *
41
  * @return mixed
42
  */
@@ -86,7 +89,7 @@ abstract class Yoast_GA_Tracking {
86
  /**
87
  * Parse article link
88
  *
89
- * @param $matches
90
  *
91
  * @return mixed
92
  */
@@ -97,7 +100,7 @@ abstract class Yoast_GA_Tracking {
97
  /**
98
  * Parse comment link
99
  *
100
- * @param $matches
101
  *
102
  * @return mixed
103
  */
@@ -108,7 +111,7 @@ abstract class Yoast_GA_Tracking {
108
  /**
109
  * Parse widget link
110
  *
111
- * @param $matches
112
  *
113
  * @return mixed
114
  */
@@ -119,7 +122,7 @@ abstract class Yoast_GA_Tracking {
119
  /**
120
  * Parse menu link
121
  *
122
- * @param $matches
123
  *
124
  * @return mixed
125
  */
@@ -130,7 +133,7 @@ abstract class Yoast_GA_Tracking {
130
  /**
131
  * Parse the_content or the_excerpt for links
132
  *
133
- * @param $text
134
  *
135
  * @return mixed
136
  */
@@ -149,7 +152,7 @@ abstract class Yoast_GA_Tracking {
149
  /**
150
  * Parse the widget content for links
151
  *
152
- * @param $text
153
  *
154
  * @return mixed
155
  */
@@ -165,7 +168,7 @@ abstract class Yoast_GA_Tracking {
165
  /**
166
  * Parse the nav menu for links
167
  *
168
- * @param $text
169
  *
170
  * @return mixed
171
  */
@@ -184,7 +187,7 @@ abstract class Yoast_GA_Tracking {
184
  /**
185
  * Parse comment text for links
186
  *
187
- * @param $text
188
  *
189
  * @return mixed
190
  */
@@ -203,7 +206,7 @@ abstract class Yoast_GA_Tracking {
203
  /**
204
  * Parse the domain
205
  *
206
- * @param $uri
207
  *
208
  * @return array|bool
209
  */
@@ -217,7 +220,8 @@ abstract class Yoast_GA_Tracking {
217
  $host = $matches[2];
218
  if ( preg_match( '/.*\..*\..*\..*$/', $host ) ) {
219
  preg_match( $domainPatternUK, $host, $matches );
220
- } else {
 
221
  preg_match( $domainPatternUS, $host, $matches );
222
  }
223
 
@@ -246,10 +250,12 @@ abstract class Yoast_GA_Tracking {
246
  $link_attribute = str_replace( "onclick='" . $matches[1] . "'", $js_snippet_single, $link_attribute );
247
 
248
  return $link_attribute;
249
- } else {
 
250
  if ( ! is_null( $onclick ) ) {
251
  return 'onclick="' . $onclick . '" ' . $link_attribute;
252
- } else {
 
253
  return $link_attribute;
254
  }
255
  }
@@ -307,6 +313,16 @@ abstract class Yoast_GA_Tracking {
307
  $this->do_tracking = false;
308
  }
309
  }
 
 
 
 
 
 
 
 
 
 
310
  }
311
 
312
  return $this->do_tracking;
@@ -363,12 +379,15 @@ abstract class Yoast_GA_Tracking {
363
  $type = null;
364
  if ( $protocol !== 'http' && $protocol !== 'https' && $protocol !== 'mailto' ) {
365
  $type = null;
366
- } else {
 
367
  if ( ( $protocol == 'mailto' ) ) {
368
  $type = 'email';
369
- } elseif ( in_array( $extension, $download_extensions ) ) {
 
370
  $type = 'download';
371
- } else {
 
372
  $type = $this->parse_outbound_type( $domain, $origin, $original_url );
373
  }
374
  }
@@ -403,7 +422,8 @@ abstract class Yoast_GA_Tracking {
403
  if ( ! isset( $type ) ) {
404
  $type = 'internal';
405
  }
406
- } elseif ( $domain['domain'] != $origin['domain'] ) {
 
407
  $type = 'outbound';
408
  }
409
 
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Frontend
5
+ */
6
 
7
  /**
8
  * The basic frontend tracking class for the GA plugin, extendable for the children
22
  public $options;
23
 
24
  /**
25
+ * @var boolean $do_tracking Should the tracking code be added
 
26
  */
27
  protected $do_tracking = null;
28
 
38
  /**
39
  * Output tracking link
40
  *
41
+ * @param string $label
42
+ * @param array $matches
43
  *
44
  * @return mixed
45
  */
89
  /**
90
  * Parse article link
91
  *
92
+ * @param array $matches
93
  *
94
  * @return mixed
95
  */
100
  /**
101
  * Parse comment link
102
  *
103
+ * @param array $matches
104
  *
105
  * @return mixed
106
  */
111
  /**
112
  * Parse widget link
113
  *
114
+ * @param array $matches
115
  *
116
  * @return mixed
117
  */
122
  /**
123
  * Parse menu link
124
  *
125
+ * @param array $matches
126
  *
127
  * @return mixed
128
  */
133
  /**
134
  * Parse the_content or the_excerpt for links
135
  *
136
+ * @param string $text
137
  *
138
  * @return mixed
139
  */
152
  /**
153
  * Parse the widget content for links
154
  *
155
+ * @param string $text
156
  *
157
  * @return mixed
158
  */
168
  /**
169
  * Parse the nav menu for links
170
  *
171
+ * @param string $text
172
  *
173
  * @return mixed
174
  */
187
  /**
188
  * Parse comment text for links
189
  *
190
+ * @param string $text
191
  *
192
  * @return mixed
193
  */
206
  /**
207
  * Parse the domain
208
  *
209
+ * @param string $uri
210
  *
211
  * @return array|bool
212
  */
220
  $host = $matches[2];
221
  if ( preg_match( '/.*\..*\..*\..*$/', $host ) ) {
222
  preg_match( $domainPatternUK, $host, $matches );
223
+ }
224
+ else {
225
  preg_match( $domainPatternUS, $host, $matches );
226
  }
227
 
250
  $link_attribute = str_replace( "onclick='" . $matches[1] . "'", $js_snippet_single, $link_attribute );
251
 
252
  return $link_attribute;
253
+ }
254
+ else {
255
  if ( ! is_null( $onclick ) ) {
256
  return 'onclick="' . $onclick . '" ' . $link_attribute;
257
+ }
258
+ else {
259
  return $link_attribute;
260
  }
261
  }
313
  $this->do_tracking = false;
314
  }
315
  }
316
+
317
+ /**
318
+ * Filter: 'yst_ga_track_super_admin' - Allows filtering if the Super admin should be tracked in a multi-site setup
319
+ *
320
+ * @api array $all_roles
321
+ */
322
+ $track_super_admin = apply_filters( 'yst_ga_track_super_admin', true );
323
+ if ( $track_super_admin === false && is_super_admin() ) {
324
+ $this->do_tracking = false;
325
+ }
326
  }
327
 
328
  return $this->do_tracking;
379
  $type = null;
380
  if ( $protocol !== 'http' && $protocol !== 'https' && $protocol !== 'mailto' ) {
381
  $type = null;
382
+ }
383
+ else {
384
  if ( ( $protocol == 'mailto' ) ) {
385
  $type = 'email';
386
+ }
387
+ elseif ( in_array( $extension, $download_extensions ) ) {
388
  $type = 'download';
389
+ }
390
+ else {
391
  $type = $this->parse_outbound_type( $domain, $origin, $original_url );
392
  }
393
  }
422
  if ( ! isset( $type ) ) {
423
  $type = 'internal';
424
  }
425
+ }
426
+ elseif ( $domain['domain'] != $origin['domain'] ) {
427
  $type = 'outbound';
428
  }
429
 
frontend/class-frontend.php CHANGED
@@ -1,10 +1,15 @@
1
  <?php
 
 
 
 
2
 
3
  /**
4
  * The basic frontend class for the GA plugin, extendable for the children
5
  */
6
  class Yoast_GA_Frontend {
7
 
 
8
  protected $options;
9
 
10
  /**
@@ -21,7 +26,8 @@ class Yoast_GA_Frontend {
21
  // Check if the customer is running Universal or not (Enable in GA Settings -> Universal)
22
  if ( isset( $this->options['enable_universal'] ) && $this->options['enable_universal'] == 1 ) {
23
  new Yoast_GA_Universal;
24
- } else {
 
25
  new Yoast_GA_JS;
26
  }
27
 
@@ -39,7 +45,8 @@ class Yoast_GA_Frontend {
39
  if ( is_feed() ) {
40
  if ( $this->options['allow_anchor'] ) {
41
  $delimiter = '#';
42
- } else {
 
43
  $delimiter = '?';
44
  if ( strpos( $guid, $delimiter ) > 0 ) {
45
  $delimiter = '&amp;';
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Frontend
5
+ */
6
 
7
  /**
8
  * The basic frontend class for the GA plugin, extendable for the children
9
  */
10
  class Yoast_GA_Frontend {
11
 
12
+ /** @var array $options */
13
  protected $options;
14
 
15
  /**
26
  // Check if the customer is running Universal or not (Enable in GA Settings -> Universal)
27
  if ( isset( $this->options['enable_universal'] ) && $this->options['enable_universal'] == 1 ) {
28
  new Yoast_GA_Universal;
29
+ }
30
+ else {
31
  new Yoast_GA_JS;
32
  }
33
 
45
  if ( is_feed() ) {
46
  if ( $this->options['allow_anchor'] ) {
47
  $delimiter = '#';
48
+ }
49
+ else {
50
  $delimiter = '?';
51
  if ( strpos( $guid, $delimiter ) > 0 ) {
52
  $delimiter = '&amp;';
frontend/class-ga-js.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  /**
4
  * The frontend JS class
@@ -10,7 +14,7 @@ class Yoast_GA_JS extends Yoast_GA_Tracking {
10
  *
11
  * @param bool $return_array
12
  *
13
- * @return array
14
  */
15
  public function tracking( $return_array = false ) {
16
  global $wp_query;
@@ -23,7 +27,8 @@ class Yoast_GA_JS extends Yoast_GA_Tracking {
23
 
24
  if ( isset( $this->options['subdomain_tracking'] ) && $this->options['subdomain_tracking'] != '' ) {
25
  $domain = $this->options['subdomain_tracking'];
26
- } else {
 
27
  $domain = null; // Default domain value
28
  }
29
 
@@ -33,7 +38,7 @@ class Yoast_GA_JS extends Yoast_GA_Tracking {
33
 
34
  $ua_code = $this->get_tracking_code();
35
  if ( is_null( $ua_code ) && $return_array == false ) {
36
- return;
37
  }
38
 
39
  $gaq_push[] = "'_setAccount', '" . $ua_code . "'";
@@ -74,23 +79,28 @@ class Yoast_GA_JS extends Yoast_GA_Tracking {
74
 
75
  if ( is_404() ) {
76
  $gaq_push[] = "'_trackPageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
77
- } else {
 
78
  if ( $wp_query->is_search ) {
79
  $pushstr = "'_trackPageview','/?s=";
80
  if ( $wp_query->found_posts == 0 ) {
81
  $gaq_push[] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
82
- } else {
 
83
  if ( $wp_query->found_posts == 1 ) {
84
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
85
- } else {
 
86
  if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
87
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
88
- } else {
 
89
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
90
  }
91
  }
92
  }
93
- } else {
 
94
  $gaq_push[] = "'_trackPageview'";
95
  }
96
  }
@@ -112,10 +122,12 @@ class Yoast_GA_JS extends Yoast_GA_Tracking {
112
  // Include the tracking view
113
  if ( $this->options['debug_mode'] == 1 ) {
114
  require( 'views/tracking-debug.php' );
115
- } else {
 
116
  require( 'views/tracking-ga-js.php' );
117
  }
118
- } else {
 
119
  require( 'views/tracking-usergroup.php' );
120
  }
121
  }
@@ -152,7 +164,8 @@ class Yoast_GA_JS extends Yoast_GA_Tracking {
152
  case 'download':
153
  if ( $this->options['track_download_as'] == 'pageview' ) {
154
  $onclick = "_gaq.push(['_trackPageview','download/" . esc_attr( $full_url ) . "']);";
155
- } else {
 
156
  $onclick = "_gaq.push(['_trackEvent','download','" . esc_attr( $full_url ) . "']);";
157
  }
158
 
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Frontend
5
+ */
6
 
7
  /**
8
  * The frontend JS class
14
  *
15
  * @param bool $return_array
16
  *
17
+ * @return null|array
18
  */
19
  public function tracking( $return_array = false ) {
20
  global $wp_query;
27
 
28
  if ( isset( $this->options['subdomain_tracking'] ) && $this->options['subdomain_tracking'] != '' ) {
29
  $domain = $this->options['subdomain_tracking'];
30
+ }
31
+ else {
32
  $domain = null; // Default domain value
33
  }
34
 
38
 
39
  $ua_code = $this->get_tracking_code();
40
  if ( is_null( $ua_code ) && $return_array == false ) {
41
+ return null;
42
  }
43
 
44
  $gaq_push[] = "'_setAccount', '" . $ua_code . "'";
79
 
80
  if ( is_404() ) {
81
  $gaq_push[] = "'_trackPageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
82
+ }
83
+ else {
84
  if ( $wp_query->is_search ) {
85
  $pushstr = "'_trackPageview','/?s=";
86
  if ( $wp_query->found_posts == 0 ) {
87
  $gaq_push[] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
88
+ }
89
+ else {
90
  if ( $wp_query->found_posts == 1 ) {
91
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
92
+ }
93
+ else {
94
  if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
95
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
96
+ }
97
+ else {
98
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
99
  }
100
  }
101
  }
102
+ }
103
+ else {
104
  $gaq_push[] = "'_trackPageview'";
105
  }
106
  }
122
  // Include the tracking view
123
  if ( $this->options['debug_mode'] == 1 ) {
124
  require( 'views/tracking-debug.php' );
125
+ }
126
+ else {
127
  require( 'views/tracking-ga-js.php' );
128
  }
129
+ }
130
+ else {
131
  require( 'views/tracking-usergroup.php' );
132
  }
133
  }
164
  case 'download':
165
  if ( $this->options['track_download_as'] == 'pageview' ) {
166
  $onclick = "_gaq.push(['_trackPageview','download/" . esc_attr( $full_url ) . "']);";
167
+ }
168
+ else {
169
  $onclick = "_gaq.push(['_trackEvent','download','" . esc_attr( $full_url ) . "']);";
170
  }
171
 
frontend/class-universal.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  /**
4
  * This is the frontend class for the GA Universal code
@@ -14,6 +18,10 @@ class Yoast_GA_Universal extends Yoast_GA_Tracking {
14
 
15
  /**
16
  * Function to output the GA Tracking code in the wp_head()
 
 
 
 
17
  */
18
  public function tracking( $return_array = false ) {
19
  global $wp_query;
@@ -26,7 +34,8 @@ class Yoast_GA_Universal extends Yoast_GA_Tracking {
26
 
27
  if ( isset( $this->options['subdomain_tracking'] ) && $this->options['subdomain_tracking'] != '' ) {
28
  $domain = $this->options['subdomain_tracking'];
29
- } else {
 
30
  $domain = 'auto'; // Default domain value
31
  }
32
 
@@ -36,20 +45,23 @@ class Yoast_GA_Universal extends Yoast_GA_Tracking {
36
 
37
  $ua_code = $this->get_tracking_code();
38
  if ( is_null( $ua_code ) && $return_array == false ) {
39
- return;
40
  }
41
 
42
  // Set tracking code here
43
  if ( ! empty( $ua_code ) ) {
44
  if ( $this->options['add_allow_linker'] && ! $this->options['allow_anchor'] ) {
45
  $gaq_push[] = "'create', '" . $ua_code . "', '" . $domain . "', {'allowLinker': true}";
46
- } else {
 
47
  if ( $this->options['allow_anchor'] && ! $this->options['add_allow_linker'] ) {
48
  $gaq_push[] = "'create', '" . $ua_code . "', '" . $domain . "', {'allowAnchor': true}";
49
- } else {
 
50
  if ( $this->options['allow_anchor'] && $this->options['add_allow_linker'] ) {
51
  $gaq_push[] = "'create', '" . $ua_code . "', '" . $domain . "', {'allowAnchor': true, 'allowLinker': true}";
52
- } else {
 
53
  $gaq_push[] = "'create', '" . $ua_code . "', '" . $domain . "'";
54
  }
55
  }
@@ -83,23 +95,28 @@ class Yoast_GA_Universal extends Yoast_GA_Tracking {
83
 
84
  if ( is_404() ) {
85
  $gaq_push[] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
86
- } else {
 
87
  if ( $wp_query->is_search ) {
88
  $pushstr = "'send','pageview','/?s=";
89
  if ( $wp_query->found_posts == 0 ) {
90
  $gaq_push[] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
91
- } else {
 
92
  if ( $wp_query->found_posts == 1 ) {
93
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
94
- } else {
 
95
  if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
96
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
97
- } else {
 
98
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
99
  }
100
  }
101
  }
102
- } else {
 
103
  $gaq_push[] = "'send','pageview'";
104
  }
105
  }
@@ -120,10 +137,12 @@ class Yoast_GA_Universal extends Yoast_GA_Tracking {
120
  // Include the tracking view
121
  if ( $this->options['debug_mode'] == 1 ) {
122
  require( 'views/tracking-debug.php' );
123
- } else {
 
124
  require( 'views/tracking-universal.php' );
125
  }
126
- } else {
 
127
  require( 'views/tracking-usergroup.php' );
128
  }
129
  }
@@ -151,7 +170,8 @@ class Yoast_GA_Universal extends Yoast_GA_Tracking {
151
  case 'download':
152
  if ( $this->options['track_download_as'] == 'pageview' ) {
153
  $onclick = "__gaTracker('send', 'pageview', '" . esc_attr( $full_url ) . "');";
154
- } else {
 
155
  $onclick = "__gaTracker('send', 'event', 'download', '" . esc_attr( $full_url ) . "');";
156
  }
157
 
@@ -176,7 +196,7 @@ class Yoast_GA_Universal extends Yoast_GA_Tracking {
176
 
177
  $link['link_attributes'] = $this->output_add_onclick( $link['link_attributes'], $onclick );
178
 
179
- if( !empty( $link['link_attributes'] ) ) {
180
  return '<a href="' . $full_url . '" ' . trim( $link['link_attributes'] ) . '>' . $link['link_text'] . '</a>';
181
  }
182
 
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Frontend
5
+ */
6
 
7
  /**
8
  * This is the frontend class for the GA Universal code
18
 
19
  /**
20
  * Function to output the GA Tracking code in the wp_head()
21
+ *
22
+ * @param boolean $return_array
23
+ *
24
+ * @return null|array
25
  */
26
  public function tracking( $return_array = false ) {
27
  global $wp_query;
34
 
35
  if ( isset( $this->options['subdomain_tracking'] ) && $this->options['subdomain_tracking'] != '' ) {
36
  $domain = $this->options['subdomain_tracking'];
37
+ }
38
+ else {
39
  $domain = 'auto'; // Default domain value
40
  }
41
 
45
 
46
  $ua_code = $this->get_tracking_code();
47
  if ( is_null( $ua_code ) && $return_array == false ) {
48
+ return null;
49
  }
50
 
51
  // Set tracking code here
52
  if ( ! empty( $ua_code ) ) {
53
  if ( $this->options['add_allow_linker'] && ! $this->options['allow_anchor'] ) {
54
  $gaq_push[] = "'create', '" . $ua_code . "', '" . $domain . "', {'allowLinker': true}";
55
+ }
56
+ else {
57
  if ( $this->options['allow_anchor'] && ! $this->options['add_allow_linker'] ) {
58
  $gaq_push[] = "'create', '" . $ua_code . "', '" . $domain . "', {'allowAnchor': true}";
59
+ }
60
+ else {
61
  if ( $this->options['allow_anchor'] && $this->options['add_allow_linker'] ) {
62
  $gaq_push[] = "'create', '" . $ua_code . "', '" . $domain . "', {'allowAnchor': true, 'allowLinker': true}";
63
+ }
64
+ else {
65
  $gaq_push[] = "'create', '" . $ua_code . "', '" . $domain . "'";
66
  }
67
  }
95
 
96
  if ( is_404() ) {
97
  $gaq_push[] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
98
+ }
99
+ else {
100
  if ( $wp_query->is_search ) {
101
  $pushstr = "'send','pageview','/?s=";
102
  if ( $wp_query->found_posts == 0 ) {
103
  $gaq_push[] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
104
+ }
105
+ else {
106
  if ( $wp_query->found_posts == 1 ) {
107
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
108
+ }
109
+ else {
110
  if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
111
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
112
+ }
113
+ else {
114
  $gaq_push[] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
115
  }
116
  }
117
  }
118
+ }
119
+ else {
120
  $gaq_push[] = "'send','pageview'";
121
  }
122
  }
137
  // Include the tracking view
138
  if ( $this->options['debug_mode'] == 1 ) {
139
  require( 'views/tracking-debug.php' );
140
+ }
141
+ else {
142
  require( 'views/tracking-universal.php' );
143
  }
144
+ }
145
+ else {
146
  require( 'views/tracking-usergroup.php' );
147
  }
148
  }
170
  case 'download':
171
  if ( $this->options['track_download_as'] == 'pageview' ) {
172
  $onclick = "__gaTracker('send', 'pageview', '" . esc_attr( $full_url ) . "');";
173
+ }
174
+ else {
175
  $onclick = "__gaTracker('send', 'event', 'download', '" . esc_attr( $full_url ) . "');";
176
  }
177
 
196
 
197
  $link['link_attributes'] = $this->output_add_onclick( $link['link_attributes'], $onclick );
198
 
199
+ if ( ! empty( $link['link_attributes'] ) ) {
200
  return '<a href="' . $full_url . '" ' . trim( $link['link_attributes'] ) . '>' . $link['link_text'] . '</a>';
201
  }
202
 
frontend/views/tracking-debug.php CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  <!-- This site uses the Google Analytics by Yoast plugin v<?php echo GAWP_VERSION; ?> - https://yoast.com/wordpress/plugins/google-analytics/ -->
2
  <!-- @Webmaster, normally you will find the Google Analytics tracking code here, but you have enabled the Debug Mode. Change that in Analytics -> (Tab) Debug mode and disable Debug Mode to enable the tracking of your site. -->
3
  <!-- / Google Analytics by Yoast -->
1
+ <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Frontend
5
+ */
6
+
7
+ ?>
8
  <!-- This site uses the Google Analytics by Yoast plugin v<?php echo GAWP_VERSION; ?> - https://yoast.com/wordpress/plugins/google-analytics/ -->
9
  <!-- @Webmaster, normally you will find the Google Analytics tracking code here, but you have enabled the Debug Mode. Change that in Analytics -> (Tab) Debug mode and disable Debug Mode to enable the tracking of your site. -->
10
  <!-- / Google Analytics by Yoast -->
frontend/views/tracking-ga-js.php CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  <!-- This site uses the Google Analytics by Yoast plugin v<?php echo GAWP_VERSION; ?> - Universal disabled - https://yoast.com/wordpress/plugins/google-analytics/ -->
2
  <script type="text/javascript">
3
 
1
+ <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Frontend
5
+ */
6
+
7
+ ?>
8
  <!-- This site uses the Google Analytics by Yoast plugin v<?php echo GAWP_VERSION; ?> - Universal disabled - https://yoast.com/wordpress/plugins/google-analytics/ -->
9
  <script type="text/javascript">
10
 
frontend/views/tracking-universal.php CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  <!-- This site uses the Google Analytics by Yoast plugin v<?php echo GAWP_VERSION; ?> - Universal enabled - https://yoast.com/wordpress/plugins/google-analytics/ -->
2
  <script type="text/javascript">
3
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -6,18 +13,18 @@
6
  })(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');
7
 
8
  <?php
9
- // List the GA elements from the class-ga-js.php
10
- if ( count( $gaq_push ) >= 1 ) {
11
- foreach ( $gaq_push as $item ) {
12
- if ( ! is_array( $item ) ) {
13
- echo ' __gaTracker('.$item.");\n";
14
- }
15
- elseif ( isset( $item['value'] ) ) {
16
- echo ' '.$item['value'] . "\n";
17
- }
18
  }
19
  }
20
- ?>
 
21
 
22
  </script>
23
  <!-- / Google Analytics by Yoast -->
1
+ <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Frontend
5
+ */
6
+
7
+ ?>
8
  <!-- This site uses the Google Analytics by Yoast plugin v<?php echo GAWP_VERSION; ?> - Universal enabled - https://yoast.com/wordpress/plugins/google-analytics/ -->
9
  <script type="text/javascript">
10
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
13
  })(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');
14
 
15
  <?php
16
+ // List the GA elements from the class-ga-js.php
17
+ if ( count( $gaq_push ) >= 1 ) {
18
+ foreach ( $gaq_push as $item ) {
19
+ if ( ! is_array( $item ) ) {
20
+ echo ' __gaTracker('.$item.");\n";
21
+ }
22
+ elseif ( isset( $item['value'] ) ) {
23
+ echo ' '.$item['value'] . "\n";
 
24
  }
25
  }
26
+ }
27
+ ?>
28
 
29
  </script>
30
  <!-- / Google Analytics by Yoast -->
frontend/views/tracking-usergroup.php CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  <!-- This site uses the Google Analytics by Yoast plugin v<?php echo GAWP_VERSION; ?> - https://yoast.com/wordpress/plugins/google-analytics/ -->
2
  <!-- @Webmaster, normally you will find the Google Analytics tracking code here, but you are in the disabled user groups. Change that in Analytics -> Settings (Ignore usergroups) -->
3
  <!-- / Google Analytics by Yoast -->
1
+ <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Frontend
5
+ */
6
+
7
+ ?>
8
  <!-- This site uses the Google Analytics by Yoast plugin v<?php echo GAWP_VERSION; ?> - https://yoast.com/wordpress/plugins/google-analytics/ -->
9
  <!-- @Webmaster, normally you will find the Google Analytics tracking code here, but you are in the disabled user groups. Change that in Analytics -> Settings (Ignore usergroups) -->
10
  <!-- / Google Analytics by Yoast -->
googleanalytics.php CHANGED
@@ -1,36 +1,41 @@
1
  <?php
2
- /*
3
- Plugin Name: Google Analytics by Yoast
4
- Plugin URI: https://yoast.com/wordpress/plugins/google-analytics/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wpgaplugin&utm_content=v504
5
- Description: This plugin makes it simple to add Google Analytics to your WordPress site, adding lots of features, e.g. error page, search result and automatic outgoing links and download tracking.
6
- Author: Team Yoast
7
- Version: 5.3.2
8
- Requires at least: 3.8
9
- Author URI: https://yoast.com/
10
- License: GPL v3
11
- Text Domain: google-analytics-for-wordpress
12
- Domain Path: /languages
13
-
14
- Google Analytics for WordPress
15
- Copyright (C) 2008-2015, Team Yoast, support@yoast.com
16
-
17
- This program is free software: you can redistribute it and/or modify
18
- it under the terms of the GNU General Public License as published by
19
- the Free Software Foundation, either version 3 of the License, or
20
- (at your option) any later version.
21
-
22
- This program is distributed in the hope that it will be useful,
23
- but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- GNU General Public License for more details.
26
-
27
- You should have received a copy of the GNU General Public License
28
- along with this program. If not, see <http://www.gnu.org/licenses/>.
29
- */
 
 
 
 
 
30
 
31
  // This plugin was originally based on Rich Boakes' Analytics plugin: http://boakes.org/analytics, but has since been rewritten and refactored multiple times.
32
 
33
- define( 'GAWP_VERSION', '5.3.2' );
34
 
35
  define( 'GAWP_FILE', __FILE__ );
36
 
@@ -47,9 +52,61 @@ if ( is_admin() ) {
47
  global $yoast_ga_admin;
48
  $yoast_ga_admin = new Yoast_GA_Admin;
49
 
50
- } else {
 
51
  global $yoast_ga_frontend;
52
  $yoast_ga_frontend = new Yoast_GA_Frontend;
53
  }
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  register_deactivation_hook( __FILE__, array( 'Yoast_GA_Admin', 'ga_deactivation_hook' ) );
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Main
5
+ */
6
+
7
+ /**
8
+ * Plugin Name: Google Analytics by Yoast
9
+ * Plugin URI: https://yoast.com/wordpress/plugins/google-analytics/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wpgaplugin&utm_content=v504
10
+ * Description: This plugin makes it simple to add Google Analytics to your WordPress site, adding lots of features, e.g. error page, search result and automatic outgoing links and download tracking.
11
+ * Author: Team Yoast
12
+ * Version: 5.3.3
13
+ * Requires at least: 3.8
14
+ * Author URI: https://yoast.com/
15
+ * License: GPL v3
16
+ * Text Domain: google-analytics-for-wordpress
17
+ * Domain Path: /languages
18
+ *
19
+ * Google Analytics for WordPress
20
+ * Copyright (C) 2008-2015, Team Yoast, support@yoast.com
21
+ *
22
+ * This program is free software: you can redistribute it and/or modify
23
+ * it under the terms of the GNU General Public License as published by
24
+ * the Free Software Foundation, either version 3 of the License, or
25
+ * (at your option) any later version.
26
+ *
27
+ * This program is distributed in the hope that it will be useful,
28
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ * GNU General Public License for more details.
31
+ *
32
+ * You should have received a copy of the GNU General Public License
33
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
34
+ */
35
 
36
  // This plugin was originally based on Rich Boakes' Analytics plugin: http://boakes.org/analytics, but has since been rewritten and refactored multiple times.
37
 
38
+ define( 'GAWP_VERSION', '5.3.3' );
39
 
40
  define( 'GAWP_FILE', __FILE__ );
41
 
52
  global $yoast_ga_admin;
53
  $yoast_ga_admin = new Yoast_GA_Admin;
54
 
55
+ }
56
+ else {
57
  global $yoast_ga_frontend;
58
  $yoast_ga_frontend = new Yoast_GA_Frontend;
59
  }
60
 
61
+ /* ***************************** BOOTSTRAP / HOOK INTO WP *************************** */
62
+ $spl_autoload_exists = function_exists( 'spl_autoload_register' );
63
+ $filter_input_exists = function_exists( 'filter_input' );
64
+ if ( ! $spl_autoload_exists ) {
65
+ add_action( 'admin_init', 'yoast_wpseo_self_deactivate_spl', 1 );
66
+ }
67
+ if ( ! $filter_input_exists ) {
68
+ add_action( 'admin_init', 'yoast_wpseo_self_deactivate_filter_input', 1 );
69
+ }
70
+
71
+ /**
72
+ * Throw an error if the PHP SPL extension is disabled (prevent white screens) and self-deactivate plugin
73
+ *
74
+ * @since 5.3.3
75
+ */
76
+ function yoast_ga_self_deactivate_spl() {
77
+ if ( is_admin() ) {
78
+ yoast_ga_extenstion_notice(
79
+ esc_html__( 'The Standard PHP Library (SPL) extension seem to be unavailable. Please ask your web host to enable it.', 'google-analytics-for-wordpress' )
80
+ );
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Throw an error if the filter extension is disabled (prevent white screens) and self-deactivate plugin
86
+ *
87
+ * @since 5.3.3
88
+ */
89
+ function yoast_ga_self_deactivate_filter_input() {
90
+ if ( is_admin() ) {
91
+ yoast_ga_extenstion_notice(
92
+ esc_html__( 'The (standard) PHP filter extension seem to be unavailable. Please ask your web host to enable it.', 'google-analytics-for-wordpress' )
93
+ );
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Show a notice in the admin
99
+ *
100
+ * @param string $message
101
+ *
102
+ * @since 5.3.3
103
+ */
104
+ function yoast_ga_extenstion_notice( $message ) {
105
+ add_action( 'admin_notices', create_function( $message, 'echo \'<div class="error"><p>\' . __( \'Activation failed:\', \'google-analytics-for-wordpress\' ) . \' \' . $message . \'</p></div>\';' ) );
106
+ deactivate_plugins( plugin_basename( GAWP_FILE ) );
107
+ if ( isset( $_GET['activate'] ) ) {
108
+ unset( $_GET['activate'] );
109
+ }
110
+ }
111
+
112
  register_deactivation_hook( __FILE__, array( 'Yoast_GA_Admin', 'ga_deactivation_hook' ) );
includes/class-options.php CHANGED
@@ -1,7 +1,15 @@
1
  <?php
2
-
 
 
 
 
 
 
 
3
  class Yoast_GA_Options {
4
 
 
5
  public $options;
6
 
7
  /**
@@ -89,8 +97,8 @@ class Yoast_GA_Options {
89
  * @return bool
90
  */
91
  public function update_option( $val ) {
92
- $options = get_option( $this->option_name );
93
- $options[$this->option_prefix] = $val;
94
 
95
  return update_option( $this->option_name, $options );
96
  }
@@ -103,14 +111,14 @@ class Yoast_GA_Options {
103
  public function get_options() {
104
  $options = get_option( $this->option_name );
105
 
106
- return $options[$this->option_prefix];
107
  }
108
 
109
  /**
110
  * Check if all the options are set, to prevent a notice if debugging is enabled
111
  * When we have new changes, the settings are saved to the options class
112
  *
113
- * @param $options
114
  *
115
  * @return mixed
116
  */
@@ -118,8 +126,8 @@ class Yoast_GA_Options {
118
 
119
  $changes = 0;
120
  foreach ( $this->default_ga_values() as $key => $value ) {
121
- if ( ! isset( $options[$key] ) ) {
122
- $options[$key] = $value;
123
  $changes ++;
124
  }
125
  }
@@ -142,7 +150,8 @@ class Yoast_GA_Options {
142
 
143
  if ( ! empty( $this->options['analytics_profile'] ) && ! empty( $this->options['analytics_profile_code'] ) ) {
144
  $tracking_code = $this->options['analytics_profile_code'];
145
- } elseif ( ! empty( $this->options['analytics_profile'] ) && empty( $this->options['analytics_profile_code'] ) ) {
 
146
  // Analytics profile is still holding the UA code
147
  $tracking_code = $this->options['analytics_profile'];
148
  }
@@ -157,14 +166,14 @@ class Yoast_GA_Options {
157
  /**
158
  * Convert a option value to a bool
159
  *
160
- * @param $option_name
161
  *
162
  * @return bool
163
  */
164
  public function option_value_to_bool( $option_name ) {
165
  $this->options = $this->get_options();
166
 
167
- if ( isset( $this->options[$option_name] ) && $this->options[$option_name] == 1 ) {
168
  return true;
169
  }
170
 
@@ -220,9 +229,9 @@ class Yoast_GA_Options {
220
  // Fallback to make sure every default option has a value
221
  $defaults = $this->default_ga_values();
222
  if ( is_array( $defaults ) ) {
223
- foreach ( $defaults[$this->option_prefix] as $key => $value ) {
224
- if ( ! isset( $this->options[$key] ) ) {
225
- $this->options[$key] = $value;
226
  }
227
  }
228
  }
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Includes
5
+ */
6
+
7
+ /**
8
+ * Options class.
9
+ */
10
  class Yoast_GA_Options {
11
 
12
+ /** @var array */
13
  public $options;
14
 
15
  /**
97
  * @return bool
98
  */
99
  public function update_option( $val ) {
100
+ $options = get_option( $this->option_name );
101
+ $options[ $this->option_prefix ] = $val;
102
 
103
  return update_option( $this->option_name, $options );
104
  }
111
  public function get_options() {
112
  $options = get_option( $this->option_name );
113
 
114
+ return $options[ $this->option_prefix ];
115
  }
116
 
117
  /**
118
  * Check if all the options are set, to prevent a notice if debugging is enabled
119
  * When we have new changes, the settings are saved to the options class
120
  *
121
+ * @param array $options
122
  *
123
  * @return mixed
124
  */
126
 
127
  $changes = 0;
128
  foreach ( $this->default_ga_values() as $key => $value ) {
129
+ if ( ! isset( $options[ $key ] ) ) {
130
+ $options[ $key ] = $value;
131
  $changes ++;
132
  }
133
  }
150
 
151
  if ( ! empty( $this->options['analytics_profile'] ) && ! empty( $this->options['analytics_profile_code'] ) ) {
152
  $tracking_code = $this->options['analytics_profile_code'];
153
+ }
154
+ elseif ( ! empty( $this->options['analytics_profile'] ) && empty( $this->options['analytics_profile_code'] ) ) {
155
  // Analytics profile is still holding the UA code
156
  $tracking_code = $this->options['analytics_profile'];
157
  }
166
  /**
167
  * Convert a option value to a bool
168
  *
169
+ * @param string $option_name
170
  *
171
  * @return bool
172
  */
173
  public function option_value_to_bool( $option_name ) {
174
  $this->options = $this->get_options();
175
 
176
+ if ( isset( $this->options[ $option_name ] ) && $this->options[ $option_name ] == 1 ) {
177
  return true;
178
  }
179
 
229
  // Fallback to make sure every default option has a value
230
  $defaults = $this->default_ga_values();
231
  if ( is_array( $defaults ) ) {
232
+ foreach ( $defaults[ $this->option_prefix ] as $key => $value ) {
233
+ if ( ! isset( $this->options[ $key ] ) ) {
234
+ $this->options[ $key ] = $value;
235
  }
236
  }
237
  }
includes/class-settings.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
2
-
 
 
 
 
 
 
 
3
  class Yoast_GA_Settings {
4
 
5
  /**
@@ -17,9 +24,7 @@ class Yoast_GA_Settings {
17
  private $options_class;
18
 
19
  /**
20
- * The main GA options
21
- *
22
- * @var
23
  */
24
  private $options;
25
 
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Includes
5
+ */
6
+
7
+ /**
8
+ * Settings class.
9
+ */
10
  class Yoast_GA_Settings {
11
 
12
  /**
24
  private $options_class;
25
 
26
  /**
27
+ * @var array $options The main GA options
 
 
28
  */
29
  private $options;
30
 
includes/class-utils.php CHANGED
@@ -1,5 +1,12 @@
1
  <?php
 
 
 
 
2
 
 
 
 
3
  class Yoast_GA_Utils {
4
 
5
  /**
@@ -10,7 +17,7 @@ class Yoast_GA_Utils {
10
  public static function wp_seo_active() {
11
  $wp_seo_active = false;
12
 
13
- //Makes sure is_plugin_active is available when called from front end
14
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
15
  if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) {
16
  $wp_seo_active = true;
@@ -22,14 +29,14 @@ class Yoast_GA_Utils {
22
  /**
23
  * Calculate the date difference, return the amount of hours between the two dates
24
  *
25
- * @param $last_run datetime
26
- * @param $now datetime
27
  *
28
  * @return int
29
  */
30
  public static function hours_between( $last_run, $now ) {
31
  $seconds = max( ( $now - $last_run ), 1 );
32
- $hours = $seconds / 3600;
33
 
34
  return floor( $hours );
35
  }
1
  <?php
2
+ /**
3
+ * @package GoogleAnalytics
4
+ * @subpackage Includes
5
+ */
6
 
7
+ /**
8
+ * Utilities class.
9
+ */
10
  class Yoast_GA_Utils {
11
 
12
  /**
17
  public static function wp_seo_active() {
18
  $wp_seo_active = false;
19
 
20
+ // Makes sure is_plugin_active is available when called from front end
21
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
22
  if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) {
23
  $wp_seo_active = true;
29
  /**
30
  * Calculate the date difference, return the amount of hours between the two dates
31
  *
32
+ * @param integer $last_run datetime
33
+ * @param integer $now datetime
34
  *
35
  * @return int
36
  */
37
  public static function hours_between( $last_run, $now ) {
38
  $seconds = max( ( $now - $last_run ), 1 );
39
+ $hours = ( $seconds / 3600 );
40
 
41
  return floor( $hours );
42
  }
phpcs.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <ruleset name="WordPress SEO">
3
+ <description>Google Analytics by Yoast rules for PHP_CodeSniffer</description>
4
+
5
+ <file>.</file>
6
+
7
+ <exclude-pattern>tests/*</exclude-pattern>
8
+ <exclude-pattern>vendor/*</exclude-pattern>
9
+
10
+ <arg name="extensions" value="php"/>
11
+ <arg value="nsp"/>
12
+
13
+ <rule ref="Yoast"/>
14
+ </ruleset>
readme.txt CHANGED
@@ -3,8 +3,9 @@ Contributors: joostdevalk
3
  Donate link: https://yoast.com/donate/
4
  Tags: analytics, google analytics, statistics, tracking, stats, google, yoast
5
  Requires at least: 3.8
6
- Tested up to: 4.1
7
- Stable tag: 5.3.2
 
8
 
9
  Track your WordPress site easily with the latest tracking codes and lots added data for search result pages and error pages.
10
 
@@ -12,13 +13,14 @@ Track your WordPress site easily with the latest tracking codes and lots added d
12
 
13
  The Google Analytics by Yoast plugin for WordPress allows you to track your blog easily and always stays up to date with the newest features in Google Analytics.
14
 
15
- > <strong>Development on GitHub</strong><br>
16
- > The development of Google Analytics by Yoast [takes place on GitHub](https://github.com/Yoast/google-analytics-for-wordpress). Bugs and pull requests are welcomed there. For support, you have two options: either [buy the premium version of Google Analytics by Yoast on Yoast.com](https://yoast.com/wordpress/plugins/google-analytics/), this will give you access to our support team, or refer to the forums.
17
 
18
  Full list of features:
19
 
20
  * Simple installation through integration with Google Analytics API: authenticate, select the site you want to track and you're done.
21
  * This plugin uses the universal or the asynchronous Google Analytics tracking code, the fastest and most reliable tracking code Google Analytics offers.
 
22
  * Option to enable demographics and interest reports.
23
  * Outbound link & downloads tracking.
24
  * Configurable options to track outbound links either as pageviews or as events.
@@ -29,8 +31,8 @@ Full list of features:
29
  * Tracking of your search result pages and 404 pages.
30
  * Full [debug mode](http://yoast.com/google-analytics-debug-mode/), including Firebug lite and ga_debug.js for debugging Google Analytics issues.
31
 
32
- > <strong>Coming soon: dashboards!</strong><br>
33
- > We're working hard on the next iteration of the plugin which will contain a Dashboard within your WordPress admin with the most important stats from Google Analytics.
34
 
35
  Other interesting stuff:
36
 
@@ -49,6 +51,21 @@ This section describes how to install the plugin and get it working.
49
 
50
  == Changelog ==
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  = 5.3.2 =
53
 
54
  Release Date: February 18th, 2015
@@ -633,13 +650,20 @@ Complete rewrite of the Google Analytics plugin.
633
  = 1.5 =
634
  * Added option to enable admin tracking, off by default.
635
 
 
 
 
 
 
636
  == Frequently Asked Questions ==
637
 
638
  For all frequently asked questions, and their answers, check the [Yoast Knowledge base](http://kb.yoast.com/category/43-google-analytics-for-wordpress).
639
 
640
  == Screenshots ==
641
 
642
- 1. Screenshot of the general settings panel for this plugin.
643
- 2. Screenshot of the universal settings panel.
644
- 3. Screenshot of the advanced settings panel.
645
- 4. Screenshot of the account selection drop down.
 
 
3
  Donate link: https://yoast.com/donate/
4
  Tags: analytics, google analytics, statistics, tracking, stats, google, yoast
5
  Requires at least: 3.8
6
+ Tested up to: 4.2
7
+ Stable tag: 5.3.3
8
+ License: GPL v3
9
 
10
  Track your WordPress site easily with the latest tracking codes and lots added data for search result pages and error pages.
11
 
13
 
14
  The Google Analytics by Yoast plugin for WordPress allows you to track your blog easily and always stays up to date with the newest features in Google Analytics.
15
 
16
+ > <strong>Upgrade to GA by Yoast Premium</strong><br>
17
+ > If you need support or want to use custom dimensions, upgrade to [Google Analytics by Yoast Premium](https://yoast.com/wordpress/plugins/google-analytics/#utm_source=wporg&utm_medium=readme&utm_campaign=wpgaplugin) today!
18
 
19
  Full list of features:
20
 
21
  * Simple installation through integration with Google Analytics API: authenticate, select the site you want to track and you're done.
22
  * This plugin uses the universal or the asynchronous Google Analytics tracking code, the fastest and most reliable tracking code Google Analytics offers.
23
+ * Gives you incredibly nice visitor metric dashboards right in your WordPress install.
24
  * Option to enable demographics and interest reports.
25
  * Outbound link & downloads tracking.
26
  * Configurable options to track outbound links either as pageviews or as events.
31
  * Tracking of your search result pages and 404 pages.
32
  * Full [debug mode](http://yoast.com/google-analytics-debug-mode/), including Firebug lite and ga_debug.js for debugging Google Analytics issues.
33
 
34
+ > <strong>Development on GitHub</strong><br>
35
+ > The development of Google Analytics by Yoast [takes place on GitHub](https://github.com/Yoast/google-analytics-for-wordpress). Bugs and pull requests are welcomed there. For support, you have two options: either [buy the premium version of Google Analytics by Yoast on Yoast.com](https://yoast.com/wordpress/plugins/google-analytics/), this will give you access to our support team, or refer to the forums.
36
 
37
  Other interesting stuff:
38
 
51
 
52
  == Changelog ==
53
 
54
+ = 5.3.3 =
55
+
56
+ Release Date: March 19th, 2015
57
+
58
+ * Several security fixes:
59
+ 1. Fix minor XSS issue where admins could XSS each other through an unescaped manual UA field.
60
+ 1. Fix stored XSS issue where changing a property's name in Google Analytics to contain malicious JS would allow execution of that JS in the admin as the profile name was not escaped properly.
61
+ 1. Fix un-authenticated change of the GA profile list, allowing the previous XSS to become a slightly bigger issue. Issues 2 and 3 combined lead to a [DREAD score](http://blog.sucuri.net/2015/03/understanding-wordpress-plugin-vulnerabilities.html) of 5.
62
+ * Other fixes:
63
+ * Small code style improvements.
64
+ * Throw an error and deactivate if either the PHP SPL or PHP filter libraries aren't loaded.
65
+ * Introduced a filter `yst_ga_track_super_admin` to allow disabling of super admin tracking on multi-site, defaulting to true.
66
+
67
+ Big thanks to [Jouko Pynnönen](http://klikki.fi) for responsibly disclosing security issues #2 and #3.
68
+
69
  = 5.3.2 =
70
 
71
  Release Date: February 18th, 2015
650
  = 1.5 =
651
  * Added option to enable admin tracking, off by default.
652
 
653
+ == Upgrade Notice ==
654
+
655
+ = 5.3.3 =
656
+ This version fixes several issues related to your site's security. Update immediately.
657
+
658
  == Frequently Asked Questions ==
659
 
660
  For all frequently asked questions, and their answers, check the [Yoast Knowledge base](http://kb.yoast.com/category/43-google-analytics-for-wordpress).
661
 
662
  == Screenshots ==
663
 
664
+ 1. Screenshot of the dashboards this plugin generates. To get dashboards for custom dimensions, upgrade to [GA by Yoast Premium](https://yoast.com/wordpress/plugins/google-analytics/#utm_source=wporg&utm_medium=readme&utm_campaign=wpgaplugin&utm_content=screenshot).
665
+ 2. Screenshot of the general settings panel for this plugin.
666
+ 3. Screenshot of the universal settings panel.
667
+ 4. Screenshot of the advanced settings panel.
668
+ 5. Screenshot of the account selection drop down.
669
+
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit0d7371c5917637133046e0ff54bddc2c::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit4bdc500f9ad408badfeb53112af5d59f::getLoader();
vendor/autoload_52.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
- return ComposerAutoloaderInitcb51162ef6e25f026ad6e42d5cb3b865::getLoader();
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
+ return ComposerAutoloaderInitc7697842af642d0524332c8e2aa408d0::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit0d7371c5917637133046e0ff54bddc2c
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit0d7371c5917637133046e0ff54bddc2c
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit0d7371c5917637133046e0ff54bddc2c', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit0d7371c5917637133046e0ff54bddc2c', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -44,7 +44,7 @@ class ComposerAutoloaderInit0d7371c5917637133046e0ff54bddc2c
44
  }
45
  }
46
 
47
- function composerRequire0d7371c5917637133046e0ff54bddc2c($file)
48
  {
49
  require $file;
50
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit4bdc500f9ad408badfeb53112af5d59f
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit4bdc500f9ad408badfeb53112af5d59f', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit4bdc500f9ad408badfeb53112af5d59f', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequire4bdc500f9ad408badfeb53112af5d59f($file)
48
  {
49
  require $file;
50
  }
vendor/composer/autoload_real_52.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
- class ComposerAutoloaderInitcb51162ef6e25f026ad6e42d5cb3b865 {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
@@ -19,9 +19,9 @@ class ComposerAutoloaderInitcb51162ef6e25f026ad6e42d5cb3b865 {
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitcb51162ef6e25f026ad6e42d5cb3b865', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitcb51162ef6e25f026ad6e42d5cb3b865', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
+ class ComposerAutoloaderInitc7697842af642d0524332c8e2aa408d0 {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInitc7697842af642d0524332c8e2aa408d0', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitc7697842af642d0524332c8e2aa408d0', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);