tillkruss / Nginx-FastCGI-Cache

A WordPress plugin that purges Nginx cache zones.
48 stars 25 forks source link

nginx_cache_purge_actions filter is applied too early #13

Closed chesio closed 6 years ago

chesio commented 6 years ago

Hi,

I'm trying to use nginx_cache_purge_actions filter to register additional actions that should flush Nginx cache, but I noticed that this filter is applied right when plugin is loaded, so there's no way how to use this filter from (child) theme.

I understand this filter should be applied early, so one can register actions that are invoked early, but I would say running this filter in after_setup_theme hook should be early enough and would allow to use the filter from within themes.

If you're fine with my suggestion, I can make a pull request.

tillkruss commented 6 years ago

Sure, please go ahead!

chesio commented 6 years ago

I've made a PR. I've added a did_action check to ensure that any purge action registered by the filter that runs before after_setup_theme triggers cache cleaning, so there should be no backwards compatibility issues.