1 <?php
2
3 4 5 6 7 8 9 10 11
12
13 namespace WC_POS\Admin;
14
15 class Notices {
16
17
18 static private $notices = array();
19
20 21 22
23 public function __construct () {
24 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
25 }
26
27 28 29 30
31 static public function add ( $message, $type = 'error' ) {
32 self::$notices[] = array(
33 'type' => $type,
34 'message' => $message
35 );
36 }
37
38 39 40
41 public function admin_notices () {
42 $notices = apply_filters( 'woocommerce_pos_admin_notices', self::$notices );
43
44 if ( !empty( $notices ) ) {
45 foreach ( $notices as $notice ) {
46 echo '<div class="' . esc_attr( $notice[ 'type' ] ) . '">
47 <p>' . wp_kses( $notice[ 'message' ], wp_kses_allowed_html( 'post' ) ) . '</p>
48 </div>';
49 }
50 }
51 }
52
53 }