after-kubio-activation.php
2 months ago
allow-kubio-blog-override.php
2 years ago
cache-plugins.php
4 years ago
default-editor-overlay.php
1 year ago
dismissable-notice.php
1 month ago
gutenerg-plugin-check.php
1 year ago
image-size-auto-fix.php
1 year ago
kubio-fresh-site.php
2 years ago
post-insert.php
2 months ago
register-meta-fields.php
3 years ago
requirements-notices.php
1 year ago
site-urls.php
1 year ago
starter-sites-feature.php
1 year ago
svg-kses.php
1 year ago
wp-import.php
1 month ago
cache-plugins.php
46 lines
| 1 | <?php |
| 2 | |
| 3 | use Kubio\Core\Utils; |
| 4 | |
| 5 | function kubio_clean_cache_plugins( $post_id, $post, $update ) { |
| 6 | |
| 7 | $post_types = array( 'page', 'post', 'wp_template', 'wp_template_part', kubio_global_data_post_type() ); |
| 8 | |
| 9 | if ( ! $update || $post->post_status !== 'publish' || ! in_array( $post->post_type, $post_types ) ) { |
| 10 | return; |
| 11 | } |
| 12 | |
| 13 | try { |
| 14 | |
| 15 | // WP Super Cache |
| 16 | if ( Utils::hasEnoughRemainingTime( 15 ) ) { |
| 17 | if ( function_exists( 'wp_cache_clean_cache' ) ) { |
| 18 | global $file_prefix; |
| 19 | $prefix = ''; |
| 20 | if ( $file_prefix ) { |
| 21 | $prefix = $file_prefix; |
| 22 | } |
| 23 | wp_cache_clean_cache( $prefix, true ); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | // Autoptimize |
| 28 | if ( Utils::hasEnoughRemainingTime( 15 ) ) { |
| 29 | if ( class_exists( 'autoptimizeCache' ) && method_exists( autoptimizeCache::class, 'clearall' ) ) { |
| 30 | autoptimizeCache::clearall(); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | // W3 Total Cache |
| 35 | if ( Utils::hasEnoughRemainingTime( 15 ) ) { |
| 36 | if ( function_exists( 'w3tc_flush_all' ) ) { |
| 37 | w3tc_flush_all(); |
| 38 | } |
| 39 | } |
| 40 | } catch ( \Exception $e ) { |
| 41 | |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | add_action( 'wp_after_insert_post', 'kubio_clean_cache_plugins', 10, 3 ); |
| 46 |