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