Skip to content

Commit

Permalink
Merge pull request #97 from wokamoto/feature/support_custome_post_typ…
Browse files Browse the repository at this point in the history
…e_archive

Feature/support custome post type archive
  • Loading branch information
wokamoto authored Jul 14, 2022
2 parents b8b2e5a + 7d1ba74 commit d74267b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion c3-cloudfront-clear-cache.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: C3 Cloudfront Cache Controller
* Version: 6.1.3
* Version: 6.1.4
* Plugin URI:https://github.com/amimoto-ami/c3-cloudfront-clear-cache
* Description: Manage CloudFront Cache and provide some fixtures.
* Author: hideokamoto
Expand Down
4 changes: 4 additions & 0 deletions classes/AWS/Invalidation_Batch_Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public function put_post_invalidation_batch( Invalidation_Batch $invalidation_ba
foreach ( $term_links as $key => $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;
}
Expand Down
20 changes: 20 additions & 0 deletions classes/WP/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d74267b

Please sign in to comment.