@@ -15,7 +15,9 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * Prevent loading the library more than once |
17 | 17 | */ |
18 | -if( defined( 'WP_ADMIN_NOTIFICATION' ) ) return; |
|
18 | +if( defined( 'WP_ADMIN_NOTIFICATION' ) ) { |
|
19 | + return; |
|
20 | +} |
|
19 | 21 | define( 'WP_ADMIN_NOTIFICATION', true ); |
20 | 22 | |
21 | 23 | /** |
@@ -59,7 +61,9 @@ discard block |
||
59 | 61 | $offset = 0; |
60 | 62 | foreach($dismissed as $id) |
61 | 63 | { |
62 | - if( $id === $handle ) break; |
|
64 | + if( $id === $handle ) { |
|
65 | + break; |
|
66 | + } |
|
63 | 67 | $offset++; |
64 | 68 | } |
65 | 69 | array_splice( $dismissed, $offset, 1); |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | if( !key_exists( $handle, $this->notifications ) ) |
38 | 38 | { |
39 | 39 | $this->notifications[$handle] = $options; |
40 | + } else { |
|
41 | + trigger_error( "The handle <strong>$handle</strong> has already been registered. Please choose a different handle for your notification." ); |
|
40 | 42 | } |
41 | - else trigger_error( "The handle <strong>$handle</strong> has already been registered. Please choose a different handle for your notification." ); |
|
42 | 43 | } |
43 | 44 | |
44 | 45 | public function render_notifications() |
@@ -53,7 +54,9 @@ discard block |
||
53 | 54 | { |
54 | 55 | foreach( $this->notifications as $handle => $notification ) |
55 | 56 | { |
56 | - if( $notification['network'] ) $this->render_notification( $handle, $notification ); |
|
57 | + if( $notification['network'] ) { |
|
58 | + $this->render_notification( $handle, $notification ); |
|
59 | + } |
|
57 | 60 | } |
58 | 61 | } |
59 | 62 | |
@@ -91,13 +94,17 @@ discard block |
||
91 | 94 | add_action( 'wp_ajax_dismiss_admin_notification', array( $this, 'dismiss_notification' ) ); |
92 | 95 | add_action( 'admin_head', array( $this, 'render_script' ) ); |
93 | 96 | $this->dismissed_notices = get_option('wp_dismissed_notices'); |
94 | - if( false === $this->dismissed_notices ) $this->dismissed_notices = array(); |
|
97 | + if( false === $this->dismissed_notices ) { |
|
98 | + $this->dismissed_notices = array(); |
|
99 | + } |
|
95 | 100 | var_dump($this->dismissed_notices); |
96 | 101 | } |
97 | 102 | |
98 | 103 | private function render_notification( $id, $n ) |
99 | 104 | { |
100 | - if( in_array( $id, $this->dismissed_notices ) ) return; |
|
105 | + if( in_array( $id, $this->dismissed_notices ) ) { |
|
106 | + return; |
|
107 | + } |
|
101 | 108 | |
102 | 109 | printf( |
103 | 110 | '<div id="%s" class="notice notice-%s %s%s"><p>%s</p></div>', |