AdminDismissibleNotice.php
5 years ago
AdminErrorNotice.php
5 years ago
AdminNotice.php
5 years ago
Filters.php
9 years ago
SitewideAdminDismissibleNotice.php
4 years ago
AdminDismissibleNotice.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Wpae\WordPress; |
| 4 | |
| 5 | |
| 6 | class AdminDismissibleNotice extends AdminNotice |
| 7 | { |
| 8 | private $noticeId; |
| 9 | |
| 10 | public function __construct($message, $noticeId) |
| 11 | { |
| 12 | parent::__construct($message); |
| 13 | $this->noticeId = $noticeId; |
| 14 | } |
| 15 | |
| 16 | public function showNotice() |
| 17 | { |
| 18 | ?> |
| 19 | <div class="<?php echo $this->getType();?>" style="position: relative;"><p> |
| 20 | <?php echo $this->message; ?> |
| 21 | </p> |
| 22 | <button class="notice-dismiss wpae-general-notice-dismiss" type="button" data-noticeId="<?php echo $this->noticeId; ?>"><span class="screen-reader-text">Dismiss this notice.</span></button> |
| 23 | </div> |
| 24 | <?php |
| 25 | } |
| 26 | |
| 27 | public function render() |
| 28 | { |
| 29 | add_action('admin_notices', array($this, 'showNotice')); |
| 30 | } |
| 31 | |
| 32 | public function getType() |
| 33 | { |
| 34 | return 'error'; |
| 35 | } |
| 36 | |
| 37 | public function isDismissed() |
| 38 | { |
| 39 | $optionName = 'wpae_dismiss_warnings_'.$this->noticeId; |
| 40 | $optionValue = get_option($optionName, false); |
| 41 | |
| 42 | return $optionValue; |
| 43 | } |
| 44 | } |