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