diff --git a/autoshare-for-twitter.php b/autoshare-for-twitter.php index ee8c4e84..19575f67 100644 --- a/autoshare-for-twitter.php +++ b/autoshare-for-twitter.php @@ -15,6 +15,8 @@ * @package TenUp\AutoshareForTwitter */ +namespace TenUp\AutoshareForTwitter; + if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } @@ -25,6 +27,49 @@ define( 'AUTOSHARE_FOR_TWITTER_PATH', plugin_dir_path( __FILE__ ) ); define( 'AUTOSHARE_FOR_TWITTER_INC', AUTOSHARE_FOR_TWITTER_PATH . 'includes/' ); +/** + * Get the minimum version of PHP required by this plugin. + * + * @return string Minimum version required. + */ +function minimum_php_requirement() { + return '7.4'; +} + +/** + * Whether PHP installation meets the minimum requirements + * + * @return bool True if meets minimum requirements, false otherwise. + */ +function site_meets_php_requirements() { + return version_compare( phpversion(), minimum_php_requirement(), '>=' ); +} + +// Ensuring our PHP version requirement is met first before loading plugin. +if ( ! site_meets_php_requirements() ) { + add_action( + 'admin_notices', + function() { + ?> +
+ +
+