frontity / wp-plugins

» Frontity - Create amazing sites using WordPress & React

Home Page:https://frontity.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow removing style/scripts filters

stevygee opened this issue · comments

I just tried to remove the filter frontity_headtags_result in an external plugin, in order for scripts and styles to appear in head_tags. However, I couldn't access the instance of Frontity_Headtags_Filters, since it isn't stored anywhere.

I was ultimately successful by using a function from https://github.com/herewithme/wp-filters-extras:

function remove_frontity_filters() {
	/* Disable filtering of scripts/styles in Frontity REST API plugin */
	remove_filters_for_anonymous_class( 'frontity_headtags_result', 'Frontity_Headtags_Filters', 'filter_javascript', 10 );
	remove_filters_for_anonymous_class( 'frontity_headtags_result', 'Frontity_Headtags_Filters', 'filter_styles', 10 );
}
add_action( 'init', 'remove_frontity_filters', 999 );

Please make this easier to do :)

This also seems to work:

function remove_frontity_filters() {
	/* Disable filtering of scripts/styles in Frontity REST API plugin */
	remove_all_filters( 'frontity_headtags_result', 10 );
}
add_action( 'init', 'remove_frontity_filters', 999 );

Oh, nice, good to know! Thanks for the heads up @stevygee. We will take it into account when we start working on the main Frontity WordPress plugin, thanks 🙂

Feel free to re-open if you need anything else.