Notice.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Message; |
| 4 | |
| 5 | use AC\Message; |
| 6 | use AC\Registrable; |
| 7 | use AC\View; |
| 8 | |
| 9 | class Notice extends Message implements Registrable { |
| 10 | |
| 11 | public function render() { |
| 12 | $data = [ |
| 13 | 'message' => $this->message, |
| 14 | 'type' => $this->type, |
| 15 | 'id' => $this->id, |
| 16 | ]; |
| 17 | |
| 18 | $view = new View( $data ); |
| 19 | $view->set_template( 'message/notice' ); |
| 20 | |
| 21 | return $view->render(); |
| 22 | } |
| 23 | |
| 24 | public function register() { |
| 25 | if ( apply_filters( 'ac/suppress_site_wide_notices', false ) ) { |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | add_action( 'admin_notices', [ $this, 'display' ] ); |
| 30 | add_action( 'network_admin_notices', [ $this, 'display' ] ); |
| 31 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Enqueue scripts & styles |
| 36 | */ |
| 37 | public function enqueue_scripts() { |
| 38 | wp_enqueue_style( 'ac-message', AC()->get_url() . 'assets/css/notice.css', [], AC()->get_version() ); |
| 39 | } |
| 40 | |
| 41 | } |