diff --git a/classifai.php b/classifai.php index 00e8ea6fe..c829020f1 100644 --- a/classifai.php +++ b/classifai.php @@ -16,30 +16,47 @@ */ /** - * Require PHP version 7.4+ - throw an error if the plugin is activated on an older version. + * Get the minimum version of PHP required by this plugin. * - * Note that this itself is only PHP5.3+ compatible because of the anonymous callback. + * @return string Minimum version required. */ -register_activation_hook( - __FILE__, - function() { - if ( version_compare( PHP_VERSION, '7.4.0', '<' ) ) { - wp_die( - sprintf( - wp_kses( - /* translators: PHP Update guide URL */ - __( 'ClassifAI requires PHP version 7.4. Click here to learn how to update your PHP version.', 'classifai' ), - array( - 'a' => array( 'href' => array() ), +function classifai_minimum_php_requirement() { + return '7.4'; +} + +/** + * Whether PHP installation meets the minimum requirements + * + * @return bool True if meets minimum requirements, false otherwise. + */ +function classifai_site_meets_php_requirements() { + return version_compare( phpversion(), classifai_minimum_php_requirement(), '>=' ); +} + +// Ensuring our PHP version requirement is met first before loading plugin. +if ( ! classifai_site_meets_php_requirements() ) { + add_action( + 'admin_notices', + function() { + ?> +
+

+ +

+
+