From c795478da430461ff832cf2a8f6293750f62750d Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Tue, 31 Dec 2019 11:33:21 +0530 Subject: [PATCH 1/8] fix: add necessary action hooks --- perform.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/perform.php b/perform.php index bde5ab2..85c658f 100644 --- a/perform.php +++ b/perform.php @@ -172,11 +172,25 @@ function_exists( 'phpversion' ) && */ public function init() { + /** + * This action will be used before init of the plugin. + * + * @since 1.2.3 + */ + do_action( 'perform_before_init' ); + // Set up localization. $this->load_textdomain(); $this->settings = new Perform_Admin_Settings(); - $this->config = new WPConfigTransformer( ABSPATH . 'wp-config.php' ); + + /** + * This action will be used after the plugin is loaded + * + * @since 1.2.3 + */ + do_action( 'perform_loaded' ); + } /** From 92ea1d1d602a11702154179518eaaa32e3f13c3b Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Tue, 31 Dec 2019 11:33:37 +0530 Subject: [PATCH 2/8] fix: remove wpconfig transformer library --- perform.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/perform.php b/perform.php index 85c658f..7b0564c 100644 --- a/perform.php +++ b/perform.php @@ -250,9 +250,6 @@ public function includes() { require_once PERFORM_PLUGIN_DIR . '/includes/admin/class-perform-admin-settings-api.php'; require_once PERFORM_PLUGIN_DIR . '/includes/admin/class-perform-admin-settings.php'; - // Load Libraries. - require_once PERFORM_PLUGIN_DIR . '/includes/libraries/WPConfigTransformer.php'; - // Load Frontend Files. require_once PERFORM_PLUGIN_DIR . '/includes/install.php'; require_once PERFORM_PLUGIN_DIR . '/includes/actions.php'; From f92d488bacf23426c2128e38b39da338c00736bd Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Tue, 31 Dec 2019 11:33:55 +0530 Subject: [PATCH 3/8] fix: modify the way the constants are defined --- includes/functions.php | 69 +++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index b655a0c..5c58776 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -273,34 +273,6 @@ function perform_load_modules_on_init() { } - /** - * Set Post Revisions Limit. - * - * @since 1.0.0 - */ - $post_revisions_limit = perform_get_option( 'limit_post_revisions', 'perform_common' ); - if ( ! empty( $post_revisions_limit ) ) { - Perform()->config->exists( 'constant', 'WP_POST_REVISIONS' ) ? - Perform()->config->update( 'constant', 'WP_POST_REVISIONS', $post_revisions_limit ) : - Perform()->config->add( 'constant', 'WP_POST_REVISIONS', $post_revisions_limit ); - } else { - Perform()->config->remove( 'constant', 'WP_POST_REVISIONS' ); - } - - /** - * Set Autosave Interval. - * - * @since 1.0.0 - */ - $autosave_interval = perform_get_option( 'autosave_interval', 'perform_common' ); - if ( ! empty( $autosave_interval ) ) { - Perform()->config->exists( 'constant', 'AUTOSAVE_INTERVAL' ) ? - Perform()->config->update( 'constant', 'AUTOSAVE_INTERVAL', $autosave_interval ) : - Perform()->config->add( 'constant', 'AUTOSAVE_INTERVAL', $autosave_interval ); - } else { - Perform()->config->remove( 'constant', 'AUTOSAVE_INTERVAL' ); - } - // Load WooCommerce Manager module when WooCommerce is active. if ( perform_is_woocommerce_active() ) { /** @@ -327,6 +299,47 @@ function perform_load_modules_on_init() { add_action( 'init', 'perform_load_modules_on_init', 0 ); +function perform_define_necessary_constants() { + + /** + * Set Autosave Interval. + * + * @since 1.0.0 + */ + $autosave_interval = perform_get_option( 'autosave_interval', 'perform_common' ); + + // If `Autosave Interval` is already defined in `wp-config.php` then leave it as is. + if ( ! empty( $autosave_interval ) && ! defined( 'AUTOSAVE_INTERVAL' ) ) { + define( 'AUTOSAVE_INTERVAL', $autosave_interval ); + } + + /** + * Set Post Revisions Limit. + * + * @since 1.0.0 + */ + $post_revisions_limit = perform_get_option( 'limit_post_revisions', 'perform_common' ); + + // If `Post Revisions` is already defined in `wp-config.php` then leave it as is. + if ( ! empty( $post_revisions_limit ) && ! defined( 'WP_POST_REVISIONS' ) ) { + define( 'WP_POST_REVISIONS', $post_revisions_limit ); + } + + /** + * Force Admin SSL. + * + * @since 1.2.3 + */ + $is_ssl_enabled = perform_get_option( 'enable_ssl', 'perform_ssl', false ); + + // If `Force Admin SSL` is already defined in `wp-config.php` then leave it as is. + if ( ! empty( $is_ssl_enabled ) && ! defined( 'FORCE_SSL_ADMIN' ) ) { + define( 'FORCE_SSL_ADMIN', 'true' ); + } +} + +add_action( 'perform_loaded', 'perform_define_necessary_constants' ); + /** * Load SSL Manager. * From 91981eca014b26d88047e8d3ad42456871ec6104 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Tue, 31 Dec 2019 11:34:14 +0530 Subject: [PATCH 4/8] fix: move force admin ssl constant to functions.php --- includes/modules/class-perform-ssl-manager.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/includes/modules/class-perform-ssl-manager.php b/includes/modules/class-perform-ssl-manager.php index 53180d3..86b9df5 100644 --- a/includes/modules/class-perform-ssl-manager.php +++ b/includes/modules/class-perform-ssl-manager.php @@ -44,19 +44,10 @@ public function __construct() { $this->is_ssl_enabled = perform_get_option( 'enable_ssl', 'perform_ssl', false ); - if ( $this->is_ssl_enabled ) { - - // Forcing SSL for admin. - Perform()->config->exists( 'constant', 'FORCE_SSL_ADMIN' ) ? - Perform()->config->update( 'constant', 'FORCE_SSL_ADMIN', 'true' ) : - Perform()->config->add( 'constant', 'FORCE_SSL_ADMIN', 'true' ); - - // Proceed, only if site accessed with non-HTTP url. - if ( ! is_ssl() ) { - $this->wp_redirect_to_ssl(); - } + // Proceed, only if site accessed with non-HTTP url. + if ( ! is_ssl() && $this->is_ssl_enabled ) { + $this->wp_redirect_to_ssl(); } - } /** From 0d6fb287f3044e17546adf9783318bd36cdd25e0 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Tue, 31 Dec 2019 11:35:21 +0530 Subject: [PATCH 5/8] fix: remove config public variable --- perform.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/perform.php b/perform.php index 7b0564c..49305dc 100644 --- a/perform.php +++ b/perform.php @@ -67,16 +67,6 @@ final class Perform { */ public $settings; - /** - * Config Object to transform. - * - * @since 1.2.2 - * @access public - * - * @var WPConfigTransformer object - */ - public $config; - /** * Throw error on object clone. * From aa9c7df79a8de9e91124ec23bab1b08d3df0c742 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Tue, 31 Dec 2019 11:36:02 +0530 Subject: [PATCH 6/8] fix: update plugin version to 1.2.3 --- perform.php | 4 ++-- readme.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/perform.php b/perform.php index 49305dc..eb11002 100644 --- a/perform.php +++ b/perform.php @@ -17,7 +17,7 @@ * Plugin Name: Perform - Performance Optimization Plugin for WordPress * Plugin URI: https://performwp.com/ * Description: This plugin adds toolset for performance and speed improvements to your WordPress sites. - * Version: 1.2.2 + * Version: 1.2.3 * Author: Mehul Gohil * Author URI: https://www.mehulgohil.in/ * License: GPLv2 or later @@ -195,7 +195,7 @@ private function setup_constants() { // Plugin version. if ( ! defined( 'PERFORM_VERSION' ) ) { - define( 'PERFORM_VERSION', '1.2.2' ); + define( 'PERFORM_VERSION', '1.2.3' ); } // Minimum Required PHP version. diff --git a/readme.txt b/readme.txt index 1693844..0a077be 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Donate link: https://mehulgohil.com/donate/ Requires at least: 4.8 Tested up to: 5.3 Requires PHP: 5.6 -Stable tag: 1.2.2 +Stable tag: 1.2.3 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html From c27ec19a6b904f3c71221a1126ebc27a0cdd48d8 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Tue, 31 Dec 2019 11:41:02 +0530 Subject: [PATCH 7/8] chore: update language.pot for 1.2.3 --- languages/perform.pot | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/languages/perform.pot b/languages/perform.pot index 675c152..9f23a2c 100644 --- a/languages/perform.pot +++ b/languages/perform.pot @@ -521,34 +521,34 @@ msgstr "" msgid "Manage Assets" msgstr "" -#: perform.php:93, perform.php:106 +#: perform.php:83, perform.php:96 msgid "Cheatin’ huh?" msgstr "" -#: perform.php:289 +#: perform.php:290 msgid "Your site could be faster and more secure with a newer PHP version." msgstr "" -#: perform.php:290 +#: perform.php:291 msgid "Hey, we've noticed that you're running an outdated version of PHP. PHP is the programming language that WordPress and Perform for WordPress are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we're sending you this notice." msgstr "" -#: perform.php:291 +#: perform.php:292 msgid "Hosts have the ability to update your PHP version, but sometimes they don't dare to do that because they're afraid they'll break your site." msgstr "" -#: perform.php:292 +#: perform.php:293 msgid "To which version should I update?" msgstr "" -#: perform.php:293 +#: perform.php:294 msgid "You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It's also the only PHP version still in active development and therefore the better option for your site in the long run." msgstr "" -#: perform.php:294 +#: perform.php:295 msgid "Can't update? Ask your host!" msgstr "" -#: perform.php:295 +#: perform.php:296 msgid "If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don't want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s." msgstr "" From 576a471d9af6c10cb894c1b508009d0852e6b2fe Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Tue, 31 Dec 2019 11:42:35 +0530 Subject: [PATCH 8/8] fix: add changelog information --- readme.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.txt b/readme.txt index 0a077be..64716c0 100644 --- a/readme.txt +++ b/readme.txt @@ -98,6 +98,9 @@ Please make sure you make a backup of your database before updating any version == Changelog == += 1.2.3: December 31st, 2019 = +Resolved fatal error when `wp-config.php` file is not writable + = 1.2.2: December 27th, 2019 = Fix: cdn rewrite is not working [#16](https://github.com/mehul0810/perform/issues/16) UI Improvements for Assets Manager