@@ -138,7 +138,9 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function register() |
| 140 | 140 | { |
| 141 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
| 141 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
| 142 | + return; |
|
| 143 | + } |
|
| 142 | 144 | foreach( parent::register() as $metabox ) { |
| 143 | 145 | new RWMetaBox( $metabox, static::ID, $this ); |
| 144 | 146 | } |
@@ -164,7 +166,9 @@ discard block |
||
| 164 | 166 | */ |
| 165 | 167 | public function renderFooterScript() |
| 166 | 168 | { |
| 167 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
| 169 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
| 170 | + return; |
|
| 171 | + } |
|
| 168 | 172 | $this->render( 'settings/script', [ |
| 169 | 173 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
| 170 | 174 | 'hook' => $this->hook, |
@@ -212,7 +216,9 @@ discard block |
||
| 212 | 216 | { |
| 213 | 217 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
| 214 | 218 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
| 215 | - )return; |
|
| 219 | + ) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 216 | 222 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
| 217 | 223 | update_option( static::id(), $this->getDefaults() ); |
| 218 | 224 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -231,7 +237,8 @@ discard block |
||
| 231 | 237 | */ |
| 232 | 238 | protected function filterArrayByKey( array $array, $key ) |
| 233 | 239 | { |
| 234 | - return array_filter( $array, function( $value ) use( $key ) { |
|
| 240 | + return array_filter( $array, function( $value ) use( $key ) |
|
| 241 | + { |
|
| 235 | 242 | return !empty( $value[$key] ); |
| 236 | 243 | }); |
| 237 | 244 | } |
@@ -243,8 +250,10 @@ discard block |
||
| 243 | 250 | { |
| 244 | 251 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
| 245 | 252 | |
| 246 | - array_walk( $metaboxes, function( &$metabox ) { |
|
| 247 | - $fields = array_map( function( $field ) { |
|
| 253 | + array_walk( $metaboxes, function( &$metabox ) |
|
| 254 | + { |
|
| 255 | + $fields = array_map( function( $field ) |
|
| 256 | + { |
|
| 248 | 257 | $field = wp_parse_args( $field, ['std' => ''] ); |
| 249 | 258 | return [$field['slug'] => $field['std']]; |
| 250 | 259 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
@@ -197,7 +197,8 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | protected function normalizeFields( array $fields, array $data, $parentId ) |
| 199 | 199 | { |
| 200 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
| 200 | + return array_map( function( $id, $field ) use( $parentId ) |
|
| 201 | + { |
|
| 201 | 202 | $defaults = [ |
| 202 | 203 | 'attributes' => [], |
| 203 | 204 | 'class' => '', |
@@ -236,7 +237,9 @@ discard block |
||
| 236 | 237 | protected function normalizeValidation( array $validation, array $data, $parentId ) |
| 237 | 238 | { |
| 238 | 239 | foreach( ['messages', 'rules'] as $key ) { |
| 239 | - if( empty( $validation[$key] ))continue; |
|
| 240 | + if( empty( $validation[$key] )) { |
|
| 241 | + continue; |
|
| 242 | + } |
|
| 240 | 243 | foreach( $validation[$key] as $id => $value ) { |
| 241 | 244 | $validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value; |
| 242 | 245 | unset( $validation[$key][$id] ); |
@@ -252,8 +255,11 @@ discard block |
||
| 252 | 255 | { |
| 253 | 256 | $fields = &$metabox['fields']; |
| 254 | 257 | $depends = array_column( $fields, 'depends' ); |
| 255 | - array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
|
| 256 | - if( empty( $value ))return; |
|
| 258 | + array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) |
|
| 259 | + { |
|
| 260 | + if( empty( $value )) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 257 | 263 | $dependency = array_search( $value, array_column( $fields, 'id' )); |
| 258 | 264 | $fields[$index]['attributes']['data-depends'] = $value; |
| 259 | 265 | if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] )) { |