diff --git a/lib/Config/PHPVersionWarnings.php b/lib/Config/PHPVersionWarnings.php
index 0d42dc9c20..79c2fce87e 100644
--- a/lib/Config/PHPVersionWarnings.php
+++ b/lib/Config/PHPVersionWarnings.php
@@ -15,36 +15,19 @@ class PHPVersionWarnings {
));
$error = null;
if (!$is_enabled) return $error;
- if (is_null($error)) $error = $this->checkPHP54Version($php_version);
- if (is_null($error)) $error = $this->checkPHP55Version($php_version);
+ if (is_null($error)) $error = $this->checkPHP70Version($php_version);
return $error;
}
- function checkPHP54Version($php_version) {
+ function checkPHP70Version($php_version) {
$error_string = null;
- if(version_compare($php_version, '5.5', '<')) {
- $error_string = __('MailPoet requires PHP version 7 or newer. Please read our [link]instructions[/link] on how to upgrade your site.', 'mailpoet');
- $error = Helpers::replaceLinkTags($error_string, 'https://beta.docs.mailpoet.com/article/251-upgrading-the-websites-php-version', array('target' => '_blank'));
- return $this->displayWPNotice($error, false);
- }
- }
-
- function checkPHP55Version($php_version) {
- $error_string = null;
- if(version_compare($php_version, '5.6', '<')) {
+ if(version_compare($php_version, '7.0', '<') && !get_transient('dismissed-php-version-outdated-notice')) {
$error_string = __('Your website is running on PHP %s. MailPoet will require version 7 by the end of the year. Please consider upgrading your site\'s PHP version. [link]Your host can help you.[/link]', 'mailpoet');
$error_string = sprintf($error_string, $php_version);
$error = Helpers::replaceLinkTags($error_string, 'https://beta.docs.mailpoet.com/article/251-upgrading-the-websites-php-version', array('target' => '_blank'));
- return $this->displayWPNotice($error, true);
- }
- }
+ $class = 'notice notice-error notice-php-warning mailpoet_notice_server is-dismissible';
- private function displayWPNotice($message, $dismissible = false) {
- $class = 'notice notice-error notice-php-warning mailpoet_notice_server';
- if($dismissible) $class .= ' is-dismissible';
-
- if(!get_transient('dismissed-php-version-outdated-notice')) {
- return sprintf('
', $class, $message);
+ return sprintf('', $class, $error);
}
}
diff --git a/mailpoet.php b/mailpoet.php
index 6292d5cf1b..4149f05004 100644
--- a/mailpoet.php
+++ b/mailpoet.php
@@ -41,7 +41,7 @@ if(version_compare(get_bloginfo('version'), '4.6', '<')) {
}
// Check for minimum supported PHP version
-if(version_compare(phpversion(), '5.4.0', '<')) {
+if(version_compare(phpversion(), '5.5.0', '<')) {
add_action('admin_notices', 'mailpoet_php_version_notice');
// deactivate the plugin
add_action('admin_init', 'mailpoet_deactivate_plugin');
@@ -64,7 +64,7 @@ function mailpoet_php_version_notice() {
$notice = str_replace(
'[link]',
'',
- __('MailPoet plugin requires PHP version 5.4.0 or newer. Please read our [link]instructions[/link] on how to resolve this issue.', 'mailpoet')
+ __('MailPoet requires PHP version 7 or newer. Please read our [link]instructions[/link] on how to upgrade your site.', 'mailpoet')
);
$notice = str_replace('[/link]', '', $notice);
printf('', $notice);
diff --git a/tests/unit/Config/PHPVersionWarningsTest.php b/tests/unit/Config/PHPVersionWarningsTest.php
index d5d80ff62a..d36f90cc9d 100644
--- a/tests/unit/Config/PHPVersionWarningsTest.php
+++ b/tests/unit/Config/PHPVersionWarningsTest.php
@@ -16,38 +16,33 @@ class PHPVersionWarningsTest extends \MailPoetTest {
delete_transient('dismissed-php-version-outdated-notice');
}
- function testItPrintsWarningFor53() {
- $warning = $this->phpVersionWarning->init('5.3.2', true);
- expect($warning)->contains('MailPoet requires PHP version 7 or newer.');
- expect($warning)->notContains('is-dismissible');
- }
-
- function testItPrintsWarningFor54() {
- $warning = $this->phpVersionWarning->init('5.4.1', true);
- expect($warning)->contains('MailPoet requires PHP version 7 or newer.');
- expect($warning)->notContains('is-dismissible');
- }
-
function testItPrintsWarningFor55() {
$warning = $this->phpVersionWarning->init('5.5.3', true);
expect($warning)->contains('Your website is running on PHP 5.5.3');
- expect($warning)->contains('is-dismissible');
+ expect($warning)->contains('MailPoet will require version 7');
}
- function testItPrintsNoWarningFor56() {
+
+ function testItPrintsWarningFor56() {
$warning = $this->phpVersionWarning->init('5.6.3', true);
+ expect($warning)->contains('Your website is running on PHP 5.6');
+ expect($warning)->contains('MailPoet will require version 7');
+ }
+
+ function testItPrintsNoWarningFor70() {
+ $warning = $this->phpVersionWarning->init('7.0', true);
expect($warning)->null();
}
function testItPrintsNoWarningWhenDisabled() {
- $warning = $this->phpVersionWarning->init('5.3.2', false);
+ $warning = $this->phpVersionWarning->init('5.5.3', false);
expect($warning)->null();
}
function testItPrintsNoWarningWhenDismised() {
- $this->phpVersionWarning->init('5.3.2', true);
+ $this->phpVersionWarning->init('5.5.3', true);
do_action('wp_ajax_dismissed_notice_handler');
- $warning = $this->phpVersionWarning->init('5.3.2', true);
+ $warning = $this->phpVersionWarning->init('5.5.3', true);
expect($warning)->null();
}