I'm trying to remove the statcounter script (which I have in footer) from one page only on a wordpress site so it wouldn't count that page and specifically because of it's hidden element.
I've looked into the plugin php but it doesn't register or enqueue any scripts so I don't know what function to use. Below is a fragment from its php:
$sc_position = get_option(key_sc_position);
if ($sc_position=="header") {
add_action('wp_head', 'add_statcounter');
} else {
add_action('wp_footer', 'add_statcounter');
}
// The guts of the StatCounter script
function add_statcounter() {
global $user_level;
$sc_project = get_option(key_sc_project);
$sc_security = get_option(key_sc_security);
$sc_invisible = 0;
$sc_invisible = get_option('sc_invisible');
if (
( $sc_project > 0 )
) {
?>
<!-- Start of StatCounter Code -->
<script>
<!--
var sc_project=<?php echo $sc_project; ?>;
var sc_security="<?php echo $sc_security; ?>";
<?php
if($sc_invisible==1) {
echo " var sc_invisible=1;\n";
}
define('HTTPS', isset($_SERVER['HTTPS']) && filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN));
$protocol = defined('HTTPS') ? "https:" : "http:";
?>
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
//-->
document.write("<sc"+"ript src='" +scJsHost +"statcounter.com/counter/counter.js'></"+"script>");
</script>
<!-- End of StatCounter Code -->
<?php
}
}
I've tried using:
function no_stat_counter_scripts() {
if(!is_page(XXX)){
global $user_level;
remove_action( 'wp_head', array($user_level, 'add_statcounter') );
remove_action( 'wp_footer', array($user_level, 'add_statcounter') );
}
}
add_action( 'wp_footer', 'no_stat_counter_scripts' );
add_action( 'wp_head', 'no_stat_counter_scripts');
but it's not working, anyone has an idea how I can accomplish it?