Files
piratepoet/lib/Config/DeferredAdminNotices.php
Pavel Dohnal 1b69fe50ff Rename function flushAll
[MAILPOET-923]
2017-06-14 14:33:21 +01:00

36 lines
941 B
PHP

<?php
namespace MailPoet\Config;
use MailPoet\WP\Notice;
class DeferredAdminNotices {
const OPTIONS_KEY_NAME = 'mailpoet_deferred_admin_notices';
/**
* @param string $message
*/
public function addNetworkAdminNotice($message) {
$notices = get_option(DeferredAdminNotices::OPTIONS_KEY_NAME, array());
$notices[] = array(
"message" => $message,
"networkAdmin" => true,// if we'll need to display the notice to anyone else
);
update_option(DeferredAdminNotices::OPTIONS_KEY_NAME, $notices);
}
public function printAndClean() {
$notices = get_option(DeferredAdminNotices::OPTIONS_KEY_NAME, array());
foreach($notices as $notice) {
$notice = new Notice(Notice::TYPE_WARNING, $notice["message"]);
add_action('network_admin_notices', array($notice, 'displayWPNotice'));
}
if(!empty($notices)) {
delete_option(DeferredAdminNotices::OPTIONS_KEY_NAME);
}
}
}