Version Description
- Fixes deprecated warnings when wp_debug is enabled.
- Fixes tracking code issues when trying to disabled certain user roles.
- Improves plugin security.
Download this release
Release Info
| Developer | cavemonkey50 |
| Plugin | |
| Version | 6.1.2 |
| Comparing to | |
| See all releases | |
Code changes from version 6.1.1 to 6.1.2
- google-analyticator.php +32 -24
- readme.txt +7 -2
google-analyticator.php
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
* Plugin Name: Google Analyticator
|
| 4 |
-
* Version: 6.1.
|
| 5 |
* Plugin URI: http://ronaldheft.com/code/analyticator/
|
| 6 |
* Description: Adds the necessary JavaScript code to enable <a href="http://www.google.com/analytics/">Google's Analytics</a>. After enabling this plugin visit <a href="options-general.php?page=google-analyticator.php">the settings page</a> and enter your Google Analytics' UID and enable logging.
|
| 7 |
* Author: Ronald Heft
|
|
@@ -9,7 +9,7 @@
|
|
| 9 |
* Text Domain: google-analyticator
|
| 10 |
*/
|
| 11 |
|
| 12 |
-
define('GOOGLE_ANALYTICATOR_VERSION', '6.1.
|
| 13 |
|
| 14 |
// Constants for enabled/disabled state
|
| 15 |
define("ga_enabled", "enabled", true);
|
|
@@ -47,24 +47,24 @@ define("ga_downloads_prefix_default", "download", true);
|
|
| 47 |
define("ga_widgets_default", ga_enabled, true);
|
| 48 |
|
| 49 |
// Create the default key and status
|
| 50 |
-
add_option(key_ga_status, ga_status_default, '
|
| 51 |
-
add_option(key_ga_uid, ga_uid_default, '
|
| 52 |
-
add_option(key_ga_admin, ga_admin_default, '
|
| 53 |
add_option(key_ga_admin_disable, ga_admin_disable_default, '');
|
| 54 |
-
add_option(key_ga_admin_role, array('administrator'), '
|
| 55 |
-
add_option(key_ga_dashboard_role, array('administrator'), '
|
| 56 |
add_option(key_ga_adsense, ga_adsense_default, '');
|
| 57 |
-
add_option(key_ga_extra, ga_extra_default, '
|
| 58 |
-
add_option(key_ga_extra_after, ga_extra_after_default, '
|
| 59 |
add_option(key_ga_event, ga_event_default, '');
|
| 60 |
-
add_option(key_ga_outbound, ga_outbound_default, '
|
| 61 |
-
add_option(key_ga_outbound_prefix, ga_outbound_prefix_default, '
|
| 62 |
-
add_option(key_ga_downloads, ga_downloads_default, '
|
| 63 |
-
add_option(key_ga_downloads_prefix, ga_downloads_prefix_default, '
|
| 64 |
-
add_option('ga_profileid', '', '
|
| 65 |
-
add_option(key_ga_widgets, ga_widgets_default, '
|
| 66 |
-
add_option('ga_google_token', '', '
|
| 67 |
-
add_option('ga_compatibility', 'off', '
|
| 68 |
|
| 69 |
# Check if we have a version of WordPress greater than 2.8
|
| 70 |
if ( function_exists('register_widget') ) {
|
|
@@ -102,7 +102,7 @@ add_action('init', 'ga_outgoing_links');
|
|
| 102 |
|
| 103 |
// Hook in the options page function
|
| 104 |
function add_ga_option_page() {
|
| 105 |
-
$plugin_page = add_options_page(__('Google Analyticator Settings', 'google-analyticator'), 'Google Analytics',
|
| 106 |
|
| 107 |
# Include javascript on the GA settings page
|
| 108 |
add_action('admin_head-' . $plugin_page, 'ga_admin_ajax');
|
|
@@ -165,11 +165,19 @@ function ga_options_page() {
|
|
| 165 |
update_option(key_ga_admin_disable, $ga_admin_disable);
|
| 166 |
|
| 167 |
// Update the admin level
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
update_option(key_ga_admin_role, $ga_admin_role);
|
| 170 |
|
| 171 |
// Update the dashboard level
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
update_option(key_ga_dashboard_role, $ga_dashboard_role);
|
| 174 |
|
| 175 |
// Update the extra tracking code
|
|
@@ -649,7 +657,7 @@ function ga_admin_ajax()
|
|
| 649 |
data: {
|
| 650 |
action: 'ga_ajax_accounts',
|
| 651 |
_ajax_nonce: '<?php echo wp_create_nonce("google-analyticator-accounts_get"); ?>'<?php if ( isset($_GET['token']) ) { ?>,
|
| 652 |
-
token: '<?php echo $_GET["token"]; ?>'
|
| 653 |
<?php } ?>
|
| 654 |
},
|
| 655 |
success: function(html) {
|
|
@@ -784,7 +792,7 @@ function add_google_analytics()
|
|
| 784 |
if ( ( get_option(key_ga_status) != ga_disabled ) && ( $uid != "XX-XXXXX-X" ) )
|
| 785 |
{
|
| 786 |
# Determine if the user is an admin, and should see the tracking code
|
| 787 |
-
if ( ( get_option(key_ga_admin) == ga_enabled || !ga_current_user_is(get_option(
|
| 788 |
{
|
| 789 |
# Add the notice that Google Analyticator tracking is enabled
|
| 790 |
echo "<!-- Google Analytics Tracking by Google Analyticator " . GOOGLE_ANALYTICATOR_VERSION . ": http://ronaldheft.com/code/analyticator/ -->\n";
|
|
@@ -831,7 +839,7 @@ function add_google_analytics()
|
|
| 831 |
echo " _gaq.push(['_trackPageview']);\n";
|
| 832 |
|
| 833 |
# Disable page tracking if admin is logged in
|
| 834 |
-
if ( ( get_option(key_ga_admin) == ga_disabled ) && ( ga_current_user_is(get_option(
|
| 835 |
echo " _gaq.push(['_setVar', 'admin']);\n";
|
| 836 |
|
| 837 |
# Add any tracking code after the trackPageview
|
|
@@ -875,7 +883,7 @@ function ga_outgoing_links()
|
|
| 875 |
if ( !is_admin() )
|
| 876 |
{
|
| 877 |
# Display page tracking if user is not an admin
|
| 878 |
-
if ( ( get_option(key_ga_admin) == ga_enabled || !ga_current_user_is(get_option(
|
| 879 |
{
|
| 880 |
add_action('wp_print_scripts', 'ga_external_tracking_js');
|
| 881 |
}
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
* Plugin Name: Google Analyticator
|
| 4 |
+
* Version: 6.1.2
|
| 5 |
* Plugin URI: http://ronaldheft.com/code/analyticator/
|
| 6 |
* Description: Adds the necessary JavaScript code to enable <a href="http://www.google.com/analytics/">Google's Analytics</a>. After enabling this plugin visit <a href="options-general.php?page=google-analyticator.php">the settings page</a> and enter your Google Analytics' UID and enable logging.
|
| 7 |
* Author: Ronald Heft
|
| 9 |
* Text Domain: google-analyticator
|
| 10 |
*/
|
| 11 |
|
| 12 |
+
define('GOOGLE_ANALYTICATOR_VERSION', '6.1.2');
|
| 13 |
|
| 14 |
// Constants for enabled/disabled state
|
| 15 |
define("ga_enabled", "enabled", true);
|
| 47 |
define("ga_widgets_default", ga_enabled, true);
|
| 48 |
|
| 49 |
// Create the default key and status
|
| 50 |
+
add_option(key_ga_status, ga_status_default, '');
|
| 51 |
+
add_option(key_ga_uid, ga_uid_default, '');
|
| 52 |
+
add_option(key_ga_admin, ga_admin_default, '');
|
| 53 |
add_option(key_ga_admin_disable, ga_admin_disable_default, '');
|
| 54 |
+
add_option(key_ga_admin_role, array('administrator'), '');
|
| 55 |
+
add_option(key_ga_dashboard_role, array('administrator'), '');
|
| 56 |
add_option(key_ga_adsense, ga_adsense_default, '');
|
| 57 |
+
add_option(key_ga_extra, ga_extra_default, '');
|
| 58 |
+
add_option(key_ga_extra_after, ga_extra_after_default, '');
|
| 59 |
add_option(key_ga_event, ga_event_default, '');
|
| 60 |
+
add_option(key_ga_outbound, ga_outbound_default, '');
|
| 61 |
+
add_option(key_ga_outbound_prefix, ga_outbound_prefix_default, '');
|
| 62 |
+
add_option(key_ga_downloads, ga_downloads_default, '');
|
| 63 |
+
add_option(key_ga_downloads_prefix, ga_downloads_prefix_default, '');
|
| 64 |
+
add_option('ga_profileid', '', '');
|
| 65 |
+
add_option(key_ga_widgets, ga_widgets_default, '');
|
| 66 |
+
add_option('ga_google_token', '', '');
|
| 67 |
+
add_option('ga_compatibility', 'off', '');
|
| 68 |
|
| 69 |
# Check if we have a version of WordPress greater than 2.8
|
| 70 |
if ( function_exists('register_widget') ) {
|
| 102 |
|
| 103 |
// Hook in the options page function
|
| 104 |
function add_ga_option_page() {
|
| 105 |
+
$plugin_page = add_options_page(__('Google Analyticator Settings', 'google-analyticator'), 'Google Analytics', 'manage_options', basename(__FILE__), 'ga_options_page');
|
| 106 |
|
| 107 |
# Include javascript on the GA settings page
|
| 108 |
add_action('admin_head-' . $plugin_page, 'ga_admin_ajax');
|
| 165 |
update_option(key_ga_admin_disable, $ga_admin_disable);
|
| 166 |
|
| 167 |
// Update the admin level
|
| 168 |
+
if ( array_key_exists(key_ga_admin_role, $_POST) ) {
|
| 169 |
+
$ga_admin_role = $_POST[key_ga_admin_role];
|
| 170 |
+
} else {
|
| 171 |
+
$ga_admin_role = "";
|
| 172 |
+
}
|
| 173 |
update_option(key_ga_admin_role, $ga_admin_role);
|
| 174 |
|
| 175 |
// Update the dashboard level
|
| 176 |
+
if ( array_key_exists(key_ga_dashboard_role, $_POST) ) {
|
| 177 |
+
$ga_dashboard_role = $_POST[key_ga_dashboard_role];
|
| 178 |
+
} else {
|
| 179 |
+
$ga_dashboard_role = "";
|
| 180 |
+
}
|
| 181 |
update_option(key_ga_dashboard_role, $ga_dashboard_role);
|
| 182 |
|
| 183 |
// Update the extra tracking code
|
| 657 |
data: {
|
| 658 |
action: 'ga_ajax_accounts',
|
| 659 |
_ajax_nonce: '<?php echo wp_create_nonce("google-analyticator-accounts_get"); ?>'<?php if ( isset($_GET['token']) ) { ?>,
|
| 660 |
+
token: '<?php echo esc_js($_GET["token"]); ?>'
|
| 661 |
<?php } ?>
|
| 662 |
},
|
| 663 |
success: function(html) {
|
| 792 |
if ( ( get_option(key_ga_status) != ga_disabled ) && ( $uid != "XX-XXXXX-X" ) )
|
| 793 |
{
|
| 794 |
# Determine if the user is an admin, and should see the tracking code
|
| 795 |
+
if ( ( get_option(key_ga_admin) == ga_enabled || !ga_current_user_is(get_option(key_ga_admin_role)) ) && get_option(key_ga_admin_disable) == 'remove' || get_option(key_ga_admin_disable) != 'remove' )
|
| 796 |
{
|
| 797 |
# Add the notice that Google Analyticator tracking is enabled
|
| 798 |
echo "<!-- Google Analytics Tracking by Google Analyticator " . GOOGLE_ANALYTICATOR_VERSION . ": http://ronaldheft.com/code/analyticator/ -->\n";
|
| 839 |
echo " _gaq.push(['_trackPageview']);\n";
|
| 840 |
|
| 841 |
# Disable page tracking if admin is logged in
|
| 842 |
+
if ( ( get_option(key_ga_admin) == ga_disabled ) && ( ga_current_user_is(get_option(key_ga_admin_role)) ) )
|
| 843 |
echo " _gaq.push(['_setVar', 'admin']);\n";
|
| 844 |
|
| 845 |
# Add any tracking code after the trackPageview
|
| 883 |
if ( !is_admin() )
|
| 884 |
{
|
| 885 |
# Display page tracking if user is not an admin
|
| 886 |
+
if ( ( get_option(key_ga_admin) == ga_enabled || !ga_current_user_is(get_option(key_ga_admin_role)) ) && get_option(key_ga_admin_disable) == 'remove' || get_option(key_ga_admin_disable) != 'remove' )
|
| 887 |
{
|
| 888 |
add_action('wp_print_scripts', 'ga_external_tracking_js');
|
| 889 |
}
|
readme.txt
CHANGED
|
@@ -3,8 +3,8 @@ Contributors: cavemonkey50
|
|
| 3 |
Donate link: http://ronaldheft.com/code/donate/
|
| 4 |
Tags: stats, statistics, google, analytics, google analytics, tracking, widget
|
| 5 |
Requires at least: 2.7
|
| 6 |
-
Tested up to: 3.
|
| 7 |
-
Stable tag: 6.1.
|
| 8 |
|
| 9 |
Adds the necessary JavaScript code to enable Google Analytics. Includes widgets for Analytics data display.
|
| 10 |
|
|
@@ -49,6 +49,11 @@ Please visit [Google Analyticator's support forum](http://forums.ronaldheft.com/
|
|
| 49 |
|
| 50 |
== Changelog ==
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
= 6.1.1 =
|
| 53 |
* Due to many questions about tracking code placement, [an FAQ article](http://forums.ronaldheft.com/viewtopic.php?f=5&t=967) has been written to address these placement questions. If you have any questions, this is a recommended read.
|
| 54 |
* Corrects issues related to selecting user roles to exclude from tracking / seeing the dashboard widget.
|
| 3 |
Donate link: http://ronaldheft.com/code/donate/
|
| 4 |
Tags: stats, statistics, google, analytics, google analytics, tracking, widget
|
| 5 |
Requires at least: 2.7
|
| 6 |
+
Tested up to: 3.1
|
| 7 |
+
Stable tag: 6.1.2
|
| 8 |
|
| 9 |
Adds the necessary JavaScript code to enable Google Analytics. Includes widgets for Analytics data display.
|
| 10 |
|
| 49 |
|
| 50 |
== Changelog ==
|
| 51 |
|
| 52 |
+
= 6.1.2 =
|
| 53 |
+
* Fixes deprecated warnings when wp_debug is enabled.
|
| 54 |
+
* Fixes tracking code issues when trying to disabled certain user roles.
|
| 55 |
+
* Improves plugin security.
|
| 56 |
+
|
| 57 |
= 6.1.1 =
|
| 58 |
* Due to many questions about tracking code placement, [an FAQ article](http://forums.ronaldheft.com/viewtopic.php?f=5&t=967) has been written to address these placement questions. If you have any questions, this is a recommended read.
|
| 59 |
* Corrects issues related to selecting user roles to exclude from tracking / seeing the dashboard widget.
|
