Skip to content

Instantly share code, notes, and snippets.

Rémy Perona Tabrisrp

Block or report user

Report or block Tabrisrp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View custom-exclude.php
// Exclude page from cache but keep optimizations.
add_action( 'wp_rocket_loaded', function() {
// Exclude post type with ID = 1.
if ( is_single(1) ) {
add_filter( 'do_rocket_generate_caching_files', '__return_false' );
}
} );
@Tabrisrp
Tabrisrp / clean-domain-post-publish.php
Created Nov 30, 2018
Clean domain on post publish
View clean-domain-post-publish.php
add_action( 'wp_rocket_loaded', function() {
add_action( 'clean_post_cache', function( $post_id ) {
rocket_clean_domain();
} );
} );
View remove-powered-by.php
add_filter( 'rocket_htaccess_files_match', function( $rules ) {
$rules = '<IfModule mod_alias.c>' . PHP_EOL;
$rules .= '<FilesMatch "\.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$">' . PHP_EOL;
$rules .= '<IfModule mod_headers.c>' . PHP_EOL;
$rules .= 'Header unset Pragma' . PHP_EOL;
$rules .= 'Header append Cache-Control "public"' . PHP_EOL;
$rules .= 'Header unset Last-Modified' . PHP_EOL;
$rules .= '</IfModule>' . PHP_EOL;
$rules .= '</FilesMatch>' . PHP_EOL . PHP_EOL;
$rules .= '<FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">' . PHP_EOL;
@Tabrisrp
Tabrisrp / mobile-cache-file-tablet.php
Created Nov 8, 2018
Serve mobile cache files to tablet
View mobile-cache-file-tablet.php
add_filter( 'rocket_cache_mobile_files_tablet', function( $version ) {
return 'mobile';
} );
@Tabrisrp
Tabrisrp / rocket-root-path-rewrite.php
Created Nov 1, 2018
Change default root for path rewrite
View rocket-root-path-rewrite.php
add_filter( 'rocket_min_documentRoot', function( $document_root ) {
return ABSPATH;
} );
@Tabrisrp
Tabrisrp / preload-cookies.php
Created Oct 29, 2018
Preload with mandatory/dynamic cookies
View preload-cookies.php
add_filter( 'rocket_partial_preload_url_request_args', 'rocket_add_cookie_preload' );
add_filter( 'rocket_preload_url_request_args', 'rocket_add_cookie_preload' );
function rocket_add_cookie_preload( $args ) {
$cookies = [
new WP_Http_Cookie(
[
'name' => 'cookie_notice_accepted',
'value' => 'true',
] ),
View wc-marketplace-fix.php
<?php
defined( 'ABSPATH' ) || die();
add_action( 'wp_rocket_loaded', function() {
remove_filter( 'delete_transient_wc_products_onsale', 'wp_suspend_cache_invalidation' );
});
View remove_polylang_mandatory_cookie.php
@Tabrisrp
Tabrisrp / remove-wpr-admin-bar-menu.php
Last active Mar 8, 2019
Remove WP Rocket Admin Bar Menu
View remove-wpr-admin-bar-menu.php
add_action( 'wp_rocket_loaded', function() {
remove_action( 'admin_bar_menu', 'rocket_admin_bar', PHP_INT_MAX );
} );
View remove_acs_mandatory_cookies.php
<?php
function rocket_remove_acs_mandatory_cookies( $cookies ) {
$cookies = array_flip( $cookies );
unset( $cookies['aelia_cs_selected_currency'] );
unset( $cookies['aelia_customer_country' );
return array_flip( $cookies );
}
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_aelia_currencyswitcher_mandatory_cookie', 11 );
You can’t perform that action at this time.