From 10a7bd5889e152504ef65fe1971ed4f5b9834eac Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Mon, 24 Jul 2023 16:36:28 -0600 Subject: [PATCH] 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() { + ?> +
+

+ +

+
+