Completed
Push — master ( c7671f...27b0e7 )
by Askupa
01:56
created
Notifications.php 1 patch
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@  discard block
 block discarded – undo
34 34
         add_action( 'wp_ajax_dismiss_admin_notification', array( $this, 'dismiss_notification' ) );
35 35
         add_action( 'admin_footer', array( $this, 'render_script' ) ); // Must be hooked to a late action hook
36 36
         $this->dismissed_notices = get_option('wp_dismissed_notices');
37
-        if( false === $this->dismissed_notices ) $this->dismissed_notices = array();
37
+        if( false === $this->dismissed_notices ) {
38
+            $this->dismissed_notices = array();
39
+        }
38 40
     }
39 41
 
40 42
     public function register_notification( $handle, $options )
@@ -42,8 +44,9 @@  discard block
 block discarded – undo
42 44
         if( !key_exists( $handle, $this->notifications ) )
43 45
         {
44 46
             $this->notifications[$handle] = $options;
47
+        } else {
48
+            trigger_error( "The handle <strong>$handle</strong> has already been registered. Please choose a different handle for your notification." );
45 49
         }
46
-        else trigger_error( "The handle <strong>$handle</strong> has already been registered. Please choose a different handle for your notification." );
47 50
     }
48 51
 
49 52
     public function render_notifications()
@@ -58,7 +61,9 @@  discard block
 block discarded – undo
58 61
     {
59 62
         foreach( $this->notifications as $handle => $notification )
60 63
         {
61
-            if( $notification['network'] ) $this->render_notification( $handle, $notification );
64
+            if( $notification['network'] ) {
65
+                $this->render_notification( $handle, $notification );
66
+            }
62 67
         }
63 68
     }
64 69
 
@@ -75,7 +80,9 @@  discard block
 block discarded – undo
75 80
 
76 81
     public function render_script()
77 82
     {
78
-        if( 0 === count( $this->notifications ) ) return;
83
+        if( 0 === count( $this->notifications ) ) {
84
+            return;
85
+        }
79 86
         ?>
80 87
         <script>
81 88
         jQuery(document).ready(function($){
@@ -92,7 +99,9 @@  discard block
 block discarded – undo
92 99
 
93 100
     private function render_notification( $id, $n )
94 101
     {
95
-        if( in_array( $id, $this->dismissed_notices ) ) return;
102
+        if( in_array( $id, $this->dismissed_notices ) ) {
103
+            return;
104
+        }
96 105
 
97 106
         printf( 
98 107
             '<div id="%s" class="notice notice-%s %s%s"><p>%s</p></div>',
Please login to merge, or discard this patch.