WC_POS_Admin_Notices

Admin Notices - add notices via static method or filter.

Defined (1)

The class is defined in the following location(s).

/includes/admin/class-wc-pos-notices.php  
  1. class WC_POS_Admin_Notices { 
  2.  
  3. /** @var */ 
  4. static private $notices = array(); 
  5.  
  6. /** 
  7. * Constructor 
  8. */ 
  9. public function __construct() { 
  10. add_action( 'admin_notices', array( $this, 'admin_notices' ) ); 
  11.  
  12. /** 
  13. * @param $type 
  14. * @param $message 
  15. */ 
  16. static public function add( $message, $type = 'error' ) { 
  17. self::$notices[] = array( 
  18. 'type' => $type,  
  19. 'message' => $message 
  20. ); 
  21.  
  22. /** 
  23. * Display the admin notices 
  24. */ 
  25. public function admin_notices() { 
  26. $notices = apply_filters( 'woocommerce_pos_admin_notices', self::$notices ); 
  27.  
  28. if( !empty( $notices ) ) { 
  29. foreach( $notices as $notice ) { 
  30. echo '<div class="' . esc_attr( $notice['type'] ) . '"> 
  31. <p>'. wp_kses( $notice['message'], wp_kses_allowed_html( 'post' ) ) .'</p> 
  32. </div>'; 
  33.