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. * 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(); } - } /** 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 "" diff --git a/perform.php b/perform.php index bde5ab2..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 @@ -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. * @@ -172,11 +162,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' ); + } /** @@ -191,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. @@ -236,9 +240,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'; diff --git a/readme.txt b/readme.txt index 1693844..64716c0 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 @@ -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