Merge pull request #1489 from mailpoet/migration-notice

Migration notice [MAILPOET-1492]
This commit is contained in:
Michelle Shull
2018-09-20 14:13:17 -04:00
committed by GitHub
10 changed files with 153 additions and 39 deletions

View File

@@ -8,6 +8,7 @@ use MailPoet\Models\Setting;
use MailPoet\Router;
use MailPoet\Util\ConflictResolver;
use MailPoet\Util\Helpers;
use MailPoet\Util\Notices\PermanentNotices;
use MailPoet\WP\Notice as WPNotice;
if(!defined('ABSPATH')) exit;
@@ -144,7 +145,7 @@ class Initializer {
$this->setupPages();
$this->setupPHPVersionWarnings();
$this->setupPermanentNotices();
$this->setupDeactivationSurvey();
do_action('mailpoet_initialized', MAILPOET_VERSION);
@@ -289,9 +290,9 @@ class Initializer {
$erasers->init();
}
function setupPHPVersionWarnings() {
$php_version_warnings = new PHPVersionWarnings();
$php_version_warnings->init(phpversion(), Menu::isOnMailPoetAdminPage());
function setupPermanentNotices() {
$notices = new PermanentNotices();
$notices->init();
}
function handleFailedInitialization($exception) {

View File

@@ -10,6 +10,7 @@ use MailPoet\Models\Setting;
use MailPoet\Models\Subscriber;
use MailPoet\Models\SubscriberCustomField;
use MailPoet\Models\SubscriberSegment;
use MailPoet\Util\Notices\AfterMigrationNotice;
use MailPoet\Util\ProgressBar;
if(!defined('ABSPATH')) exit;
@@ -169,6 +170,8 @@ class MP2Migrator {
if(!$this->importStopped()) {
Setting::setValue('mailpoet_migration_complete', true);
$this->log(mb_strtoupper(__('Import complete', 'mailpoet'), 'UTF-8'));
$after_migration_notice = new AfterMigrationNotice();
$after_migration_notice->enable();
}
$this->log(sprintf('=== ' . mb_strtoupper(__('End import', 'mailpoet'), 'UTF-8') . ' %s ===', $datetime->formatTime(time(), \MailPoet\WP\DateTime::DEFAULT_DATE_TIME_FORMAT)));

View File

@@ -1,41 +0,0 @@
<?php
namespace MailPoet\Config;
use MailPoet\Util\Helpers;
use MailPoet\WP\Notice as WPNotice;
class PHPVersionWarnings {
const DISMISS_NOTICE_TIMEOUT_SECONDS = 2592000; // 30 days
function init($php_version, $is_enabled) {
add_action('wp_ajax_dismissed_notice_handler', array(
$this,
'ajaxDismissNoticeHandler'
));
if($is_enabled && $this->isOutdatedPHPVersion($php_version)) {
return $this->displayError($php_version);
}
}
function isOutdatedPHPVersion($php_version) {
return version_compare($php_version, '5.6', '<') && !get_transient('dismissed-php-version-outdated-notice');
}
function displayError($php_version) {
$error_string = __('Your website is running on PHP %s. MailPoet requires version 5.6. 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'));
$extra_classes = 'notice-php-warning is-dismissible';
$data_notice_name = 'php-version-outdated';
return WPNotice::displayError($error, $extra_classes, $data_notice_name);
}
function ajaxDismissNoticeHandler() {
set_transient('dismissed-php-version-outdated-notice', true, self::DISMISS_NOTICE_TIMEOUT_SECONDS);
}
}