Created
November 21, 2013 12:32
-
-
Save tbartels/7580798 to your computer and use it in GitHub Desktop.
Adjust google-analytics-for-wordpress by Yoast to clean up magic quotes and allow for a custom script that correctly writes Javascript so alternate tracking codes will validate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Plugin Name: Google Analytics for Wordpress Slashes Fix | |
Description: Strip slashes on the GAforWP plugin by Yoast to correctly avoid excess/infinite magic quotes. | |
Version: 0.1.0 | |
Author: Thomas Bartels <<a href="mailto:[email protected]">[email protected]</a>> | |
This plugin fixes the options for Yoast's 'google-analytics-for-wordpress' plugin | |
allowing for more complex content to be used in the form fields. Specifically it | |
will now be possible to put Javascript in the `gajsurl` field in order to use the | |
Demographics tracking code from Google Analytics. Once this plugin is installed | |
and enabled select the 'Host ga.js locally' option and enter (with quotes!!): | |
'+('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js | |
as the URL for the ga.js file. | |
*/ | |
if ( class_exists( "GA_Admin" ) ) { | |
global $ga_admin; | |
function fix_ga4wp_slashes( $new, $old="" ) { | |
return stripslashes_deep( $new ); | |
} | |
add_filter( "pre_update_option_{$ga_admin->optionname}", "fix_ga4wp_slashes", 10, 2 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment