Skip to content

Instantly share code, notes, and snippets.

@lukapaunovic
Created October 28, 2025 09:34
Show Gist options
  • Select an option

  • Save lukapaunovic/41a836a40694f220465e985404af706e to your computer and use it in GitHub Desktop.

Select an option

Save lukapaunovic/41a836a40694f220465e985404af706e to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: WP Rocket | Ignore Query Strings
* Description: Define query strings that should use the same set of cache.
* Plugin URI: https://github.com/wp-media/wp-rocket-helpers/cache/wp-rocket-cache-ignore-query-strings
* 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\ignore_query_strings;
defined( 'ABSPATH' ) or die();
/**
* Add new ignored parameters.
*/
function define_ignored_parameters( array $params ) {
// tvoji dodatni:
$params['utm_campagin'] = 1;
$params['campaign_id'] = 1;
$params['ad_id'] = 1;
$params['media_type'] = 1;
$params['brid'] = 1;
// KRITIČNO: uključi ignorisanje i za utm_source
$params['utm_source'] = 1;
return $params;
}
add_filter( 'rocket_cache_ignored_parameters', __NAMESPACE__ . '\define_ignored_parameters', PHP_INT_MAX );
/**
* Flush WP Rocket rules on activation.
*/
function flush_wp_rocket() {
if ( function_exists( 'rocket_generate_config_file' ) ) {
rocket_generate_config_file();
}
}
register_activation_hook( __FILE__, __NAMESPACE__ . '\flush_wp_rocket' );
/**
* On deactivate, remove filter and flush config/rules.
*/
function deactivate() {
remove_filter( 'rocket_cache_ignored_parameters', __NAMESPACE__ . '\define_ignored_parameters' );
flush_wp_rocket();
}
register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment