Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alfonso100/a735c77ba21786b936c1a34ab889832d to your computer and use it in GitHub Desktop.
Save alfonso100/a735c77ba21786b936c1a34ab889832d to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: WP Rocket | Remove Post URLs from purge based on strings
* Description: Removes URLs from WP Rocket’s automatic cache purging based on a partial string match.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
*/
namespace WP_Rocket\Helpers\cache\no_purge_urls_string;
// Standard plugin security, keep this line in place.
defined( 'ABSPATH' ) or die();
/**
* Exclude URLs WP Rocket’s automatic cache purgin based on string.
*
* @param array $urls Array with URLs to be purged
* @return array Modified array with URLs to be purged
*/
function disable_cache_clearing_files( $urls ){
$urls = array_filter($urls, function($value) {
return strpos($value, 'elementor_library') === false;
});
return $urls;
}
add_filter( 'rocket_post_purge_urls', __NAMESPACE__ . '\disable_cache_clearing_files');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment