@@ -48,10 +48,14 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function filterByTaxonomy( WP_Query $query ) |
50 | 50 | { |
51 | - if( !is_admin() || ( new Helper )->getCurrentScreen()->base != 'edit' )return; |
|
51 | + if( !is_admin() || ( new Helper )->getCurrentScreen()->base != 'edit' ) { |
|
52 | + return; |
|
53 | + } |
|
52 | 54 | $vars = &$query->query_vars; |
53 | 55 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
54 | - if( !isset( $vars[$taxonomy] ))return; |
|
56 | + if( !isset( $vars[$taxonomy] )) { |
|
57 | + return; |
|
58 | + } |
|
55 | 59 | if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
56 | 60 | $vars[$taxonomy] = $term->slug; |
57 | 61 | } |
@@ -67,7 +71,9 @@ discard block |
||
67 | 71 | { |
68 | 72 | global $wp_query; |
69 | 73 | foreach( $this->taxonomies as $taxonomy => $args ) { |
70 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
74 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] )) { |
|
75 | + continue; |
|
76 | + } |
|
71 | 77 | $selected = isset( $wp_query->query[$taxonomy] ) |
72 | 78 | ? $wp_query->query[$taxonomy] |
73 | 79 | : false; |
@@ -88,7 +94,8 @@ discard block |
||
88 | 94 | */ |
89 | 95 | public function register() |
90 | 96 | { |
91 | - array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
|
97 | + array_walk( $this->taxonomies, function( $args, $taxonomy ) |
|
98 | + { |
|
92 | 99 | register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
93 | 100 | foreach( $args['post_types'] as $type ) { |
94 | 101 | register_taxonomy_for_object_type( $taxonomy, $type ); |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function validate( array $conditions ) |
23 | 23 | { |
24 | - array_walk( $conditions, function( &$value, $key ) { |
|
24 | + array_walk( $conditions, function( &$value, $key ) |
|
25 | + { |
|
25 | 26 | $method = ( new Helper )->buildMethodName( $key, 'validate' ); |
26 | 27 | $value = method_exists( $this, $method ) |
27 | 28 | ? $this->$method( $value ) |
@@ -41,7 +42,8 @@ discard block |
||
41 | 42 | foreach( $conditions as $key ) { |
42 | 43 | $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
43 | 44 | } |
44 | - $conditions = array_filter( $conditions, function( $key ) { |
|
45 | + $conditions = array_filter( $conditions, function( $key ) |
|
46 | + { |
|
45 | 47 | return !is_numeric( $key ); |
46 | 48 | }, ARRAY_FILTER_USE_KEY ); |
47 | 49 | } |
@@ -142,7 +142,8 @@ discard block |
||
142 | 142 | */ |
143 | 143 | protected function normalizeFields( array $fields, array $data, $parentId ) |
144 | 144 | { |
145 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
145 | + return array_map( function( $id, $field ) use( $parentId ) |
|
146 | + { |
|
146 | 147 | $defaults = [ |
147 | 148 | 'attributes' => [], |
148 | 149 | 'class' => '', |
@@ -182,8 +183,11 @@ discard block |
||
182 | 183 | { |
183 | 184 | $fields = &$metabox['fields']; |
184 | 185 | $depends = array_column( $fields, 'depends' ); |
185 | - array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
|
186 | - if( empty( $value ))return; |
|
186 | + array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) |
|
187 | + { |
|
188 | + if( empty( $value )) { |
|
189 | + return; |
|
190 | + } |
|
187 | 191 | $dependency = array_search( $value, array_column( $fields, 'id' )); |
188 | 192 | $fields[$index]['attributes']['data-depends'] = $value; |
189 | 193 | 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 | - return array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
|
47 | - $fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) { |
|
48 | + return array_reduce( $this->getInstructions(), function( $html, $metabox ) |
|
49 | + { |
|
50 | + $fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) |
|
51 | + { |
|
48 | 52 | if( !$this->validate( $field['condition'] )) { |
49 | 53 | return $html; |
50 | 54 | } |
@@ -63,7 +67,8 @@ discard block |
||
63 | 67 | */ |
64 | 68 | protected function getInstructions() |
65 | 69 | { |
66 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
70 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
71 | + { |
|
67 | 72 | return $this->validate( $metabox['condition'] ) |
68 | 73 | && $this->hasPostType( $metabox ); |
69 | 74 | }); |
@@ -74,7 +79,8 @@ discard block |
||
74 | 79 | */ |
75 | 80 | protected function showInstructions() |
76 | 81 | { |
77 | - return count( array_filter( $this->metaboxes, function( $metabox ) { |
|
82 | + return count( array_filter( $this->metaboxes, function( $metabox ) |
|
83 | + { |
|
78 | 84 | return $this->show( false, $metabox ); |
79 | 85 | })) > 0; |
80 | 86 | } |
@@ -12,7 +12,9 @@ |
||
12 | 12 | */ |
13 | 13 | public function get( $metaKey, array $args = [] ) |
14 | 14 | { |
15 | - if( empty( $metaKey ))return; |
|
15 | + if( empty( $metaKey )) { |
|
16 | + return; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $args = $this->normalize( $args ); |
18 | 20 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |