Create permanent notices

[MAILPOET-1492]
This commit is contained in:
Pavel Dohnal
2018-09-04 10:46:50 +02:00
parent 21af85aee6
commit 4a641ba94e
6 changed files with 32 additions and 10 deletions

View File

@ -1,8 +1,8 @@
import jQuery from 'jquery';
jQuery(($) => {
$(document).on('click', '.notice-php-warning .notice-dismiss', function xyz() {
const type = $(this).closest('.notice-php-warning').data('notice');
$(document).on('click', '.mailpoet-dismissible-notice .notice-dismiss', function dismiss() {
const type = $(this).closest('.mailpoet-dismissible-notice').data('notice');
$.ajax(window.ajaxurl,
{
type: 'POST',

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

@ -1,6 +1,6 @@
<?php
namespace MailPoet\Config;
namespace MailPoet\Util\Notices;
use MailPoet\Util\Helpers;
use MailPoet\WP\Notice as WPNotice;
@ -28,14 +28,20 @@ class PHPVersionWarnings {
$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';
$extra_classes = 'mailpoet-dismissible-notice is-dismissible';
$data_notice_name = 'php-version-outdated';
return WPNotice::displayError($error, $extra_classes, $data_notice_name);
}
function ajaxDismissNoticeHandler() {
if($_POST['type'] !== 'php-version-outdated') return;
set_transient('dismissed-php-version-outdated-notice', true, self::DISMISS_NOTICE_TIMEOUT_SECONDS);
}
}
\MailPoet\WP\Notice::displaySuccess(Helpers::replaceLinkTags(
__('Congrats! Youre progressing well so far. Complete your upgrade thanks to this [link]checklist[/link].', 'mailpoet'),
'https://beta.docs.mailpoet.com/article/199-checklist-after-migrating-to-mailpoet3',
array('target' => '_blank')
), 'is-dismissible');

View File

@ -0,0 +1,15 @@
<?php
namespace MailPoet\Util\Notices;
use MailPoet\Config\Menu;
class PermanentNotices {
public function init() {
$php_version_warnings = new PHPVersionWarnings();
$php_version_warnings->init(phpversion(), Menu::isOnMailPoetAdminPage());
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace MailPoet\Config;
namespace MailPoet\Util\Notices;
use AspectMock\Test as Mock;

View File

@ -239,7 +239,7 @@ var adminConfig = {
'analytics_event',
'help-tooltip.jsx',
'help-tooltip',
'notice-php-warning.jsx',
'dismissible-notice.jsx',
],
admin_vendor: [
'react',