Skip to content
Snippets Groups Projects
Commit 7f44b3fb authored by Grzegorz Rola's avatar Grzegorz Rola
Browse files

init

parent 4e9512c4
No related branches found
No related tags found
No related merge requests found
Pipeline #6372 passed with warnings
......@@ -66,7 +66,10 @@ class AjaxHandler implements HookablePluginDependant
{
if (isset($_POST[self::POST_FIELD_NOTICE_NAME])) {
$noticeName = $_POST[self::POST_FIELD_NOTICE_NAME];
delete_option(PermanentDismissibleNotice::OPTION_NAME_PREFIX . $noticeName);
update_option(
PermanentDismissibleNotice::OPTION_NAME_PREFIX . $noticeName,
PermanentDismissibleNotice::OPTION_VALUE_DISMISSED
);
}
die();
}
......
......@@ -11,6 +11,7 @@ class PermanentDismissibleNotice extends Notice
{
const OPTION_NAME_PREFIX = 'wpdesk_notice_dismiss_';
const OPTION_VALUE_DISMISSED = '1';
/**
* @var string
......@@ -28,12 +29,17 @@ class PermanentDismissibleNotice extends Notice
* @param string $noticeType Notice type.
* @param string $noticeContent Notice content.
* @param string $noticeName Notice dismiss option name.
* @param int $priority Priority
*/
public function __construct($noticeType, $noticeContent, $noticeName)
public function __construct($noticeType, $noticeContent, $noticeName, $priority = 10)
{
parent::__construct($noticeType, $noticeContent, true);
parent::__construct($noticeType, $noticeContent, true, $priority);
$this->noticeName = $noticeName;
$this->noticeDismissOptionName = static::OPTION_NAME_PREFIX . $noticeName;
if (self::OPTION_VALUE_DISMISSED === get_option($this->noticeDismissOptionName, '')) {
remove_action('admin_notices', [$this, 'showNotice'], $priority);
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment