-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from wp-media/branch-2.9.1
2.9.1
- Loading branch information
Showing
11 changed files
with
199 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' ); | ||
|
||
/** | ||
* Compatibility with WeePie Cookie Allow | ||
* | ||
* @since 2.9 | ||
*/ | ||
if ( class_exists( 'WpieCookieAllow' ) ) : | ||
/* | ||
* Update .htaccess & config files when the "Enabled" and "Autoblock" options are turned on | ||
* | ||
*/ | ||
add_filter( 'rocket_cache_mandatory_cookies' , 'rocket_add_weepie_cookie_allow_mandatory_cookie' ); | ||
add_action( 'update_option_wpca_settings_general', 'rocket_after_update_wp_cookie_allow_options', 10, 2 ); | ||
function rocket_after_update_wp_cookie_allow_options( $old_value, $value ) { | ||
if ( ( isset( $old_value['general_plugin_status'], $value['general_plugin_status'] ) && ( $old_value['general_plugin_status'] == $value['general_plugin_status'] ) ) && isset( $old_value['general_cookies_before_consent'], $value['general_cookies_before_consent'] ) && $old_value['general_cookies_before_consent'] == $value['general_cookies_before_consent'] ) { | ||
return; | ||
} | ||
|
||
// Update the WP Rocket rules on the .htaccess file | ||
flush_rocket_htaccess(); | ||
|
||
// Update the config file | ||
rocket_generate_config_file(); | ||
} | ||
|
||
// Don't add the WP Rocket rewrite rules to avoid issues | ||
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false' ); | ||
endif; | ||
|
||
// Add cookies when we activate the plugin | ||
add_action( 'activate_wp-cookie-allow/wp-cookie-allow.php', 'rocket_activate_wp_cookie_allow', 11 ); | ||
function rocket_activate_wp_cookie_allow() { | ||
add_filter( 'rocket_htaccess_mod_rewrite' , '__return_false' ); | ||
add_filter( 'rocket_cache_mandatory_cookies' , 'rocket_add_weepie_cookie_allow_mandatory_cookie' ); | ||
|
||
// Update the WP Rocket rules on the .htaccess file | ||
flush_rocket_htaccess(); | ||
|
||
// Regenerate the config file | ||
rocket_generate_config_file(); | ||
} | ||
|
||
// Remove cookies when we deactivate the plugin | ||
add_action( 'deactivate_wp-cookie-allow/wp-cookie-allow.php', 'rocket_deactivate_wp_cookie_allow', 11 ); | ||
function rocket_deactivate_wp_cookie_allow() { | ||
remove_filter( 'rocket_htaccess_mod_rewrite' , '__return_false' ); | ||
remove_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_weepie_cookie_allow_mandatory_cookie' ); | ||
|
||
// Update the WP Rocket rules on the .htaccess file | ||
flush_rocket_htaccess(); | ||
|
||
// Regenerate the config file | ||
rocket_generate_config_file(); | ||
} | ||
|
||
// Add the WeePie Cookie Allow cookie to the list of mandatory cookies before generating caching files | ||
function rocket_add_weepie_cookie_allow_mandatory_cookie( $cookies ) { | ||
$options = get_option( 'wpca_settings_general' ); | ||
|
||
if ( 1 === (int) $options['general_plugin_status'] && 1 === (int) $options['general_cookies_before_consent'] ) { | ||
$cookies['weepie-cookie-allow'] = 'wpca_consent'; | ||
} | ||
|
||
return $cookies; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
if ( class_exists( 'WR2X_Admin' ) ) : | ||
add_filter( 'wr2x_img_retina_url', 'rocket_cdn_on_images_from_wp_retina_x2' ); | ||
add_filter( 'wr2x_img_url', 'rocket_cdn_on_images_from_wp_retina_x2' ); | ||
/** | ||
* Conflict with WP Retina x2: Apply CDN on srcset attribute. | ||
* | ||
* @since 2.9.1 Use global $wr2x_admin | ||
* @since 2.5.5 | ||
* | ||
* @param string $url URL of the image. | ||
* @return string Updated URL with CDN | ||
*/ | ||
function rocket_cdn_on_images_from_wp_retina_x2( $url ) { | ||
global $wr2x_admin; | ||
|
||
if ( ! method_exists( $wr2x_admin, 'is_pro' ) || ! $wr2x_admin->is_pro() ) { | ||
return $url; | ||
} | ||
|
||
$cdn_domain = get_option( 'wr2x_cdn_domain' ); | ||
|
||
if ( ! empty( $cdn_domain ) ) { | ||
return $url; | ||
} | ||
|
||
return get_rocket_cdn_url( $url, array( 'all', 'images' ) ); | ||
} | ||
endif; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.