This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'rocket_minify_html_options', 'wp_rocket_minify_inline_js' ); | |
function wp_rocket_minify_inline_js( $options ) { | |
$options['jsMinifier'] = 'rocket_minify_inline_js'; | |
return $options; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user_agent = $_SERVER['HTTP_USER_AGENT']; | |
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'WP-Rocket' ) === false ) { | |
if ( strpos( $_SERVER['HTTP_X_ROCKET'], 'WP-Rocket' ) === false ) { | |
die( 'BAD_UA_XR: ' . ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? htmlspecialchars( $_SERVER['HTTP_USER_AGENT'] ) : 'not set' ) . ' & ' . ( isset( $_SERVER['HTTP_X_ROCKET'] ) ? htmlspecialchars( $_SERVER['HTTP_X_ROCKET'] ) : 'not set' ) ); | |
} | |
$user_agent = $_SERVER['HTTP_X_ROCKET']; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ================================================================================== // | |
// # Document on Ready | |
// # Document on Resize | |
// # Document on Scroll | |
// # Document on Load | |
// # Header Settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wp_rocket_cpcss_exclude_post_type( $excluded_post_types ) { | |
$excluded_post_types[] = 'page'; | |
return $excluded_post_types; | |
} | |
add_filter( 'rocket_cpcss_excluded_post_types', 'wp_rocket_cpcss_exclude_post_type' ); | |
function wp_rocket_cpcss_exclude_taxonomy( $excluded_taxonomies ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined( 'ABSPATH' ) or die(); | |
/** | |
* Plugin Name: WP Rocket | Fix Polylang conflict | |
* Description: Prevent warning when adding a new translation with Polylang | |
* Author: WP Rocket Support Team | |
* Author URI: https://wp-rocket.me/ | |
* License: GNU General Public License v3 or later | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wp_rocket_clean_domain_polylang( $urls, $lang ) { | |
foreach( $urls as $key => $url ) { | |
if ( empty( $lang ) ) { | |
$urls[ $key ] = parse_url( $url, PHP_URL_HOST ); | |
} else { | |
if ( function_exists( 'PLL' ) ) { | |
$urls[ $key ] = PLL()->links->get_home_url( $lang, true ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wp_rocket_clear_user_cache_logout() { | |
$user = wp_get_current_user(); | |
rocket_clean_user( $user->ID ); | |
} | |
add_action( 'clear_auth_cookie', 'wp_rocket_clear_user_cache_logout' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |