From 858bc167bb9146849a9a0f81c7a2dd8b6e35b855 Mon Sep 17 00:00:00 2001 From: FerhanGit Date: Mon, 21 Aug 2017 14:44:35 +0300 Subject: [PATCH] adding check for the server php version required to run the plugin --- README.md | 2 +- readme.txt | 2 +- wp-mailjet.php | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 578e06a5..8c5cfa26 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Mailjet offers user interfaces, documentation and 24/7 customer support in 4 lan 2. Go to Extensions > Add and send `mailjet-for-wordpress.zip`. 3. Activate the Mailjet extension through the 'Plugins' menu in WordPress. -You must have cURL extension enabled. +You must have cURL extension enabled. PHP 5.3 or later version is required. ## Frequently Asked Questions diff --git a/readme.txt b/readme.txt index 5295d631..33d5865a 100644 --- a/readme.txt +++ b/readme.txt @@ -49,7 +49,7 @@ Mailjet offers user interfaces, documentation and 24/7 customer support in 4 lan 2. Go to Extensions > Add and send `mailjet-for-wordpress.zip`. 3. Activate the Mailjet extension through the 'Plugins' menu in WordPress. -You must have cURL extension enabled. +You must have cURL extension enabled. PHP 5.3 or later version is required. ## Frequently Asked Questions diff --git a/wp-mailjet.php b/wp-mailjet.php index d48a1312..573bcbf8 100755 --- a/wp-mailjet.php +++ b/wp-mailjet.php @@ -39,6 +39,31 @@ # Define mailjet options object $optionsMj = new WP_Mailjet_Options(); +// Check the PHP version and display warning message if it is < 5.3 +// (we may also deactivate automatically the plugin, but for now that code is commented) +if (version_compare(PHP_VERSION, '5.3', '<')) { + add_action('admin_notices', 'wp_mailjet_check_php_version'); + /* + add_action('admin_init', 'wp_mailjet_deactivate_self'); + function wp_mailjet_deactivate_self() { + deactivate_plugins(plugin_basename(__FILE__)); + } + */ + return; +} + +function wp_mailjet_check_php_version() +{ + echo '

'; + _e('Mailjet plugin requires PHP 5.3 to function properly. Please upgrade PHP', 'wp-mailjet'); + echo "

"; +/* + if (isset($_GET['activate'])) { + unset($_GET['activate']); + } +*/ +} + # Check if the plugin is set up properly if (get_option('mailjet_password') && get_option('mailjet_username')) {