Skip to content

Commit

Permalink
Merge pull request #428 from wp-media/branch-2.10.1
Browse files Browse the repository at this point in the history
2.10.1
  • Loading branch information
remyperona authored Jun 7, 2017
2 parents 8cc8fe1 + 19cb70d commit 48a18b2
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 56 deletions.
4 changes: 1 addition & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# PHPUnit files
.travis.yml export-ignore
bin export-ignore
tests/bootstrap.php export-ignore
tests/test-sample.php export-ignore
tests/inc export-ignore
tests export-ignore
phpunit.xml export-ignore
README.md export-ignore
.gitattributes export-ignore
Expand Down
38 changes: 0 additions & 38 deletions inc/3rd-party/hosting/wpengine.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,6 @@ function rocket_run_rocket_bot_after_wpengine() {
}
add_action( 'admin_init', 'rocket_run_rocket_bot_after_wpengine' );

/**
* Activate the CDN option if WPEngine CDN is active
*
* @since 2.7
*
* @param bool $value WP Rocket CDN option value.
* @return bool true if there is a CDN domain, default value otherwise
*/
function rocket_auto_activate_cdn_on_wpengine( $value ) {
$cdn_domain = rocket_get_wp_engine_cdn_domain();

if ( ! empty( $cdn_domain ) ) {
$value = true;
}

return $value;
}
add_filter( 'get_rocket_option_cdn', 'rocket_auto_activate_cdn_on_wpengine' );

/**
* Add WP Engine CDN CNAMES to the list of allowed CNAMES
*
* @since 2.7
*
* @param array $hosts WP Rocket CDN cnames.
* @return array Updated WP Rocket CDN cnames values
*/
function rocket_add_wpengine_cdn_cnames( $hosts ) {
$cdn_domain = rocket_get_wp_engine_cdn_domain();

if ( ! empty( $cdn_domain ) ) {
$hosts[] = $cdn_domain;
}

return $hosts;
}
add_filter( 'rocket_cdn_cnames', 'rocket_add_wpengine_cdn_cnames' );

/**
* Call the cache server to purge the cache with WP Engine hosting.
*
Expand Down
117 changes: 106 additions & 11 deletions inc/3rd-party/jetpack.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<?php
/**
* Compatibility file with the Jetpack plugin.
* https://wordpress.org/plugins/jetpack/
*
* @package WP Rocket
*/

if ( defined( 'JETPACK__VERSION' ) ) :
$jetpack_active_modules = get_option( 'jetpack_active_modules' );
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );

// Is Jetpack installed and active?
if ( class_exists( 'Jetpack' ) ) :
/**
* Improvement with Jetpack: auto-detect the XML sitemaps for the preload option
*
* @since 2.8
* @author Remy Perona
*/
if ( is_array( $jetpack_active_modules ) && in_array( 'sitemaps', $jetpack_active_modules, true ) && function_exists( 'jetpack_sitemap_uri' ) ) {
if (
Jetpack::is_module_active( 'sitemaps' )
&& function_exists( 'jetpack_sitemap_uri' )
) {
/**
* Add Jetpack option to WP Rocket options
*
Expand Down Expand Up @@ -73,20 +83,105 @@ function rocket_sitemap_preload_jetpack_option( $options ) {
$options[] = array(
'parent' => 'sitemap_preload',
'type' => 'checkbox',
'label' => __( 'Jetpack XML Sitemaps', 'rocket' ),
'label_for' => 'jetpack_xml_sitemap',
'label_screen' => sprintf( __( 'Preload the sitemap from the %s plugin', 'rocket' ), 'Jetpack' ),
'default' => 0,
'label' => __( 'Jetpack XML Sitemaps', 'rocket' ),
'label_for' => 'jetpack_xml_sitemap',
'label_screen' => sprintf( __( 'Preload the sitemap from the Jetpack plugin', 'rocket' ), 'Jetpack' ),
'default' => 0,
);
$options[] = array(
'parent' => 'sitemap_preload',
'type' => 'helper_description',
'name' => 'jetpack_xml_sitemap_desc',
'type' => 'helper_description',
'name' => 'jetpack_xml_sitemap_desc',
// translators: %s = plugin name, e.g. Yoast SEO.
'description' => sprintf( __( 'We automatically detected the sitemap generated by the %s plugin. You can check the option to preload it.', 'rocket' ), 'Jetpack' ),
);

return $options;
}
add_filter( 'rocket_sitemap_preload_options', 'rocket_sitemap_preload_jetpack_option' );
}
endif;
} // End if().

/**
* Support Jetpack's EU Cookie Law Widget.
*
* @see https://jetpack.com/support/extra-sidebar-widgets/eu-cookie-law-widget/
*
* @since 2.10.1
* @author Jeremy Herve
*/
if ( Jetpack::is_module_active( 'widgets' ) ) :

/**
* Add the EU Cookie Law to the list of mandatory cookies before generating caching files.
*
* @since 2.10.1
* @author Jeremy Herve
*
* @param array $cookies List of mandatory cookies.
*/
function rocket_add_jetpack_cookie_law_mandatory_cookie( $cookies ) {
$cookies['jetpack-eu-cookie-law'] = 'eucookielaw';

return $cookies;
}
add_filter( 'rocket_cache_mandatory_cookies' , 'rocket_add_jetpack_cookie_law_mandatory_cookie' );

// Don't add the WP Rocket rewrite rules to avoid issues.
add_filter( 'rocket_htaccess_mod_rewrite', '__return_false' );

/**
* Add Jetpack cookie when:
* - Jetpack is active.
* - Jetpack's Extra Sidebar Widgets module is active.
* - The widget is active.
* - the rocket_jetpack_eu_cookie_widget option is empty or not set.
*
* @since 2.10.1
* @author Jeremy Herve
*/
function rocket_activate_jetpack_cookie_law() {
$rocket_jp_eu_cookie_widget = get_option( 'rocket_jetpack_eu_cookie_widget' );

if (
is_active_widget( false, false, 'eu_cookie_law_widget' )
&& empty( $rocket_jp_eu_cookie_widget )
) {
add_filter( 'rocket_htaccess_mod_rewrite' , '__return_false' );
add_filter( 'rocket_cache_mandatory_cookies' , 'rocket_add_jetpack_cookie_law_mandatory_cookie' );

// Update the WP Rocket rules on the .htaccess file.
flush_rocket_htaccess();

// Regenerate the config file.
rocket_generate_config_file();

// Set the option, so this is not triggered again.
update_option( 'rocket_jetpack_eu_cookie_widget', 1, true );
}
}
add_action( 'admin_init', 'rocket_activate_jetpack_cookie_law' );

endif; // End if Widgets module is active check.

endif; // End if Jetpack is active check.

/**
* Remove cookies if Jetpack gets deactivated.
*
* @since 2.10.1
* @author Jeremy Herve
*/
function rocket_remove_jetpack_cookie_law_mandatory_cookie() {
remove_filter( 'rocket_htaccess_mod_rewrite' , '__return_false' );
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();

// Delete our option.
delete_option( 'rocket_jetpack_eu_cookie_widget' );
}
add_action( 'deactivate_jetpack/jetpack.php', 'rocket_remove_jetpack_cookie_law_mandatory_cookie', 11 );
5 changes: 4 additions & 1 deletion uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
// Delete WP Rocket options.
delete_option( 'wp_rocket_settings' );

// Delete all user meta related to WP Rocket.
// Delete Compatibility options.
delete_option( 'rocket_jetpack_eu_cookie_widget' );

// Delete all user meta related to WP Rocket
delete_metadata( 'user', '', 'rocket_boxes', '', true );

// Clear scheduled WP Rocket Cron.
Expand Down
5 changes: 2 additions & 3 deletions wp-rocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Rocket
* Plugin URI: https://wp-rocket.me
* Description: The best WordPress performance plugin.
* Version: 2.10
* Version: 2.10.1
* Code Name: Endor
* Author: WP Media
* Contributors: Jonathan Buttigieg, Julio Potier, Remy Perona
Expand All @@ -19,7 +19,7 @@
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );

// Rocket defines.
define( 'WP_ROCKET_VERSION' , '2.10' );
define( 'WP_ROCKET_VERSION' , '2.10.1' );
define( 'WP_ROCKET_PRIVATE_KEY' , false );
define( 'WP_ROCKET_SLUG' , 'wp_rocket_settings' );
define( 'WP_ROCKET_WEB_MAIN' , false );
Expand Down Expand Up @@ -269,7 +269,6 @@ function rocket_activation() {
require( WP_ROCKET_FUNCTIONS_PATH . 'plugins.php' );
require( WP_ROCKET_FUNCTIONS_PATH . 'i18n.php' );
require( WP_ROCKET_FUNCTIONS_PATH . 'htaccess.php' );
require( WP_ROCKET_3RD_PARTY_PATH . 'hosting/godaddy.php' );

if ( version_compare( phpversion(), '5.3.0', '>=' ) ) {
require( WP_ROCKET_3RD_PARTY_PATH . 'hosting/godaddy.php' );
Expand Down

0 comments on commit 48a18b2

Please sign in to comment.