PluginProbe
Boxzilla – WordPress Popup Builder / trunk
Boxzilla – WordPress Popup Builder vtrunk
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
boxzilla / src / admin / class-notices.php

class-notices.php in Boxzilla – WordPress Popup Builder trunk, at src/admin/class-notices.php

51 lines 986 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Boxzilla\Admin;
4
5 if (! defined('ABSPATH')) {
6 exit;
7 }
8
9 class Notices
10 {
11 /**
12 * @var array
13 */
14 protected $notices = [];
15
16 /**
17 * Constructor
18 */
19 public function __construct()
20 {
21 add_action('admin_notices', [ $this, 'action_admin_notices' ], 10, 0);
22 }
23
24 /**
25 * @param $message
26 * @param $type
27 *
28 * @return $this
29 */
30 public function add($message, $type = 'updated')
31 {
32 $this->notices[] = [
33 'message' => $message,
34 'type' => $type,
35 ];
36
37 return $this;
38 }
39
40 /**
41 * Output the registered notices
42 */
43 public function admin_notices(): void
44 {
45 $allowed_html = [ 'strong' => [], 'em' => [], 'a' => [ 'href' => [] ] ];
46 foreach ($this->notices as $notice) {
47 echo "<div class=\"notice notice-", esc_attr($notice['type']), "><p>", wp_kses($notice['message'], $allowed_html), "</p></div>";
48 }
49 }
50 }
51