Remove cache when theme options are saved
<?php
function clear_wprocket_cache() {
$screen = get_current_screen();
if (strpos($screen->id, "theme-general-settings") == true) {
if (function_exists('rocket_clean_domain')) {
rocket_clean_domain();
$options = get_option('wp_rocket_settings');
$options['minify_css_key'] = rand(1, 99999999999);
$options['minify_js_key'] = rand(1, 99999999999);
remove_all_filters('update_option_' . 'wp_rocket_settings');
update_option('wp_rocket_settings', $options);
}
if (function_exists('run_rocket_sitemap_preload')) {
run_rocket_sitemap_preload();
}
}
}
add_action('acf/save_post', 'clear_wprocket_cache', 20);
add_filter('rocket_exclude_defer_js', function ($excluded_files) {
$excluded_files[] = '/cookieconsent2/';
return $excluded_files;
});