| @@ -1,45 +1,42 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Boxzilla\Admin; |
| 4 | 4 | |
| 5 | -class Notices | |
| 6 | -{ | |
| 7 | - /** | |
| 8 | - * @var array | |
| 9 | - */ | |
| 10 | - protected $notices = []; | |
| 5 | +class Notices { | |
| 11 | 6 | |
| 12 | - /** | |
| 13 | - * Constructor | |
| 14 | - */ | |
| 15 | - public function __construct() | |
| 16 | - { | |
| 17 | - add_action('admin_notices', [ $this, 'show' ]); | |
| 18 | - } | |
| 7 | + /** | |
| 8 | + * @var array | |
| 9 | + */ | |
| 10 | + protected $notices = array(); | |
| 19 | 11 | |
| 20 | - /** | |
| 21 | - * @param $message | |
| 22 | - * @param $type | |
| 23 | - * | |
| 24 | - * @return $this | |
| 25 | - */ | |
| 26 | - public function add($message, $type = 'updated') | |
| 27 | - { | |
| 28 | - $this->notices[] = [ | |
| 29 | - 'message' => $message, | |
| 30 | - 'type' => $type, | |
| 31 | - ]; | |
| 12 | + /** | |
| 13 | + * Constructor | |
| 14 | + */ | |
| 15 | + public function __construct() { | |
| 16 | + add_action( 'admin_notices', array( $this, 'show' ) ); | |
| 17 | + } | |
| 32 | 18 | |
| 33 | - return $this; | |
| 34 | - } | |
| 19 | + /** | |
| 20 | + * @param $message | |
| 21 | + * @param $type | |
| 22 | + * | |
| 23 | + * @return $this | |
| 24 | + */ | |
| 25 | + public function add( $message, $type = 'updated' ) { | |
| 26 | + $this->notices[] = array( | |
| 27 | + 'message' => $message, | |
| 28 | + 'type' => $type, | |
| 29 | + ); | |
| 35 | 30 | |
| 36 | - /** | |
| 37 | - * Output the registered notices | |
| 38 | - */ | |
| 39 | - public function show() | |
| 40 | - { | |
| 41 | - foreach ($this->notices as $notice) { | |
| 42 | - echo "<div class=\"notice notice-{$notice['type']}\"><p>{$notice['message']}</p></div>"; | |
| 43 | - } | |
| 44 | - } | |
| 31 | + return $this; | |
| 32 | + } | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * Output the registered notices | |
| 36 | + */ | |
| 37 | + public function show() { | |
| 38 | + foreach( $this->notices as $notice ) { | |
| 39 | + echo sprintf( '<div class="notice notice-%s"><p>%s</p></div>', $notice['type'], $notice['message'] ); | |
| 40 | + } | |
| 41 | + } | |
| 45 | 42 | } |