diff --git a/c3-cloudfront-clear-cache.php b/c3-cloudfront-clear-cache.php index 79bbda81..5aa4d0f3 100644 --- a/c3-cloudfront-clear-cache.php +++ b/c3-cloudfront-clear-cache.php @@ -1,7 +1,7 @@ $url ) { $invalidation_batch->put_invalidation_path( $url ); } + $archive_links = $this->post->get_the_post_type_archive_links(); + foreach ( $archive_links as $key => $url ) { + $invalidation_batch->put_invalidation_path( $url ); + } $invalidation_batch->apply_invalidation_item_filter( $post ); return $invalidation_batch; } diff --git a/classes/WP/Post.php b/classes/WP/Post.php index 7d8d3ef4..b4403c0c 100644 --- a/classes/WP/Post.php +++ b/classes/WP/Post.php @@ -93,4 +93,24 @@ public function get_the_post_term_links() { return $links; } + /** + * Load the post's term links + * + * @throws \WP_Error If no post provided, should throw it. + */ + public function get_the_post_type_archive_links() { + if ( ! $this->post ) { + throw new \WP_Error( 'Post is required' ); + } + $post = $this->post; + $url = $this->parse_url( get_post_type_archive_link( $post->post_type ) ); + $home_url = $this->parse_url( home_url() ); + + $links = array(); + if ( trailingslashit( $home_url ) !== $url ) { + $links[] = $url . '*'; + } + + return $links; + } } diff --git a/readme.txt b/readme.txt index 3c0cfc78..7bd007c3 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: amimotoami,hideokamoto,megumithemes,wokamoto,miyauchi,hnle,bartosz Donate link: http://wp-kyoto.net/ Tags: AWS,CDN,CloudFront Requires at least: 4.9.0 -Tested up to: 5.9.3 -Stable tag: 6.1.3 +Tested up to: 6.0.1 +Stable tag: 6.1.4 License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -110,6 +110,9 @@ add_filter( 'c3_select_aws_sdk', function() { == Changelog == +== 6.1.4 == +* [Update] Support post_type_archive_link + == 6.1.3 == * [Fix] Lost filter c3_invalidation_items From v6.0.0