wp-filters-extras icon indicating copy to clipboard operation
wp-filters-extras copied to clipboard

remove_filters_for_anonymous_class not removing action for extended class

Open Jarrydcrawford opened this issue 12 years ago • 3 comments

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? :)

Jarrydcrawford avatar Feb 07 '13 08:02 Jarrydcrawford

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 );

herewithme avatar Feb 07 '13 09:02 herewithme

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.

Jarrydcrawford avatar Feb 08 '13 01:02 Jarrydcrawford

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 );
    }

herewithme avatar Feb 08 '13 08:02 herewithme