Skip to content

Instantly share code, notes, and snippets.

View Tabrisrp's full-sized avatar

Rémy Perona Tabrisrp

View GitHub Profile
<?php
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
/**
* Plugin Name: WP Rocket | Fix 404 error on cached page
* Description: Fix 404 error on cached page.
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
<?php
/**
* Plugin Name: Rocket CDN exe file
* Description: Use the CDN URL for exe files.
* Author: WP Rocket team
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
// Basic security, prevents file from being loaded directly.
<?php
/**
* Plugin Name: WP Rocket exclude dynamic CSS
* Description: Exclude dynamic CSS from static save
* Author: WP Rocket team
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
// Basic security, prevents file from being loaded directly.
<?php
/**
* Plugin Name: WP Rocket exclude dynamic CSS
* Description: Exclude dynamic CSS from static save
* Author: WP Rocket team
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
// Basic security, prevents file from being loaded directly.
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
<?php
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
/**
* Plugin Name: WP Rocket | LazyLoad Mobile
* Description: Enable LazyLoad only for mobile
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
<?php
function wp_rocket_add_images( $file_types ) {
$file_types[] = 'jpg';
$file_types[] = 'gif';
$file_types[] = 'png';
return $file_types;
}
add_filter( 'rocket_cdn_custom_filetypes', 'wp_rocket_add_images' );
<?php
add_filter('rocket_htaccess_mod_expires', 'wp_rocket_remove_html_expire_dreampress');
/**
* Remove expiration on HTML to prevent issue with Varnish cache
*
* @param string $rules htaccess rules.
* @return Updated htaccess rules
*/
function wp_rocket_remove_html_expire_dreampress( $rules ) {
<?php
function rocket_disable_rewrite_amp() {
if ( defined( 'AMP_QUERY_VAR' ) && function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
// this filter is documented in inc/front/protocol.php
$do_rocket_protocol_rewrite = apply_filters( 'do_rocket_protocol_rewrite', false );
if ( ( get_rocket_option( 'do_cloudflare', 0 ) && get_rocket_option( 'cloudflare_protocol_rewrite', 0 ) || $do_rocket_protocol_rewrite ) ) {
remove_filter( 'rocket_buffer', '__rocket_protocol_rewrite', PHP_INT_MAX );
remove_filter( 'wp_calculate_image_srcset', '__rocket_protocol_rewrite_srcset', PHP_INT_MAX );
<?php
add_filter( 'rocket_cache_busting_filename', 'wp_rocket_filter_cache_busting_filename' );
function wp_rocket_filter_cache_busting_filename( $filename ) {
$filename = str_replace( '../', '', $filename );
return $filename;
}