Version Description
- The first version
=
Download this release
Release Info
Developer | wp-buddy |
Plugin | Google Analytics Opt-Out |
Version | 0.1 |
Comparing to | |
See all releases |
Version 0.1
- classes/admin.php +78 -0
- classes/functions.php +76 -0
- classes/scripts.php +60 -0
- classes/settings.php +118 -0
- classes/shortcodes.php +64 -0
- google-analytics-opt-out.php +43 -0
- images/optout-editor-icon.png +0 -0
- js/editor-button.js +60 -0
- js/settings.js +23 -0
- languages/gaoo-de_DE.mo +0 -0
- languages/gaoo-de_DE.po +85 -0
- languages/gaoo.mo +0 -0
- languages/gaoo.po +73 -0
- readme.txt +65 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
classes/admin.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function gaoo_admin_notice() {
|
4 |
+
$code = gaoo_get_ua_code();
|
5 |
+
if ( ! empty( $code ) ) {
|
6 |
+
return;
|
7 |
+
}
|
8 |
+
?>
|
9 |
+
<div class="error">
|
10 |
+
<p>
|
11 |
+
<a href="<?php echo admin_url( 'options-general.php?page=gaoo-options' ); ?>"><?php _e( 'To use the Google Analytics Opt-Out Plugin please enter an UA-Code on the settings page.', 'gaoo' ); ?></a>
|
12 |
+
</p>
|
13 |
+
</div>
|
14 |
+
<?php
|
15 |
+
}
|
16 |
+
|
17 |
+
add_action( 'admin_notices', 'gaoo_admin_notice' );
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Adds some action links to the plugin on the list of plugins page
|
22 |
+
*
|
23 |
+
* @param array $links
|
24 |
+
*
|
25 |
+
* @since 0.1
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
function gaoo_plugin_action_links( $links ) {
|
30 |
+
$links[] = '<a href="' . admin_url( 'options-general.php?page=gaoo-options' ) . '">' . __( 'Settings', 'gaoo' ) . '</a>';
|
31 |
+
$links[] = '<a target="_blank" href="http://wp-buddy.com">' . __( 'More by WP-Buddy', 'gaoo' ) . '</a>';
|
32 |
+
return $links;
|
33 |
+
}
|
34 |
+
|
35 |
+
add_filter( 'plugin_action_links_' . plugin_basename( GAOO_FILE ), 'gaoo_plugin_action_links' );
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Adds the editor button functions
|
40 |
+
* @since 0.1
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
function gaoo_editor_button() {
|
44 |
+
if ( get_user_option( 'rich_editing' ) == true ) {
|
45 |
+
add_filter( "mce_external_plugins", 'gaoo_add_mce_plugin' );
|
46 |
+
add_filter( 'mce_buttons', 'gaoo_register_mce_buttons' );
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
add_action( 'init', 'gaoo_editor_button' );
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Adds the plugin to tinymce
|
54 |
+
*
|
55 |
+
* @param array $plugin_array
|
56 |
+
*
|
57 |
+
* @since 0.1
|
58 |
+
*
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
function gaoo_add_mce_plugin( $plugin_array ) {
|
62 |
+
$plugin_array['wpb_analytics_opt_out'] = GAOO_URL . 'js/editor-button.js';
|
63 |
+
return $plugin_array;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Adds the button
|
68 |
+
*
|
69 |
+
* @param array $buttons
|
70 |
+
*
|
71 |
+
* @since 0.1
|
72 |
+
*
|
73 |
+
* @return array
|
74 |
+
*/
|
75 |
+
function gaoo_register_mce_buttons( $buttons ) {
|
76 |
+
array_push( $buttons, "wpb_analytics_opt_out" );
|
77 |
+
return $buttons;
|
78 |
+
}
|
classes/functions.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Checks if the Yoast Analytics Plugin is active
|
5 |
+
* @since 0.1
|
6 |
+
* @return bool
|
7 |
+
*/
|
8 |
+
function gaoo_yoast_plugin_active() {
|
9 |
+
global $ga_admin;
|
10 |
+
|
11 |
+
if ( ! isset( $ga_admin ) ) {
|
12 |
+
return false;
|
13 |
+
}
|
14 |
+
|
15 |
+
if ( ! $ga_admin instanceof GA_Admin ) {
|
16 |
+
return false;
|
17 |
+
}
|
18 |
+
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Return the UA from Yoast settings, if Yoast Analytics plugin is installed
|
24 |
+
* If Yoast Analytics is not installed this will return an empty string
|
25 |
+
*
|
26 |
+
* @since 0.1
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
function gaoo_get_yoast_ua() {
|
30 |
+
|
31 |
+
if ( ! gaoo_yoast_plugin_active() ) {
|
32 |
+
return '';
|
33 |
+
}
|
34 |
+
|
35 |
+
global $ga_admin;
|
36 |
+
|
37 |
+
if ( ! isset( $ga_admin->optionname ) ) {
|
38 |
+
return '';
|
39 |
+
}
|
40 |
+
|
41 |
+
$yoast_settings = get_option( $ga_admin->optionname );
|
42 |
+
|
43 |
+
if ( ! isset( $yoast_settings['uastring'] ) ) {
|
44 |
+
return '';
|
45 |
+
}
|
46 |
+
|
47 |
+
return $yoast_settings['uastring'];
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Returns the UA-Code
|
52 |
+
* @since 0.1
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
function gaoo_get_ua_code() {
|
56 |
+
|
57 |
+
$use_yoast = get_option( 'gaoo_yoast', null );
|
58 |
+
|
59 |
+
// if the plugin is used the first time, this value is NULL
|
60 |
+
if ( is_null( $use_yoast ) ) {
|
61 |
+
$use_yoast = 1;
|
62 |
+
}
|
63 |
+
|
64 |
+
// if yoast should be used, try to get the ua code from the plugin
|
65 |
+
if ( 1 == intval( $use_yoast ) ) {
|
66 |
+
$yoast_code = gaoo_get_yoast_ua();
|
67 |
+
|
68 |
+
if ( ! empty( $yoast_code ) ) {
|
69 |
+
return apply_filters( 'gaoo_get_ua_code', $yoast_code );
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
// if yoast returns an empty string OR if the checkbox was set to 0 return the textbox content
|
74 |
+
return apply_filters( 'gaoo_get_ua_code', esc_attr( get_option( 'gaoo_property', '' ) ) );
|
75 |
+
|
76 |
+
}
|
classes/scripts.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Echos out the JavaScript for the opt-out
|
4 |
+
* @since 0.1
|
5 |
+
* @return void
|
6 |
+
*/
|
7 |
+
function gaoo_head_script() {
|
8 |
+
|
9 |
+
if ( apply_filters( 'gaoo_stop_head', false ) ) {
|
10 |
+
return;
|
11 |
+
}
|
12 |
+
|
13 |
+
gaoo_js();
|
14 |
+
}
|
15 |
+
|
16 |
+
// To call it before the Yoast Analytics Plugin (2) this has a priority of 1
|
17 |
+
add_action( 'wp_head', 'gaoo_head_script', 1 );
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Echos out the Javascript or returns it (if $echo is set to TRUE)
|
21 |
+
*
|
22 |
+
* @since 0.1
|
23 |
+
*
|
24 |
+
* @param bool $echo
|
25 |
+
*
|
26 |
+
* @return void|string
|
27 |
+
*/
|
28 |
+
function gaoo_js( $echo = true ) {
|
29 |
+
$ua_code = gaoo_get_ua_code();
|
30 |
+
if ( empty( $ua_code ) ) {
|
31 |
+
return '';
|
32 |
+
}
|
33 |
+
ob_start();
|
34 |
+
?>
|
35 |
+
<script type="text/javascript">
|
36 |
+
/* <![CDATA[ */
|
37 |
+
/* Google Analytics Opt-Out WordPress by WP-Buddy | http://wp-buddy.com/products/plugins/google-analytics-opt-out */
|
38 |
+
<?php do_action('gaoo_js_before_script'); ?>
|
39 |
+
var gaoo_property = '<?php echo $ua_code; ?>';
|
40 |
+
var gaoo_disable_str = 'ga-disable-' + gaoo_property;
|
41 |
+
if (document.cookie.indexOf(gaoo_disable_str + '=true') > -1) {
|
42 |
+
window[gaoo_disable_str] = true;
|
43 |
+
}
|
44 |
+
function gaoo_analytics_optout() {
|
45 |
+
document.cookie = gaoo_disable_str + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
|
46 |
+
window[gaoo_disable_str] = true;
|
47 |
+
<?php echo apply_filters( 'gaoo_', "alert('" . __( 'Thanks. We have set a cookie so that Google Analytics data collection will be disabled on your next visit.', 'gaoo' ) . "');" ); ?>
|
48 |
+
}
|
49 |
+
<?php do_action('gaoo_js_after_script'); ?>
|
50 |
+
/* ]]> */
|
51 |
+
</script>
|
52 |
+
<?php
|
53 |
+
$content = ob_get_clean();
|
54 |
+
if ( $echo ) {
|
55 |
+
echo $content;
|
56 |
+
}
|
57 |
+
else {
|
58 |
+
return $content;
|
59 |
+
}
|
60 |
+
}
|
classes/settings.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Creating the menu item
|
5 |
+
* @since 0.1
|
6 |
+
* @return void
|
7 |
+
*/
|
8 |
+
function gaoo_admin_menu() {
|
9 |
+
$hook = add_submenu_page( 'options-general.php', __( 'Analytics Opt-Out', 'gaoo' ), __( 'Analytics Opt-Out', 'gaoo' ), 'manage_options', 'gaoo-options', 'gaoo_settings_page' );
|
10 |
+
add_action( "load-$hook", 'gaoo_settings_scripts' );
|
11 |
+
}
|
12 |
+
|
13 |
+
add_action( 'admin_menu', 'gaoo_admin_menu' );
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Creating the settings page HTML output
|
18 |
+
* @since 0.1
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
function gaoo_settings_page() {
|
22 |
+
?>
|
23 |
+
<div class="wrap">
|
24 |
+
<div id="icon-options-general" class="icon32"></div>
|
25 |
+
<h2><?php _e( 'Google Analaytics Opt-Out', 'gaoo' ); ?> </h2>
|
26 |
+
|
27 |
+
<form action="options.php" method="post">
|
28 |
+
<?php
|
29 |
+
settings_fields( 'gaoo_options_page' );
|
30 |
+
do_settings_sections( 'gaoo_options_page' );
|
31 |
+
submit_button();
|
32 |
+
?>
|
33 |
+
</form>
|
34 |
+
</div>
|
35 |
+
<?php
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Enqueues the settings page scripts and styles
|
41 |
+
* @since 0.1
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
function gaoo_settings_scripts() {
|
45 |
+
wp_enqueue_script( 'equipment', GAOO_URL . '/js/settings.js', array( 'jquery' ), false, true );
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Registers Settings sections and fields
|
51 |
+
* @since 0.1
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
function gaoo_register_theme_options_section() {
|
55 |
+
|
56 |
+
add_settings_section( 'gaoo_settings_section', __( 'Analytics Opt-Out', 'gaoo' ), null, 'gaoo_options_page' );
|
57 |
+
|
58 |
+
add_settings_field( 'gaoo_yoast', __( 'Use Yoast Analytics Settings', 'gaoo' ), 'gaoo_options_yoast', 'gaoo_options_page', 'gaoo_settings_section', array( 'label_for' => 'gaoo_options_yoast' ) );
|
59 |
+
register_setting( 'gaoo_options_page', 'gaoo_yoast' );
|
60 |
+
|
61 |
+
add_settings_field( 'gaoo_property', __( 'UA-Code', 'gaoo' ), 'gaoo_options_property', 'gaoo_options_page', 'gaoo_settings_section', array( 'label_for' => 'gaoo_options_property' ) );
|
62 |
+
register_setting( 'gaoo_options_page', 'gaoo_property', 'sanitize_text_field' );
|
63 |
+
}
|
64 |
+
|
65 |
+
add_action( 'admin_init', 'gaoo_register_theme_options_section' );
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Settings field for the Yoast Checkbox
|
70 |
+
* @since 0.1
|
71 |
+
* @return void
|
72 |
+
*/
|
73 |
+
function gaoo_options_yoast() {
|
74 |
+
|
75 |
+
$yoast_active = gaoo_yoast_plugin_active();
|
76 |
+
|
77 |
+
$option = get_option( 'gaoo_yoast', null );
|
78 |
+
|
79 |
+
// if the plugin is used the first time it has the value of NULL. In this case we set the option to 1
|
80 |
+
if ( is_null( $option ) ) {
|
81 |
+
$option = 1;
|
82 |
+
}
|
83 |
+
|
84 |
+
if ( ! $yoast_active ) {
|
85 |
+
$option = 0;
|
86 |
+
}
|
87 |
+
|
88 |
+
echo '<input ' . disabled( ! $yoast_active, true, false ) . ' ' . checked( $option, 1, false ) . ' id="gaoo_options_yoast" type="checkbox" name="gaoo_yoast" value="1" />';
|
89 |
+
echo '<p class="description">';
|
90 |
+
if ( $yoast_active ) {
|
91 |
+
echo '<span style="color: #5EB95E;">' . __( 'Yoast Analytics Plugin has been detected.', 'gaoo' ) . '</span>';
|
92 |
+
}
|
93 |
+
else {
|
94 |
+
echo '<span style="color: #DD514C;">' . __( 'Yoast Analytics Plugin has NOT been detected. Please enter your UA code manually and then check the sourcode of your website. Make sure that Analytics code appears AFTER the opt-out code (which starts with <code>/* Google Analytics Opt-Out</code>).', 'gaoo' ) . '</span>';
|
95 |
+
}
|
96 |
+
echo '</p>';
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Settings field for the UA property
|
102 |
+
* @since 0.1
|
103 |
+
* @return void
|
104 |
+
*/
|
105 |
+
function gaoo_options_property() {
|
106 |
+
$yoast_active = gaoo_yoast_plugin_active();
|
107 |
+
$option = get_option( 'gaoo_yoast', null );
|
108 |
+
|
109 |
+
if ( $yoast_active && 1 == $option ) {
|
110 |
+
$value = gaoo_get_yoast_ua();
|
111 |
+
}
|
112 |
+
else {
|
113 |
+
$value = sanitize_text_field( get_option( 'gaoo_property', '' ) );
|
114 |
+
}
|
115 |
+
|
116 |
+
echo '<input id="gaoo_options_property" placeholder="UA-XXXXXX-X" type="text" class="regular-text" value="' . $value . '" name="gaoo_property" /> ';
|
117 |
+
|
118 |
+
}
|
classes/shortcodes.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Checks if a shortcode is used in a string
|
9 |
+
*
|
10 |
+
* @param string $shortcode
|
11 |
+
* @param string $content
|
12 |
+
*
|
13 |
+
* @return bool
|
14 |
+
*/
|
15 |
+
function gaoo_has_shortcode( $shortcode, $content = '' ) {
|
16 |
+
if ( stripos( $content, '[' . $shortcode ) !== false ) {
|
17 |
+
return true;
|
18 |
+
}
|
19 |
+
return false;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Adds the shortcodes
|
24 |
+
*
|
25 |
+
* @since 0.1
|
26 |
+
* @return void
|
27 |
+
*/
|
28 |
+
function gaoo_init_shortcodes() {
|
29 |
+
add_shortcode( 'google_analytics_optout', 'gaoo_shortcode' );
|
30 |
+
}
|
31 |
+
|
32 |
+
add_action( 'init', 'gaoo_init_shortcodes' );
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Creating the shortcode content
|
37 |
+
*
|
38 |
+
* @param array $atts
|
39 |
+
* @param string $content
|
40 |
+
*
|
41 |
+
* @since 0.1
|
42 |
+
*
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
function gaoo_shortcode( $atts, $content = '' ) {
|
46 |
+
//$atts = shortcode_atts( array(), $atts );
|
47 |
+
|
48 |
+
if ( empty( $content ) ) {
|
49 |
+
$content = __( 'Click here to opt out.', 'gaoo' );
|
50 |
+
}
|
51 |
+
|
52 |
+
$ua_code = gaoo_get_ua_code();
|
53 |
+
|
54 |
+
if ( empty( $ua_code ) ) {
|
55 |
+
return '<span style="cursor: help; border: 0 none; border-bottom-width: 1px; border-style: dashed;" title="' . __( 'No UA-Code has been entered. Please ask the admin to solve this issue!', 'gaoo' ) . '">' . do_shortcode( $content ) . '</span>';
|
56 |
+
}
|
57 |
+
|
58 |
+
return '<a class="gaoo-opt-out google-analytics-opt-out" href="javascript:gaoo_analytics_optout();">' . do_shortcode( $content ) . '</a>';
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Doing shortcodes in the text widget, too
|
63 |
+
*/
|
64 |
+
add_filter( 'widget_text', 'do_shortcode' );
|
google-analytics-opt-out.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Google Analytics Opt-Out
|
4 |
+
Plugin URI: http://wp-buddy.com/products/plugins/google-analytics-opt-out
|
5 |
+
Description: Provides an Opt-Out functionality for Google Analytics
|
6 |
+
Version: 0.1
|
7 |
+
Author: WP-Buddy
|
8 |
+
Author URI: http://wp-buddy.com
|
9 |
+
License: GPL2
|
10 |
+
|
11 |
+
Copyright 2013 WP-Buddy (email : info@wp-buddy.com)
|
12 |
+
|
13 |
+
This program is free software; you can redistribute it and/or modify
|
14 |
+
it under the terms of the GNU General Public License, version 2, as
|
15 |
+
published by the Free Software Foundation.
|
16 |
+
|
17 |
+
This program is distributed in the hope that it will be useful,
|
18 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
+
GNU General Public License for more details.
|
21 |
+
|
22 |
+
You should have received a copy of the GNU General Public License
|
23 |
+
along with this program; if not, write to the Free Software
|
24 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
+
*/
|
26 |
+
|
27 |
+
// Exit if accessed directly
|
28 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
29 |
+
exit;
|
30 |
+
}
|
31 |
+
|
32 |
+
define( 'GAOO_FILE', __FILE__ );
|
33 |
+
define( 'GAOO_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
34 |
+
define( 'GAOO_URL', trailingslashit( plugins_url() ) . trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );
|
35 |
+
|
36 |
+
load_plugin_textdomain( 'gaoo', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
37 |
+
|
38 |
+
require_once GAOO_PATH . 'classes/functions.php';
|
39 |
+
require_once GAOO_PATH . 'classes/admin.php';
|
40 |
+
require_once GAOO_PATH . 'classes/shortcodes.php';
|
41 |
+
require_once GAOO_PATH . 'classes/scripts.php';
|
42 |
+
require_once GAOO_PATH . 'classes/settings.php';
|
43 |
+
|
images/optout-editor-icon.png
ADDED
Binary file
|
js/editor-button.js
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function ($) {
|
2 |
+
"use strict";
|
3 |
+
|
4 |
+
tinymce.create('tinymce.plugins.WPB_Analytics_Opt_Out', {
|
5 |
+
/**
|
6 |
+
* Initializes the plugin, this will be executed after the plugin has been created.
|
7 |
+
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
8 |
+
* of the editor instance to intercept that event.
|
9 |
+
*
|
10 |
+
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
|
11 |
+
* @param {string} url Absolute URL to where the plugin is located.
|
12 |
+
*/
|
13 |
+
init: function (ed, url) {
|
14 |
+
ed.addButton('wpb_analytics_opt_out', {
|
15 |
+
title: 'Analytics Opt-Out',
|
16 |
+
cmd : 'wpb_analytics_opt_out',
|
17 |
+
image: url + '/../images/optout-editor-icon.png'
|
18 |
+
});
|
19 |
+
|
20 |
+
ed.addCommand('wpb_analytics_opt_out', function () {
|
21 |
+
var shortcode = '[google_analytics_optout]Click here to opt-out.[/google_analytics_optout]';
|
22 |
+
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode + ' ');
|
23 |
+
})
|
24 |
+
},
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Creates control instances based in the incomming name. This method is normally not
|
28 |
+
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
|
29 |
+
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
|
30 |
+
* method can be used to create those.
|
31 |
+
*
|
32 |
+
* @param {String} n Name of the control to create.
|
33 |
+
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
|
34 |
+
* @return {tinymce.ui.Control} New control instance or null if no control was created.
|
35 |
+
*/
|
36 |
+
createControl: function (n, cm) {
|
37 |
+
return null;
|
38 |
+
},
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Returns information about the plugin as a name/value array.
|
42 |
+
* The current keys are longname, author, authorurl, infourl and version.
|
43 |
+
*
|
44 |
+
* @return {Object} Name/value array containing information about the plugin.
|
45 |
+
*/
|
46 |
+
getInfo: function () {
|
47 |
+
return {
|
48 |
+
longname : 'Analytics Opt-Out',
|
49 |
+
author : 'WP-Buddy',
|
50 |
+
authorurl: 'http://wp-buddy.com',
|
51 |
+
infourl : 'http://wp-buddy.com',
|
52 |
+
version : "0.1"
|
53 |
+
};
|
54 |
+
}
|
55 |
+
});
|
56 |
+
|
57 |
+
// Register plugin
|
58 |
+
tinymce.PluginManager.add('wpb_analytics_opt_out', tinymce.plugins.WPB_Analytics_Opt_Out);
|
59 |
+
|
60 |
+
})(jQuery);
|
js/settings.js
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function ($) {
|
2 |
+
"use strict";
|
3 |
+
jQuery(document).ready(function () {
|
4 |
+
|
5 |
+
jQuery('#gaoo_options_property').focus();
|
6 |
+
|
7 |
+
if (jQuery('#gaoo_options_yoast').is(':checked')) {
|
8 |
+
jQuery('.form-table tr:eq(1)').hide();
|
9 |
+
} else {
|
10 |
+
jQuery('.form-table tr:eq(1)').show();
|
11 |
+
}
|
12 |
+
|
13 |
+
jQuery('#gaoo_options_yoast').click(function () {
|
14 |
+
if (jQuery(this).is(':checked')) {
|
15 |
+
jQuery('.form-table tr:eq(1)').hide();
|
16 |
+
} else {
|
17 |
+
jQuery('.form-table tr:eq(1)').show();
|
18 |
+
jQuery('#gaoo_options_property').focus();
|
19 |
+
}
|
20 |
+
});
|
21 |
+
|
22 |
+
});
|
23 |
+
})(jQuery);
|
languages/gaoo-de_DE.mo
ADDED
Binary file
|
languages/gaoo-de_DE.po
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Google Analytics Opt-Out\n"
|
4 |
+
"POT-Creation-Date: 2013-11-07 16:04+0100\n"
|
5 |
+
"PO-Revision-Date: 2013-11-07 16:04+0100\n"
|
6 |
+
"Last-Translator: WP-Buddy <info@wp-buddy.com>\n"
|
7 |
+
"Language-Team: WP-Buddy <info@wp-buddy.com>\n"
|
8 |
+
"Language: de_DE\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Textdomain-Support: yes\n"
|
13 |
+
"X-Generator: Poedit 1.5.7\n"
|
14 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
15 |
+
"_n_noop:1,2;_c;_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;"
|
16 |
+
"esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
17 |
+
"X-Poedit-Basepath: .\n"
|
18 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
19 |
+
"X-Poedit-SearchPath-0: ..\n"
|
20 |
+
|
21 |
+
#: ../classes/admin.php:11
|
22 |
+
msgid ""
|
23 |
+
"To use the Google Analytics Opt-Out Plugin please enter an UA-Code on the "
|
24 |
+
"settings page."
|
25 |
+
msgstr ""
|
26 |
+
"Um das Google Analytics Opt-Oput Plugin zu benutzen müssen Sie einen UA-Code "
|
27 |
+
"auf der Einstellungsseite eingeben."
|
28 |
+
|
29 |
+
#: ../classes/admin.php:30
|
30 |
+
msgid "Settings"
|
31 |
+
msgstr "Einstellungen"
|
32 |
+
|
33 |
+
#: ../classes/admin.php:31
|
34 |
+
msgid "More by WP-Buddy"
|
35 |
+
msgstr "Mehr von WP-Buddy"
|
36 |
+
|
37 |
+
#: ../classes/scripts.php:25
|
38 |
+
msgid ""
|
39 |
+
"Thanks. We have set a cookie so that Google Analytics data collection will "
|
40 |
+
"be disabled on your next visit."
|
41 |
+
msgstr ""
|
42 |
+
"Vielen Dank. Wir haben ein Cookie gesetzt damit Google Analytics bei Ihrem "
|
43 |
+
"nächsten Besuch keine Daten mehr sammeln kann."
|
44 |
+
|
45 |
+
#: ../classes/settings.php:9 ../classes/settings.php:56
|
46 |
+
msgid "Analytics Opt-Out"
|
47 |
+
msgstr "Analytics Opt-Out"
|
48 |
+
|
49 |
+
#: ../classes/settings.php:25
|
50 |
+
msgid "Google Analaytics Opt-Out"
|
51 |
+
msgstr "Google Analytics Opt-Out"
|
52 |
+
|
53 |
+
#: ../classes/settings.php:58
|
54 |
+
msgid "Use Yoast Analytics Settings"
|
55 |
+
msgstr "Yoast Analytics Einstellungen benutzen"
|
56 |
+
|
57 |
+
#: ../classes/settings.php:61
|
58 |
+
msgid "UA-Code"
|
59 |
+
msgstr "UA-Code"
|
60 |
+
|
61 |
+
#: ../classes/settings.php:91
|
62 |
+
msgid "Yoast Analytics Plugin has been detected."
|
63 |
+
msgstr "Yoast Analytics Plugin wurde gefunden."
|
64 |
+
|
65 |
+
#: ../classes/settings.php:94
|
66 |
+
msgid ""
|
67 |
+
"Yoast Analytics Plugin has NOT been detected. Please enter your UA code "
|
68 |
+
"manually and then check the sourcode of your website. Make sure that "
|
69 |
+
"Analytics code appears AFTER the opt-out code (which starts with <code>/* "
|
70 |
+
"Google Analytics Opt-Out</code>)."
|
71 |
+
msgstr ""
|
72 |
+
"Das Yoast Analytics Plugin wurde nicht gefunden. Bitte geben Sie Ihren UA-"
|
73 |
+
"Code manuell ein und prüfen Sie den Quellcode Ihrer Website. Stellen Sie "
|
74 |
+
"sicher, dass der Analytics Code NACH dem Opt-Out-Code eingebunden wird. Der "
|
75 |
+
"Opt-Out-Code beginnt mit <code>/* Google Analytics Opt-Out</code>."
|
76 |
+
|
77 |
+
#: ../classes/shortcodes.php:49
|
78 |
+
msgid "Click here to opt out."
|
79 |
+
msgstr "Zum Opt-Out hier klicken."
|
80 |
+
|
81 |
+
#: ../classes/shortcodes.php:55
|
82 |
+
msgid "No UA-Code has been entered. Please ask the admin to solve this issue!"
|
83 |
+
msgstr ""
|
84 |
+
"Es wurde kein UA-Code eingegeben. Bitte Fragen Sie beim Administrator nach "
|
85 |
+
"um dieses Problem zu beheben!"
|
languages/gaoo.mo
ADDED
Binary file
|
languages/gaoo.po
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Google Analytics Opt-Out\n"
|
4 |
+
"POT-Creation-Date: 2013-11-07 16:04+0100\n"
|
5 |
+
"PO-Revision-Date: 2013-11-07 16:04+0100\n"
|
6 |
+
"Last-Translator: WP-Buddy <info@wp-buddy.com>\n"
|
7 |
+
"Language-Team: \n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"X-Generator: Poedit 1.5.7\n"
|
12 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
|
13 |
+
"_n_noop:1,2;_c;_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;"
|
14 |
+
"esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
|
15 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
+
"X-Poedit-Basepath: .\n"
|
17 |
+
"X-Poedit-SearchPath-0: ..\n"
|
18 |
+
|
19 |
+
#: ../classes/admin.php:11
|
20 |
+
msgid ""
|
21 |
+
"To use the Google Analytics Opt-Out Plugin please enter an UA-Code on the "
|
22 |
+
"settings page."
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
#: ../classes/admin.php:30
|
26 |
+
msgid "Settings"
|
27 |
+
msgstr ""
|
28 |
+
|
29 |
+
#: ../classes/admin.php:31
|
30 |
+
msgid "More by WP-Buddy"
|
31 |
+
msgstr ""
|
32 |
+
|
33 |
+
#: ../classes/scripts.php:25
|
34 |
+
msgid ""
|
35 |
+
"Thanks. We have set a cookie so that Google Analytics data collection will "
|
36 |
+
"be disabled on your next visit."
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: ../classes/settings.php:9 ../classes/settings.php:56
|
40 |
+
msgid "Analytics Opt-Out"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: ../classes/settings.php:25
|
44 |
+
msgid "Google Analaytics Opt-Out"
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: ../classes/settings.php:58
|
48 |
+
msgid "Use Yoast Analytics Settings"
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: ../classes/settings.php:61
|
52 |
+
msgid "UA-Code"
|
53 |
+
msgstr ""
|
54 |
+
|
55 |
+
#: ../classes/settings.php:91
|
56 |
+
msgid "Yoast Analytics Plugin has been detected."
|
57 |
+
msgstr ""
|
58 |
+
|
59 |
+
#: ../classes/settings.php:94
|
60 |
+
msgid ""
|
61 |
+
"Yoast Analytics Plugin has NOT been detected. Please enter your UA code "
|
62 |
+
"manually and then check the sourcode of your website. Make sure that "
|
63 |
+
"Analytics code appears AFTER the opt-out code (which starts with <code>/* "
|
64 |
+
"Google Analytics Opt-Out</code>)."
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#: ../classes/shortcodes.php:49
|
68 |
+
msgid "Click here to opt out."
|
69 |
+
msgstr ""
|
70 |
+
|
71 |
+
#: ../classes/shortcodes.php:55
|
72 |
+
msgid "No UA-Code has been entered. Please ask the admin to solve this issue!"
|
73 |
+
msgstr ""
|
readme.txt
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Google Analytics Opt-Out ===
|
2 |
+
Contributors: wp-buddy
|
3 |
+
Donate link: http://wp-buddy.com/products/plugins/google-analytics-opt-out
|
4 |
+
Tags: google analytics, analytics, analytics opt-out, analytics opt out
|
5 |
+
Version: 0.1
|
6 |
+
Requires at least: 3.7
|
7 |
+
Stable tag: 0.1
|
8 |
+
Tested up to: 3.8
|
9 |
+
License: GPLv2
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
|
12 |
+
Provides an Opt-Out functionality for Google Analytics
|
13 |
+
|
14 |
+
== Description ==
|
15 |
+
|
16 |
+
This plugin provides an Opt-Out functionality for Google Analytics by setting a cookie that prevents analytics.js to collect data.
|
17 |
+
|
18 |
+
Works perfectly together with the [Yoast Analytics Plugin](http://wordpress.org/plugins/google-analytics-for-wordpress/ "Yoast Analytics Plugin").
|
19 |
+
|
20 |
+
== Installation ==
|
21 |
+
|
22 |
+
* Install and activate the plugin via your WordPress Administration panel
|
23 |
+
* Go the "Settings" -> "Analytics Opt Out" and enter your UA-code (you don't need this step if Yoasts Analytics plugin is active)
|
24 |
+
*
|
25 |
+
* IMPORTANT: Check the sourcecode of your website and make sure that the Analytics code follows AFTER the opt-out code. Otherwise the Opt-Out feature will not work.
|
26 |
+
* Read the FAQ for more information.
|
27 |
+
|
28 |
+
== Frequently Asked Questions ==
|
29 |
+
|
30 |
+
= The opt-out code appears AFTER the Analytics code. What can I do? =
|
31 |
+
|
32 |
+
Use Yoasts Analytics plugin OR add the code manually:
|
33 |
+
|
34 |
+
add this code to your themes functions.php:
|
35 |
+
`<?php
|
36 |
+
// This stops the plugin to integrate the JS into the header
|
37 |
+
function my_gaoo_stop_head(){
|
38 |
+
return true;
|
39 |
+
}
|
40 |
+
add_filter('gaoo_stop_head', 'my_gaoo_stop_head');
|
41 |
+
?>`
|
42 |
+
|
43 |
+
Then open your themes header.php and add the following code BEFORE your Analytics code AND between `<head>` and `</head>`:
|
44 |
+
`<?php
|
45 |
+
if ( function_exists( 'gaoo_js' ) ) {
|
46 |
+
// echos out the Javascript
|
47 |
+
gaoo_js();
|
48 |
+
}
|
49 |
+
?>`
|
50 |
+
|
51 |
+
|
52 |
+
== Screenshots ==
|
53 |
+
|
54 |
+
1. The Opt-Out link can be added with this little button (shortcode)
|
55 |
+
|
56 |
+
2. This is how the code looks like
|
57 |
+
|
58 |
+
3. This is the settings page
|
59 |
+
|
60 |
+
== Changelog ==
|
61 |
+
|
62 |
+
= 0.1 =
|
63 |
+
* The first version
|
64 |
+
|
65 |
+
== Upgrade Notice ==
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
screenshot-3.png
ADDED
Binary file
|