Skip to content

Commit

Permalink
Flush cache on job listing post meta updates
Browse files Browse the repository at this point in the history
  • Loading branch information
yscik committed Jan 12, 2024
1 parent 7e6ce09 commit 8636606
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions includes/class-wp-job-manager-cache-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class WP_Job_Manager_Cache_Helper {
*/
public static function init() {
add_action( 'save_post', [ __CLASS__, 'flush_get_job_listings_cache' ] );
add_action( 'update_post_meta', [ __CLASS__, 'maybe_flush_get_job_listings_cache_on_meta_update' ], 10, 2 );
add_action( 'delete_post', [ __CLASS__, 'flush_get_job_listings_cache' ] );
add_action( 'trash_post', [ __CLASS__, 'flush_get_job_listings_cache' ] );
add_action( 'job_manager_my_job_do_action', [ __CLASS__, 'job_manager_my_job_do_action' ] );
Expand All @@ -43,6 +44,16 @@ public static function flush_get_job_listings_cache( $post_id ) {
}
}

/**
* Flush the cache on updates to job listing meta.
*
* @param int $meta_id
* @param int $post_id
*/
public static function maybe_flush_get_job_listings_cache_on_meta_update( $meta_id, $post_id ) {
self::flush_get_job_listings_cache( $post_id );
}

/**
* Refreshes the Job Listing cache when performing actions on it.
*
Expand Down

0 comments on commit 8636606

Please sign in to comment.