From af876b3a3034fa432c0340e10f2bc180dfcd192d Mon Sep 17 00:00:00 2001 From: Jonathan Buttigieg Date: Mon, 27 Feb 2017 15:36:24 +0100 Subject: [PATCH 1/5] Add tagging to 2.9.7 --- wp-rocket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-rocket.php b/wp-rocket.php index f99bc4107b..f401d2e511 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,7 +19,7 @@ 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/' ); From 0be7598764820dd9f05f1c3ea50f6effd89d9ea4 Mon Sep 17 00:00:00 2001 From: Jonathan Buttigieg Date: Mon, 27 Feb 2017 15:36:42 +0100 Subject: [PATCH 2/5] Set WP_ROCKET_WEB_MAIN to false by default --- wp-rocket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-rocket.php b/wp-rocket.php index f401d2e511..e802a291e7 100755 --- a/wp-rocket.php +++ b/wp-rocket.php @@ -22,7 +22,7 @@ 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' ); From 3d59163e40e6a2aca690335d8ee8c7e89f65a4fb Mon Sep 17 00:00:00 2001 From: Jonathan Buttigieg Date: Mon, 27 Feb 2017 15:39:38 +0100 Subject: [PATCH 3/5] Stop to check valid key for 1 & 30 days --- inc/functions/options.php | 89 +++++++++++++++++++-------------------- uninstall.php | 6 +-- 2 files changed, 45 insertions(+), 50 deletions(-) diff --git a/inc/functions/options.php b/inc/functions/options.php index 5783f38854..bf2852aeee 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; } @@ -530,10 +530,7 @@ function rocket_check_key( $type = 'transient_1', $data = null ) { // 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 ) { + if ( ! rocket_valid_key() || 'live' == $type ) { $response = wp_remote_get( WP_ROCKET_WEB_VALID, array( 'timeout'=>30 ) ); @@ -551,7 +548,7 @@ function rocket_check_key( $type = 'transient_1', $data = null ) { 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 ); @@ -562,15 +559,15 @@ function rocket_check_key( $type = 'transient_1', $data = null ) { } 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 ); @@ -580,4 +577,4 @@ function rocket_check_key( $type = 'transient_1', $data = null ) { } 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/' ); From 7ef515ca471edff974cbeab1a769704730150e30 Mon Sep 17 00:00:00 2001 From: Jonathan Buttigieg Date: Mon, 27 Feb 2017 15:56:06 +0100 Subject: [PATCH 4/5] Stop to check valid_key after 1 & 30 days --- inc/admin/options.php | 122 +++++++++++++++++++------------------- inc/admin/upgrader.php | 21 +++---- inc/functions/options.php | 26 +++----- 3 files changed, 77 insertions(+), 92 deletions(-) diff --git a/inc/admin/options.php b/inc/admin/options.php index 7f1d02825f..b822cd876b 100644 --- a/inc/admin/options.php +++ b/inc/admin/options.php @@ -54,7 +54,7 @@ function rocket_field( $args ) { $readonly = isset( $args['readonly'] ) && $args['readonly'] ? ' readonly="readonly" disabled="disabled"' : ''; $cols = isset( $args['cols'] ) ? (int) $args['cols'] : 50; $rows = isset( $args['rows'] ) ? (int) $args['rows'] : 5; - + if( ! isset( $args['fieldset'] ) || 'start' == $args['fieldset'] ){ echo '
'; } @@ -68,7 +68,7 @@ function rocket_field( $args ) { if ( $value === false ) { $value = $default; } - + $value = esc_attr( $value ); $number_options = $args['type']=='number' ? ' min="0" class="small-text"' : ''; $autocomplete = in_array( $args['name'], array( 'consumer_key', 'consumer_email' ) ) ? ' autocomplete="off"' : ''; @@ -83,11 +83,11 @@ function rocket_field( $args ) { case 'cloudflare_api_key' : $value = get_rocket_option( $args['name'] ); - + if ( 'cloudflare_api_key' == $args['name'] && defined( 'WP_ROCKET_CF_API_KEY' ) ) { $value = WP_ROCKET_CF_API_KEY; - } - + } + $value = esc_attr( $value ); $disabled = ( 'cloudflare_api_key' == $args['name'] && defined( 'WP_ROCKET_CF_API_KEY' ) ) ? ' disabled="disabled"' : $readonly; $cf_valid_credentials = false; @@ -95,7 +95,7 @@ function rocket_field( $args ) { $cf_valid_credentials = ( is_wp_error( rocket_cloudflare_valid_auth() ) ) ? false : true; } ?> - +