AHSC_Comments.php
5 months ago
AHSC_Deferer.php
5 months ago
AHSC_Plugins.php
5 months ago
AHSC_PostType.php
3 days ago
AHSC_Terms.php
3 days ago
AHSC_Themes.php
5 months ago
AHSC_Deferer.php
44 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | if ( ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() || defined('DOING_AJAX') && DOING_AJAX) || |
| 6 | (defined('REST_REQUEST') && REST_REQUEST) || true === wp_is_json_request() || |
| 7 | (isset( $_SERVER['REQUEST_URI'] ) && strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), trailingslashit( rest_get_url_prefix() ) ) !== false) ) { |
| 8 | |
| 9 | add_action( 'init', 'ahsc_deferred_purge' , 200, 0 ); |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Fires after a post type has been updated, and the term cache has been cleaned. |
| 14 | * |
| 15 | * @see https://developer.wordpress.org/reference/hooks/post_updated/ |
| 16 | * or |
| 17 | * @see https://github.com/WordPress/WordPress/blob/master/wp-includes/post.php |
| 18 | * |
| 19 | * param int $post_ID Post ID. |
| 20 | * param WP_Post $post_after Post object following the update. |
| 21 | * param WP_Post $post_before Post object before the update. |
| 22 | * |
| 23 | * @return void |
| 24 | */ |
| 25 | function ahsc_deferred_purge() { |
| 26 | $cleaner =new \ArubaSPA\HiSpeedCache\Purger\WpPurger(); |
| 27 | $cleaner->setPurger( AHSC_PURGER ); |
| 28 | /** |
| 29 | * I check whether the cleaning transient is present in case. I remove it and clear the entire proxy cache. |
| 30 | */ |
| 31 | $do_purge = ahsc_has_transient( 'ahsc_do_purge_deferred' ); |
| 32 | if ( $do_purge ) { |
| 33 | /** |
| 34 | * I clear the entire proxy cache. |
| 35 | */ |
| 36 | if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')){ |
| 37 | // Logger. |
| 38 | AHSC_log( __NAMESPACE__ . '::' . __FUNCTION__, 'debug' ); |
| 39 | // Logger. |
| 40 | } |
| 41 | $cleaner->purgeAll(); |
| 42 | ahsc_delete_transient( 'ahsc_do_purge_deferred' ); |
| 43 | } |
| 44 | } |