Skip to content

Commit

Permalink
Limit to specific post types to prevent interfering with other plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
greos committed Mar 15, 2022
1 parent 977fc5a commit 47538e0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions purge-varnish-cache.php
Expand Up @@ -16,8 +16,10 @@ class PostHooks
{
public static function init()
{
// Add action to save post to purge varnish cache
add_action('save_post', [static::class, 'onPostSaveAndUpdate']);
// Add action to save post to purge varnish cache for specific post types.
add_action('save_post_post', [static::class, 'onPostSaveAndUpdate']);
add_action('save_post_page', [static::class, 'onPostSaveAndUpdate']);
add_action('save_post_weekly_issue', [static::class, 'onPostSaveAndUpdate']);

// // Add action to post status transition to purge varnish cache. This may be overkill in some cases. Hence it has been disabled unless you need it.
// add_action('transition_post_status', [static::class, 'onPostStatusTransition'], 10, 3);
Expand Down Expand Up @@ -51,7 +53,7 @@ public static function onPostStatusTransition($newStatus, $oldStatus, $post)
'method' => $purge_method
);

$debug_mode = false;
$debug_mode = true;
$debug_log_file = 'curl_status_log.txt';

// wp_remote_request is used to PURGE or BAN varnish cache
Expand Down

0 comments on commit 47538e0

Please sign in to comment.