Move cache purge hooks to the top

Some cache operations might affect how new caches are generated, so calling this early is better.
This commit is contained in:
Tetrakern 2023-08-06 02:50:54 +02:00
parent a28335cf06
commit 85633921f1
2 changed files with 8 additions and 8 deletions

View File

@ -168,12 +168,12 @@ Fires after `wp_body_open()` in the `<body>` right before the inline storage ele
---
### `do_action( 'fictioneer_cache_purge_all' )`
Fires after all caches from known plugins have been purged in the `fictioneer_purge_all_caches()` function, normally triggered by a site-wide update. You can use this hook to purge additional caches.
Fires *before* all caches from known plugins have been purged in the `fictioneer_purge_all_caches()` function, normally triggered by a site-wide update. You can use this hook to purge additional caches.
---
### `do_action( 'fictioneer_cache_purge_post', $post_id )`
Fires after a post cache from known plugins has been purged in the `fictioneer_purge_post_cache( $post_id )` function, normally triggered by a specific post or page update. You can use this hook to purge additional caches.
Fires *before* a post cache from known plugins has been purged in the `fictioneer_purge_post_cache( $post_id )` function, normally triggered by a specific post or page update. You can use this hook to purge additional caches.
**Parameter:**
* $post_id (int) The ID of the post/page to purge the cache for.

View File

@ -63,6 +63,9 @@ if ( ! function_exists( 'fictioneer_purge_all_caches' ) ) {
// WordPress Query Cache
wp_cache_flush();
// Hook for additional purges
do_action( 'fictioneer_cache_purge_all' );
// LiteSpeed Cache
if ( class_exists( '\LiteSpeed\Purge' ) ) {
do_action( 'litespeed_purge_all' );
@ -83,9 +86,6 @@ if ( ! function_exists( 'fictioneer_purge_all_caches' ) ) {
if ( function_exists( 'w3tc_flush_all' ) ) {
w3tc_flush_all();
}
// Hook for additional purges
do_action( 'fictioneer_cache_purge_all' );
}
}
@ -108,6 +108,9 @@ if ( ! function_exists( 'fictioneer_purge_post_cache' ) ) {
// Abort if...
if ( empty( $post_id ) ) return;
// Hook for additional purges
do_action( 'fictioneer_cache_purge_post', $post_id );
// WordPress Query Cache
clean_post_cache( $post_id );
@ -130,9 +133,6 @@ if ( ! function_exists( 'fictioneer_purge_post_cache' ) ) {
if ( function_exists( 'w3tc_flush_post' ) ) {
w3tc_flush_post( $post_id );
}
// Hook for additional purges
do_action( 'fictioneer_cache_purge_post', $post_id );
}
}