Version Description
- Added IP Anonymization Option.
- Added Google Optimization field.
- Updated GA code posting method.
Download this release
Release Info
Developer | ShareThis |
Plugin | Google Analytics |
Version | 2.1.5 |
Comparing to | |
See all releases |
Code changes from version 2.1.4 to 2.1.5
- class/Ga_Admin.php +28 -12
- class/controller/Ga_Frontend_Controller.php +9 -3
- googleanalytics.php +1 -1
- js/googleanalytics_page.js +1 -1
- readme.txt +7 -2
- view/ga_code.php +19 -13
- view/ga_googleanalytics_loader.php +4 -2
- view/page.php +53 -28
class/Ga_Admin.php
CHANGED
@@ -109,10 +109,10 @@ class Ga_Admin {
|
|
109 |
* Update hook fires when plugin is being loaded.
|
110 |
*/
|
111 |
public static function update_googleanalytics() {
|
|
|
|
|
|
|
112 |
|
113 |
-
$version = get_option( self::GA_VERSION_OPTION_NAME );
|
114 |
-
$installed_version = get_option( self::GA_VERSION_OPTION_NAME, '1.0.7' );
|
115 |
-
$old_property_value = Ga_Helper::get_option( 'web_property_id' );
|
116 |
if ( version_compare( $installed_version, GOOGLEANALYTICS_VERSION, 'eq' ) ) {
|
117 |
return;
|
118 |
}
|
@@ -122,7 +122,7 @@ class Ga_Admin {
|
|
122 |
|
123 |
if ( version_compare( $installed_version, GOOGLEANALYTICS_VERSION, 'lt' ) ) {
|
124 |
|
125 |
-
if ( !empty( $old_property_value ) ) {
|
126 |
Ga_Helper::update_option( self::GA_WEB_PROPERTY_ID_MANUALLY_VALUE_OPTION_NAME, $old_property_value );
|
127 |
Ga_Helper::update_option( self::GA_WEB_PROPERTY_ID_MANUALLY_OPTION_NAME, 1 );
|
128 |
delete_option( 'web_property_id' );
|
@@ -133,7 +133,7 @@ class Ga_Admin {
|
|
133 |
}
|
134 |
|
135 |
public static function preupdate_exclude_roles( $new_value, $old_value ) {
|
136 |
-
if ( !Ga_Helper::are_features_enabled() ) {
|
137 |
return '';
|
138 |
}
|
139 |
|
@@ -169,6 +169,18 @@ class Ga_Admin {
|
|
169 |
return $new_value;
|
170 |
}
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
/**
|
173 |
* Registers plugin's settings.
|
174 |
*/
|
@@ -180,8 +192,12 @@ class Ga_Admin {
|
|
180 |
register_setting( GA_NAME, self::GA_WEB_PROPERTY_ID_MANUALLY_OPTION_NAME );
|
181 |
register_setting( GA_NAME, self::GA_WEB_PROPERTY_ID_MANUALLY_VALUE_OPTION_NAME );
|
182 |
register_setting( GA_NAME, self::GA_DISABLE_ALL_FEATURES );
|
|
|
|
|
183 |
add_filter( 'pre_update_option_' . Ga_Admin::GA_EXCLUDE_ROLES_OPTION_NAME, 'Ga_Admin::preupdate_exclude_roles', 1, 2 );
|
184 |
add_filter( 'pre_update_option_' . Ga_Admin::GA_SELECTED_ACCOUNT, 'Ga_Admin::preupdate_selected_account', 1, 2 );
|
|
|
|
|
185 |
// add_filter( 'pre_update_option_' . Ga_Admin::GA_DISABLE_ALL_FEATURES, 'Ga_Admin::preupdate_disable_all_features', 1, 2 );
|
186 |
}
|
187 |
|
@@ -255,9 +271,9 @@ class Ga_Admin {
|
|
255 |
if ( !Ga_Helper::is_wp_version_valid() || !Ga_Helper::is_php_version_valid() ) {
|
256 |
return false;
|
257 |
}
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
/**
|
262 |
* Keeps data to be extracted as variables in the view.
|
263 |
*
|
@@ -329,10 +345,10 @@ class Ga_Admin {
|
|
329 |
*/
|
330 |
public static function get_accounts_selector() {
|
331 |
$selected = Ga_Helper::get_selected_account_data();
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
return Ga_View_Core::load( 'ga_accounts_selector', array(
|
337 |
'selector' => $selector,
|
338 |
'selected' => $selected ? implode( "_", $selected ) : null,
|
109 |
* Update hook fires when plugin is being loaded.
|
110 |
*/
|
111 |
public static function update_googleanalytics() {
|
112 |
+
$version = get_option( self::GA_VERSION_OPTION_NAME );
|
113 |
+
$installed_version = get_option( self::GA_VERSION_OPTION_NAME, '1.0.7' );
|
114 |
+
$old_property_value = Ga_Helper::get_option( 'web_property_id' );
|
115 |
|
|
|
|
|
|
|
116 |
if ( version_compare( $installed_version, GOOGLEANALYTICS_VERSION, 'eq' ) ) {
|
117 |
return;
|
118 |
}
|
122 |
|
123 |
if ( version_compare( $installed_version, GOOGLEANALYTICS_VERSION, 'lt' ) ) {
|
124 |
|
125 |
+
if ( ! empty( $old_property_value ) ) {
|
126 |
Ga_Helper::update_option( self::GA_WEB_PROPERTY_ID_MANUALLY_VALUE_OPTION_NAME, $old_property_value );
|
127 |
Ga_Helper::update_option( self::GA_WEB_PROPERTY_ID_MANUALLY_OPTION_NAME, 1 );
|
128 |
delete_option( 'web_property_id' );
|
133 |
}
|
134 |
|
135 |
public static function preupdate_exclude_roles( $new_value, $old_value ) {
|
136 |
+
if ( ! Ga_Helper::are_features_enabled() ) {
|
137 |
return '';
|
138 |
}
|
139 |
|
169 |
return $new_value;
|
170 |
}
|
171 |
|
172 |
+
public static function preupdate_optimize_code( $new_value, $old_value ) {
|
173 |
+
if ( ! empty( $new_value ) ) {
|
174 |
+
$new_value = sanitize_text_field( wp_unslash( $new_value ) );
|
175 |
+
}
|
176 |
+
|
177 |
+
return $new_value;
|
178 |
+
}
|
179 |
+
|
180 |
+
public static function preupdate_ip_anonymization( $new_value, $old_value ) {
|
181 |
+
return $new_value;
|
182 |
+
}
|
183 |
+
|
184 |
/**
|
185 |
* Registers plugin's settings.
|
186 |
*/
|
192 |
register_setting( GA_NAME, self::GA_WEB_PROPERTY_ID_MANUALLY_OPTION_NAME );
|
193 |
register_setting( GA_NAME, self::GA_WEB_PROPERTY_ID_MANUALLY_VALUE_OPTION_NAME );
|
194 |
register_setting( GA_NAME, self::GA_DISABLE_ALL_FEATURES );
|
195 |
+
register_setting( GA_NAME, 'googleanalytics_optimize_code' );
|
196 |
+
register_setting( GA_NAME, 'googleanalytics_ip_anonymization' );
|
197 |
add_filter( 'pre_update_option_' . Ga_Admin::GA_EXCLUDE_ROLES_OPTION_NAME, 'Ga_Admin::preupdate_exclude_roles', 1, 2 );
|
198 |
add_filter( 'pre_update_option_' . Ga_Admin::GA_SELECTED_ACCOUNT, 'Ga_Admin::preupdate_selected_account', 1, 2 );
|
199 |
+
add_filter( 'pre_update_option_googleanalytics_optimize_code', 'Ga_Admin::preupdate_optimize_code', 1, 2 );
|
200 |
+
add_filter( 'pre_update_option_googleanalytics_ip_anonymization', 'Ga_Admin::preupdate_ip_anonymization', 1, 2 );
|
201 |
// add_filter( 'pre_update_option_' . Ga_Admin::GA_DISABLE_ALL_FEATURES, 'Ga_Admin::preupdate_disable_all_features', 1, 2 );
|
202 |
}
|
203 |
|
271 |
if ( !Ga_Helper::is_wp_version_valid() || !Ga_Helper::is_php_version_valid() ) {
|
272 |
return false;
|
273 |
}
|
274 |
+
if ( Ga_Helper::are_features_enabled() && Ga_Helper::is_curl_disabled() ) {
|
275 |
+
echo Ga_Helper::ga_wp_notice( _( 'Looks like cURL is not configured on your server. In order to authenticate your Google Analytics account and display statistics, cURL is required. Please contact your server administrator to enable it, or manually enter your Tracking ID.' ), self::NOTICE_WARNING );
|
276 |
+
}
|
277 |
/**
|
278 |
* Keeps data to be extracted as variables in the view.
|
279 |
*
|
345 |
*/
|
346 |
public static function get_accounts_selector() {
|
347 |
$selected = Ga_Helper::get_selected_account_data();
|
348 |
+
$selector = json_decode( get_option( self::GA_ACCOUNT_DATA_OPTION_NAME ), true );
|
349 |
+
if ( !Ga_Helper::is_code_manually_enabled() && empty( $selector ) ) {
|
350 |
+
echo Ga_Helper::ga_wp_notice( "Hi there! It seems like we weren't able to locate a Google Analytics account attached to your email account. Can you please register for Google Analytics and then deactivate and reactivate the plugin?", self::NOTICE_WARNING );
|
351 |
+
}
|
352 |
return Ga_View_Core::load( 'ga_accounts_selector', array(
|
353 |
'selector' => $selector,
|
354 |
'selected' => $selected ? implode( "_", $selected ) : null,
|
class/controller/Ga_Frontend_Controller.php
CHANGED
@@ -11,12 +11,18 @@ class Ga_Frontend_Controller extends Ga_Controller_Core {
|
|
11 |
public static function googleanalytics_get_script() {
|
12 |
if ( !empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) == 'xmlhttprequest' ) {
|
13 |
$web_property_id = Ga_Frontend::get_web_property_id();
|
|
|
|
|
|
|
14 |
if ( Ga_Helper::should_load_ga_javascript( $web_property_id ) ) {
|
15 |
$javascript = Ga_View_Core::load( 'ga_code', array(
|
16 |
'data' => array(
|
17 |
-
Ga_Admin::GA_WEB_PROPERTY_ID_OPTION_NAME => $web_property_id
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
echo strip_tags( $javascript );
|
21 |
}
|
22 |
} else {
|
11 |
public static function googleanalytics_get_script() {
|
12 |
if ( !empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) == 'xmlhttprequest' ) {
|
13 |
$web_property_id = Ga_Frontend::get_web_property_id();
|
14 |
+
$optimize = get_option( 'googleanalytics_optimize_code' );
|
15 |
+
$anonymization = get_option( 'googleanalytics_ip_anonymization' );
|
16 |
+
|
17 |
if ( Ga_Helper::should_load_ga_javascript( $web_property_id ) ) {
|
18 |
$javascript = Ga_View_Core::load( 'ga_code', array(
|
19 |
'data' => array(
|
20 |
+
Ga_Admin::GA_WEB_PROPERTY_ID_OPTION_NAME => $web_property_id,
|
21 |
+
'optimize' => $optimize,
|
22 |
+
'anonymization' => $anonymization,
|
23 |
+
),
|
24 |
+
),
|
25 |
+
true );
|
26 |
echo strip_tags( $javascript );
|
27 |
}
|
28 |
} else {
|
googleanalytics.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Google Analytics
|
5 |
* Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
|
6 |
* Description: Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
|
7 |
-
* Version: 2.1.
|
8 |
* Author: ShareThis
|
9 |
* Author URI: http://sharethis.com
|
10 |
*/
|
4 |
* Plugin Name: Google Analytics
|
5 |
* Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
|
6 |
* Description: Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
|
7 |
+
* Version: 2.1.5
|
8 |
* Author: ShareThis
|
9 |
* Author URI: http://sharethis.com
|
10 |
*/
|
js/googleanalytics_page.js
CHANGED
@@ -131,7 +131,7 @@ const GA_AUTHENTICATION_CODE_ERROR = 'That looks like your Google Analytics Trac
|
|
131 |
checkbox.removeProp('checked');
|
132 |
}
|
133 |
|
134 |
-
$("
|
135 |
var manually_enter_not_checked = $('#ga_enter_code_manually').not(':checked');
|
136 |
if (checkbox.not(':checked').length > 0) {
|
137 |
if (confirm('This will disable Dashboards, Viral Alerts and Google API')) {
|
131 |
checkbox.removeProp('checked');
|
132 |
}
|
133 |
|
134 |
+
$(".ga-slider-disable").on("click", function (e) {
|
135 |
var manually_enter_not_checked = $('#ga_enter_code_manually').not(':checked');
|
136 |
if (checkbox.not(':checked').length > 0) {
|
137 |
if (confirm('This will disable Dashboards, Viral Alerts and Google API')) {
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: sharethis, scottstorebloom
|
3 |
Tags: analytics, dashboard, google, google analytics, google analytics plugin, javascript, marketing, pageviews, statistics, stats, tracking, visits, web stats, widget, analytics dashboard, google analytics dashboard, google analytics widget, google analytics dashboard
|
4 |
Requires at least: 3.8
|
5 |
-
Tested up to: 4.9.
|
6 |
-
Stable tag: 2.1.
|
7 |
|
8 |
Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
|
9 |
|
@@ -74,6 +74,11 @@ We are always happy to help.
|
|
74 |
|
75 |
== Changelog ==
|
76 |
|
|
|
|
|
|
|
|
|
|
|
77 |
= 2.1.4 =
|
78 |
* Updated SSL cert reference.
|
79 |
* Fixed Trending Content connection issue.
|
2 |
Contributors: sharethis, scottstorebloom
|
3 |
Tags: analytics, dashboard, google, google analytics, google analytics plugin, javascript, marketing, pageviews, statistics, stats, tracking, visits, web stats, widget, analytics dashboard, google analytics dashboard, google analytics widget, google analytics dashboard
|
4 |
Requires at least: 3.8
|
5 |
+
Tested up to: 4.9.8
|
6 |
+
Stable tag: 2.1.5
|
7 |
|
8 |
Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
|
9 |
|
74 |
|
75 |
== Changelog ==
|
76 |
|
77 |
+
= 2.1.5 =
|
78 |
+
* Added IP Anonymization Option.
|
79 |
+
* Added Google Optimization field.
|
80 |
+
* Updated GA code posting method.
|
81 |
+
|
82 |
= 2.1.4 =
|
83 |
* Updated SSL cert reference.
|
84 |
* Fixed Trending Content connection issue.
|
view/ga_code.php
CHANGED
@@ -1,18 +1,24 @@
|
|
1 |
<script>
|
2 |
(function() {
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
})();
|
18 |
</script>
|
1 |
<script>
|
2 |
(function() {
|
3 |
+
(function (i, s, o, g, r, a, m) {
|
4 |
+
i['GoogleAnalyticsObject'] = r;
|
5 |
+
i[r] = i[r] || function () {
|
6 |
+
(i[r].q = i[r].q || []).push(arguments)
|
7 |
+
}, i[r].l = 1 * new Date();
|
8 |
+
a = s.createElement(o),
|
9 |
+
m = s.getElementsByTagName(o)[0];
|
10 |
+
a.async = 1;
|
11 |
+
a.src = g;
|
12 |
+
m.parentNode.insertBefore(a, m)
|
13 |
+
})(window, document, 'script', 'https://google-analytics.com/analytics.js', 'ga');
|
14 |
|
15 |
+
ga('create', '<?php echo esc_attr( $data[ Ga_Admin::GA_WEB_PROPERTY_ID_OPTION_NAME ] ); ?>', 'auto');
|
16 |
+
<?php if ( 'on' === $data['anonymization'] ) : ?>
|
17 |
+
ga('set', 'anonymizeIp', true);
|
18 |
+
<?php endif; ?>
|
19 |
+
<?php if ( ! empty( $data['optimize'] ) ) : ?>
|
20 |
+
ga('require', '<?php echo esc_html( $data['optimize'] ); ?>' );
|
21 |
+
<?php endif; ?>
|
22 |
+
ga('send', 'pageview');
|
23 |
})();
|
24 |
</script>
|
view/ga_googleanalytics_loader.php
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
<script>
|
2 |
jQuery(document).ready(function () {
|
3 |
jQuery.post('<?php echo esc_attr( $ajaxurl ); ?>', {action: 'googleanalytics_get_script'}, function(response) {
|
4 |
-
var
|
5 |
-
|
|
|
|
|
6 |
});
|
7 |
});
|
8 |
</script>
|
1 |
<script>
|
2 |
jQuery(document).ready(function () {
|
3 |
jQuery.post('<?php echo esc_attr( $ajaxurl ); ?>', {action: 'googleanalytics_get_script'}, function(response) {
|
4 |
+
var s = document.createElement("script");
|
5 |
+
s.type = "text/javascript";
|
6 |
+
s.innerHTML = response;
|
7 |
+
jQuery("head").append(s);
|
8 |
});
|
9 |
});
|
10 |
</script>
|
view/page.php
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<div id="ga_access_code_modal" class="ga-modal" tabindex="-1">
|
2 |
<div class="ga-modal-dialog">
|
3 |
<div class="ga-modal-content">
|
@@ -142,31 +147,35 @@
|
|
142 |
|
143 |
</td>
|
144 |
</tr>
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
170 |
</table>
|
171 |
|
172 |
<p class="submit">
|
@@ -175,9 +184,25 @@
|
|
175 |
</p>
|
176 |
</form>
|
177 |
</div>
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
</div>
|
182 |
<script type="text/javascript">
|
183 |
const GA_DISABLE_FEATURE_URL = '<?php echo Ga_Helper::create_url(admin_url(Ga_Helper::GA_SETTINGS_PAGE_URL), array(Ga_Controller_Core::ACTION_PARAM_NAME => 'ga_action_disable_all_features')); ?>';
|
1 |
+
<?php
|
2 |
+
$optimize_code = get_option( 'googleanalytics_optimize_code' );
|
3 |
+
$universal = get_option( 'googleanalytics_enable_universal_analytics', true );
|
4 |
+
$anonymization = get_option( 'googleanalytics_ip_anonymization', true );
|
5 |
+
?>
|
6 |
<div id="ga_access_code_modal" class="ga-modal" tabindex="-1">
|
7 |
<div class="ga-modal-dialog">
|
8 |
<div class="ga-modal-content">
|
147 |
|
148 |
</td>
|
149 |
</tr>
|
150 |
+
<tr valign="top">
|
151 |
+
<th scope="row"><?php _e( 'Enable IP Anonymization' ) ?>:</th>
|
152 |
+
<td>
|
153 |
+
<label class="ga-switch">
|
154 |
+
<input id="ga-anonymization" name="googleanalytics_ip_anonymization"
|
155 |
+
type="checkbox" <?php echo checked( $anonymization, 'on' ); ?>>
|
156 |
+
<div id="ga-slider" class="ga-slider round"></div>
|
157 |
+
</label
|
158 |
+
</td>
|
159 |
+
</tr>
|
160 |
+
<tr valign="top">
|
161 |
+
<th scope="row"><?php _e( 'If using Google Optimize, enter optimize code here' ) ?>:</th>
|
162 |
+
<td>
|
163 |
+
<label class="ga-text">
|
164 |
+
<input id="ga-optimize" name="googleanalytics_optimize_code"
|
165 |
+
type="text" placeholder="GTM-XXXXXX" value="<?php echo esc_attr( $optimize_code ); ?>">
|
166 |
+
</label
|
167 |
+
</td>
|
168 |
+
</tr>
|
169 |
+
<tr valign="top">
|
170 |
+
<th scope="row"><?php _e( 'Disable all features' ) ?>:</th>
|
171 |
+
<td>
|
172 |
+
<label class="ga-switch">
|
173 |
+
<input id="ga-disable" name="<?php echo Ga_Admin::GA_DISABLE_ALL_FEATURES; ?>"
|
174 |
+
type="checkbox">
|
175 |
+
<div id="ga-slider" class="ga-slider-disable ga-slider round"></div>
|
176 |
+
</label
|
177 |
+
</td>
|
178 |
+
</tr>
|
179 |
</table>
|
180 |
|
181 |
<p class="submit">
|
184 |
</p>
|
185 |
</form>
|
186 |
</div>
|
187 |
+
<tr valign="top">
|
188 |
+
<td colspan="2">
|
189 |
+
<p>If you are still experiencing an issue, we are here to help! We recommend clickingthe "Send Debugging Info" button below and pasting the information within an email to support@sharethis.com.</p>
|
190 |
+
<p>
|
191 |
+
<button id="ga_debug_button" class="button button-secondary" onclick="ga_debug.open_modal( event )" >Send Debugging Info</button>
|
192 |
+
<?php if ( ! empty( $data['ga_accounts_selector'] ) ): ?>
|
193 |
+
<?php echo $data[ 'auth_button' ] ?>
|
194 |
+
<br>
|
195 |
+
<small class="notice">
|
196 |
+
*If you reset your google password you MUST re-authenticate to continue viewing your analytics dashboard.
|
197 |
+
</small>
|
198 |
+
<?php endif; ?>
|
199 |
+
</p>
|
200 |
+
</td>
|
201 |
+
</tr>
|
202 |
+
|
203 |
+
<p class="ga-love-text"><?php _e( 'Love this plugin?' ); ?> <a
|
204 |
+
href="https://wordpress.org/support/plugin/googleanalytics/reviews/#new-post"><?php _e( ' Please help spread the word by leaving a 5-star review!' ); ?> </a>
|
205 |
+
</p>
|
206 |
</div>
|
207 |
<script type="text/javascript">
|
208 |
const GA_DISABLE_FEATURE_URL = '<?php echo Ga_Helper::create_url(admin_url(Ga_Helper::GA_SETTINGS_PAGE_URL), array(Ga_Controller_Core::ACTION_PARAM_NAME => 'ga_action_disable_all_features')); ?>';
|