Requires PHP 5.5 or newer.

This commit is contained in:
Vlad
2018-08-06 21:55:42 -04:00
committed by pavel-mailpoet
parent 659f748dc9
commit 51c89d5aa1
3 changed files with 19 additions and 41 deletions

View File

@@ -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('<div class="%1$s" data-notice="php-version-outdated"><p>%2$s</p></div>', $class, $message);
return sprintf('<div class="%1$s" data-notice="php-version-outdated"><p>%2$s</p></div>', $class, $error);
}
}