I am using a plugin called “syntaxhighlighter”.
I know not to ask for plugin specific questions but rather how to filter out action added to the wp_head / wp_footer conditionally…
This is a part of the plugin script:
// Outputting SyntaxHighlighter's JS and CSS
add_action( 'wp_head', array( $this, 'output_header_placeholder' ), 15 );
add_action( 'wp_footer', array( $this, 'maybe_output_scripts' ), 15 );
Now, i would like to add a filter that says:
if(is_home() || is_category()) {
// REMOVE THOSE SCRIPS
}
.
I dont want to change that plugin code becouse i would have
to remmember to do it again when it updates…
How can i filter those actions out when needed?
You can try this (untested):
to remove these action hooks conditionally with template tags. We use the
wp_head
action with the default priority10
.You can use other hooks but they must fire earlier than
wp_head
with priority15
and after the$SyntaxHighlighter
object creation via the init hook.You must also make sure that your template tags, you want to use in your conditional checks, are available in the hook you choose.