WordPress-Plugin
WordPress-Plugin copied to clipboard
Add filter to allow adding/editing keys within the context of Purgely_Related_Surrogate_Keys
Right now, while it's certainly possible, it can get a bit complicated to set up purging of custom surrogate keys. If I want to purge a key based on a post updating (saving trashing etc), I have to re-hook a number of cases just like the Purgely_Purges classes does.
It would be easier if there was a hook within Purgely_Purges' code path where I could simply see "here is the post being updated." (This would also ensure keys are bundled into as few collections of keys as possible, as opposed to always having to make at least one additional call to Purgely_Purge::purge() with the custom stuff.) This PR adds such a filter to the Purgely_Related_Surrogate_Keys class used to collect keys for purging, and notes it in the readme.
My own use case: I want to set the surrogate key "cpt-my-type" on pages that perform custom aggregation of post type my_type. Then whenever a post of that type is edited, I want the "cpt-my-type" surrogate key purged alongside all the fastly defaults. This PR makes the second part much easier.