@@ -46,10 +46,14 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function filterBy( WP_Query $query ) |
48 | 48 | { |
49 | - if( !is_admin() || $this->app->screen()->base != 'edit' )return; |
|
49 | + if( !is_admin() || $this->app->screen()->base != 'edit' ) { |
|
50 | + return; |
|
51 | + } |
|
50 | 52 | $vars = &$query->query_vars; |
51 | 53 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
52 | - if( !isset( $vars[$taxonomy] ))return; |
|
54 | + if( !isset( $vars[$taxonomy] )) { |
|
55 | + return; |
|
56 | + } |
|
53 | 57 | if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
54 | 58 | $vars[$taxonomy] = $term->slug; |
55 | 59 | } |
@@ -64,7 +68,9 @@ discard block |
||
64 | 68 | { |
65 | 69 | global $wp_query; |
66 | 70 | foreach( $this->taxonomies as $taxonomy => $args ) { |
67 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
71 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] )) { |
|
72 | + continue; |
|
73 | + } |
|
68 | 74 | $selected = isset( $wp_query->query[$taxonomy] ) |
69 | 75 | ? $wp_query->query[$taxonomy] |
70 | 76 | : false; |
@@ -84,7 +90,8 @@ discard block |
||
84 | 90 | */ |
85 | 91 | public function register() |
86 | 92 | { |
87 | - array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
|
93 | + array_walk( $this->taxonomies, function( $args, $taxonomy ) |
|
94 | + { |
|
88 | 95 | register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
89 | 96 | foreach( $args['post_types'] as $type ) { |
90 | 97 | register_taxonomy_for_object_type( $taxonomy, $type ); |
@@ -113,7 +113,9 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function register( $metaboxes = [] ) |
115 | 115 | { |
116 | - if( $this->app->screen()->id != $this->hook )return; |
|
116 | + if( $this->app->screen()->id != $this->hook ) { |
|
117 | + return; |
|
118 | + } |
|
117 | 119 | foreach( parent::register() as $metabox ) { |
118 | 120 | new SettingsMetaBox( $metabox ); |
119 | 121 | } |
@@ -180,7 +182,9 @@ discard block |
||
180 | 182 | { |
181 | 183 | if( filter_input( INPUT_GET, 'page' ) !== static::ID |
182 | 184 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
183 | - )return; |
|
185 | + ) { |
|
186 | + return; |
|
187 | + } |
|
184 | 188 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
185 | 189 | update_option( static::ID, $this->getDefaults() ); |
186 | 190 | return add_settings_error( static::ID, 'reset', __( 'Settings reset to defaults.', 'pollux' ), 'updated' ); |
@@ -194,7 +198,8 @@ discard block |
||
194 | 198 | */ |
195 | 199 | protected function filterArrayByKey( array $array, $key ) |
196 | 200 | { |
197 | - return array_filter( $array, function( $value ) use( $key ) { |
|
201 | + return array_filter( $array, function( $value ) use( $key ) |
|
202 | + { |
|
198 | 203 | return !empty( $value[$key] ); |
199 | 204 | }); |
200 | 205 | } |
@@ -206,8 +211,10 @@ discard block |
||
206 | 211 | { |
207 | 212 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
208 | 213 | |
209 | - array_walk( $metaboxes, function( &$metabox ) { |
|
210 | - $fields = array_map( function( $field ) { |
|
214 | + array_walk( $metaboxes, function( &$metabox ) |
|
215 | + { |
|
216 | + $fields = array_map( function( $field ) |
|
217 | + { |
|
211 | 218 | $field = wp_parse_args( $field, ['std' => ''] ); |
212 | 219 | return [$field['slug'] => $field['std']]; |
213 | 220 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |