Advertisement
Guest User

wp-rocket-no-cache-auto-purge.php

a guest
Feb 27th, 2020
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.91 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Plugin Name: WP Rocket | Disable Cache Clearing
  4.  * Description: Disables all of WP Rocket’s automatic cache clearing.
  5.  * Plugin URI:  https://github.com/wp-media/wp-rocket-helpers/tree/master/cache/wp-rocket-no-cache-auto-purge/
  6.  * Author:      WP Rocket Support Team
  7.  * Author URI:  http://wp-rocket.me/
  8.  * License:     GNU General Public License v2 or later
  9.  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
  10.  *
  11.  * Copyright SAS WP MEDIA 2018
  12.  */
  13.  
  14. namespace WP_Rocket\Helpers\cache\no_cache_auto_purge;
  15.  
  16. // Standard plugin security, keep this line in place.
  17. defined( 'ABSPATH' ) or die();
  18.  
  19. /**
  20.  * Remove all of WP Rocket's cache purging actions.
  21.  *
  22.  * @author Caspar Hübinger
  23.  */
  24. function remove_purge_hooks() {
  25.  
  26.     // WP core action hooks rocket_clean_domain() gets hooked into.
  27.     $clean_domain_hooks = array(
  28.         // When user changes the theme
  29.         //'switch_theme',
  30.         // When a user is added
  31.         'user_register',
  32.         // When a user is updated
  33.         'profile_update',
  34.         // When a user is deleted
  35.         'deleted_user',
  36.         // When a custom menu is updated
  37.         //'wp_update_nav_menu',
  38.         // When any theme modifications are updated
  39.         //'update_option_theme_mods_' . get_option( 'stylesheet' ),
  40.         // When you change the order of widgets
  41.         //'update_option_sidebars_widgets',
  42.         // When category permalink prefix is update
  43.         //'update_option_category_base',
  44.         // When tag permalink prefix is update
  45.         //'update_option_tag_base',
  46.         // When permalink structure is update
  47.         //'permalink_structure_changed',
  48.         // When a term is created
  49.         'create_term',
  50.         // When a term is updated
  51.         'edited_terms',
  52.         // When a term is deleted
  53.         'delete_term',
  54.         // When a link (post type) is added
  55.         //'add_link',
  56.         // When a link (post type) is updated
  57.         //'edit_link',
  58.         // When a link (post type) is deleted
  59.         //'delete_link',
  60.         // When resulty are saved in the Customizer
  61.         //'customize_save',
  62.         // When Avada theme purges its own cache
  63.         //'avada_clear_dynamic_css_cache',
  64.     );
  65.  
  66.     // WP core action hooks rocket_clean_post() gets hooked into.
  67.     $clean_post_hooks = array(
  68.         // Disables the refreshing of partial cache when content is edited
  69.         'wp_trash_post',
  70.         'delete_post',
  71.         'clean_post_cache',
  72.         'wp_update_comment_count',
  73.     );
  74.  
  75.     // Remove rocket_clean_domain() from core action hooks.
  76.     foreach ( $clean_domain_hooks as $key => $handle ) {
  77.         remove_action( $handle, 'rocket_clean_domain' );
  78.     }
  79.  
  80.     // Remove rocket_clean_post() from core action hooks.
  81.     foreach ( $clean_post_hooks as $key => $handle ) {
  82.         remove_action( $handle, 'rocket_clean_post' );
  83.     }
  84.    
  85.     // Prevent cache purge when a widget is updated.
  86.     remove_filter( 'widget_update_callback' , 'rocket_widget_update_callback' );
  87.    
  88.     // Prevent cache purge when current theme is updated.
  89.     remove_action( 'upgrader_process_complete', 'rocket_clean_cache_theme_update', 10, 2 );
  90. }
  91. add_action( 'wp_rocket_loaded', __NAMESPACE__ . '\remove_purge_hooks' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement