diff --git a/lib/Config/Menu.php b/lib/Config/Menu.php index 521a598345..e3eb66f04c 100644 --- a/lib/Config/Menu.php +++ b/lib/Config/Menu.php @@ -671,10 +671,8 @@ class Menu { function checkPremiumKey(ServicesChecker $checker = null) { if(self::isOnMailPoetAdminPage()) { - $show_notices = isset($_REQUEST['page']) - && stripos($_REQUEST['page'], self::MAIN_PAGE_SLUG) === false; $checker = $checker ?: new ServicesChecker(); - $this->premium_key_valid = $checker->isPremiumKeyValid($show_notices); + $this->premium_key_valid = $checker->isPremiumKeyValid($show_notices = true); } } diff --git a/lib/Config/ServicesChecker.php b/lib/Config/ServicesChecker.php index 2cb0d198e7..4d0611867b 100644 --- a/lib/Config/ServicesChecker.php +++ b/lib/Config/ServicesChecker.php @@ -70,9 +70,9 @@ class ServicesChecker { || $premium_key['state'] === Bridge::KEY_ALREADY_USED ) { if($display_error_notice) { - $errorString = __('[link1]Register[/link1] your copy of the MailPoet Premium plugin to receive access to automatic upgrades and support. Need a license key? [link2]Purchase one now.[/link2]', 'mailpoet'); + $error_string = __('[link1]Register[/link1] your copy of the MailPoet Premium plugin to receive access to automatic upgrades and support. Need a license key? [link2]Purchase one now.[/link2]', 'mailpoet'); $error = Helpers::replaceLinkTags( - $errorString, + $error_string, 'admin.php?page=mailpoet-settings#premium', array(), 'link1' @@ -83,7 +83,7 @@ class ServicesChecker { array(), 'link2' ); - WPNotice::displayWarning($error); + WPNotice::displayInlineWarning($error); } return false; } elseif($premium_key['state'] === Bridge::KEY_EXPIRING @@ -98,7 +98,7 @@ class ServicesChecker { array('target' => '_blank') ); $error = sprintf($error, $date); - WPNotice::displayWarning($error); + WPNotice::displayInlineWarning($error); } return true; } elseif($premium_key['state'] === Bridge::KEY_VALID) { diff --git a/lib/WP/Notice.php b/lib/WP/Notice.php index 6dc3791637..5b6e358fb7 100644 --- a/lib/WP/Notice.php +++ b/lib/WP/Notice.php @@ -10,10 +10,12 @@ class Notice { private $type; private $message; + private $display_inline; - function __construct($type, $message) { + function __construct($type, $message, $display_inline) { $this->type = $type; $this->message = $message; + $this->display_inline = $display_inline; } static function displayError($message) { @@ -29,6 +31,10 @@ class Notice { self::createNotice(self::TYPE_WARNING, $message); } + static function displayInlineWarning($message) { + self::createNotice(self::TYPE_WARNING, $message, true); + } + static function displaySuccess($message) { self::createNotice(self::TYPE_SUCCESS, $message); } @@ -37,13 +43,16 @@ class Notice { self::createNotice(self::TYPE_INFO, $message); } - protected static function createNotice($type, $message) { - $notice = new Notice($type, $message); + protected static function createNotice($type, $message, $display_inline = false) { + $notice = new Notice($type, $message, $display_inline); add_action('admin_notices', array($notice, 'displayWPNotice')); } function displayWPNotice() { $class = sprintf('notice notice-%s mailpoet_notice_server', $this->type); + if($this->display_inline) { + $class .= ' inline'; + } $message = nl2br($this->message); printf('
%2$s