Show a notice to admin if network activation

Mailpoet seems to be working on network activated multisites but we
don't support it.
[MAILPOET-923]
This commit is contained in:
Pavel Dohnal
2017-06-13 12:49:00 +01:00
parent cdd8e51ef9
commit fa3ba609f3
4 changed files with 103 additions and 3 deletions

View File

@ -0,0 +1,36 @@
<?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 flushAll() {
$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);
}
}
}