wp-filters-extras
wp-filters-extras copied to clipboard
remove_filters_for_anonymous_class not removing action for extended class
The plug-in authors of Shopp have added in-line styles to <head> of the document. They attach it via the class Storefront which extends FlowController. Within the class you have two functions: behaviors (540) and catalogcss (739). See https://gist.github.com/Jarrydcrawford/3cd52271dab887e0bb7a
The function catalogcss sets the CSS, while behaviors sets it via
add_action('wp_print_styles',array($this, 'catalogcss'));
I tried using your seconds example like so
// Remove inline CSS from Shopp
remove_filters_for_anonymous_class( 'wp_print_styles', 'Storefront', 'catalogcss', 999 );
But it seems to do nothing. I'm assuming it has something to do with the extending, but I honestly have no idea. Reckon you could take time out of your busy schedule to see if you can figure it out? :)
Try with correct priority, by default WP set 10
// Remove inline CSS from Shopp
remove_filters_for_anonymous_class( 'wp_print_styles', 'Storefront', 'catalogcss', 10 );
I tried with the new priority and still no effect. I only used 999 to make sure that the action was being registered before I was trying to remove it.
This function must be call after plugin hook registration : Here is the code below (untested) :
add_action('wp', array($this, 'remove_storefront_catalogcss'), 11);
function remove_storefront_catalogcss() {
// Remove inline CSS from Shopp
remove_filters_for_anonymous_class( 'wp_print_styles', 'Storefront', 'catalogcss', 10 );
}