Completed
Push — master ( 0461e0...9cf8ee )
by Askupa
01:57
created
handler.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!class_exists('WPAdminNotifications'))
3
+if (!class_exists('WPAdminNotifications'))
4 4
 {
5 5
     class WPAdminNotifications
6 6
     {
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
          */
21 21
         public static function get_instance()
22 22
         {
23
-            if( null === static::$instance ) 
23
+            if (null === static::$instance) 
24 24
             {
25 25
                 static::$instance = new static();
26 26
             }
@@ -29,53 +29,53 @@  discard block
 block discarded – undo
29 29
         
30 30
         public function init()
31 31
         {
32
-            add_action( 'admin_notices', array( $this, 'render_notifications' ) );
33
-            add_action( 'network_admin_notices', array( $this, 'render_network_notifications' ) );
34
-            add_action( 'wp_ajax_dismiss_admin_notification', array( $this, 'dismiss_notification' ) );
35
-            add_action( 'admin_footer', array( $this, 'render_script' ) ); // Must be hooked to a late action hook
32
+            add_action('admin_notices', array($this, 'render_notifications'));
33
+            add_action('network_admin_notices', array($this, 'render_network_notifications'));
34
+            add_action('wp_ajax_dismiss_admin_notification', array($this, 'dismiss_notification'));
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) $this->dismissed_notices = array();
38 38
         }
39 39
         
40
-        public function register_notification( $handle, $options )
40
+        public function register_notification($handle, $options)
41 41
         {
42
-            if( !key_exists( $handle, $this->notifications ) )
42
+            if (!key_exists($handle, $this->notifications))
43 43
             {
44 44
                 $this->notifications[$handle] = $options;
45 45
             }
46
-            else trigger_error( "The handle <strong>$handle</strong> has already been registered. Please choose a different handle for your notification." );
46
+            else trigger_error("The handle <strong>$handle</strong> has already been registered. Please choose a different handle for your notification.");
47 47
         }
48 48
         
49 49
         public function render_notifications()
50 50
         {
51
-            foreach($this->notifications as $handle => $notification)
51
+            foreach ($this->notifications as $handle => $notification)
52 52
             {
53
-                $this->render_notification( $handle, $notification );
53
+                $this->render_notification($handle, $notification);
54 54
             }
55 55
         }
56 56
         
57 57
         public function render_network_notifications()
58 58
         {
59
-            foreach( $this->notifications as $handle => $notification )
59
+            foreach ($this->notifications as $handle => $notification)
60 60
             {
61
-                if( $notification['network'] ) $this->render_notification( $handle, $notification );
61
+                if ($notification['network']) $this->render_notification($handle, $notification);
62 62
             }
63 63
         }
64 64
         
65 65
         public function dismiss_notification()
66 66
         {
67
-            $id = filter_input( INPUT_POST, 'id' );
68
-            if( !in_array( $id, $this->dismissed_notices ) )
67
+            $id = filter_input(INPUT_POST, 'id');
68
+            if (!in_array($id, $this->dismissed_notices))
69 69
             {
70 70
                 $this->dismissed_notices[] = $id;
71
-                update_option( 'wp_dismissed_notices', $this->dismissed_notices);
71
+                update_option('wp_dismissed_notices', $this->dismissed_notices);
72 72
             }
73 73
             die();
74 74
         }
75 75
         
76 76
         public function render_script()
77 77
         {
78
-            if( 0 === count( $this->notifications ) ) return;
78
+            if (0 === count($this->notifications)) return;
79 79
             ?>
80 80
             <script>
81 81
             jQuery(document).ready(function($){
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
             <?php
91 91
         }
92 92
         
93
-        private function render_notification( $id, $n )
93
+        private function render_notification($id, $n)
94 94
         {
95
-            if( in_array( $id, $this->dismissed_notices ) ) return;
95
+            if (in_array($id, $this->dismissed_notices)) return;
96 96
             
97 97
             printf( 
98 98
                 '<div id="%s" class="notice notice-%s %s%s"><p>%s</p></div>',
99 99
                 $id,
100 100
                 $n['type'], 
101
-                $n['dismissible']?'is-dismissible ':'', 
101
+                $n['dismissible'] ? 'is-dismissible ' : '', 
102 102
                 $n['class'], 
103 103
                 $n['html'] 
104 104
             );
Please login to merge, or discard this 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.
bootstrap.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,29 +10,29 @@  discard block
 block discarded – undo
10 10
  * @copyright 2016 Askupa Software
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
13
+defined('ABSPATH') or die('No script kiddies please!');
14 14
 
15 15
 /**
16 16
  * Prevent loading the library more than once
17 17
  */
18
-if( defined( 'WP_ADMIN_NOTIFICATION' ) ) return;
19
-define( 'WP_ADMIN_NOTIFICATION', true );
18
+if (defined('WP_ADMIN_NOTIFICATION')) return;
19
+define('WP_ADMIN_NOTIFICATION', true);
20 20
 
21 21
 /**
22 22
  * Require the handler class and initiate it:
23 23
  */
24 24
 require_once 'handler.php';
25
-if(!function_exists('_wp_admin_notification_init'))
25
+if (!function_exists('_wp_admin_notification_init'))
26 26
 {
27 27
     function _wp_admin_notification_init() 
28 28
     {
29 29
         $notifier = WPAdminNotifications::get_instance();
30 30
         $notifier->init();
31 31
     }
32
-    add_action( 'init', '_wp_admin_notification_init' );
32
+    add_action('init', '_wp_admin_notification_init');
33 33
 }
34 34
 
35
-if(!function_exists('wp_admin_notification'))
35
+if (!function_exists('wp_admin_notification'))
36 36
 {
37 37
     /**
38 38
      * Register an admin notification.
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param type $class
45 45
      * @param type $network
46 46
      */
47
-    function wp_admin_notification( $handle, $html, $type = 'success', $dismissible = false, $class = '', $network = false )
47
+    function wp_admin_notification($handle, $html, $type = 'success', $dismissible = false, $class = '', $network = false)
48 48
     {
49 49
         $notifier = WPAdminNotifications::get_instance();
50 50
         $notifier->register_notification($handle, array(
@@ -57,22 +57,22 @@  discard block
 block discarded – undo
57 57
     }
58 58
 }
59 59
 
60
-if(!function_exists('wp_reset_admin_notification'))
60
+if (!function_exists('wp_reset_admin_notification'))
61 61
 {
62 62
     /**
63 63
      * 
64 64
      * @param string $handle
65 65
      */
66
-    function wp_reset_admin_notification( $handle )
66
+    function wp_reset_admin_notification($handle)
67 67
     {
68
-        $dismissed = get_option( 'wp_dismissed_notices' );
68
+        $dismissed = get_option('wp_dismissed_notices');
69 69
         $offset = 0;
70
-        foreach($dismissed as $id)
70
+        foreach ($dismissed as $id)
71 71
         {
72
-            if( $id === $handle ) break;
72
+            if ($id === $handle) break;
73 73
             $offset++;
74 74
         }
75
-        array_splice( $dismissed, $offset, 1);
76
-        update_option( 'wp_dismissed_notices', $dismissed );
75
+        array_splice($dismissed, $offset, 1);
76
+        update_option('wp_dismissed_notices', $dismissed);
77 77
     }
78 78
 }
79 79
\ No newline at end of file
Please login to merge, or discard this patch.