From b33b1d85172c0aa2b94be73db949221c6ad200bc Mon Sep 17 00:00:00 2001 From: Stephen Hartley Date: Wed, 13 Nov 2019 16:54:13 +0000 Subject: [PATCH] Added support for modifying the post authors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For example, if you have most posts created by a single ‘automation’ author you probably don’t want every post purged when any one of them changes, so you could use: ``` add_filter('purgely_post_authors', function ($authors, $post) { return []; }, 10, 2); ``` --- src/classes/surrogate-key-collection.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/classes/surrogate-key-collection.php b/src/classes/surrogate-key-collection.php index 503522a..514ed32 100644 --- a/src/classes/surrogate-key-collection.php +++ b/src/classes/surrogate-key-collection.php @@ -230,11 +230,15 @@ private function _add_key_terms_taxonomy() */ private function _add_key_author($post) { - $author = absint($post->post_author); + $authors = array(absint($post->post_author)); + $authors = apply_filters('purgely_post_authors', $authors, $post); + $key = array(); - if ($author > 0) { - $key[] = 'a-' . absint($author); + foreach ($authors as $author) { + if ($author > 0) { + $key[] = 'a-' . absint($author); + } } return $key;