From 81f3aea13bac078e0e3684788c7e3dd8a0d6a5ec Mon Sep 17 00:00:00 2001 From: Rahul Prajapati Date: Thu, 20 Jul 2023 17:27:14 +0530 Subject: [PATCH 1/2] Add PHP version check for plugin. --- autoshare-for-twitter.php | 51 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/autoshare-for-twitter.php b/autoshare-for-twitter.php index ee8c4e84..9788e0a1 100644 --- a/autoshare-for-twitter.php +++ b/autoshare-for-twitter.php @@ -3,7 +3,7 @@ * Plugin Name: Autoshare for Twitter * Description: Automatically tweets the post title or custom message and a link to the post. * Disclaimer: TWITTER, TWEET, RETWEET and the Twitter logo are trademarks of Twitter, Inc. or its affiliates. - * Version: 2.1.0 + * Version: 2.1.1 * Requires at least: 5.7 * Requires PHP: 7.4 * Author: 10up @@ -20,11 +20,58 @@ } define( 'AUTOSHARE_FOR_TWITTER', __FILE__ ); -define( 'AUTOSHARE_FOR_TWITTER_VERSION', '2.1.0' ); +define( 'AUTOSHARE_FOR_TWITTER_VERSION', '2.1.1' ); define( 'AUTOSHARE_FOR_TWITTER_URL', plugin_dir_url( __FILE__ ) ); 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. + * + * @since 2.1.1 + * + * @return string Minimum version required. + */ +function minimum_php_requirement() { + return '7.4'; +} + +/** + * Whether PHP installation meets the minimum requirements + * + * @since 2.1.1 + * + * @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() { + ?> +
+

+ +

+
+ Date: Fri, 28 Jul 2023 17:52:48 +0530 Subject: [PATCH 2/2] Revert version change and add namespace for plugin file. --- autoshare-for-twitter.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/autoshare-for-twitter.php b/autoshare-for-twitter.php index 9788e0a1..19575f67 100644 --- a/autoshare-for-twitter.php +++ b/autoshare-for-twitter.php @@ -3,7 +3,7 @@ * Plugin Name: Autoshare for Twitter * Description: Automatically tweets the post title or custom message and a link to the post. * Disclaimer: TWITTER, TWEET, RETWEET and the Twitter logo are trademarks of Twitter, Inc. or its affiliates. - * Version: 2.1.1 + * Version: 2.1.0 * Requires at least: 5.7 * Requires PHP: 7.4 * Author: 10up @@ -15,12 +15,14 @@ * @package TenUp\AutoshareForTwitter */ +namespace TenUp\AutoshareForTwitter; + if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } define( 'AUTOSHARE_FOR_TWITTER', __FILE__ ); -define( 'AUTOSHARE_FOR_TWITTER_VERSION', '2.1.1' ); +define( 'AUTOSHARE_FOR_TWITTER_VERSION', '2.1.0' ); define( 'AUTOSHARE_FOR_TWITTER_URL', plugin_dir_url( __FILE__ ) ); define( 'AUTOSHARE_FOR_TWITTER_PATH', plugin_dir_path( __FILE__ ) ); define( 'AUTOSHARE_FOR_TWITTER_INC', AUTOSHARE_FOR_TWITTER_PATH . 'includes/' ); @@ -28,8 +30,6 @@ /** * Get the minimum version of PHP required by this plugin. * - * @since 2.1.1 - * * @return string Minimum version required. */ function minimum_php_requirement() { @@ -39,8 +39,6 @@ function minimum_php_requirement() { /** * Whether PHP installation meets the minimum requirements * - * @since 2.1.1 - * * @return bool True if meets minimum requirements, false otherwise. */ function site_meets_php_requirements() {