Show warning only on plugins page

[PREMIUM-28]
This commit is contained in:
Pavel Dohnal
2017-08-29 11:22:39 +02:00
parent b74be8777a
commit c75b6bd7eb
3 changed files with 9 additions and 18 deletions

View File

@ -670,10 +670,10 @@ class Menu {
}
function checkPremiumKey(ServicesChecker $checker = null) {
if(self::isOnMailPoetAdminPage()) {
$checker = $checker ?: new ServicesChecker();
$this->premium_key_valid = $checker->isPremiumKeyValid($show_notices = true);
}
$show_notices = isset($_SERVER['SCRIPT_NAME'])
&& stripos($_SERVER['SCRIPT_NAME'], 'plugins.php') !== false;
$checker = $checker ?: new ServicesChecker();
$this->premium_key_valid = $checker->isPremiumKeyValid($show_notices);
}
private function getLimitPerPage($model = null) {

View File

@ -83,7 +83,7 @@ class ServicesChecker {
array(),
'link2'
);
WPNotice::displayInlineWarning($error);
WPNotice::displayWarning($error);
}
return false;
} elseif($premium_key['state'] === Bridge::KEY_EXPIRING
@ -98,7 +98,7 @@ class ServicesChecker {
array('target' => '_blank')
);
$error = sprintf($error, $date);
WPNotice::displayInlineWarning($error);
WPNotice::displayWarning($error);
}
return true;
} elseif($premium_key['state'] === Bridge::KEY_VALID) {

View File

@ -10,12 +10,10 @@ class Notice {
private $type;
private $message;
private $display_inline;
function __construct($type, $message, $display_inline) {
function __construct($type, $message) {
$this->type = $type;
$this->message = $message;
$this->display_inline = $display_inline;
}
static function displayError($message) {
@ -31,10 +29,6 @@ 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);
}
@ -43,16 +37,13 @@ class Notice {
self::createNotice(self::TYPE_INFO, $message);
}
protected static function createNotice($type, $message, $display_inline = false) {
$notice = new Notice($type, $message, $display_inline);
protected static function createNotice($type, $message) {
$notice = new Notice($type, $message);
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('<div class="%1$s"><p>%2$s</p></div>', $class, $message);