@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | public function filterBeforeInstructions() |
56 | 56 | { |
57 | 57 | return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
58 | - array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) { |
|
58 | + array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) |
|
59 | + { |
|
59 | 60 | return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL; |
60 | 61 | }) |
61 | 62 | ); |
@@ -100,7 +101,9 @@ discard block |
||
100 | 101 | */ |
101 | 102 | public function registerFeaturedImageMetaBox() |
102 | 103 | { |
103 | - if( !current_user_can( 'upload_files' ))return; |
|
104 | + if( !current_user_can( 'upload_files' )) { |
|
105 | + return; |
|
106 | + } |
|
104 | 107 | add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' ); |
105 | 108 | } |
106 | 109 | |
@@ -156,7 +159,9 @@ discard block |
||
156 | 159 | public function renderPage() |
157 | 160 | { |
158 | 161 | $type = $this->getPostType(); |
159 | - if( empty( $type ))return; |
|
162 | + if( empty( $type )) { |
|
163 | + return; |
|
164 | + } |
|
160 | 165 | $labels = get_post_type_labels( get_post_type_object( $type )); |
161 | 166 | $this->render( 'archive/index', [ |
162 | 167 | 'columns' => get_current_screen()->get_columns(), |
@@ -192,7 +197,8 @@ discard block |
||
192 | 197 | */ |
193 | 198 | protected function getPostTypesWithArchive() |
194 | 199 | { |
195 | - $types = array_map( function( $value ) { |
|
200 | + $types = array_map( function( $value ) |
|
201 | + { |
|
196 | 202 | return sprintf( 'edit.php?post_type=%s', $value ); |
197 | 203 | }, get_post_types( ['has_archive' => 1] )); |
198 | 204 | return array_merge( $types, ['post' => 'edit.php'] ); |
@@ -147,7 +147,9 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function register() |
149 | 149 | { |
150 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
150 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
151 | + return; |
|
152 | + } |
|
151 | 153 | foreach( parent::register() as $metabox ) { |
152 | 154 | new RWMetaBox( $metabox, static::ID, $this->hook ); |
153 | 155 | } |
@@ -173,7 +175,9 @@ discard block |
||
173 | 175 | */ |
174 | 176 | public function renderFooterScript() |
175 | 177 | { |
176 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
178 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
179 | + return; |
|
180 | + } |
|
177 | 181 | $this->render( 'settings/script', [ |
178 | 182 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
179 | 183 | 'hook' => $this->hook, |
@@ -221,7 +225,9 @@ discard block |
||
221 | 225 | { |
222 | 226 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
223 | 227 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
224 | - )return; |
|
228 | + ) { |
|
229 | + return; |
|
230 | + } |
|
225 | 231 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
226 | 232 | update_option( static::id(), $this->getDefaults() ); |
227 | 233 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -240,7 +246,8 @@ discard block |
||
240 | 246 | */ |
241 | 247 | protected function filterArrayByKey( array $array, $key ) |
242 | 248 | { |
243 | - return array_filter( $array, function( $value ) use( $key ) { |
|
249 | + return array_filter( $array, function( $value ) use( $key ) |
|
250 | + { |
|
244 | 251 | return !empty( $value[$key] ); |
245 | 252 | }); |
246 | 253 | } |
@@ -252,8 +259,10 @@ discard block |
||
252 | 259 | { |
253 | 260 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
254 | 261 | |
255 | - array_walk( $metaboxes, function( &$metabox ) { |
|
256 | - $fields = array_map( function( $field ) { |
|
262 | + array_walk( $metaboxes, function( &$metabox ) |
|
263 | + { |
|
264 | + $fields = array_map( function( $field ) |
|
265 | + { |
|
257 | 266 | $field = wp_parse_args( $field, ['std' => ''] ); |
258 | 267 | return [$field['slug'] => $field['std']]; |
259 | 268 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
@@ -181,7 +181,8 @@ discard block |
||
181 | 181 | */ |
182 | 182 | protected function normalizeFields( array $fields, array $data, $parentId ) |
183 | 183 | { |
184 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
184 | + return array_map( function( $id, $field ) use( $parentId ) |
|
185 | + { |
|
185 | 186 | $defaults = [ |
186 | 187 | 'attributes' => [], |
187 | 188 | 'class' => '', |
@@ -220,7 +221,9 @@ discard block |
||
220 | 221 | protected function normalizeValidation( array $validation, array $data, $parentId ) |
221 | 222 | { |
222 | 223 | foreach( ['messages', 'rules'] as $key ) { |
223 | - if( empty( $validation[$key] ))continue; |
|
224 | + if( empty( $validation[$key] )) { |
|
225 | + continue; |
|
226 | + } |
|
224 | 227 | foreach( $validation[$key] as $id => $value ) { |
225 | 228 | $validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value; |
226 | 229 | unset( $validation[$key][$id] ); |
@@ -236,8 +239,11 @@ discard block |
||
236 | 239 | { |
237 | 240 | $fields = &$metabox['fields']; |
238 | 241 | $depends = array_column( $fields, 'depends' ); |
239 | - array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
|
240 | - if( empty( $value ))return; |
|
242 | + array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) |
|
243 | + { |
|
244 | + if( empty( $value )) { |
|
245 | + return; |
|
246 | + } |
|
241 | 247 | $dependency = array_search( $value, array_column( $fields, 'id' )); |
242 | 248 | $fields[$index]['attributes']['data-depends'] = $value; |
243 | 249 | if( !$this->getValue( $fields[$dependency]['slug'], $metabox['slug'] )) { |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | */ |
23 | 23 | protected function addInstructions() |
24 | 24 | { |
25 | - if( !$this->showInstructions() )return; |
|
25 | + if( !$this->showInstructions() ) { |
|
26 | + return; |
|
27 | + } |
|
26 | 28 | $this->normalize([ |
27 | 29 | 'infodiv' => [ |
28 | 30 | 'context' => 'side', |
@@ -43,8 +45,10 @@ discard block |
||
43 | 45 | */ |
44 | 46 | protected function generateInstructions() |
45 | 47 | { |
46 | - $instructions = array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
|
47 | - $fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) { |
|
48 | + $instructions = array_reduce( $this->getInstructions(), function( $html, $metabox ) |
|
49 | + { |
|
50 | + $fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) |
|
51 | + { |
|
48 | 52 | return $this->validate( $field['condition'] ) |
49 | 53 | ? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL |
50 | 54 | : $html; |
@@ -62,7 +66,8 @@ discard block |
||
62 | 66 | */ |
63 | 67 | protected function getInstructions() |
64 | 68 | { |
65 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
69 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
70 | + { |
|
66 | 71 | return $this->validate( $metabox['condition'] ) |
67 | 72 | && $this->hasPostType( $metabox ); |
68 | 73 | }); |
@@ -73,7 +78,8 @@ discard block |
||
73 | 78 | */ |
74 | 79 | protected function showInstructions() |
75 | 80 | { |
76 | - return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) { |
|
81 | + return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) |
|
82 | + { |
|
77 | 83 | return $this->show( false, $metabox ); |
78 | 84 | })) > 0 ); |
79 | 85 | } |