From 10a7bd5889e152504ef65fe1971ed4f5b9834eac Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Mon, 24 Jul 2023 16:36:28 -0600 Subject: [PATCH 1/2] Add a PHP version check. If site doesn't meet requirements, show an admin notice and don't run any plugin functionality --- convert-to-blocks.php | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/convert-to-blocks.php b/convert-to-blocks.php index 40711c5..4e2a5d6 100644 --- a/convert-to-blocks.php +++ b/convert-to-blocks.php @@ -45,6 +45,52 @@ function convert_to_blocks_get_setting( $name ) { return apply_filters( 'convert_to_blocks_setting_' . $name, constant( $name ), \get_current_blog_id() ); } +/** + * Get the minimum version of PHP required by this plugin. + * + * @since 1.2.1 + * + * @return string Minimum version required. + */ +function convert_to_blocks_minimum_php_requirement() { + return '8.0'; +} + +/** + * Whether PHP installation meets the minimum requirements + * + * @since 1.2.1 + * + * @return bool True if meets minimum requirements, false otherwise. + */ +function convert_to_blocks_site_meets_php_requirements() { + return version_compare( phpversion(), convert_to_blocks_minimum_php_requirement(), '>=' ); +} + +if ( ! convert_to_blocks_site_meets_php_requirements() ) { + add_action( + 'admin_notices', + function() { + ?> +
+

+ +

+
+ Date: Wed, 26 Jul 2023 08:02:33 -0600 Subject: [PATCH 2/2] Add details to changelog. Update release date. Change PHP version to 8.0 --- CHANGELOG.md | 6 +++++- convert-to-blocks.php | 2 +- readme.txt | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae3cd1a..585336a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file, per [the Ke ## [Unreleased] - TBD -## [1.2.1] - 2023-07-25 +## [1.2.1] - 2023-07-26 +### Added +- More robust minimum PHP version check (props [@dkotter](https://github.com/dkotter), [@ravinderk](https://github.com/ravinderk) via [#129](https://github.com/10up/convert-to-blocks/pull/129)). + ### Changed - Bump minimum required PHP version from 7.4 to 8.0 in our `composer.json` config (props [@c0ntax](https://github.com/c0ntax), [@Sidsector9](https://github.com/Sidsector9) via [#122](https://github.com/10up/convert-to-blocks/pull/122)). @@ -119,6 +122,7 @@ All notable changes to this project will be documented in this file, per [the Ke - Initial release of Convert to Blocks. [Unreleased]: https://github.com/10up/convert-to-blocks/compare/trunk...develop +[1.2.1]: https://github.com/10up/convert-to-blocks/compare/1.2.0...1.2.1 [1.2.0]: https://github.com/10up/convert-to-blocks/compare/1.1.1...1.2.0 [1.1.1]: https://github.com/10up/convert-to-blocks/compare/1.1.0...1.1.1 [1.1.0]: https://github.com/10up/convert-to-blocks/compare/1.0.2...1.1.0 diff --git a/convert-to-blocks.php b/convert-to-blocks.php index 4e2a5d6..8707291 100644 --- a/convert-to-blocks.php +++ b/convert-to-blocks.php @@ -5,7 +5,7 @@ * Description: Convert classic editor posts to blocks on the fly. * Version: 1.2.1 * Requires at least: 6.1 - * Requires PHP: 8 + * Requires PHP: 8.0 * Author: 10up * Author URI: https://10up.com * License: GPLv2 or later diff --git a/readme.txt b/readme.txt index 4e18589..77f338e 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: 10up, dsawardekar, tlovett1, jeffpaul Tags: gutenberg, block, block migration, gutenberg migration, gutenberg conversion, convert to blocks Requires at least: 5.7 Tested up to: 6.2 -Requires PHP: 7.4 +Requires PHP: 8.0 Stable tag: 1.2.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -43,7 +43,8 @@ Nested / Inner Block support does not work with Gutenberg bundled with WordPress == Changelog == -= 1.2.1 - 2023-07-25 = += 1.2.1 - 2023-07-26 = +* **Added:** More robust minimum PHP version check (props [@dkotter](https://github.com/dkotter), [@ravinderk](https://github.com/ravinderk) via [#129](https://github.com/10up/convert-to-blocks/pull/129)). * **Changed:** Bump minimum required PHP version from 7.4 to 8.0 in our `composer.json` config (props [@c0ntax](https://github.com/c0ntax), [@Sidsector9](https://github.com/Sidsector9) via [#122](https://github.com/10up/convert-to-blocks/pull/122)). * **Fixed:** Parse error caused by a comma (props [@Sidsector9](https://github.com/Sidsector9), [@iamdharmesh](https://github.com/iamdharmesh), [@ravinderk](https://github.com/ravinderk), [@felipeelia](https://github.com/felipeelia) via [#123](https://github.com/10up/convert-to-blocks/pull/123)). * **Security:** Bump `minimist` from 1.2.0 to 1.2.7 and `mkdirp` from 0.5.1 to 0.5.6 (props [@dependabot](https://github.com/apps/dependabot) via [#117](https://github.com/10up/convert-to-blocks/pull/117)).