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 | 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 ) {
@Tabrisrp
Tabrisrp / rocket-remove-html-expire.php
Created March 15, 2017 20:09
Remove WP Rocket html expire rule
<?php
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
/**
* Remove expiration on HTML to prevent issue with Varnish cache
*
* @author Remy Perona
*
* @param string $rules htaccess rules.
* @return Updated htaccess 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;
}
@Tabrisrp
Tabrisrp / rocket-cache-feed.php
Last active October 11, 2018 14:59
Allow caching of WP feed by WP Rocket
function wp_rocket_cache_feed( $uri ) {
$feed = '/(.+/)?' . $GLOBALS['wp_rewrite']->feed_base . '/?';
if ( in_array( $feed, $uri ) ) {
$uri = array_flip( $uri );
unset( $uri[ $feed ] );
$uri = array_flip( $uri );
}
return $uri;
}
<?php
/**
* Plugin Name: No cache after logged-in user comment
* Description: Don't use cache after a user made a comment
* 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.