Create permanent notices
[MAILPOET-1492]
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
jQuery(($) => {
|
jQuery(($) => {
|
||||||
$(document).on('click', '.notice-php-warning .notice-dismiss', function xyz() {
|
$(document).on('click', '.mailpoet-dismissible-notice .notice-dismiss', function dismiss() {
|
||||||
const type = $(this).closest('.notice-php-warning').data('notice');
|
const type = $(this).closest('.mailpoet-dismissible-notice').data('notice');
|
||||||
$.ajax(window.ajaxurl,
|
$.ajax(window.ajaxurl,
|
||||||
{
|
{
|
||||||
type: 'POST',
|
type: 'POST',
|
@ -8,6 +8,7 @@ use MailPoet\Models\Setting;
|
|||||||
use MailPoet\Router;
|
use MailPoet\Router;
|
||||||
use MailPoet\Util\ConflictResolver;
|
use MailPoet\Util\ConflictResolver;
|
||||||
use MailPoet\Util\Helpers;
|
use MailPoet\Util\Helpers;
|
||||||
|
use MailPoet\Util\Notices\PermanentNotices;
|
||||||
use MailPoet\WP\Notice as WPNotice;
|
use MailPoet\WP\Notice as WPNotice;
|
||||||
|
|
||||||
if(!defined('ABSPATH')) exit;
|
if(!defined('ABSPATH')) exit;
|
||||||
@ -144,7 +145,7 @@ class Initializer {
|
|||||||
|
|
||||||
$this->setupPages();
|
$this->setupPages();
|
||||||
|
|
||||||
$this->setupPHPVersionWarnings();
|
$this->setupPermanentNotices();
|
||||||
$this->setupDeactivationSurvey();
|
$this->setupDeactivationSurvey();
|
||||||
|
|
||||||
do_action('mailpoet_initialized', MAILPOET_VERSION);
|
do_action('mailpoet_initialized', MAILPOET_VERSION);
|
||||||
@ -289,9 +290,9 @@ class Initializer {
|
|||||||
$erasers->init();
|
$erasers->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupPHPVersionWarnings() {
|
function setupPermanentNotices() {
|
||||||
$php_version_warnings = new PHPVersionWarnings();
|
$notices = new PermanentNotices();
|
||||||
$php_version_warnings->init(phpversion(), Menu::isOnMailPoetAdminPage());
|
$notices->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFailedInitialization($exception) {
|
function handleFailedInitialization($exception) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace MailPoet\Config;
|
namespace MailPoet\Util\Notices;
|
||||||
|
|
||||||
use MailPoet\Util\Helpers;
|
use MailPoet\Util\Helpers;
|
||||||
use MailPoet\WP\Notice as WPNotice;
|
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 = __('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_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'));
|
$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';
|
$data_notice_name = 'php-version-outdated';
|
||||||
|
|
||||||
return WPNotice::displayError($error, $extra_classes, $data_notice_name);
|
return WPNotice::displayError($error, $extra_classes, $data_notice_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajaxDismissNoticeHandler() {
|
function ajaxDismissNoticeHandler() {
|
||||||
|
if($_POST['type'] !== 'php-version-outdated') return;
|
||||||
set_transient('dismissed-php-version-outdated-notice', true, self::DISMISS_NOTICE_TIMEOUT_SECONDS);
|
set_transient('dismissed-php-version-outdated-notice', true, self::DISMISS_NOTICE_TIMEOUT_SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
\MailPoet\WP\Notice::displaySuccess(Helpers::replaceLinkTags(
|
||||||
|
__('Congrats! You’re 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');
|
15
lib/Util/Notices/PermanentNotices.php
Normal file
15
lib/Util/Notices/PermanentNotices.php
Normal 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace MailPoet\Config;
|
namespace MailPoet\Util\Notices;
|
||||||
|
|
||||||
use AspectMock\Test as Mock;
|
use AspectMock\Test as Mock;
|
||||||
|
|
@ -239,7 +239,7 @@ var adminConfig = {
|
|||||||
'analytics_event',
|
'analytics_event',
|
||||||
'help-tooltip.jsx',
|
'help-tooltip.jsx',
|
||||||
'help-tooltip',
|
'help-tooltip',
|
||||||
'notice-php-warning.jsx',
|
'dismissible-notice.jsx',
|
||||||
],
|
],
|
||||||
admin_vendor: [
|
admin_vendor: [
|
||||||
'react',
|
'react',
|
||||||
|
Reference in New Issue
Block a user