@@ -158,7 +158,9 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function register() |
| 160 | 160 | { |
| 161 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
| 161 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
| 162 | + return; |
|
| 163 | + } |
|
| 162 | 164 | foreach( parent::register() as $metabox ) { |
| 163 | 165 | new RWMetaBox( $metabox ); |
| 164 | 166 | } |
@@ -184,7 +186,9 @@ discard block |
||
| 184 | 186 | */ |
| 185 | 187 | public function renderFooterScript() |
| 186 | 188 | { |
| 187 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
| 189 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
| 190 | + return; |
|
| 191 | + } |
|
| 188 | 192 | $this->render( 'settings/script', [ |
| 189 | 193 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
| 190 | 194 | 'hook' => $this->hook, |
@@ -231,7 +235,9 @@ discard block |
||
| 231 | 235 | { |
| 232 | 236 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
| 233 | 237 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
| 234 | - )return; |
|
| 238 | + ) { |
|
| 239 | + return; |
|
| 240 | + } |
|
| 235 | 241 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
| 236 | 242 | update_option( static::id(), $this->getDefaults() ); |
| 237 | 243 | return add_settings_error( static::id(), 'reset', __( 'All values have been reset to defaults.', 'pollux' ), 'updated' ); |
@@ -245,7 +251,8 @@ discard block |
||
| 245 | 251 | */ |
| 246 | 252 | protected function filterArrayByKey( array $array, $key ) |
| 247 | 253 | { |
| 248 | - return array_filter( $array, function( $value ) use( $key ) { |
|
| 254 | + return array_filter( $array, function( $value ) use( $key ) |
|
| 255 | + { |
|
| 249 | 256 | return !empty( $value[$key] ); |
| 250 | 257 | }); |
| 251 | 258 | } |
@@ -257,8 +264,10 @@ discard block |
||
| 257 | 264 | { |
| 258 | 265 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
| 259 | 266 | |
| 260 | - array_walk( $metaboxes, function( &$metabox ) { |
|
| 261 | - $fields = array_map( function( $field ) { |
|
| 267 | + array_walk( $metaboxes, function( &$metabox ) |
|
| 268 | + { |
|
| 269 | + $fields = array_map( function( $field ) |
|
| 270 | + { |
|
| 262 | 271 | $field = wp_parse_args( $field, ['std' => ''] ); |
| 263 | 272 | return [$field['slug'] => $field['std']]; |
| 264 | 273 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |