Completed
Push — master ( 9c0738...41953e )
by Askupa
01:56
created
Manager.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function get_instance()
31 31
     {
32
-        if( null === static::$instance ) 
32
+        if (null === static::$instance) 
33 33
         {
34 34
             static::$instance = new static();
35 35
         }
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
      * @param array $args
52 52
      * @throws \RuntimeException if the given metabox id has already been registered
53 53
      */
54
-    public function add( $id, array $args )
54
+    public function add($id, array $args)
55 55
     {
56
-        if( !in_array($id, $this->metaboxes) )
56
+        if (!in_array($id, $this->metaboxes))
57 57
         {
58 58
             $this->metaboxes[$id] = array_merge($this->default_args(), $args);
59 59
         }
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
      * @param WP_Post $post
67 67
      * @param array $args
68 68
      */
69
-    public function render( $post, $args )
69
+    public function render($post, $args)
70 70
     {
71 71
         $metabox = $this->metaboxes[$args['id']];
72 72
         wp_nonce_field(self::NONCE_ACTION, $args['id'].'_nonce');
73
-        foreach( $metabox['fields'] as $field )
73
+        foreach ($metabox['fields'] as $field)
74 74
         {
75 75
             $field['post_id'] = $post->ID;
76 76
             $field_template = new Field($field);
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function add_meta_boxes()
85 85
     {
86
-        foreach( $this->metaboxes as $id => $args )
86
+        foreach ($this->metaboxes as $id => $args)
87 87
         {
88 88
             \add_meta_box(
89 89
                 $id,
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * 
102 102
      * @param number $post_id
103 103
      */
104
-    public function save_meta_boxes( $post_id )
104
+    public function save_meta_boxes($post_id)
105 105
     {
106 106
         /**
107 107
          * A note on security:
@@ -119,22 +119,22 @@  discard block
 block discarded – undo
119 119
          * If this is an autosave, our form has not been submitted,
120 120
          * so we don't want to do anything.
121 121
          */
122
-        if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 
122
+        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) 
123 123
         {
124 124
             return $post_id;
125 125
         }
126 126
 
127 127
         // Check the user's permissions.
128 128
         $post_type = filter_input(INPUT_POST, 'post_type');
129
-        if( null !== $post_type && !current_user_can('edit_'.$post_type, $post_id) )
129
+        if (null !== $post_type && !current_user_can('edit_'.$post_type, $post_id))
130 130
         {
131 131
             return $post_id;
132 132
         }
133 133
 
134 134
         // Update the meta fields.
135
-        foreach( $this->metaboxes as $id => $metabox )
135
+        foreach ($this->metaboxes as $id => $metabox)
136 136
         {
137
-            $this->save_meta_box( $post_id, $id, $metabox );
137
+            $this->save_meta_box($post_id, $id, $metabox);
138 138
         }
139 139
     }
140 140
     
@@ -145,21 +145,21 @@  discard block
 block discarded – undo
145 145
      * @param string $id
146 146
      * @param array $metabox
147 147
      */
148
-    public function save_meta_box( $post_id, $id, $metabox )
148
+    public function save_meta_box($post_id, $id, $metabox)
149 149
     {
150 150
         $nonce_name  = $id.'_nonce';
151 151
         $nonce_value = filter_input(INPUT_POST, $nonce_name);
152 152
         
153 153
         // Check if our nonce is set and verify it
154
-        if( null === $nonce_value || !wp_verify_nonce($nonce_value, self::NONCE_ACTION) ) 
154
+        if (null === $nonce_value || !wp_verify_nonce($nonce_value, self::NONCE_ACTION)) 
155 155
         {
156 156
             return $post_id;
157 157
         }
158 158
         
159
-        foreach( $metabox['fields'] as $field )
159
+        foreach ($metabox['fields'] as $field)
160 160
         {
161
-            $data = filter_input( INPUT_POST, $field['name'] );
162
-            \update_post_meta( $post_id, $field['name'], $data );
161
+            $data = filter_input(INPUT_POST, $field['name']);
162
+            \update_post_meta($post_id, $field['name'], $data);
163 163
         }
164 164
     }
165 165
     
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
     {
171 171
         $cs = get_current_screen();
172 172
         
173
-        foreach( $this->metaboxes as $metabox )
173
+        foreach ($this->metaboxes as $metabox)
174 174
         {
175
-            if( $metabox['screen'] === $cs->id )
175
+            if ($metabox['screen'] === $cs->id)
176 176
             {
177 177
                 echo '<style>';
178 178
                 include 'metabox.css';
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
      */
188 188
     private function init()
189 189
     {
190
-        \add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
191
-        \add_action( 'save_post', array( $this, 'save_meta_boxes' ) );
192
-        \add_action( 'admin_footer', array( $this, 'print_style' ) );
190
+        \add_action('add_meta_boxes', array($this, 'add_meta_boxes'));
191
+        \add_action('save_post', array($this, 'save_meta_boxes'));
192
+        \add_action('admin_footer', array($this, 'print_style'));
193 193
     }
194 194
     
195 195
     /**
Please login to merge, or discard this patch.