3.15.3
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Clear cache when ACF options page is updated.
|
||||
*
|
||||
* @since 2.10.7
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $post_id ACF options page ID is 'options'.
|
||||
*/
|
||||
function rocket_clear_cache_on_acf_options_save( $post_id ) {
|
||||
if ( 'options' === $post_id ) {
|
||||
rocket_clean_domain();
|
||||
}
|
||||
}
|
||||
add_action( 'acf/save_post', 'rocket_clear_cache_on_acf_options_save' );
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'autoptimizeCache' ) ) :
|
||||
/**
|
||||
* Deactivate WP Rocket lazyload if Autoptimize lazyload is enabled
|
||||
*
|
||||
* @since 3.3.4
|
||||
*
|
||||
* @param string $old_value Previous autoptimize option value.
|
||||
* @param string $value New autoptimize option value.
|
||||
* @return void
|
||||
*/
|
||||
function rocket_maybe_deactivate_lazyload( $old_value, $value ) {
|
||||
if ( empty( $old_value['autoptimize_imgopt_checkbox_field_3'] ) && ! empty( $value['autoptimize_imgopt_checkbox_field_3'] ) ) {
|
||||
update_rocket_option( 'lazyload', 0 );
|
||||
}
|
||||
}
|
||||
add_action( 'update_option_autoptimize_imgopt_settings', 'rocket_maybe_deactivate_lazyload', 10, 2 );
|
||||
|
||||
/**
|
||||
* Improvement with Autoptimize: clear the cache when Autoptimize's cache is cleared
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
add_action( 'autoptimize_action_cachepurged', 'rocket_clean_domain' );
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'autoptimizeConfig' ) ) :
|
||||
/**
|
||||
* Deactivate WP Rocket CSS Minification if Autoptimize CSS minification is enabled
|
||||
*
|
||||
* @since 2.9.5
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $old_value Previous autoptimize option value.
|
||||
* @param string $value New autoptimize option value.
|
||||
*/
|
||||
function rocket_maybe_deactivate_minify_css( $old_value, $value ) {
|
||||
if ( $value !== $old_value && 'on' === $value ) {
|
||||
update_rocket_option( 'minify_css', 0 );
|
||||
}
|
||||
}
|
||||
add_action( 'update_option_autoptimize_css', 'rocket_maybe_deactivate_minify_css', 10, 2 );
|
||||
|
||||
/**
|
||||
* Deactivate WP Rocket JS Minification if Autoptimize JS minification is enabled
|
||||
*
|
||||
* @since 2.9.5
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $old_value Previous autoptimize option value.
|
||||
* @param string $value New autoptimize option value.
|
||||
*/
|
||||
function rocket_maybe_deactivate_minify_js( $old_value, $value ) {
|
||||
if ( $value !== $old_value && 'on' === $value ) {
|
||||
update_rocket_option( 'minify_js', 0 );
|
||||
update_rocket_option( 'minify_concatenate_js', 0 );
|
||||
}
|
||||
}
|
||||
add_action( 'update_option_autoptimize_js', 'rocket_maybe_deactivate_minify_js', 10, 2 );
|
||||
|
||||
/**
|
||||
* Deactivate WP Rocket async CSS if Autoptimize async CSS is enabled
|
||||
*
|
||||
* @since 2.10
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $old_value Previous autoptimize option value.
|
||||
* @param string $value New autoptimize option value.
|
||||
*/
|
||||
function rocket_maybe_deactivate_css_defer( $old_value, $value ) {
|
||||
if ( $value !== $old_value && 'on' === $value ) {
|
||||
update_rocket_option( 'autoptimize_css_defer', 0 );
|
||||
}
|
||||
}
|
||||
add_action( 'update_option_autoptimize_css_defer', 'rocket_maybe_deactivate_css_defer', 10, 2 );
|
||||
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Disable WP Rocket minification options when activating Autoptimize and values are already in the database.
|
||||
*
|
||||
* @since 2.9.5
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_activate_autoptimize() {
|
||||
if ( 'on' === get_option( 'autoptimize_css' ) ) {
|
||||
update_rocket_option( 'minify_css', 0 );
|
||||
}
|
||||
|
||||
if ( 'on' === get_option( 'autoptimize_js' ) ) {
|
||||
update_rocket_option( 'minify_js', 0 );
|
||||
update_rocket_option( 'minify_concatenate_js', 0 );
|
||||
}
|
||||
|
||||
if ( 'on' === get_option( 'autoptimize_css_defer' ) ) {
|
||||
update_rocket_option( 'async_css', 0 );
|
||||
}
|
||||
|
||||
$lazyload = get_option( 'autoptimize_imgopt_settings' );
|
||||
|
||||
if ( ! empty( $lazyload['autoptimize_imgopt_checkbox_field_3'] ) ) {
|
||||
update_rocket_option( 'lazyload', 0 );
|
||||
}
|
||||
}
|
||||
add_action( 'activate_autoptimize/autoptimize.php', 'rocket_activate_autoptimize', 11 );
|
||||
|
||||
/**
|
||||
* Disable WP Rocket lazyload fields if Autoptimize lazyload is enabled
|
||||
*
|
||||
* @since 3.3.4
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function rocket_maybe_disable_lazyload() {
|
||||
$lazyload = get_option( 'autoptimize_imgopt_settings' );
|
||||
|
||||
if ( is_plugin_active( 'autoptimize/autoptimize.php' ) && ! empty( $lazyload['autoptimize_imgopt_checkbox_field_3'] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable WP Rocket CSS minification field if Autoptimize CSS minification is enabled
|
||||
*
|
||||
* @since 2.9.5
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return bool|null True if it is active
|
||||
*/
|
||||
function rocket_maybe_disable_minify_css() {
|
||||
if ( is_plugin_active( 'autoptimize/autoptimize.php' ) && 'on' === get_option( 'autoptimize_css' ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable WP Rocket JS minification field if Autoptimize JS minification is enabled
|
||||
*
|
||||
* @since 2.9.5
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return bool|null True if it is active
|
||||
*/
|
||||
function rocket_maybe_disable_minify_js() {
|
||||
if ( is_plugin_active( 'autoptimize/autoptimize.php' ) && 'on' === get_option( 'autoptimize_js' ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable WP Rocket async CSS field if Autoptimize async CSS is enabled
|
||||
*
|
||||
* @since 2.10
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @return bool|null True if it is active
|
||||
*/
|
||||
function rocket_maybe_disable_async_css() {
|
||||
if ( is_plugin_active( 'autoptimize/autoptimize.php' ) && 'on' === get_option( 'autoptimize_css_defer' ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'BuddyPress' ) ) :
|
||||
/**
|
||||
* Conflict with BuddyPress: don't apply LazyLoad on BuddyPress profil pages & group creation
|
||||
*
|
||||
* @since 2.8.15 Improve checks for user profile & disable for cover images
|
||||
* @since 2.6.9
|
||||
*/
|
||||
if ( function_exists( 'bp_is_user_profile' ) ) :
|
||||
/**
|
||||
* Prevent lazyload if on a BuddyPress profil page
|
||||
*
|
||||
* @param Bool $run_filter Do lazyload value.
|
||||
* @return Bool False if on a BuddyPress profil page, initial value otherwise
|
||||
*/
|
||||
function rocket_deactivate_lazyload_on_buddypress_profil_pages( $run_filter ) {
|
||||
if ( bp_is_user_profile() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $run_filter;
|
||||
}
|
||||
add_filter( 'do_rocket_lazyload', 'rocket_deactivate_lazyload_on_buddypress_profil_pages' );
|
||||
add_filter( 'do_rocket_lazyload_iframes', 'rocket_deactivate_lazyload_on_buddypress_profil_pages' );
|
||||
endif;
|
||||
|
||||
if ( function_exists( 'bp_is_group_creation_step' ) && function_exists( 'bp_is_group_admin_screen' ) ) :
|
||||
/**
|
||||
* Prevent lazyload if on a BuddyPress group creation page
|
||||
*
|
||||
* @param Bool $run_filter Do lazyload value.
|
||||
* @return Bool False if on a BuddyPress profil page, initial value otherwise
|
||||
*/
|
||||
function rocket_deactivate_lazyload_on_buddypress_group_pages( $run_filter ) {
|
||||
if ( bp_is_group_creation_step( 'group-avatar' ) || bp_is_group_creation_step( 'group-cover-image' ) || bp_is_group_admin_screen( 'group-avatar' ) || bp_is_group_admin_screen( 'group-cover-image' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $run_filter;
|
||||
}
|
||||
add_filter( 'do_rocket_lazyload', 'rocket_deactivate_lazyload_on_buddypress_group_pages' );
|
||||
add_filter( 'do_rocket_lazyload_iframes', 'rocket_deactivate_lazyload_on_buddypress_group_pages' );
|
||||
endif;
|
||||
endif;
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* Compatibility with Cookie Notice by dFactory.
|
||||
*
|
||||
* @since 2.11.6
|
||||
* @author Arun Basil Lal
|
||||
* @link https://wordpress.org/plugins/cookie-notice/
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'Cookie_Notice' ) ) {
|
||||
// Don't add the WP Rocket rewrite rules to avoid issues.
|
||||
if ( ! class_exists( 'CC4R_options' ) || ! CC4R_options::rewrite_enabled() ) {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 56 );
|
||||
}
|
||||
// Create cache version based on value set in cookie_notice_accepted cookie.
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_get_cookie_notice_cookie' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cookie name set by Cookie Notice plugin.
|
||||
*
|
||||
* @since 2.11.6
|
||||
* @author Arun Basil Lal
|
||||
*
|
||||
* @param array $cookies List of dynamic cookies.
|
||||
* @return array List of dynamic cookies with the Cookie Notice cookie appended.
|
||||
*/
|
||||
function rocket_get_cookie_notice_cookie( $cookies ) {
|
||||
$cookies[] = 'cookie_notice_accepted';
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add dynamic cookie and mandatory cookie when Cookie Notice plugin is activated.
|
||||
*
|
||||
* @since 2.11.6
|
||||
* @author Arun Basil Lal
|
||||
*/
|
||||
function rocket_add_cookie_notice_dynamic_cookie() {
|
||||
// Don't add the WP Rocket rewrite rules to avoid issues.
|
||||
if ( ! class_exists( 'CC4R_options' ) || ! CC4R_options::rewrite_enabled() ) {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 56 );
|
||||
}
|
||||
// Create cache version based on value set in cookie_notice_accepted cookie.
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_get_cookie_notice_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
|
||||
// Clear WP Rocket cache.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'activate_cookie-notice/cookie-notice.php', 'rocket_add_cookie_notice_dynamic_cookie', 11 );
|
||||
|
||||
/**
|
||||
* Remove dynamic cookie when Cookie Notice plugin is deactivated.
|
||||
*
|
||||
* @since 2.11.6
|
||||
* @author Arun Basil Lal
|
||||
*/
|
||||
function rocket_remove_cookie_notice_dynamic_cookie() {
|
||||
if ( ! class_exists( 'CC4R_options' ) || ! CC4R_options::rewrite_enabled() ) {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 56 );
|
||||
}
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_get_cookie_notice_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
|
||||
// Clear WP Rocket cache.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'deactivate_cookie-notice/cookie-notice.php', 'rocket_remove_cookie_notice_dynamic_cookie', 11 );
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with EU Cookie Law
|
||||
* https://wordpress.org/plugins/eu-cookie-law/
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( function_exists( 'eucookie_start' ) ) :
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_eu_cookie_law_mandatory_cookie' );
|
||||
|
||||
/**
|
||||
* Update .htaccess & config files when the "Activate" and "Autoblock" options are turned on
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param Array $old_value Array of previous values.
|
||||
* @param Array $value Array of submitted values.
|
||||
*/
|
||||
function rocket_after_update_eu_cookie_law_options( $old_value, $value ) {
|
||||
if ( ( isset( $old_value['enabled'], $value['enabled'] ) && ( $old_value['enabled'] === $value['enabled'] ) ) && isset( $old_value['autoblock'], $value['autoblock'] ) && $old_value['autoblock'] === $value['autoblock'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Update the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'update_option_peadig_eucookie', 'rocket_after_update_eu_cookie_law_options', 10, 2 );
|
||||
|
||||
// Don't add the WP Rocket rewrite rules to avoid issues.
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 58 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add mandatory cookie when we activate the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_activate_eu_cookie_law() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 58 );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_eu_cookie_law_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_eu-cookie-law/eu-cookie-law.php', 'rocket_activate_eu_cookie_law', 11 );
|
||||
|
||||
/**
|
||||
* Remove mandatory cookie when we deactivate the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_deactivate_eu_cookie_law() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 58 );
|
||||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_eu_cookie_law_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_eu-cookie-law/eu-cookie-law.php', 'rocket_deactivate_eu_cookie_law', 11 );
|
||||
|
||||
/**
|
||||
* Add the EU Cookie Law to the list of mandatory cookies before generating caching files.
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param Array $cookies Array of mandatory cookies.
|
||||
* @return Array Updated array of mandatory cookies
|
||||
*/
|
||||
function rocket_add_eu_cookie_law_mandatory_cookie( $cookies ) {
|
||||
$options = get_option( 'peadig_eucookie' );
|
||||
|
||||
if ( ! empty( $options['enabled'] ) && ! empty( $options['autoblock'] ) ) {
|
||||
$cookies['eu-cookie-law'] = 'euCookie';
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Compatibility with GDPR by Trew Knowledge
|
||||
*
|
||||
* @link https://github.com/trewknowledge/GDPR/
|
||||
* @link https://wordpress.org/plugins/gdpr/
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'GDPR' ) ) {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 60 );
|
||||
// Create cache version based on value set in gdpr[] cookies.
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_get_gdpr_dynamic_cookies' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cookie names set by GDPR plugin
|
||||
*
|
||||
* @since 3.1.4
|
||||
* @author jorditarrida
|
||||
*
|
||||
* @param array $cookies array List of dynamic cookies.
|
||||
* @return array List of dynamic cookies with the GDPR cookie appended
|
||||
*/
|
||||
function rocket_get_gdpr_mandatory_cookies( $cookies ) {
|
||||
$cookies[] = 'allowed_cookies';
|
||||
$cookies[] = 'consent_types';
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cookie names set by GDPR plugin
|
||||
*
|
||||
* @since 3.1.4
|
||||
* @author jorditarrida
|
||||
*
|
||||
* @param array $cookies array List of dynamic cookies.
|
||||
* @return array List of dynamic cookies with the GDPR cookie appended
|
||||
*/
|
||||
function rocket_get_gdpr_dynamic_cookies( $cookies ) {
|
||||
$cookies['gdpr'] = [
|
||||
'allowed_cookies',
|
||||
'consent_types',
|
||||
];
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add dynamic cookie when GDPR plugin is activated
|
||||
*
|
||||
* @since 3.1.4
|
||||
* @author jorditarrida
|
||||
*/
|
||||
function rocket_add_gdpr_mandatory_cookies() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 60 );
|
||||
|
||||
// Create cache version based on value set in GDPR cookies.
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_get_gdpr_dynamic_cookies' );
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
// Clear WP Rocket cache.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'activate_gdpr/gdpr.php', 'rocket_add_gdpr_mandatory_cookies', 11 );
|
||||
|
||||
/**
|
||||
* Remove dynamic cookie when GDPR plugin is deactivated.
|
||||
*
|
||||
* @since 3.1.4
|
||||
* @author jorditarrida
|
||||
*/
|
||||
function rocket_remove_gdpr_mandatory_cookies() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 60 );
|
||||
|
||||
// Delete the dynamic cookie filter.
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_get_gdpr_dynamic_cookies' );
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
// Clear WP Rocket cache.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'deactivate_gdpr/gdpr.php', 'rocket_remove_gdpr_mandatory_cookies', 11 );
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Compatibility with UK Cookie Consent.
|
||||
*
|
||||
* @since 3.2
|
||||
* @author TheZoker
|
||||
* @link https://wordpress.org/plugins/uk-cookie-consent/
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'CTCC_Public' ) ) {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 62 );
|
||||
// Create cache version based on value set in cookie_consent_accepted cookie.
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_get_cookie_uk_consent_cookie' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cookie name set by UK Cookie Consent plugin.
|
||||
*
|
||||
* @since 3.2
|
||||
* @author TheZoker
|
||||
*
|
||||
* @param array $cookies List of dynamic cookies.
|
||||
* @return array List of dynamic cookies with the UK Cookie Consent cookie appended.
|
||||
*/
|
||||
function rocket_get_cookie_uk_consent_cookie( $cookies ) {
|
||||
$cookies[] = 'catAccCookies';
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add dynamic cookie and mandatory cookie when UK Cookie Consent plugin is activated.
|
||||
*
|
||||
* @since 3.2
|
||||
* @author TheZoker
|
||||
*/
|
||||
function rocket_add_uk_cookie_consent_dynamic_cookie() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 62 );
|
||||
// Create cache version based on value set in cookie_consent_accepted cookie.
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_get_cookie_uk_consent_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
|
||||
// Clear WP Rocket cache.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'activate_uk-cookie-consent/uk-cookie-consent.php', 'rocket_add_uk_cookie_consent_dynamic_cookie', 11 );
|
||||
|
||||
/**
|
||||
* Remove dynamic cookie when Cookie Consent plugin is deactivated.
|
||||
*
|
||||
* @since 3.2
|
||||
* @author TheZoker
|
||||
*/
|
||||
function rocket_remove_uk_cookie_consent_dynamic_cookie() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 62 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_get_cookie_uk_consent_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
|
||||
// Clear WP Rocket cache.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'deactivate_uk-cookie-consent/uk-cookie-consent.php', 'rocket_remove_uk_cookie_consent_dynamic_cookie', 11 );
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with WeePie Cookie Allow
|
||||
*
|
||||
* @since 2.9
|
||||
*/
|
||||
if ( class_exists( 'WpieCookieAllow' ) ) :
|
||||
add_action( 'update_option_wpca_settings_general', 'rocket_after_update_wp_cookie_allow_options', 10, 2 );
|
||||
add_action( 'update_option_wpca_settings_style', 'rocket_after_update_wp_cookie_allow_options', 10, 2 );
|
||||
add_action( 'update_option_wpca_settings_content', 'rocket_after_update_wp_cookie_allow_options', 10, 2 );
|
||||
add_action( 'update_option_wpca_settings_consent_log', 'rocket_after_update_wp_cookie_allow_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Update .htaccess & config files when the "Enabled" and "Autoblock" options are turned on.
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $old_value Previous values for the plugin options.
|
||||
* @param array $value New values for the plugin options.
|
||||
*/
|
||||
function rocket_after_update_wp_cookie_allow_options( $old_value, $value ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
|
||||
// clear the cache because WeePie Cookie Allow plugin settings might have been changed.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add cookies when we activate the plugin.
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_activate_wp_cookie_allow() {
|
||||
// clear the cache because plugin might be enabled already before.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'activate_wp-cookie-allow/wp-cookie-allow.php', 'rocket_activate_wp_cookie_allow', 11 );
|
||||
|
||||
/**
|
||||
* Remove cookies when we deactivate the plugin
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_deactivate_wp_cookie_allow() {
|
||||
// clear the cache because the bar/box and other WeePie Cookie Allow plugin frontend HTML is not needed anymore.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'deactivate_wp-cookie-allow/wp-cookie-allow.php', 'rocket_deactivate_wp_cookie_allow', 11 );
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Exclude plugin custom login page template from cache.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( class_exists( 'Custom_Login_Page_Template' ) ) {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_custom_login_exclude_pages', 2, 2 );
|
||||
add_action( 'update_option_custom_login_page_template', 'rocket_after_update_single_options', 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom login page to excluded urls array
|
||||
*
|
||||
* @since 2.7
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param Array $urls Array of pages to exclude.
|
||||
* @param bool $show_safe_content show sensitive uris.
|
||||
* @return Array Updated array of pages to exclude
|
||||
*/
|
||||
function rocket_add_custom_login_exclude_pages( $urls, $show_safe_content = true ) {
|
||||
if ( ! $show_safe_content ) {
|
||||
return $urls;
|
||||
}
|
||||
|
||||
$clpt_options = get_option( 'custom_login_page_template' );
|
||||
$urls = array_merge( $urls, get_rocket_i18n_translated_post_urls( $clpt_options['login_page_id'], 'page' ) );
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom login page to excluded urls array on plugin activation
|
||||
*
|
||||
* @since 2.7
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_activate_custom_login_page_template() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_custom_login_exclude_pages', 2, 2 );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_custom-login-page-template/custom-login-page-template.php', 'rocket_activate_custom_login_page_template', 11 );
|
||||
|
||||
/**
|
||||
* Remove custom login page from excluded urls array on plugin activation
|
||||
*
|
||||
* @since 2.7
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_remove_custom_login_exclude_pages() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_add_custom_login_exclude_pages' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_custom-login-page-template/custom-login-page-template.php', 'rocket_remove_custom_login_exclude_pages', 11 );
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'DISQUS_VERSION' ) ) :
|
||||
/**
|
||||
* Excludes Disqus scripts from JS minification
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param Array $excluded_js An array of JS handles enqueued in WordPress.
|
||||
* @return Array the updated array of handles
|
||||
*/
|
||||
function rocket_exclude_js_disqus( $excluded_js ) {
|
||||
$excluded_js[] = str_replace( home_url(), '', plugins_url( '/disqus-comment-system/media/js/disqus.js' ) );
|
||||
$excluded_js[] = str_replace( home_url(), '', plugins_url( '/disqus-comment-system/media/js/count.js' ) );
|
||||
|
||||
return $excluded_js;
|
||||
}
|
||||
add_filter( 'rocket_exclude_js', 'rocket_exclude_js_disqus' );
|
||||
endif;
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with Aelia Currency Switcher.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( class_exists( 'WC_Aelia_CurrencySwitcher' ) ) :
|
||||
/**
|
||||
* Update .htaccess & config files when the Geolocation option is updated
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $old_value Previous setting values.
|
||||
* @param array $value Submitted settings values.
|
||||
*/
|
||||
function rocket_after_update_aelia_currencyswitcher_options( $old_value, $value ) {
|
||||
if ( ( ! isset( $old_value['ipgeolocation_enabled'] ) && isset( $value['ipgeolocation_enabled'] ) ) || ( isset( $old_value['ipgeolocation_enabled'], $value['ipgeolocation_enabled'] ) && $old_value['ipgeolocation_enabled'] !== $value['ipgeolocation_enabled'] )
|
||||
) {
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Update the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
}
|
||||
add_action( 'update_option_wc_aelia_currency_switcher', 'rocket_after_update_aelia_currencyswitcher_options', 10, 2 );
|
||||
|
||||
/**
|
||||
* Generate a caching file depending on the currency cookie value
|
||||
*/
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_currencyswitcher_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_aelia_currencyswitcher_mandatory_cookie' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add the Aelia Currency Switcher cookies when activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_activate_aelia_currencyswitcher() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_currencyswitcher_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_aelia_currencyswitcher_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_woocommerce-aelia-currencyswitcher/woocommerce-aelia-currencyswitcher.php', 'rocket_activate_aelia_currencyswitcher', 11 );
|
||||
|
||||
/**
|
||||
* Remove the Aelia Currency Switcher cookies when deactivating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_deactivate_aelia_currencyswitcher() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_currencyswitcher_dynamic_cookies' );
|
||||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_aelia_currencyswitcher_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-aelia-currencyswitcher/woocommerce-aelia-currencyswitcher.php', 'rocket_deactivate_aelia_currencyswitcher', 11 );
|
||||
|
||||
/**
|
||||
* Add the Aelia Currency Switcher cookies to the dynamic cookies list
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $cookies Cookies to use for dynamic caching.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_aelia_currencyswitcher_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'aelia_cs_recalculate_cart_totals';
|
||||
$cookies[] = 'aelia_cs_selected_currency';
|
||||
$cookies[] = 'aelia_customer_country';
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the Aelia Currency Switcher to the list of mandatory cookies before generating caching files
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $cookies Mandatory cookies to serve the cache.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_aelia_currencyswitcher_mandatory_cookie( $cookies ) {
|
||||
$acs_options = get_option( 'wc_aelia_currency_switcher' );
|
||||
|
||||
if ( ! empty( $acs_options['ipgeolocation_enabled'] ) ) {
|
||||
$cookies[] = 'aelia_cs_selected_currency';
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with Aelia Prices by Country.
|
||||
*
|
||||
* @since 2.8.15
|
||||
*/
|
||||
if ( class_exists( 'Aelia\WC\PricesByCountry\WC_Aelia_Prices_By_Country' ) ) :
|
||||
/**
|
||||
* Generate a caching file depending on the country cookie value
|
||||
*/
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 66 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_prices_by_country_dynamic_cookies' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add cookie when we activate the plugin
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_activate_aelia_prices_by_country() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 66 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_prices_by_country_dynamic_cookies' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_woocommerce-prices-by-country/woocommerce-prices-by-country.php', 'rocket_activate_aelia_prices_by_country', 11 );
|
||||
|
||||
/**
|
||||
* Remove cookies when we deactivate the plugin
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_deactivate_aelia_prices_by_country() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 66 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_prices_by_country_dynamic_cookies' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-prices-by-country/woocommerce-prices-by-country.php', 'rocket_deactivate_aelia_prices_by_country', 11 );
|
||||
|
||||
/**
|
||||
* Add the Aelia Prices by Country cookie to generate caching files depending on its value
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $cookies Cookies list to use for dynamic caching.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_aelia_prices_by_country_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'aelia_customer_country';
|
||||
return $cookies;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with Aelia Tax Display by Country.
|
||||
*
|
||||
* @since 2.8.15
|
||||
*/
|
||||
if ( class_exists( 'Aelia\WC\TaxDisplayByCountry\WC_Aelia_Tax_Display_By_Country' ) ) :
|
||||
/**
|
||||
* Generate a caching file depending to the tax display cookie values
|
||||
*/
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 68 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_tax_display_by_country_dynamic_cookies' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add cookies when we activate the plugin
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_activate_aelia_tax_display_by_country() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 68 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_tax_display_by_country_dynamic_cookies' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_woocommerce-tax-display-by-country/woocommerce-tax-display-by-country.php', 'rocket_activate_aelia_tax_display_by_country', 11 );
|
||||
|
||||
/**
|
||||
* Remove cookies when we deactivate the plugin
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_deactivate_aelia_tax_display_by_country() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 68 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_aelia_tax_display_by_country_dynamic_cookies' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-tax-display-by-country/woocommerce-tax-display-by-country.php', 'rocket_deactivate_aelia_tax_display_by_country', 11 );
|
||||
|
||||
/**
|
||||
* Add the Aelia Tax Display by Country cookies to generate caching files depending on their values
|
||||
*
|
||||
* @since 2.8.15
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $cookies Cookies list to use for dynamic caching.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_aelia_tax_display_by_country_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'aelia_customer_country';
|
||||
$cookies[] = 'aelia_customer_state';
|
||||
$cookies[] = 'aelia_tax_exempt';
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( function_exists( 'EDD' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_pages' );
|
||||
add_action( 'update_option_edd_settings', 'rocket_after_update_array_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Exclude EDD pages from cache
|
||||
*
|
||||
* @param array $urls Array of URLs to exclude from cache.
|
||||
* @return array Updated array of URLs
|
||||
*/
|
||||
function rocket_exclude_edd_pages( $urls ) {
|
||||
$edd_settings = get_option( 'edd_settings' );
|
||||
if ( isset( $edd_settings['purchase_page'] ) ) {
|
||||
$checkout_urls = get_rocket_i18n_translated_post_urls( $edd_settings['purchase_page'], 'page', '(.*)' );
|
||||
$urls = array_merge( $urls, $checkout_urls );
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude EDD pages from cache on EDD activation.
|
||||
*/
|
||||
function rocket_activate_edd() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_easy-digital-downloads/easy-digital-downloads.php', 'rocket_activate_edd', 11 );
|
||||
|
||||
/**
|
||||
* Remove EDD pages from cache exclusion on EDD deactivation.
|
||||
*/
|
||||
function rocket_deactivate_edd() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_easy-digital-downloads/easy-digital-downloads.php', 'rocket_deactivate_edd', 11 );
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with Easy Digital Downloads Software Licensing addon.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( class_exists( 'EDD_Software_Licensing' ) && defined( 'EDD_SL_VERSION' ) ) :
|
||||
// Exclude EDD SL endpoint from cache on WP Rocket activation.
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_sl_endpoint' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Exclude EDD SL endpoint from cache when activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_activate_edd_software_licensing() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_sl_endpoint' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_edd-software-licensing/edd-software-licenses.php', 'rocket_activate_edd_software_licensing', 11 );
|
||||
|
||||
/**
|
||||
* Remove exclusion of EDD SL endpoint from cache when deactivating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_deactivate_edd_software_licensing() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_edd_sl_endpoint' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_edd-software-licensing/edd-software-licenses.php', 'rocket_deactivate_edd_software_licensing', 11 );
|
||||
|
||||
/**
|
||||
* Exclude EDD SL endpoint from caching
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $uri URLs to exclude from caching.
|
||||
* @return array Updated list of URLs to exclude
|
||||
*/
|
||||
function rocket_exclude_edd_sl_endpoint( $uri ) {
|
||||
$uri[] = '/edd-sl/(.*)';
|
||||
return $uri;
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Exclude pages of Give plugin from cache.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( defined( 'GIVE_VERSION' ) && function_exists( 'give_get_settings' ) ) {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_give_exclude_pages' );
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'update_option_give_settings', 'rocket_after_update_single_options', 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add give pages to the excluded pages
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param Array $urls Array of excluded pages.
|
||||
* @return Array Updated array of excluded pages
|
||||
*/
|
||||
function rocket_add_give_exclude_pages( $urls ) {
|
||||
$give_options = give_get_settings();
|
||||
$urls = array_merge( $urls, get_rocket_i18n_translated_post_urls( $give_options['success_page'], 'page' ) );
|
||||
$urls = array_merge( $urls, get_rocket_i18n_translated_post_urls( $give_options['history_page'], 'page' ) );
|
||||
$urls = array_merge( $urls, get_rocket_i18n_translated_post_urls( $give_options['failure_page'], 'page' ) );
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add give pages to the excluded pages when activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_activate_give() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_give_exclude_pages' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_give/give.php', 'rocket_activate_give', 11 );
|
||||
|
||||
/**
|
||||
* Remove give pages from the excluded pages when activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_remove_give_exclude_pages() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_add_give_exclude_pages' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_give/give.php', 'rocket_remove_give_exclude_pages', 11 );
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( function_exists( 'it_exchange_get_page_type' ) && function_exists( 'it_exchange_get_page_url' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_ithemes_exchange_pages' );
|
||||
add_action( 'update_option_it-storage-exchange_settings_pages', 'rocket_after_update_single_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
|
||||
/**
|
||||
* Exclude iThemes Exchange pages from cache.
|
||||
*
|
||||
* @param array $urls Array of URLs to exclude from cache.
|
||||
* @return array Updated array of URLs to exclude from cache
|
||||
*/
|
||||
function rocket_exclude_ithemes_exchange_pages( $urls ) {
|
||||
$pages = [
|
||||
'purchases',
|
||||
'confirmation',
|
||||
'account',
|
||||
'profile',
|
||||
'downloads',
|
||||
'purchases',
|
||||
'log-in',
|
||||
'log-out',
|
||||
];
|
||||
|
||||
foreach ( $pages as $page ) {
|
||||
if ( it_exchange_get_page_type( $page ) === 'WordPress' ) {
|
||||
$exchange_urls = get_rocket_i18n_translated_post_urls( it_exchange_get_page_wpid( $page ) );
|
||||
} else {
|
||||
$exchange_urls = [ rocket_extract_url_component( it_exchange_get_page_url( $page ), PHP_URL_PATH ) ];
|
||||
}
|
||||
|
||||
$urls = array_merge( $urls, $exchange_urls );
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exclude iThemes Exchanges pages from cache on plugin activation.
|
||||
*/
|
||||
function rocket_activate_ithemes_exchange() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_ithemes_exchange_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_ithemes-exchange/ithemes-exchange.php', 'rocket_activate_ithemes_exchange', 11 );
|
||||
|
||||
/**
|
||||
* Remove iThemes Exchanges pages from cache exclusion on plugin deactivation.
|
||||
*/
|
||||
function rocket_deactivate_ithemes_exchange() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_ithemes_exchange_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_ithemes-exchange/ithemes-exchange.php', 'rocket_deactivate_ithemes_exchange', 11 );
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'JIGOSHOP_VERSION' ) && function_exists( 'jigoshop_get_page_id' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_jigoshop_pages' );
|
||||
add_action( 'update_option_jigoshop_options', 'rocket_after_update_array_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Exclude Jigoshop pages from cache.
|
||||
*
|
||||
* @param array $urls Array of URLs to exclude from cache.
|
||||
* @return array Updated array of URLs to exclude from cache
|
||||
*/
|
||||
function rocket_exclude_jigoshop_pages( $urls ) {
|
||||
if ( jigoshop_get_page_id( 'checkout' ) && jigoshop_get_page_id( 'checkout' ) !== '-1' ) {
|
||||
$checkout_urls = get_rocket_i18n_translated_post_urls( jigoshop_get_page_id( 'checkout' ), 'page', '(.*)' );
|
||||
$urls = array_merge( $urls, $checkout_urls );
|
||||
}
|
||||
|
||||
if ( jigoshop_get_page_id( 'cart' ) && jigoshop_get_page_id( 'cart' ) !== '-1' ) {
|
||||
$cart_urls = get_rocket_i18n_translated_post_urls( jigoshop_get_page_id( 'cart' ) );
|
||||
$urls = array_merge( $urls, $cart_urls );
|
||||
}
|
||||
|
||||
if ( jigoshop_get_page_id( 'myaccount' ) && jigoshop_get_page_id( 'myaccount' ) !== '-1' ) {
|
||||
$cart_urls = get_rocket_i18n_translated_post_urls( jigoshop_get_page_id( 'myaccount' ), 'page', '(.*)' );
|
||||
$urls = array_merge( $urls, $cart_urls );
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude Jigoshop pages from cache on plugin activation.
|
||||
*/
|
||||
function rocket_activate_jigoshop() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_jigoshop_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_jigoshop/jigoshop.php', 'rocket_activate_jigoshop', 11 );
|
||||
|
||||
/**
|
||||
* Remove Jigoshop pages from cache exclusion on plugin deactivation.
|
||||
*/
|
||||
function rocket_deactivate_jigoshop() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_jigoshop_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_jigoshop/jigoshop.php', 'rocket_deactivate_jigoshop', 11 );
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Compatibility with WooCommerce Currency Converter Widget.
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
if ( class_exists( 'WC_Currency_Converter' ) ) :
|
||||
// Add cookie to config file when WP Rocket is activated and WooCommerce Currency Converter Widget is already active.
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 70 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_woocommerce_currency_converter_dynamic_cookies', 11 );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_woocommerce_currency_converter_mandatory_cookie', 11 );
|
||||
add_action( 'update_option_woocommerce_default_customer_address', 'rocket_after_update_single_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add cookies when we activating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_activate_woocommerce_currency_converter() {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 70 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_woocommerce_currency_converter_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_woocommerce_currency_converter_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_woocommerce-currency-converter-widget/currency-converter.php', 'rocket_activate_woocommerce_currency_converter', 11 );
|
||||
|
||||
/**
|
||||
* Remove cookies when deactivating the plugin
|
||||
*
|
||||
* @since 2.7
|
||||
*/
|
||||
function rocket_deactivate_woocommerce_currency_converter() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 70 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_add_woocommerce_currency_converter_dynamic_cookies' );
|
||||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_woocommerce_currency_converter_mandatory_cookie' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-currency-converter-widget/currency-converter.php', 'rocket_deactivate_woocommerce_currency_converter', 11 );
|
||||
|
||||
/**
|
||||
* Add the WC Currency Converter Widget cookie to generate caching files depending on its value
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $cookies Cookies list to use for dynamic caching.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_woocommerce_currency_converter_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'woocommerce_current_currency';
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the WC Currency Converter Widget cookie to the list of mandatory cookies before generating the caching files
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @param array $cookies Mandatory cookies list.
|
||||
* @return array Updated cookies list
|
||||
*/
|
||||
function rocket_add_woocommerce_currency_converter_mandatory_cookie( $cookies ) {
|
||||
$widget_woocommerce_currency_converter = get_option( 'widget_woocommerce_currency_converter' );
|
||||
|
||||
if ( ! empty( $widget_woocommerce_currency_converter ) && 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) ) {
|
||||
$cookies[] = 'woocommerce_current_currency';
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Check if WCML is active and has minimum requirements.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function rocket_wcml_has_requirements() {
|
||||
return defined( 'ICL_SITEPRESS_VERSION' )
|
||||
&& version_compare( ICL_SITEPRESS_VERSION, '4.4.11', '>=' )
|
||||
&& defined( 'WCML_VERSION' )
|
||||
&& version_compare( WCML_VERSION, '4.12.6', '>=' );
|
||||
}
|
||||
|
||||
if ( rocket_wcml_has_requirements() ) :
|
||||
/**
|
||||
* Use Cookie instead of WCSession
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function rocket_wcml_use_cookie_storage() {
|
||||
return 'cookie';
|
||||
}
|
||||
add_filter( 'wcml_user_store_strategy', 'rocket_wcml_use_cookie_storage', 10, 2 );
|
||||
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_wcml_add_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_wcml_add_mandatory_cookies' );
|
||||
add_action( 'updated_option', 'rocket_wcml_reset_settings', 10, 3 );
|
||||
|
||||
/**
|
||||
* Reset WP Rocket settings on WCML deactivation.
|
||||
*/
|
||||
function rocket_wcml_deactivate() {
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
remove_filter( 'rocket_cache_dynamic_cookies', 'rocket_wcml_add_dynamic_cookies' );
|
||||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_wcml_add_mandatory_cookies' );
|
||||
flush_rocket_htaccess();
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_woocommerce-multilingual/wpml-woocommerce.php', 'rocket_wcml_deactivate', 11 );
|
||||
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add dynamic cookies for WCML.
|
||||
*
|
||||
* @param array $cookies Cookies.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function rocket_wcml_add_dynamic_cookies( $cookies ) {
|
||||
$cookies[] = 'wcml_client_currency';
|
||||
$cookies[] = 'wcml_client_currency_language';
|
||||
$cookies[] = 'wcml_client_country';
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add mandatory cookies for WCML.
|
||||
*
|
||||
* @param array $cookies Cookies.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function rocket_wcml_add_mandatory_cookies( $cookies ) {
|
||||
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
|
||||
if ( apply_filters( 'wcml_geolocation_is_used', false ) ) {
|
||||
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
|
||||
$cookies[] = 'wcml_client_country';
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset WP Rocket settings when a relevant WCML setting is changed.
|
||||
*
|
||||
* @param string $option Option name.
|
||||
* @param mixed $old_data Old data.
|
||||
* @param mixed $data New data.
|
||||
*/
|
||||
function rocket_wcml_reset_settings( $option, $old_data, $data ) {
|
||||
$keys_to_check = [
|
||||
'enable_multi_currency',
|
||||
'currency_mode',
|
||||
'default_currencies',
|
||||
];
|
||||
|
||||
$check_key = function ( $result, $key ) use ( $old_data, $data ) {
|
||||
$has_value_changed = function ( $key ) use ( $old_data, $data ) {
|
||||
$get_value = function ( $key, $data ) {
|
||||
return isset( $data[ $key ] ) ? $data[ $key ] : null;
|
||||
};
|
||||
|
||||
return $get_value( $key, $old_data ) !== $get_value( $key, $data );
|
||||
};
|
||||
|
||||
return $result || $has_value_changed( $key );
|
||||
};
|
||||
|
||||
if (
|
||||
'_wcml_settings' === $option
|
||||
&& array_reduce( $keys_to_check, $check_key, false )
|
||||
) {
|
||||
flush_rocket_htaccess();
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset WP Rocket settings on WCML activation.
|
||||
*/
|
||||
function rocket_wcml_activate() {
|
||||
if ( rocket_wcml_has_requirements() ) {
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 64 );
|
||||
add_filter( 'rocket_cache_dynamic_cookies', 'rocket_wcml_add_dynamic_cookies' );
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_wcml_add_mandatory_cookies' );
|
||||
flush_rocket_htaccess();
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
}
|
||||
add_action( 'activate_woocommerce-multilingual/wpml-woocommerce.php', 'rocket_wcml_activate', 11 );
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'WPSHOP_VERSION' ) && class_exists( 'wpshop_tools' ) && method_exists( 'wpshop_tools', 'get_page_id' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_wpshop_pages' );
|
||||
add_action( 'update_option_wpshop_cart_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
add_action( 'update_option_wpshop_checkout_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
add_action( 'update_option_wpshop_payment_return_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
add_action( 'update_option_wpshop_payment_return_nok_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
add_action( 'update_option_wpshop_myaccount_page_id', 'rocket_after_update_single_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
|
||||
/**
|
||||
* Exclude WP Shop pages from cache.
|
||||
*
|
||||
* @param array $urls Array of URLs to exclude from cache.
|
||||
* @return array Updated array of URLs to exclude from cache
|
||||
*/
|
||||
function rocket_exclude_wpshop_pages( $urls ) {
|
||||
$pages = [
|
||||
'wpshop_cart_page_id',
|
||||
'wpshop_checkout_page_id',
|
||||
'wpshop_payment_return_page_id',
|
||||
'wpshop_payment_return_nok_page_id',
|
||||
'wpshop_myaccount_page_id',
|
||||
];
|
||||
|
||||
foreach ( $pages as $page ) {
|
||||
$page_id = wpshop_tools::get_page_id( get_option( $page ) );
|
||||
if ( $page_id ) {
|
||||
$urls = array_merge( $urls, get_rocket_i18n_translated_post_urls( $page_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude WP Shop pages from cache on plugin activation.
|
||||
*/
|
||||
function rocket_activate_wpshop() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_wpshop_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_wpshop/wpshop.php', 'rocket_activate_wpshop', 11 );
|
||||
|
||||
/**
|
||||
* Remove WP Shop pages from cache exclusion on plugin deactivation.
|
||||
*/
|
||||
function rocket_deactivate_wpshop() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_wpshop_pages' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_wpshop/wpshop.php', 'rocket_deactivate_wpshop', 11 );
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Conflict with Envira Gallery: don't apply LazyLoad on all images
|
||||
*
|
||||
* @since 2.3.10
|
||||
*
|
||||
* @param string $attr Envira gallery image attributes.
|
||||
* @return string Updated attributes
|
||||
*/
|
||||
function rocket_deactivate_lazyload_on_envira_gallery( $attr ) {
|
||||
return $attr . ' data-no-lazy="1" ';
|
||||
}
|
||||
add_filter( 'envira_gallery_output_image_attr', 'rocket_deactivate_lazyload_on_envira_gallery', PHP_INT_MAX );
|
||||
|
||||
/**
|
||||
* Conflict with Envira Gallery: don't apply LazyLoad on all images
|
||||
*
|
||||
* @since 2.3.10
|
||||
*
|
||||
* @param string $images Envira gallery images HTML code.
|
||||
* @return string Updated HTML code
|
||||
*/
|
||||
function rocket_deactivate_lazyload_on_envira_gallery_indexable_images( $images ) {
|
||||
$images = str_replace( '<img', '<img data-no-lazy="1" ', $images );
|
||||
|
||||
return $images;
|
||||
}
|
||||
add_filter( 'envira_gallery_indexable_images', 'rocket_deactivate_lazyload_on_envira_gallery_indexable_images', PHP_INT_MAX );
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'POLYLANG_VERSION' ) && POLYLANG_VERSION ) :
|
||||
/**
|
||||
* Conflict with Polylang: Clear the whole cache when the "The language is set from content" option is activated.
|
||||
*
|
||||
* @since 2.6.8
|
||||
*/
|
||||
function rocket_force_clean_domain_on_polylang() {
|
||||
$pll = function_exists( 'PLL' ) ? PLL() : $GLOBALS['polylang'];
|
||||
|
||||
if ( isset( $pll ) && 0 === $pll->options['force_lang'] ) {
|
||||
rocket_clean_cache_dir();
|
||||
}
|
||||
}
|
||||
add_action( 'after_rocket_clean_domain', 'rocket_force_clean_domain_on_polylang' );
|
||||
|
||||
// Filter mandatory cookies and WP Rocket rewrite rules if Polylang module 'Detect browser language' is enabled.
|
||||
if ( function_exists( 'PLL' ) && PLL()->options['browser'] ) {
|
||||
|
||||
// Add Polylang's language cookie as a mandatory cookie.
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_polylang_mandatory_cookie' );
|
||||
|
||||
// Remove WP Rocket rewrite rules from .htaccess file.
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 74 );
|
||||
}
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add Polylang's language cookie to the mandatory cookies of WP Rocket.
|
||||
*
|
||||
* Polylang saves the users preferred language in this cookie by detecting browser language or by user choice
|
||||
* Adding this as a mandatory cookie prevents WP Rocket from serving the cache when the cookie is not set.
|
||||
*
|
||||
* @param array $cookies Array with mandatory cookies.
|
||||
* @return (array) Array of mandatory cookies with the Polylang cookie appended
|
||||
*
|
||||
* @author Arun Basil Lal
|
||||
* @since 3.0.5
|
||||
*/
|
||||
function rocket_add_polylang_mandatory_cookie( $cookies ) {
|
||||
$cookies[] = defined( 'PLL_COOKIE' ) ? PLL_COOKIE : 'pll_language';
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add mandatory cookie to WP Rocket config and remove rewrite rules from .htaccess on Polylang activation.
|
||||
*
|
||||
* Add mandatory cookie only if the Polylang module 'Detect browser language' is active.
|
||||
* Also purge the homepage cache.
|
||||
*
|
||||
* @author Arun Basil Lal
|
||||
* @since 3.0.5
|
||||
*/
|
||||
function rocket_activate_polylang() {
|
||||
// Read Polylang settings from db.
|
||||
$polylang_settings = get_option( 'polylang' );
|
||||
|
||||
if ( isset( $polylang_settings['browser'] ) && ( 1 === (int) $polylang_settings['browser'] ) ) {
|
||||
// Add Polylang's language cookie as a mandatory cookie.
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_polylang_mandatory_cookie' );
|
||||
|
||||
// Remove WP Rocket rewrite rules from .htaccess file.
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 74 );
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
|
||||
// Regenerate .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Purge homepage cache.
|
||||
rocket_clean_home();
|
||||
}
|
||||
}
|
||||
add_action( 'activate_polylang/polylang.php', 'rocket_activate_polylang', 11 );
|
||||
|
||||
/**
|
||||
* Remove mandatory cookie and add rewrite rules back to .htaccess when Polylang is deactivated.
|
||||
*
|
||||
* @author Arun Basil Lal
|
||||
* @since 3.0.5
|
||||
*/
|
||||
function rocket_deactivate_polylang() {
|
||||
// Remove Polylang's language cookie as a mandatory cookie.
|
||||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_polylang_mandatory_cookie' );
|
||||
|
||||
// Add back WP Rocket rewrite rules from .htaccess file.
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 74 );
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
|
||||
// Regenerate .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
}
|
||||
add_action( 'deactivate_polylang/polylang.php', 'rocket_deactivate_polylang', 11 );
|
||||
|
||||
/**
|
||||
* Update mandatory cookie in WP Rocket config file and remove rewrite rules from .htaccess
|
||||
* when Detect browser language module is enabled / disabled.
|
||||
*
|
||||
* @param array $value Array containing Polylang settings before its written to db.
|
||||
* @return array
|
||||
*
|
||||
* @author Arun Basil Lal
|
||||
* @since 3.0.5
|
||||
*/
|
||||
function rocket_detect_browser_language_status_change( $value ) {
|
||||
if ( function_exists( 'PLL' ) && PLL()->options['browser'] ) {
|
||||
|
||||
// Add Polylang's language cookie as a mandatory cookie.
|
||||
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_polylang_mandatory_cookie' );
|
||||
|
||||
// Remove WP Rocket rewrite rules from .htaccess file.
|
||||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 74 );
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
|
||||
// Regenerate .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Purge homepage cache.
|
||||
rocket_clean_home();
|
||||
} else {
|
||||
// Remove Polylang's language cookie as a mandatory cookie.
|
||||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_polylang_mandatory_cookie' );
|
||||
|
||||
// Add back WP Rocket rewrite rules from .htaccess file.
|
||||
remove_filter( 'rocket_htaccess_mod_rewrite', '__return_false', 74 );
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
|
||||
// Regenerate .htaccess file.
|
||||
flush_rocket_htaccess();
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
add_filter( 'pre_update_option_polylang', 'rocket_detect_browser_language_status_change' );
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Conflict with MailChimp List Subscribe Form: Enqueue style without lack of performance, grrrr!!!
|
||||
*
|
||||
* @since 2.6
|
||||
*/
|
||||
function rocket_fix_mailchimp_main_css() {
|
||||
if ( ! defined( 'MCSF_VER' ) || ! function_exists( 'mailchimpSF_main_css' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$blog_id = get_current_blog_id();
|
||||
$cache_path = WP_ROCKET_MINIFY_CACHE_PATH . $blog_id . '/';
|
||||
$cache_url = WP_ROCKET_MINIFY_CACHE_URL . $blog_id . '/';
|
||||
$css_path = $cache_path . 'mailchimpSF_main_css.css';
|
||||
|
||||
if ( ! rocket_direct_filesystem()->is_dir( $cache_path ) ) {
|
||||
rocket_mkdir_p( $cache_path );
|
||||
}
|
||||
|
||||
if ( ! rocket_direct_filesystem()->exists( $css_path ) ) {
|
||||
ob_start();
|
||||
mailchimpSF_main_css();
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
rocket_put_content( $css_path, $content );
|
||||
}
|
||||
|
||||
wp_deregister_style( 'mailchimpSF_main_css' );
|
||||
wp_register_style( 'mailchimpSF_main_css', $cache_url . 'mailchimpSF_main_css.css', null, MCSF_VER );
|
||||
}
|
||||
add_action( 'init', 'rocket_fix_mailchimp_main_css', PHP_INT_MAX );
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'WpAppKit' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_appkit_exclude_pages' );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Add WP Appkit path to cache exclusion
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $urls URLs to exclude from cache.
|
||||
* @return array Updated URLs array
|
||||
*/
|
||||
function rocket_add_appkit_exclude_pages( $urls ) {
|
||||
$urls[] = '/wp-appkit-api/(.*)';
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add WP Appkit path to cache exclusion when activating the plugin
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_activate_wp_appkit() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_appkit_exclude_pages' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_wp-appkit/wp-appkit.php', 'rocket_activate_wp_appkit', 11 );
|
||||
|
||||
/**
|
||||
* Remove Appkit path from cache exclusion when deactivating the plugin
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_deactivate_wp_appkit() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_add_appkit_exclude_pages' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_wp-appkit/wp-appkit.php', 'rocket_deactivate_wp_appkit', 11 );
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
global $nginx_helper;
|
||||
|
||||
if ( isset( $nginx_helper ) ) :
|
||||
global $nginx_purger;
|
||||
|
||||
/**
|
||||
* Clear WP Rocket cache after the NGINX cache is purged from Nginx Helper.
|
||||
*
|
||||
* @since 3.3.0.1
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clear_cache_after_nginx_helper_purge() {
|
||||
if ( ! isset( $_GET['nginx_helper_action'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! check_admin_referer( 'nginx_helper-purge_all' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'done' !== sanitize_text_field( wp_unslash( $_GET['nginx_helper_action'] ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'rocket_purge_cache' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear all caching files.
|
||||
rocket_clean_domain();
|
||||
}
|
||||
add_action( 'admin_init', 'rocket_clear_cache_after_nginx_helper_purge' );
|
||||
|
||||
/**
|
||||
* Clear WP Rocket cache for the current page after the NGINX cache is purged from Nginx Helper.
|
||||
*
|
||||
* @since 3.3.0.1
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clear_current_page_after_nginx_helper_purge() {
|
||||
if ( ! isset( $_GET['nginx_helper_action'], $_GET['_wpnonce'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'nginx_helper-purge_all' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'rocket_purge_posts' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$referer = wp_get_referer();
|
||||
|
||||
if ( 0 !== strpos( $referer, 'http' ) ) {
|
||||
$parse_url = get_rocket_parse_url( untrailingslashit( home_url() ) );
|
||||
$referer = $parse_url['scheme'] . '://' . $parse_url['host'] . $referer;
|
||||
}
|
||||
|
||||
if ( home_url( '/' ) === $referer ) {
|
||||
rocket_clean_home();
|
||||
return;
|
||||
}
|
||||
|
||||
rocket_clean_files( $referer );
|
||||
}
|
||||
add_action( 'init', 'rocket_clear_current_page_after_nginx_helper_purge' );
|
||||
|
||||
/**
|
||||
* Clears NGINX cache for the homepage URL when using "Purge this URL" from the admin bar on the front end
|
||||
*
|
||||
* @since 3.3.0.1
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $root WP Rocket root cache path.
|
||||
* @param string $lang Current language.
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_nginx_cache_home( $root = '', $lang = '' ) {
|
||||
global $nginx_purger;
|
||||
|
||||
if ( ! isset( $nginx_purger ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$url = get_rocket_i18n_home_url( $lang );
|
||||
|
||||
$nginx_purger->purge_url( $url );
|
||||
}
|
||||
add_action( 'after_rocket_clean_home', 'rocket_clean_nginx_cache_home', 10, 2 );
|
||||
|
||||
/**
|
||||
* Clears NGINX cache for a specific URL when using "Purge this URL" from the admin bar on the front end
|
||||
*
|
||||
* @since 3.3.0.1
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $url URL to purge.
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_nginx_cache_url( $url ) {
|
||||
global $nginx_purger;
|
||||
|
||||
if ( ! isset( $nginx_purger ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $_GET['type'], $_GET['_wpnonce'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
return;
|
||||
}
|
||||
|
||||
if ( false !== strpos( $url, 'index.html' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'page' === substr( $url, -4 ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$url = str_replace( '*', '', $url );
|
||||
|
||||
$nginx_purger->purge_url( $url );
|
||||
}
|
||||
add_action( 'after_rocket_clean_file', 'rocket_clean_nginx_cache_url' );
|
||||
|
||||
/**
|
||||
* Clean the NGINX cache using Nginx Helper after WP Rocket's cache is purged.
|
||||
*
|
||||
* @since 3.3.0.1
|
||||
*/
|
||||
function rocket_clean_nginx_helper_cache() {
|
||||
if ( isset( $_GET['nginx_helper_action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'rt_nginx_helper_purge_all' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
|
||||
}
|
||||
add_action( 'after_rocket_clean_domain', 'rocket_clean_nginx_helper_cache' );
|
||||
|
||||
/**
|
||||
* Clean the NGINX cache after the Used CSS has been generated.
|
||||
*
|
||||
* @since 3.12.3
|
||||
*/
|
||||
add_action( 'rocket_rucss_after_clearing_usedcss', 'rocket_clean_nginx_cache_url' );
|
||||
add_action( 'rocket_rucss_complete_job_status', 'rocket_clean_nginx_helper_cache' );
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( function_exists( 'tve_editor_url' ) ) {
|
||||
/**
|
||||
* Forces Thrive Visual Editor’s bot detection to assume a human visitor.
|
||||
*
|
||||
* @since 2.8.11
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param boolean|integer $bot_detection 1|0 when crawler has|not been detected, FALSE when user agent string is unavailable
|
||||
* @return integer
|
||||
*/
|
||||
add_filter( 'tve_dash_is_crawler', '__return_zero', PHP_INT_MAX );
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'WPB_VC_VERSION' ) && class_exists( 'Vc_Manager' ) ) :
|
||||
/**
|
||||
* Disable nonce checking for Visual Composer grid
|
||||
*/
|
||||
add_filter( 'vc_grid_get_grid_data_access', '__return_true' );
|
||||
endif;
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'BhittaniPlugin_kkStarRatings' ) ) :
|
||||
/**
|
||||
* Conflict with kk Star Ratings: Clear the cache when a post gets rated.
|
||||
*
|
||||
* @since 2.5.3
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
*/
|
||||
function rocket_clear_cache_on_kksr_rate( $post_id ) {
|
||||
rocket_clean_post( $post_id );
|
||||
}
|
||||
add_action( 'kksr_rate', 'rocket_clear_cache_on_kksr_rate' );
|
||||
endif;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'WP_POSTRATINGS_VERSION' ) ) :
|
||||
/**
|
||||
* Conflict with WP-PostRatings: Clear the cache when a post gets rated.
|
||||
*
|
||||
* @since 2.6.6
|
||||
*
|
||||
* @param int $user_id user ID.
|
||||
* @param int $post_id post ID.
|
||||
*/
|
||||
function rocket_clear_cache_on_wp_postratings_rate( $user_id, $post_id ) {
|
||||
rocket_clean_post( $post_id );
|
||||
}
|
||||
add_action( 'rate_post', 'rocket_clear_cache_on_wp_postratings_rate', 10, 2 );
|
||||
endif;
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Excludes s2 Member dynamic file from saving as static resource
|
||||
*
|
||||
* @since 2.11.4
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $excluded_files Array of excluded files.
|
||||
*/
|
||||
function rocket_exclude_s2member_dynamic_files( $excluded_files ) {
|
||||
$excluded_files[] = rocket_clean_exclude_file( plugins_url( '/s2member/s2member-o.php' ) );
|
||||
|
||||
return $excluded_files;
|
||||
}
|
||||
add_action( 'rocket_exclude_static_dynamic_resources', 'rocket_exclude_s2member_dynamic_files' );
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
add_action( 'update_option_secupress_users-login_settings', 'rocket_after_update_single_options', 10, 2 );
|
||||
|
||||
/**
|
||||
* Add SecuPress move login pages to cache exclusion
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param array $urls URLs to exclude from cache.
|
||||
* @param bool $show_safe_content show sensitive uris.
|
||||
* @return array Updated URLs to exclude
|
||||
*/
|
||||
function rocket_exclude_secupress_move_login( $urls, $show_safe_content = true ) {
|
||||
|
||||
if ( ! $show_safe_content ) {
|
||||
return $urls;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'secupress_move_login_get_slugs' ) ) {
|
||||
return $urls;
|
||||
}
|
||||
|
||||
$bases = secupress_get_rewrite_bases();
|
||||
$slugs = secupress_move_login_get_slugs();
|
||||
|
||||
foreach ( $slugs as $slug ) {
|
||||
$urls[] = $bases['base'] . ltrim( $bases['site_from'], '/' ) . $slug . '/?';
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_secupress_move_login', 2, 2 );
|
||||
|
||||
/**
|
||||
* Add SecuPress move login pages to cache exclusion when activating the plugin
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_maybe_activate_secupress() {
|
||||
if ( function_exists( 'secupress_move_login_get_slugs' ) ) {
|
||||
rocket_activate_secupress();
|
||||
}
|
||||
}
|
||||
add_action( 'secupress.plugins.activation', 'rocket_maybe_activate_secupress', 10001 );
|
||||
|
||||
/**
|
||||
* Add SecuPress move login pages to cache exclusion when activating the move login module
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_activate_secupress() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_secupress_move_login', 2, 2 );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'secupress.plugin.move_login.activate', 'rocket_activate_secupress' );
|
||||
|
||||
/**
|
||||
* Remove SecuPress move login pages from cache exclusion when deactivating the plugin
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_maybe_deactivate_secupress() {
|
||||
if ( function_exists( 'secupress_move_login_get_slugs' ) ) {
|
||||
rocket_deactivate_secupress();
|
||||
}
|
||||
}
|
||||
add_action( 'secupress.deactivation', 'rocket_maybe_deactivate_secupress', 10001 );
|
||||
|
||||
/**
|
||||
* Remove SecuPress move login pages from cache exclusion when deactivating the move login module
|
||||
*
|
||||
* @since 2.9
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_deactivate_secupress() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_secupress_move_login' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'secupress.plugin.move_login.deactivate', 'rocket_deactivate_secupress' );
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( defined( 'SFML_VERSION' ) ) :
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_sfml_exclude_pages', 2, 2 );
|
||||
add_action( 'update_option_sfml', 'rocket_after_update_single_options', 10, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Exclude SF Move Login custom urls from caching
|
||||
*
|
||||
* @since 2.9.3 Moved to 3rd party file and improved
|
||||
* @since 2.6
|
||||
*
|
||||
* @param array $urls An array of URLs to exclude from cache.
|
||||
* @param bool $show_safe_content show sensitive uris.
|
||||
* @return array Updated array of URLs
|
||||
*/
|
||||
function rocket_add_sfml_exclude_pages( $urls, $show_safe_content = true ) {
|
||||
if ( ! $show_safe_content ) {
|
||||
return $urls;
|
||||
}
|
||||
if ( ! function_exists( 'sfml_get_slugs' ) ) {
|
||||
if ( file_exists( SFML_PLUGIN_DIR . 'inc/utilities.php' ) ) {
|
||||
include SFML_PLUGIN_DIR . 'inc/utilities.php';
|
||||
} else {
|
||||
return $urls;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SFML_Options' ) && ! defined( 'SFML_NOOP_VERSION' ) ) {
|
||||
if ( file_exists( SFML_PLUGIN_DIR . 'inc/class-sfml-options.php' ) ) {
|
||||
include SFML_PLUGIN_DIR . 'inc/class-sfml-options.php';
|
||||
} else {
|
||||
return $urls;
|
||||
}
|
||||
}
|
||||
|
||||
$sfml_slugs = sfml_get_slugs();
|
||||
$sfml_slugs = array_map( 'home_url', $sfml_slugs );
|
||||
$sfml_slugs = array_map( 'trailingslashit', $sfml_slugs );
|
||||
$sfml_slugs = array_map( 'rocket_clean_exclude_file', $sfml_slugs );
|
||||
|
||||
foreach ( $sfml_slugs as $key => $slug ) {
|
||||
$sfml_slugs[ $key ] = $slug . '?';
|
||||
}
|
||||
|
||||
return array_merge( $urls, $sfml_slugs );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add SFML custom urls to caching exclusion when activating the plugin
|
||||
*
|
||||
* @since 2.9.3
|
||||
*/
|
||||
function rocket_activate_sfml() {
|
||||
if ( defined( 'SFML_VERSION' ) ) {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_add_sfml_exclude_pages', 2, 2 );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
}
|
||||
add_action( 'activate_sf-move-login/sf-move-login.php', 'rocket_activate_sfml', 11 );
|
||||
|
||||
/**
|
||||
* Remove SFML custom urls from caching exclusion when deactivating the plugin
|
||||
*
|
||||
* @since 2.9.3
|
||||
*/
|
||||
function rocket_deactivate_sfml() {
|
||||
if ( defined( 'SFML_VERSION' ) ) {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_add_sfml_exclude_pages' );
|
||||
|
||||
// Update the WP Rocket rules on the .htaccess.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Regenerate the config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
}
|
||||
add_action( 'deactivate_sf-move-login/sf-move-login.php', 'rocket_deactivate_sfml', 11 );
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'WPS_Hide_Login' ) || defined( 'WPS_HIDE_LOGIN_VERSION' ) ) :
|
||||
add_action( 'update_option_whl_page', 'rocket_after_update_single_options', 10, 2 );
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exlude_wps_hide_login_page', 2, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Exclude WPS Hide Login custom url from caching
|
||||
*
|
||||
* @since 3.1 Switch implementation depending on the WPS Hide Login version
|
||||
* @since 2.11.7 Login url is retrieved using new_login_url() method of WPS_Hide_Login() class.
|
||||
* @since 2.11 Moved to 3rd party file
|
||||
* @since 2.6
|
||||
*
|
||||
* @param array $urls An array of URLs to exclude from cache.
|
||||
* @param bool $show_safe_content show sensitive uris.
|
||||
* @return array Updated array of URLs
|
||||
*/
|
||||
function rocket_exlude_wps_hide_login_page( $urls, $show_safe_content = true ) {
|
||||
if ( ! $show_safe_content ) {
|
||||
return $urls;
|
||||
}
|
||||
|
||||
if ( class_exists( 'WPS_Hide_Login' ) ) {
|
||||
$wps_hide_login = new WPS_Hide_Login();
|
||||
$urls[] = rocket_clean_exclude_file( $wps_hide_login->new_login_url() );
|
||||
} elseif ( class_exists( '\WPS\WPS_Hide_Login\Plugin' ) ) {
|
||||
$urls[] = rocket_clean_exclude_file( \WPS\WPS_Hide_Login\Plugin::get_instance()->new_login_url() );
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add WPS Hide Login custom url to caching exclusion when activating the plugin
|
||||
*
|
||||
* @since 2.11
|
||||
*/
|
||||
function rocket_activate_wps_hide_login() {
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exlude_wps_hide_login_page', 2, 2 );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Update config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'activate_wps-hide-login/wps-hide-login.php', 'rocket_activate_wps_hide_login', 11 );
|
||||
|
||||
/**
|
||||
* Remove WPS Hide Login custom url from caching exclusion when deactivating the plugin
|
||||
*
|
||||
* @since 2.11
|
||||
*/
|
||||
function rocket_deactivate_wps_hide_login() {
|
||||
remove_filter( 'rocket_cache_reject_uri', 'rocket_exlude_wps_hide_login_page' );
|
||||
|
||||
// Update .htaccess file rules.
|
||||
flush_rocket_htaccess();
|
||||
|
||||
// Update config file.
|
||||
rocket_generate_config_file();
|
||||
}
|
||||
add_action( 'deactivate_wps-hide-login/wps-hide-login.php', 'rocket_deactivate_wps_hide_login', 11 );
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Compatibility with Premium SEO Pack
|
||||
*
|
||||
* @link http://premiumseopack.com
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'psp' ) ) {
|
||||
|
||||
/**
|
||||
* Dequeue the stylesheet of Premium SEO Pack on WP Rocket settings page.
|
||||
*
|
||||
* @since 2.11.6
|
||||
* @author Arun Basil Lal
|
||||
*/
|
||||
function rocket_dequeue_premium_seo_pack_stylesheet() {
|
||||
|
||||
// Retun on all pages but WP Rocket settings page.
|
||||
$screen = get_current_screen();
|
||||
if ( 'settings_page_wprocket' !== $screen->id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Dequeueing this stylesheet unfreezes WP Rocket.
|
||||
wp_dequeue_style( 'psp-main-style' );
|
||||
}
|
||||
add_action( 'admin_print_styles', 'rocket_dequeue_premium_seo_pack_stylesheet', 11 );
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Conflict with Meta Slider (Nivo Slider): don't apply LazyLoad on all images
|
||||
*
|
||||
* @since 2.4
|
||||
*
|
||||
* @param array $slide Slide attributes.
|
||||
* @return array Updated slide attributes
|
||||
*/
|
||||
function rocket_deactivate_lazyload_on_metaslider( $slide ) {
|
||||
$slide['data-no-lazy'] = 1;
|
||||
return $slide;
|
||||
}
|
||||
add_filter( 'metaslider_nivo_slider_image_attributes', 'rocket_deactivate_lazyload_on_metaslider' );
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Conflict with Soliloquy: don't apply LazyLoad on all images
|
||||
*
|
||||
* @since 2.4.2
|
||||
*
|
||||
* @param string $attr Image attributes.
|
||||
* @return string Updated attributes
|
||||
*/
|
||||
function rocket_deactivate_lazyload_on_soliloquy( $attr ) {
|
||||
return $attr . ' data-no-lazy="1" ';
|
||||
}
|
||||
add_filter( 'soliloquy_output_image_attr', 'rocket_deactivate_lazyload_on_soliloquy', PHP_INT_MAX );
|
||||
|
||||
/**
|
||||
* Conflict with Soliloquy: don't apply LazyLoad on all images
|
||||
*
|
||||
* @since 2.4.2
|
||||
*
|
||||
* @param string $images Image HTML code.
|
||||
* @return string Updated image HTML code
|
||||
*/
|
||||
function rocket_deactivate_lazyload_on_soliloquy_indexable_images( $images ) {
|
||||
$images = str_replace( '<img', '<img data-no-lazy="1" ', $images );
|
||||
|
||||
return $images;
|
||||
}
|
||||
add_filter( 'soliloquy_indexable_images', 'rocket_deactivate_lazyload_on_soliloquy_indexable_images', PHP_INT_MAX );
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Compatibility with SumoMe
|
||||
*
|
||||
* Prevents conflict with SumoMe and the WP Rocket UI by removing SumoMe
|
||||
* styles and scripts on WP Rocket admin pages.
|
||||
*
|
||||
* @link https://wordpress.org/plugins/sumome/
|
||||
* @since 3.0.4
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'WP_Plugin_SumoMe' ) ) {
|
||||
|
||||
/**
|
||||
* Dequeue SumoMe styles
|
||||
*
|
||||
* @since 3.0.4
|
||||
* @author Arun Basil Lal
|
||||
*/
|
||||
function rocket_dequeue_sumo_me_css() {
|
||||
|
||||
// Retun on all pages but WP Rocket settings page.
|
||||
$screen = get_current_screen();
|
||||
if ( 'settings_page_wprocket' !== $screen->id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_dequeue_style( 'sumome-admin-styles' );
|
||||
wp_dequeue_style( 'sumome-admin-media' );
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'rocket_dequeue_sumo_me_css', PHP_INT_MAX );
|
||||
|
||||
/**
|
||||
* Dequeue SumoMe inline script
|
||||
*
|
||||
* @since 3.0.4
|
||||
* @author Arun Basil Lal
|
||||
*/
|
||||
function rocket_dequeue_sumo_me_js() {
|
||||
|
||||
// Retun on all pages but WP Rocket settings page.
|
||||
$screen = get_current_screen();
|
||||
if ( 'settings_page_wprocket' !== $screen->id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wp_plugin_sumome;
|
||||
remove_action( 'admin_footer', [ $wp_plugin_sumome, 'append_admin_script_code' ] );
|
||||
}
|
||||
add_action( 'admin_head', 'rocket_dequeue_sumo_me_js' );
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Conflict with Thrive Leads: override the DONOTCACHEPAGE behavior because this plugin add this constant!
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
function rocket_override_donotcachepage_on_thrive_leads() {
|
||||
return defined( 'TVE_LEADS_VERSION' ) && TVE_LEADS_VERSION > 0;
|
||||
}
|
||||
add_filter( 'rocket_override_donotcachepage', 'rocket_override_donotcachepage_on_thrive_leads' );
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'VarnishPurger' ) ) :
|
||||
add_action( 'admin_init', 'rocket_clear_cache_after_varnish_http_purge' );
|
||||
/**
|
||||
* Clear WP Rocket cache after purged the Varnish cache via Varnish HTTP Purge plugin
|
||||
*
|
||||
* @since 2.5.5
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clear_cache_after_varnish_http_purge() {
|
||||
if ( isset( $_GET['vhp_flush_all'] ) && current_user_can( 'manage_options' ) && check_admin_referer( 'varnish-http-purge' ) ) {
|
||||
// Clear all caching files.
|
||||
rocket_clean_domain();
|
||||
|
||||
// Preload cache.
|
||||
run_rocket_bot();
|
||||
run_rocket_sitemap_preload();
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
add_action( 'after_rocket_clean_domain', 'rocket_clean_varnish_http_purge' );
|
||||
/**
|
||||
* Call the cache server to purge the cache with Varnish HTTP Purge.
|
||||
*
|
||||
* @since 2.5.5
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rocket_clean_varnish_http_purge() {
|
||||
if ( class_exists( 'VarnishPurger' ) ) {
|
||||
$url = home_url( '/?vhp-regex' );
|
||||
$p = wp_parse_url( $url );
|
||||
$path = '';
|
||||
$pregex = '.*';
|
||||
|
||||
// Build a varniship.
|
||||
if ( defined( 'VHP_VARNISH_IP' ) && VHP_VARNISH_IP ) {
|
||||
$varniship = VHP_VARNISH_IP;
|
||||
} else {
|
||||
$varniship = get_option( 'vhp_varnish_ip' );
|
||||
}
|
||||
|
||||
if ( isset( $p['path'] ) ) {
|
||||
$path = $p['path'];
|
||||
}
|
||||
|
||||
$schema = apply_filters( 'varnish_http_purge_schema', 'http://' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
|
||||
|
||||
// If we made varniship, let it sail.
|
||||
if ( ! empty( $varniship ) ) {
|
||||
$purgeme = $schema . $varniship . $path . $pregex;
|
||||
} else {
|
||||
$purgeme = $schema . $p['host'] . $path . $pregex;
|
||||
}
|
||||
|
||||
wp_remote_request(
|
||||
$purgeme,
|
||||
[
|
||||
'method' => 'PURGE',
|
||||
'blocking' => false,
|
||||
'headers' => [
|
||||
'host' => $p['host'],
|
||||
'X-Purge-Method' => 'regex',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
do_action( 'after_purge_url', $url, $purgeme ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( is_admin() && function_exists( 'as3cf_assets_init' ) ) :
|
||||
add_action( 'aws_init', 'rocket_as3cf_assets_compatibility', 13 );
|
||||
add_action( 'update_option_as3cf_assets', 'rocket_maybe_deactivate_cdn', 10, 2 );
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Compatibility with WP Offload S3 assets addon.
|
||||
*
|
||||
* @since 2.10.7
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_as3cf_assets_compatibility() {
|
||||
global $as3cf_assets;
|
||||
|
||||
if ( isset( $as3cf_assets ) && $as3cf_assets->is_plugin_setup() && 1 === (int) $as3cf_assets->get_setting( 'enable-addon' ) ) {
|
||||
// Disable WP Rocket CDN option.
|
||||
add_filter( 'rocket_readonly_cdn_option', '__return_true' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate WP Rocket CDN if WP Offload S3 assets addon copy & serve is active.
|
||||
*
|
||||
* @since 2.10.7
|
||||
* @author Remy Perona
|
||||
*
|
||||
* @param string $old_value Previous assets option value.
|
||||
* @param string $new_value New assets option value.
|
||||
*/
|
||||
function rocket_maybe_deactivate_cdn( $old_value, $new_value ) {
|
||||
if ( $old_value['enable-addon'] !== $new_value['enable-addon'] && 1 === (int) $new_value['enable-addon'] ) {
|
||||
update_rocket_option( 'cdn', 0 );
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( is_admin() && ( function_exists( 'as3cf_init' ) || function_exists( 'as3cf_pro_init' ) ) ) :
|
||||
add_action( 'aws_init', 'rocket_as3cf_compatibility', 12 );
|
||||
endif;
|
||||
|
||||
|
||||
/**
|
||||
* Compatibility with WP Offload S3.
|
||||
*
|
||||
* @since 2.10.7
|
||||
* @author Remy Perona
|
||||
*/
|
||||
function rocket_as3cf_compatibility() {
|
||||
global $as3cf;
|
||||
|
||||
if ( isset( $as3cf ) && $as3cf->is_plugin_setup() && 1 === (int) $as3cf->get_setting( 'serve-from-s3' ) ) {
|
||||
// Remove images option from WP Rocket CDN dropdown settings.
|
||||
add_filter( 'rocket_allow_cdn_images', '__return_false' );
|
||||
}
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( function_exists( 'print_link' ) ) :
|
||||
/**
|
||||
* Conflict with WP-Print: don't apply LazyLoad on print pages
|
||||
*
|
||||
* @since 2.6.8
|
||||
*/
|
||||
function rocket_deactivate_lazyload_on_print_pages() {
|
||||
global $wp_query;
|
||||
|
||||
if ( isset( $wp_query->query_vars['print'] ) ) {
|
||||
add_filter( 'do_rocket_lazyload', '__return_false' );
|
||||
}
|
||||
}
|
||||
add_action( 'wp', 'rocket_deactivate_lazyload_on_print_pages' );
|
||||
endif;
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Add WP REST API path to cache exclusion
|
||||
*
|
||||
* @since 2.5.12
|
||||
*
|
||||
* @param array $uri URLs to exclude from cache.
|
||||
* @return array Updated URLs
|
||||
*/
|
||||
function rocket_exclude_wp_rest_api( $uri ) {
|
||||
global $wp_rewrite;
|
||||
|
||||
/**
|
||||
* By default, don't cache the WP REST API.
|
||||
*
|
||||
* @since 2.5.12
|
||||
*
|
||||
* @param bool false will force to cache the WP REST API
|
||||
*/
|
||||
$reject_wp_rest_api = apply_filters( 'rocket_cache_reject_wp_rest_api', true );
|
||||
|
||||
if ( ! $reject_wp_rest_api ) {
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* `(/[^/]+)?` is used instead of `(/.+)?` to match only one level.
|
||||
* This prevents to match a taxonomy term named `wp-json` (on multisite, the main site's posts and taxonomy archives are prefixed with `blog` => example.com/blog/category/wp-json/).
|
||||
*/
|
||||
$prefix = rocket_is_subfolder_install() ? '(/[^/]+)?' : '';
|
||||
$index = ! empty( $wp_rewrite->index ) ? $wp_rewrite->index : 'index.php';
|
||||
$index = preg_quote( $index, '/' );
|
||||
$suffix = rest_get_url_prefix();
|
||||
$suffix = preg_quote( trim( $suffix, '/' ), '/' );
|
||||
|
||||
/**
|
||||
* Results in:
|
||||
* - Single site: (/index\.php)?/wp\-json(/.*|$)
|
||||
* - Multisite: (/[^/]+)?(/index\.php)?/wp\-json(/.*|$)
|
||||
*/
|
||||
$uri[] = $prefix . '/(' . $index . '/)?(.*)' . $suffix . '(/.*|$)';
|
||||
|
||||
return $uri;
|
||||
}
|
||||
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_wp_rest_api' );
|
||||
Reference in New Issue
Block a user