@@ -814,7 +814,7 @@ function rocket_settings_callback( $inputs ) {
if ( $inputs['schedule_automatic_cleanup'] != 1 && ( 'daily' != $inputs['automatic_cleanup_frequency'] || 'weekly' != $inputs['automatic_cleanup_frequency'] || 'monthly' != $inputs['automatic_cleanup_frequency'] ) ) {
unset( $inputs['automatic_cleanup_frequency'] );
}
-
+
/**
* Options: Activate bot preload
*/
@@ -859,15 +859,15 @@ function rocket_settings_callback( $inputs ) {
$inputs['wl_author_URI'] = isset( $inputs['wl_author_URI'] ) ? esc_url( $inputs['wl_author_URI'] ) : get_rocket_option( 'wl_author_URI' );
$inputs['wl_description'] = isset( $inputs['wl_description'] ) ? (array)$inputs['wl_description'] : get_rocket_option( 'wl_description' );
$inputs['wl_plugin_slug'] = sanitize_key( $inputs['wl_plugin_name'] );
-
+
/*
* Option : CloudFlare
*/
-
+
if ( defined( 'WP_ROCKET_CF_API_KEY' ) ) {
$inputs['cloudflare_api_key'] = get_rocket_option( 'cloudflare_api_key' );
}
-
+
/*
* Option : CDN
*/
@@ -904,24 +904,24 @@ function rocket_settings_callback( $inputs ) {
} else {
$inputs['cdn_reject_files'] = array();
}
-
+
/*
* Option: Support
*/
- $fake_options = array(
+ $fake_options = array(
'support_summary',
'support_description',
'support_documentation_validation'
);
-
+
foreach ( $fake_options as $option ) {
if( isset( $inputs[$option] ) ) {
unset($inputs[$option]);
}
}
-
+
$filename_prefix = rocket_is_white_label() ? sanitize_title( get_rocket_option( 'wl_plugin_name' ) ) : 'wp-rocket';
-
+
if ( isset( $_FILES['import'] )
&& preg_match( '/'. $filename_prefix . '-settings-20\d{2}-\d{2}-\d{2}-[a-f0-9]{13}\.txt/', $_FILES['import']['name'] )
&& 'text/plain' == $_FILES['import']['type'] ) {
@@ -951,15 +951,13 @@ function rocket_settings_callback( $inputs ) {
}
if ( ! rocket_valid_key() ) {
- $checked = rocket_check_key( 'live' );
- } else {
- $checked = rocket_check_key( 'transient_1' );
+ $checked = rocket_check_key();
}
if ( is_array( $checked ) ) {
- $inputs['consumer_key'] = $checked['consumer_key'];
+ $inputs['consumer_key'] = $checked['consumer_key'];
$inputs['consumer_email'] = $checked['consumer_email'];
- $inputs['secret_key'] = $checked['secret_key'];
+ $inputs['secret_key'] = $checked['secret_key'];
}
if ( rocket_valid_key() && ! empty( $inputs['secret_key'] ) && ! isset( $inputs['ignore'] ) ) {
@@ -986,17 +984,17 @@ function rocket_after_save_options( $oldvalue, $value ) {
if ( ! ( is_array( $oldvalue ) && is_array( $value ) ) ) {
return;
}
-
+
// This values do not need to clean the cache domain
- $removed = array(
- 'purge_cron_interval' => true,
- 'purge_cron_unit' => true,
- 'wl_plugin_name' => true,
- 'wl_plugin_URI' => true,
- 'wl_author' => true,
- 'wl_author_URI' => true,
- 'wl_description' => true,
- 'wl_plugin_slug' => true
+ $removed = array(
+ 'purge_cron_interval' => true,
+ 'purge_cron_unit' => true,
+ 'wl_plugin_name' => true,
+ 'wl_plugin_URI' => true,
+ 'wl_author' => true,
+ 'wl_author_URI' => true,
+ 'wl_description' => true,
+ 'wl_plugin_slug' => true
);
// Create 2 arrays to compare
@@ -1038,7 +1036,7 @@ function rocket_after_save_options( $oldvalue, $value ) {
if ( ! empty( $_POST ) && isset( $_POST['wp_rocket_settings']['submit_optimize'] ) ) {
do_rocket_database_optimization();
}
-
+
// Update CloudFlare Development Mode
$cloudflare_update_result = array();
@@ -1051,11 +1049,11 @@ function rocket_after_save_options( $oldvalue, $value ) {
$cloudflare_update_result[] = array( 'result' => 'success', 'message' => sprintf( __( 'CloudFlare development mode %s', 'rocket' ), $cloudflare_dev_mode_return ) );
}
}
-
+
// Update CloudFlare settings
if ( ! empty( $_POST ) && isset( $oldvalue['cloudflare_auto_settings'], $value['cloudflare_auto_settings'] ) && $oldvalue['cloudflare_auto_settings'] != $value['cloudflare_auto_settings'] ) {
$cf_old_settings = explode( ',', $value['cloudflare_old_settings'] );
- // Set Cache Level to Aggressive
+ // Set Cache Level to Aggressive
$cf_cache_level = ( isset( $cf_old_settings[0] ) && $value['cloudflare_auto_settings'] == 0 ) ? $cf_old_settings[0] : 'aggressive';
$cf_cache_level_return = set_rocket_cloudflare_cache_level( $cf_cache_level );
@@ -1099,12 +1097,12 @@ function rocket_after_save_options( $oldvalue, $value ) {
if ( ( bool ) $cloudflare_update_result ) {
set_transient( $GLOBALS['current_user']->ID . '_cloudflare_update_settings', $cloudflare_update_result );
}
-
+
// Regenerate advanced-cache.php file
if ( ! empty( $_POST ) && ( ( isset( $oldvalue['do_caching_mobile_files'] ) && ! isset( $value['do_caching_mobile_files'] ) ) || ( ! isset( $oldvalue['do_caching_mobile_files'] ) && isset( $value['do_caching_mobile_files'] ) ) || ( isset( $oldvalue['do_caching_mobile_files'], $value['do_caching_mobile_files'] ) ) && $oldvalue['do_caching_mobile_files'] != $value['do_caching_mobile_files'] ) ) {
rocket_generate_advanced_cache_file();
}
-
+
// Update .htaccess file rules
flush_rocket_htaccess( ! rocket_valid_key() );
@@ -1115,7 +1113,7 @@ function rocket_after_save_options( $oldvalue, $value ) {
if ( ! defined( 'WP_CACHE' ) || ! WP_CACHE ) {
set_rocket_wp_cache_define( true );
}
-
+
// Redirect on the correct page slug name to avoid false negative error message
if ( ! empty( $_POST ) && $oldvalue['wl_plugin_name'] != $value['wl_plugin_name'] &&
isset( $_POST['option_page'], $_POST['action'] ) && 'wp_rocket' == $_POST['option_page'] && 'update' == $_POST['action'] )
@@ -1187,12 +1185,12 @@ function rocket_pre_main_option( $newvalue, $oldvalue ) {
$cf_settings = get_rocket_cloudflare_settings();
$newvalue['cloudflare_old_settings'] = ( ! is_wp_error( $cf_settings ) ) ? implode( ',', array_filter( $cf_settings ) ) : '';
}
-
+
// Checked the SSL option if the whole website is on SSL
if( rocket_is_ssl_website() ) {
$newvalue['cache_ssl'] = 1;
}
-
+
if ( ! defined( 'WP_ROCKET_ADVANCED_CACHE' ) ) {
rocket_generate_advanced_cache_file();
}
diff --git a/inc/admin/upgrader.php b/inc/admin/upgrader.php
index a4d990167b..055263328d 100644
--- a/inc/admin/upgrader.php
+++ b/inc/admin/upgrader.php
@@ -29,7 +29,7 @@ function rocket_upgrader() {
$options = get_option( WP_ROCKET_SLUG ); // do not use get_rocket_option() here
$options['version'] = WP_ROCKET_VERSION;
- $keys = rocket_check_key( 'live' );
+ $keys = rocket_check_key();
if ( is_array( $keys ) ) {
$options = array_merge( $keys, $options );
}
@@ -40,11 +40,8 @@ function rocket_upgrader() {
if ( function_exists( 'opcache_reset' ) ) {
@opcache_reset();
}
- } else {
- if ( empty( $_POST ) && rocket_valid_key() ) {
- rocket_check_key( 'transient_30' );
- }
}
+
/** This filter is documented in inc/admin-bar.php */
if ( ! rocket_valid_key() && current_user_can( apply_filters( 'rocket_capacity', 'manage_options' ) ) &&
( ! isset( $_GET['page'] ) || 'wprocket' != $_GET['page'] ) ) {
@@ -263,21 +260,21 @@ function rocket_new_upgrade( $wp_rocket_version, $actual_version ) {
$options['minify_html_inline_css'] = 1;
$options['minify_html_inline_js'] = 1;
}
-
+
update_option( WP_ROCKET_SLUG, $options );
// Regenerate advanced-cache.php file
rocket_generate_advanced_cache_file();
}
-
+
if ( version_compare( $actual_version, '2.7', '<' ) ) {
// Regenerate advanced-cache.php file
rocket_generate_advanced_cache_file();
-
+
// Regenerate config file
rocket_generate_config_file();
}
-
+
if ( version_compare( $actual_version, '2.7.1', '<' ) ) {
// Regenerate advanced-cache.php file
rocket_generate_advanced_cache_file();
@@ -288,7 +285,7 @@ function rocket_new_upgrade( $wp_rocket_version, $actual_version ) {
$options['manual_preload'] = 1;
$options['automatic_preload'] = 1;
$options['sitemap_preload_url_crawl'] = '500000';
-
+
update_option( WP_ROCKET_SLUG, $options );
}
@@ -323,14 +320,20 @@ function rocket_new_upgrade( $wp_rocket_version, $actual_version ) {
update_rocket_option( 'minify_html_inline_css', 0 );
update_rocket_option( 'minify_html_inline_js', 0 );
}
-
+
if ( 'on' === get_option( 'autoptimize_css') ) {
update_rocket_option( 'minify_css', 0 );
}
-
+
if ( 'on' === get_option( 'autoptimize_js') ) {
update_rocket_option( 'minify_js', 0 );
}
}
}
+
+ // Delete old transients.
+ if ( version_compare( $actual_version, '2.9.7', '<' ) ) {
+ delete_transient( 'rocket_check_licence_30' );
+ delete_transient( 'rocket_check_licence_1' );
+ }
}
diff --git a/inc/functions/options.php b/inc/functions/options.php
index 5783f38854..3e5125da5b 100755
--- a/inc/functions/options.php
+++ b/inc/functions/options.php
@@ -29,7 +29,7 @@ function get_rocket_option( $option, $default = false ) {
return WP_ROCKET_EMAIL;
}
$value = isset( $options[ $option ] ) && $options[ $option ] !== '' ? $options[ $option ] : $default;
-
+
/**
* Filter any WP Rocket option after read
*
@@ -52,7 +52,7 @@ function get_rocket_option( $option, $default = false ) {
function update_rocket_option( $key, $value ) {
$options = get_option( WP_ROCKET_SLUG );
$options[ $key ] = $value;
-
+
update_option( WP_ROCKET_SLUG, $options );
}
@@ -70,15 +70,15 @@ function is_rocket_post_excluded_option( $option ) {
if ( ! is_object( $post ) ) {
return false;
}
-
+
if( is_home() ) {
$post_id = get_queried_object_id();
}
-
+
if ( is_singular() && isset( $post ) ) {
$post_id = $post->ID;
}
-
+
return ( isset( $post_id ) ) ? get_post_meta( $post_id, '_rocket_exclude_' . $option, true ) : false;
}
@@ -139,7 +139,7 @@ function is_rocket_cdn_on_ssl() {
/**
* Get the domain names to DNS prefetch from WP Rocket options
- *
+ *
* @since 2.8.9
* @author Remy Perona
*
@@ -191,10 +191,10 @@ function get_rocket_purge_cron_interval() {
*/
function get_rocket_cache_reject_uri() {
$uri = get_rocket_option( 'cache_reject_uri', array() );
-
+
// Exclude cart & checkout pages from e-commerce plugins
$uri = array_merge( $uri, get_rocket_ecommerce_exclude_pages() );
-
+
// Exclude hide login plugins
$uri = array_merge( $uri, get_rocket_logins_exclude_pages() );
@@ -202,7 +202,7 @@ function get_rocket_cache_reject_uri() {
if ( ! is_rocket_cache_feed() ) {
$uri[] = '.*/' . $GLOBALS['wp_rewrite']->feed_base . '/?';
}
-
+
/**
* Filter the rejected uri
*
@@ -253,7 +253,7 @@ function get_rocket_cache_reject_cookies() {
*/
function get_rocket_cache_mandatory_cookies() {
$cookies = array();
-
+
/**
* Filter list of mandatory cookies
*
@@ -263,7 +263,7 @@ function get_rocket_cache_mandatory_cookies() {
*/
$cookies = apply_filters( 'rocket_cache_mandatory_cookies', $cookies );
$cookies = array_filter( $cookies );
-
+
$cookies = implode( '|', $cookies );
return $cookies;
}
@@ -277,7 +277,7 @@ function get_rocket_cache_mandatory_cookies() {
*/
function get_rocket_cache_dynamic_cookies() {
$cookies = array();
-
+
/**
* Filter list of dynamic cookies
*
@@ -287,7 +287,7 @@ function get_rocket_cache_dynamic_cookies() {
*/
$cookies = apply_filters( 'rocket_cache_dynamic_cookies', $cookies );
$cookies = array_filter( $cookies );
-
+
return $cookies;
}
@@ -310,10 +310,10 @@ function get_rocket_cache_reject_ua() {
* @param array $ua List of rejected User-Agent
*/
$ua = apply_filters( 'rocket_cache_reject_ua', $ua );
-
+
$ua = implode( '|', array_filter( $ua ) );
$ua = str_replace( array( ' ', '\\\\ ' ), '\\ ', $ua );
-
+
return $ua;
}
@@ -326,7 +326,7 @@ function get_rocket_cache_reject_ua() {
*/
function get_rocket_cdn_reject_files() {
$files = get_rocket_option( 'cdn_reject_files', array() );
-
+
/**
* Filter the rejected files
*
@@ -335,9 +335,9 @@ function get_rocket_cdn_reject_files() {
* @param array $files List of rejected files
*/
$files = apply_filters( 'rocket_cdn_reject_files', $files );
-
- $files = implode( '|', array_filter( $files ) );
-
+
+ $files = implode( '|', array_filter( $files ) );
+
return $files;
}
@@ -369,7 +369,7 @@ function get_rocket_cdn_cnames( $zone = 'all' ) {
}
}
}
-
+
/**
* Filter all CNAMES.
*
@@ -379,7 +379,7 @@ function get_rocket_cdn_cnames( $zone = 'all' ) {
*/
$hosts = apply_filters( 'rocket_cdn_cnames', $hosts );
$hosts = array_filter( $hosts );
-
+
return $hosts;
}
@@ -392,7 +392,7 @@ function get_rocket_cdn_cnames( $zone = 'all' ) {
*/
function get_rocket_cache_query_string() {
$query_strings = get_rocket_option( 'cache_query_strings', array() );
-
+
/**
* Filter query strings which can be cached.
*
@@ -414,10 +414,10 @@ function get_rocket_cache_query_string() {
*/
function get_rocket_exclude_css() {
global $rocket_excluded_enqueue_css;
-
+
$css_files = get_rocket_option( 'exclude_css', array() );
$css_files = array_unique( array_merge( $css_files, (array) $rocket_excluded_enqueue_css ) );
-
+
/**
* Filter CSS files to exclude to the minification.
*
@@ -426,7 +426,7 @@ function get_rocket_exclude_css() {
* @param array $css_files List of excluded CSS files.
*/
$css_files = apply_filters( 'rocket_exclude_css', $css_files );
-
+
return $css_files;
}
@@ -437,12 +437,12 @@ function get_rocket_exclude_css() {
*
* @return array List of excluded JS files.
*/
-function get_rocket_exclude_js() {
+function get_rocket_exclude_js() {
global $rocket_excluded_enqueue_js;
-
+
$js_files = get_rocket_option( 'exclude_js', array() );
$js_files = array_unique( array_merge( $js_files, (array) $rocket_excluded_enqueue_js ) );
-
+
/**
* Filter JS files to exclude to the minification.
*
@@ -451,7 +451,7 @@ function get_rocket_exclude_js() {
* @param array $css_files List of excluded JS files.
*/
$js_files = apply_filters( 'rocket_exclude_js', $js_files );
-
+
return $js_files;
}
@@ -464,15 +464,15 @@ function get_rocket_exclude_js() {
*/
function get_rocket_minify_js_in_footer() {
global $rocket_enqueue_js_in_footer, $wp_scripts;
-
+
$js_files = get_rocket_option( 'minify_js_in_footer', array() );
$js_files = array_map( 'rocket_set_internal_url_scheme', $js_files );
$js_files = array_unique( array_merge( $js_files, (array) $rocket_enqueue_js_in_footer ) );
-
+
if ( rocket_is_plugin_active('sitepress-multilingual-cms/sitepress.php') && isset( $wp_scripts->registered['sitepress'] ) ) {
$js_files[] = $wp_scripts->registered['sitepress']->src;
}
-
+
/**
* Filter JS files to move in the footer during the minification.
*
@@ -481,7 +481,7 @@ function get_rocket_minify_js_in_footer() {
* @param array $js_files List of JS files.
*/
$js_files = apply_filters( 'rocket_minify_js_in_footer', $js_files );
-
+
return $js_files;
}
@@ -501,7 +501,7 @@ function get_rocket_deferred_js_files() {
* @param array List of Deferred JavaScript files
*/
$deferred_js_files = apply_filters( 'rocket_minify_deferred_js', get_rocket_option( 'deferred_js_files', array() ) );
-
+
return $deferred_js_files;
}
@@ -522,62 +522,49 @@ function rocket_valid_key() {
}
/**
- * Determine if the key is valid
+ * Determine if the key is valid.
*
- * @since 2.2 The function do the live check and update the option
+ * @since 2.9.7 Remove arguments ($type & $data).
+ * @since 2.9.7 Stop to auto-check the validation each 1 & 30 days.
+ * @since 2.2 The function do the live check and update the option.
*/
-function rocket_check_key( $type = 'transient_1', $data = null ) {
+function rocket_check_key() {
// Recheck the license
$return = rocket_valid_key();
- if ( ! rocket_valid_key()
- || ( 'transient_1' == $type && ! get_transient( 'rocket_check_licence_1' ) )
- || ( 'transient_30' == $type && ! get_transient( 'rocket_check_licence_30' ) )
- || 'live' == $type ) {
-
- $response = wp_remote_get( WP_ROCKET_WEB_VALID, array( 'timeout'=>30 ) );
+ if ( ! rocket_valid_key() ) {
+ $response = wp_remote_get( WP_ROCKET_WEB_VALID, array( 'timeout' => 30 ) );
$json = ! is_wp_error( $response ) ? json_decode( $response['body'] ) : false;
$rocket_options = array();
if ( $json ) {
-
$rocket_options['consumer_key'] = $json->data->consumer_key;
$rocket_options['consumer_email'] = $json->data->consumer_email;
if( $json->success ) {
-
$rocket_options['secret_key'] = $json->data->secret_key;
+
if ( ! get_rocket_option( 'license' ) ) {
$rocket_options['license'] = '1';
}
-
- if ( 'live' != $type ) {
- if ( 'transient_1' == $type ) {
- set_transient( 'rocket_check_licence_1', true, DAY_IN_SECONDS );
- } elseif ( 'transient_30' == $type ) {
- set_transient( 'rocket_check_licence_30', true, DAY_IN_SECONDS*30 );
- }
- }
-
} else {
- $messages = array( 'BAD_LICENSE' => __( 'Your license is not valid.', 'rocket' ),
- 'BAD_NUMBER' => __( 'You cannot add more websites. Upgrade your account.', 'rocket' ),
- 'BAD_SITE' => __( 'This website is not allowed.', 'rocket' ),
- 'BAD_KEY' => __( 'This license key is not accepted.', 'rocket' ),
- );
+ $messages = array(
+ 'BAD_LICENSE' => __( 'Your license is not valid.', 'rocket' ),
+ 'BAD_NUMBER' => __( 'You cannot add more websites. Upgrade your account.', 'rocket' ),
+ 'BAD_SITE' => __( 'This website is not allowed.', 'rocket' ),
+ 'BAD_KEY' => __( 'This license key is not accepted.', 'rocket' ),
+ );
$rocket_options['secret_key'] = '';
add_settings_error( 'general', 'settings_updated', $messages[ $json->data->reason ], 'error' );
-
}
set_transient( WP_ROCKET_SLUG, $rocket_options );
$return = (array) $rocket_options;
-
}
}
return $return;
-}
\ No newline at end of file
+}
diff --git a/uninstall.php b/uninstall.php
index 2940b83d38..bc6af530ed 100755
--- a/uninstall.php
+++ b/uninstall.php
@@ -7,8 +7,6 @@
delete_site_transient( 'update_wprocket' );
delete_site_transient( 'update_wprocket_response' );
delete_transient( 'wp_rocket_settings' );
-delete_transient( 'rocket_check_licence_30' );
-delete_transient( 'rocket_check_licence_1' );
delete_transient( 'rocket_cloudflare_ips' );
// Delete WP Rocket options
@@ -32,7 +30,7 @@ function __rocket_rrmdir( $dir ) {
if ( ! is_dir( $dir ) ) {
@unlink( $dir );
- return;
+ return;
}
if ( $globs = glob( $dir . '/*', GLOB_NOSORT ) ) {
@@ -48,4 +46,4 @@ function __rocket_rrmdir( $dir ) {
__rocket_rrmdir( WP_CONTENT_DIR . '/cache/wp-rocket/' );
__rocket_rrmdir( WP_CONTENT_DIR . '/cache/min/' );
__rocket_rrmdir( WP_CONTENT_DIR . '/cache/busting/' );
-__rocket_rrmdir( WP_CONTENT_DIR . '/wp-rocket-config/' );
\ No newline at end of file
+__rocket_rrmdir( WP_CONTENT_DIR . '/wp-rocket-config/' );
diff --git a/wp-rocket.php b/wp-rocket.php
index f99bc4107b..e802a291e7 100755
--- a/wp-rocket.php
+++ b/wp-rocket.php
@@ -3,7 +3,7 @@
Plugin Name: WP Rocket
Plugin URI: https://wp-rocket.me
Description: The best WordPress performance plugin.
-Version: 2.9.6
+Version: 2.9.7
Code Name: Iridonia
Author: WP Media
Contributors: Jonathan Buttigieg, Julio Potier, Remy Perona
@@ -19,10 +19,10 @@
defined( 'ABSPATH' ) or die( 'Cheatin’ uh?' );
// Rocket defines
-define( 'WP_ROCKET_VERSION' , '2.9.6' );
+define( 'WP_ROCKET_VERSION' , '2.9.7' );
define( 'WP_ROCKET_PRIVATE_KEY' , false );
define( 'WP_ROCKET_SLUG' , 'wp_rocket_settings' );
-define( 'WP_ROCKET_WEB_MAIN' , 'https://wp-rocket.me/' );
+define( 'WP_ROCKET_WEB_MAIN' , false );
define( 'WP_ROCKET_WEB_API' , WP_ROCKET_WEB_MAIN . 'api/wp-rocket/' );
define( 'WP_ROCKET_WEB_CHECK' , WP_ROCKET_WEB_MAIN . 'check_update.php' );
define( 'WP_ROCKET_WEB_VALID' , WP_ROCKET_WEB_MAIN . 'valid_key.php' );