@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function validate( array $conditions ) |
30 | 30 | { |
31 | 31 | array_walk( $conditions, function( &$value, $key ) { |
32 | - $method = ( new Helper )->buildMethodName( $key, 'validate' ); |
|
32 | + $method = (new Helper)->buildMethodName( $key, 'validate' ); |
|
33 | 33 | $value = method_exists( $this, $method ) |
34 | 34 | ? $this->$method( $value ) |
35 | 35 | : $this->validateUnknown( $key, $value ); |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected function normalizeCondition( $conditions ) |
45 | 45 | { |
46 | - if( !is_array( $conditions )) { |
|
46 | + if( !is_array( $conditions ) ) { |
|
47 | 47 | $conditions = []; |
48 | 48 | } |
49 | - if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) { |
|
49 | + if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) { |
|
50 | 50 | foreach( $conditions as $key ) { |
51 | 51 | $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
52 | 52 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | return array_intersect_key( |
58 | 58 | $conditions, |
59 | - array_flip( $this->filter( 'conditions', static::conditions() )) |
|
59 | + array_flip( $this->filter( 'conditions', static::conditions() ) ) |
|
60 | 60 | ); |
61 | 61 | } |
62 | 62 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function validateIsFrontPage( $value ) |
104 | 104 | { |
105 | - return $value == ( $this->getPostId() == get_option( 'page_on_front' )); |
|
105 | + return $value == ($this->getPostId() == get_option( 'page_on_front' )); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function validateIsHome( $value ) |
113 | 113 | { |
114 | - return $value == ( $this->getPostId() == get_option( 'page_for_posts' )); |
|
114 | + return $value == ($this->getPostId() == get_option( 'page_for_posts' )); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function validateIsPageTemplate( $value ) |
122 | 122 | { |
123 | - return ( new Helper )->endsWith( |
|
123 | + return (new Helper)->endsWith( |
|
124 | 124 | $value, |
125 | - basename( get_page_template_slug( $this->getPostId() )) |
|
125 | + basename( get_page_template_slug( $this->getPostId() ) ) |
|
126 | 126 | ); |
127 | 127 | } |
128 | 128 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $args = array_pad( $args, 2, null ); |
32 | 32 | $group = $this->$group; |
33 | - if( is_object( $group )) { |
|
33 | + if( is_object( $group ) ) { |
|
34 | 34 | return $group; |
35 | 35 | } |
36 | 36 | return $this->get( $group, $args[0], $args[1] ); |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | public function __get( $group ) |
44 | 44 | { |
45 | 45 | if( $group == 'all' ) { |
46 | - return (object) $this->options; |
|
46 | + return (object)$this->options; |
|
47 | 47 | } |
48 | - if( empty( $group )) { |
|
48 | + if( empty($group) ) { |
|
49 | 49 | $group = $this->getDefaultGroup(); |
50 | 50 | } |
51 | - if( is_array( $group )) { |
|
51 | + if( is_array( $group ) ) { |
|
52 | 52 | $group = reset( $group ); |
53 | 53 | } |
54 | - return isset( $this->options[$group] ) |
|
54 | + return isset($this->options[$group]) |
|
55 | 55 | ? $this->options[$group] |
56 | 56 | : null; |
57 | 57 | } |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | if( func_num_args() < 1 ) { |
68 | 68 | return $this->all; |
69 | 69 | } |
70 | - if( is_string( $group )) { |
|
70 | + if( is_string( $group ) ) { |
|
71 | 71 | $group = $this->$group; |
72 | 72 | } |
73 | - if( !is_array( $group )) { |
|
73 | + if( !is_array( $group ) ) { |
|
74 | 74 | return $fallback; |
75 | 75 | } |
76 | - if( is_null( $key )) { |
|
76 | + if( is_null( $key ) ) { |
|
77 | 77 | return $group; |
78 | 78 | } |
79 | 79 | return $this->getValue( $group, $key, $fallback ); |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | */ |
95 | 95 | protected function getValue( array $group, $key, $fallback ) |
96 | 96 | { |
97 | - if( !array_key_exists( $key, $group )) { |
|
97 | + if( !array_key_exists( $key, $group ) ) { |
|
98 | 98 | return $fallback; |
99 | 99 | } |
100 | - return empty( $group[$key] ) && !is_null( $fallback ) |
|
100 | + return empty($group[$key]) && !is_null( $fallback ) |
|
101 | 101 | ? $fallback |
102 | 102 | : $group[$key]; |
103 | 103 | } |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | { |
23 | 23 | $instructions = array_reduce( $this->getInstructionGroups(), function( $html, $metabox ) { |
24 | 24 | $fields = $this->getInstructionFields( $metabox ); |
25 | - if( empty( $fields )) { |
|
25 | + if( empty($fields) ) { |
|
26 | 26 | return $html; |
27 | 27 | } |
28 | - return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
|
28 | + return $html.sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
|
29 | 29 | $metabox['title'], |
30 | 30 | $fields |
31 | 31 | ); |
32 | 32 | }); |
33 | - return $this->filter( 'before/instructions', '' ) . $instructions . $this->filter( 'after/instructions', '' ); |
|
33 | + return $this->filter( 'before/instructions', '' ).$instructions.$this->filter( 'after/instructions', '' ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | protected function getInstructionFields( $metabox ) |
40 | 40 | { |
41 | 41 | $skipFields = ['custom_html', 'divider', 'heading', 'taxonomy']; |
42 | - return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox, $skipFields ) { |
|
42 | + return array_reduce( $metabox['fields'], function( $html, $field ) use($metabox, $skipFields) { |
|
43 | 43 | return $this->validate( $field['condition'] ) && !in_array( $field['type'], $skipFields ) |
44 | - ? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL |
|
44 | + ? $html.$this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ).PHP_EOL |
|
45 | 45 | : $html; |
46 | 46 | }); |
47 | 47 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) { |
87 | 87 | return $this->show( false, $metabox ); |
88 | - })) > 0 ); |
|
88 | + }) ) > 0 ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -62,7 +62,9 @@ |
||
62 | 62 | */ |
63 | 63 | protected function initInstructions() |
64 | 64 | { |
65 | - if( !$this->showInstructions() )return; |
|
65 | + if( !$this->showInstructions() ) { |
|
66 | + return; |
|
67 | + } |
|
66 | 68 | return [ |
67 | 69 | 'infodiv' => [ |
68 | 70 | 'context' => 'side', |
@@ -32,16 +32,16 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function init() |
34 | 34 | { |
35 | - if( empty( $this->app->config->{static::ID} ))return; |
|
35 | + if( empty($this->app->config->{static::ID} ) )return; |
|
36 | 36 | |
37 | 37 | $this->normalize( $this->app->config->{static::ID}, [ |
38 | 38 | 'post_types' => [], |
39 | - ]); |
|
39 | + ] ); |
|
40 | 40 | |
41 | 41 | add_filter( 'rwmb_normalize_map_field', [$this, 'normalizeMapField'] ); |
42 | - add_filter( 'rwmb_show', [$this, 'show'], 10, 2 ); |
|
43 | - add_filter( 'rwmb_meta_boxes', [$this, 'register'] ); |
|
44 | - add_filter( 'rwmb_outer_html', [$this, 'renderField'], 10, 2 ); |
|
42 | + add_filter( 'rwmb_show', [$this, 'show'], 10, 2 ); |
|
43 | + add_filter( 'rwmb_meta_boxes', [$this, 'register'] ); |
|
44 | + add_filter( 'rwmb_outer_html', [$this, 'renderField'], 10, 2 ); |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | { |
76 | 76 | return PostMeta::get( $key, [ |
77 | 77 | 'id' => $this->getPostId(), |
78 | - ]); |
|
78 | + ] ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function normalizeMapField( $field ) |
86 | 86 | { |
87 | - if( empty( $field['address_field'] )) { |
|
87 | + if( empty($field['address_field']) ) { |
|
88 | 88 | return $field; |
89 | 89 | } |
90 | - if( !$this->app->make( Helper::class )->startsWith( Application::PREFIX, $field['address_field'] )) { |
|
91 | - $field['address_field'] = Application::PREFIX . $field['address_field']; |
|
90 | + if( !$this->app->make( Helper::class )->startsWith( Application::PREFIX, $field['address_field'] ) ) { |
|
91 | + $field['address_field'] = Application::PREFIX.$field['address_field']; |
|
92 | 92 | } |
93 | 93 | $apiKey = SiteMeta::services( $field['api_key'] ); |
94 | - if( !empty( $apiKey ) && is_string( $apiKey )) { |
|
94 | + if( !empty($apiKey) && is_string( $apiKey ) ) { |
|
95 | 95 | $field['api_key'] = $apiKey; |
96 | 96 | } |
97 | 97 | return $field; |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function register() |
105 | 105 | { |
106 | - if( current_user_can( 'switch_themes' )) { |
|
106 | + if( current_user_can( 'switch_themes' ) ) { |
|
107 | 107 | $instructions = $this->initInstructions(); |
108 | - if( is_array( $instructions )) { |
|
108 | + if( is_array( $instructions ) ) { |
|
109 | 109 | $this->normalize( $instructions ); |
110 | 110 | } |
111 | 111 | } |
112 | 112 | $metaboxes = func_num_args() |
113 | - ? ( new Helper )->toArray( func_get_arg(0) ) |
|
113 | + ? (new Helper)->toArray( func_get_arg( 0 ) ) |
|
114 | 114 | : []; |
115 | 115 | return array_merge( $metaboxes, $this->metaboxes ); |
116 | 116 | } |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | public function show( $bool, array $metabox ) |
134 | 134 | { |
135 | 135 | if( defined( 'DOING_AJAX' ) |
136 | - || !isset( $metabox['condition'] ) |
|
137 | - || !$this->hasPostType( $metabox )) { |
|
136 | + || !isset($metabox['condition']) |
|
137 | + || !$this->hasPostType( $metabox ) ) { |
|
138 | 138 | return $bool; |
139 | 139 | } |
140 | 140 | return $this->validate( $metabox['condition'] ); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | protected function getPostId() |
147 | 147 | { |
148 | - if( !( $postId = filter_input( INPUT_GET, 'post' ))) { |
|
148 | + if( !($postId = filter_input( INPUT_GET, 'post' )) ) { |
|
149 | 149 | $postId = filter_input( INPUT_POST, 'post_ID' ); |
150 | 150 | } |
151 | 151 | return intval( $postId ); |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | { |
159 | 159 | return array_unique( iterator_to_array( |
160 | 160 | new RecursiveIteratorIterator( |
161 | - new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' )) |
|
161 | + new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) ) |
|
162 | 162 | ), |
163 | 163 | false |
164 | - )); |
|
164 | + ) ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | */ |
170 | 170 | protected function hasPostType( array $metabox ) |
171 | 171 | { |
172 | - if( !isset( $metabox['post_types'] )) { |
|
172 | + if( !isset($metabox['post_types']) ) { |
|
173 | 173 | return true; |
174 | 174 | } |
175 | - if( !( $type = filter_input( INPUT_GET, 'post_type' ))) { |
|
175 | + if( !($type = filter_input( INPUT_GET, 'post_type' )) ) { |
|
176 | 176 | $type = get_post_type( $this->getPostId() ); |
177 | 177 | } |
178 | 178 | return in_array( $type, $metabox['post_types'] ); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | 'id' => $id, |
191 | 191 | 'slug' => $id, |
192 | 192 | 'validation' => [], |
193 | - ]); |
|
193 | + ] ); |
|
194 | 194 | $this->metaboxes[] = $this->setDependencies( |
195 | 195 | $this->normalizeThis( $metabox, $data, $id ) |
196 | 196 | ); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | protected function normalizeDepends( $depends, array $data, $parentId ) |
206 | 206 | { |
207 | - return is_string( $depends ) && !empty( $depends ) |
|
207 | + return is_string( $depends ) && !empty($depends) |
|
208 | 208 | ? $this->normalizeId( $depends, $data, $parentId ) |
209 | 209 | : ''; |
210 | 210 | } |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | */ |
225 | 225 | protected function normalizeFields( array $fields, array $data, $parentId ) |
226 | 226 | { |
227 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
228 | - $defaults = [ |
|
227 | + return array_map( function( $id, $field ) use($parentId) { |
|
228 | + $defaults = [ |
|
229 | 229 | 'attributes' => [], |
230 | 230 | 'class' => '', |
231 | 231 | 'condition' => [], |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | protected function normalizeId( $id, array $data, $parentId ) |
247 | 247 | { |
248 | - return Application::prefix() . $id; |
|
248 | + return Application::prefix().$id; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | protected function normalizePostTypes( $types ) |
256 | 256 | { |
257 | - return ( new Helper )->toArray( $types ); |
|
257 | + return (new Helper)->toArray( $types ); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | protected function normalizeValidation( array $validation, array $data, $parentId ) |
264 | 264 | { |
265 | 265 | foreach( ['messages', 'rules'] as $key ) { |
266 | - if( empty( $validation[$key] ))continue; |
|
266 | + if( empty($validation[$key]) )continue; |
|
267 | 267 | foreach( $validation[$key] as $id => $value ) { |
268 | 268 | $validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value; |
269 | - unset( $validation[$key][$id] ); |
|
269 | + unset($validation[$key][$id]); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | return $validation; |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | { |
280 | 280 | $fields = &$metabox['fields']; |
281 | 281 | $depends = array_column( $fields, 'depends' ); |
282 | - array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
|
283 | - if( empty( $value ))return; |
|
284 | - $dependency = array_search( $value, array_column( $fields, 'id' )); |
|
282 | + array_walk( $depends, function( $value, $index ) use(&$fields, $metabox) { |
|
283 | + if( empty($value) )return; |
|
284 | + $dependency = array_search( $value, array_column( $fields, 'id' ) ); |
|
285 | 285 | $fields[$index]['attributes']['data-depends'] = $value; |
286 | - if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] )) { |
|
287 | - $fields[$index]['class'] = trim( 'hidden ' . $fields[$index]['class'] ); |
|
286 | + if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] ) ) { |
|
287 | + $fields[$index]['class'] = trim( 'hidden '.$fields[$index]['class'] ); |
|
288 | 288 | } |
289 | 289 | }); |
290 | 290 | return $metabox; |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function init() |
34 | 34 | { |
35 | - if( empty( $this->app->config->{static::ID} ))return; |
|
35 | + if( empty( $this->app->config->{static::ID} )) { |
|
36 | + return; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $this->normalize( $this->app->config->{static::ID}, [ |
38 | 40 | 'post_types' => [], |
@@ -263,7 +265,9 @@ discard block |
||
263 | 265 | protected function normalizeValidation( array $validation, array $data, $parentId ) |
264 | 266 | { |
265 | 267 | foreach( ['messages', 'rules'] as $key ) { |
266 | - if( empty( $validation[$key] ))continue; |
|
268 | + if( empty( $validation[$key] )) { |
|
269 | + continue; |
|
270 | + } |
|
267 | 271 | foreach( $validation[$key] as $id => $value ) { |
268 | 272 | $validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value; |
269 | 273 | unset( $validation[$key][$id] ); |
@@ -280,7 +284,9 @@ discard block |
||
280 | 284 | $fields = &$metabox['fields']; |
281 | 285 | $depends = array_column( $fields, 'depends' ); |
282 | 286 | array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
283 | - if( empty( $value ))return; |
|
287 | + if( empty( $value )) { |
|
288 | + return; |
|
289 | + } |
|
284 | 290 | $dependency = array_search( $value, array_column( $fields, 'id' )); |
285 | 291 | $fields[$index]['attributes']['data-depends'] = $value; |
286 | 292 | if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] )) { |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function buildClassName( $name, $path = '' ) |
15 | 15 | { |
16 | - $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ))); |
|
16 | + $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ) ) ); |
|
17 | 17 | $className = implode( '', $className ); |
18 | - return !empty( $path ) |
|
19 | - ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className )) |
|
18 | + return !empty($path) |
|
19 | + ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ) ) |
|
20 | 20 | : $className; |
21 | 21 | } |
22 | 22 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function buildMethodName( $name, $prefix = 'get' ) |
29 | 29 | { |
30 | - return lcfirst( $this->buildClassName( $prefix . '-' . $name )); |
|
30 | + return lcfirst( $this->buildClassName( $prefix.'-'.$name ) ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | public function getCurrentScreen() |
64 | 64 | { |
65 | 65 | global $hook_suffix, $pagenow; |
66 | - if( function_exists( 'get_current_screen' )) { |
|
66 | + if( function_exists( 'get_current_screen' ) ) { |
|
67 | 67 | $screen = get_current_screen(); |
68 | 68 | } |
69 | - if( empty( $screen )) { |
|
69 | + if( empty($screen) ) { |
|
70 | 70 | $screen = new \stdClass(); |
71 | 71 | $screen->base = $screen->id = $hook_suffix; |
72 | 72 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function startsWith( $needle, $haystack ) |
83 | 83 | { |
84 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
84 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,6 +90,6 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function toArray( $value ) |
92 | 92 | { |
93 | - return array_filter( (array) $value ); |
|
93 | + return array_filter( (array)$value ); |
|
94 | 94 | } |
95 | 95 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | { |
30 | 30 | $method = strtolower( $name ); |
31 | 31 | $status = substr( $method, 3 ); |
32 | - if( 'add' == substr( $method, 0, 3 ) && in_array( $status, ['error', 'info', 'success', 'warning'] )) { |
|
33 | - return call_user_func_array( [$this, 'addNotice'], array_merge( [$status], $args )); |
|
32 | + if( 'add' == substr( $method, 0, 3 ) && in_array( $status, ['error', 'info', 'success', 'warning'] ) ) { |
|
33 | + return call_user_func_array( [$this, 'addNotice'], array_merge( [$status], $args ) ); |
|
34 | 34 | } |
35 | - throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name )); |
|
35 | + throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name ) ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function __get( $property ) |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | if( $property == 'all' ) { |
41 | 41 | return $this->app->notices; |
42 | 42 | } |
43 | - throw new Exception( sprintf( 'Not a valid property: %s', $property )); |
|
43 | + throw new Exception( sprintf( 'Not a valid property: %s', $property ) ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function activateButton( array $plugin ) |
50 | 50 | { |
51 | - $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin['plugin'] )); |
|
51 | + $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin['plugin'] ) ); |
|
52 | 52 | return $this->button( sprintf( '%s %s', __( 'Activate', 'pollux' ), $plugin['name'] ), [ |
53 | 53 | 'data-name' => $plugin['name'], |
54 | 54 | 'data-plugin' => $plugin['plugin'], |
55 | 55 | 'data-slug' => $plugin['slug'], |
56 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin['plugin'] )), |
|
57 | - ]); |
|
56 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin['plugin'] ) ), |
|
57 | + ] ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | $atts = wp_parse_args( $atts, [ |
67 | 67 | 'class' => '', |
68 | 68 | 'href' => '', |
69 | - ]); |
|
70 | - $atts['class'] = trim( $atts['class'] . ' button button-small' ); |
|
71 | - $attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use( $atts ) { |
|
72 | - return $carry . sprintf( ' %s="%s"', $key, $atts[$key] ); |
|
69 | + ] ); |
|
70 | + $atts['class'] = trim( $atts['class'].' button button-small' ); |
|
71 | + $attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use($atts) { |
|
72 | + return $carry.sprintf( ' %s="%s"', $key, $atts[$key] ); |
|
73 | 73 | }); |
74 | 74 | return sprintf( '<a%s>%s</a>', $attributes, $title ); |
75 | 75 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | if( $unset ) { |
83 | 83 | $index = array_search( $notice, $this->app->notices ); |
84 | 84 | if( $index !== false ) { |
85 | - unset( $this->app->notices[$index] ); |
|
85 | + unset($this->app->notices[$index]); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | return $this->buildNotice( $notice ); |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function installButton( array $plugin ) |
95 | 95 | { |
96 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin['slug'] )); |
|
96 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin['slug'] ) ); |
|
97 | 97 | return $this->button( sprintf( '%s %s', __( 'Install', 'pollux' ), $plugin['name'] ), [ |
98 | 98 | 'data-name' => $plugin['name'], |
99 | 99 | 'data-plugin' => $plugin['plugin'], |
100 | 100 | 'data-slug' => $plugin['slug'], |
101 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin['slug'] )), |
|
102 | - ]); |
|
101 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin['slug'] ) ), |
|
102 | + ] ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function updateButton( array $plugin ) |
109 | 109 | { |
110 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin['plugin'] )); |
|
110 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin['plugin'] ) ); |
|
111 | 111 | return $this->button( sprintf( '%s %s', __( 'Update', 'pollux' ), $plugin['name'] ), [ |
112 | 112 | 'data-name' => $plugin['name'], |
113 | 113 | 'data-plugin' => $plugin['plugin'], |
114 | 114 | 'data-slug' => $plugin['slug'], |
115 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin['plugin'] )), |
|
116 | - ]); |
|
115 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin['plugin'] ) ), |
|
116 | + ] ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | { |
136 | 136 | $this->app->notices[] = [ |
137 | 137 | 'dismissible' => $dismissible, |
138 | - 'message' => $this->buildMessage( array_filter( (array) $messages )), |
|
138 | + 'message' => $this->buildMessage( array_filter( (array)$messages ) ), |
|
139 | 139 | 'type' => $type, |
140 | 140 | ]; |
141 | 141 | $this->app->notices = array_unique( $this->app->notices, SORT_REGULAR ); |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | protected function buildMessage( array $messages ) |
148 | 148 | { |
149 | 149 | foreach( $messages as $key => &$message ) { |
150 | - if( !is_wp_error( $message ))continue; |
|
150 | + if( !is_wp_error( $message ) )continue; |
|
151 | 151 | $message = $message->get_error_message(); |
152 | 152 | } |
153 | - return wpautop( implode( PHP_EOL . PHP_EOL, $messages )); |
|
153 | + return wpautop( implode( PHP_EOL.PHP_EOL, $messages ) ); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -147,7 +147,9 @@ |
||
147 | 147 | protected function buildMessage( array $messages ) |
148 | 148 | { |
149 | 149 | foreach( $messages as $key => &$message ) { |
150 | - if( !is_wp_error( $message ))continue; |
|
150 | + if( !is_wp_error( $message )) { |
|
151 | + continue; |
|
152 | + } |
|
151 | 153 | $message = $message->get_error_message(); |
152 | 154 | } |
153 | 155 | return wpautop( implode( PHP_EOL . PHP_EOL, $messages )); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public static function id() |
32 | 32 | { |
33 | - return apply_filters( sprintf( 'pollux/%s/id', static::ID ), Application::prefix() . static::ID ); |
|
33 | + return apply_filters( sprintf( 'pollux/%s/id', static::ID ), Application::prefix().static::ID ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -42,20 +42,20 @@ discard block |
||
42 | 42 | |
43 | 43 | $this->normalize( $this->app->config->{static::ID} ); |
44 | 44 | |
45 | - add_action( 'pollux/'.static::ID.'/init', [$this, 'addSubmitMetaBox'] ); |
|
46 | - add_action( 'current_screen', [$this, 'register'] ); |
|
47 | - add_action( 'admin_menu', [$this, 'registerPage'] ); |
|
48 | - add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
49 | - add_action( 'pollux/'.static::ID.'/init', [$this, 'resetPage'] ); |
|
50 | - add_action( 'admin_print_footer_scripts', [$this, 'renderFooterScript'] ); |
|
51 | - add_filter( 'pollux/'.static::ID.'/instruction', [$this, 'filterInstruction'], 10, 3 ); |
|
45 | + add_action( 'pollux/'.static::ID.'/init', [$this, 'addSubmitMetaBox'] ); |
|
46 | + add_action( 'current_screen', [$this, 'register'] ); |
|
47 | + add_action( 'admin_menu', [$this, 'registerPage'] ); |
|
48 | + add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
49 | + add_action( 'pollux/'.static::ID.'/init', [$this, 'resetPage'] ); |
|
50 | + add_action( 'admin_print_footer_scripts', [$this, 'renderFooterScript'] ); |
|
51 | + add_filter( 'pollux/'.static::ID.'/instruction', [$this, 'filterInstruction'], 10, 3 ); |
|
52 | 52 | add_filter( 'pollux/'.static::ID.'/before/instructions', [$this, 'filterBeforeInstructions'] ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | public function canProceed() |
56 | 56 | { |
57 | 57 | return $this->app->gatekeeper->hasDependency( static::DEPENDENCY ) |
58 | - && !empty( $this->app->config->{static::ID} ); |
|
58 | + && !empty($this->app->config->{static::ID} ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->hook, |
72 | 72 | 'side', |
73 | 73 | 'high', |
74 | - ])); |
|
74 | + ] ) ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function filterSavedSettings( $settings ) |
102 | 102 | { |
103 | - $settings = ( new Helper )->toArray( $settings ); |
|
103 | + $settings = (new Helper)->toArray( $settings ); |
|
104 | 104 | return $this->filter( 'save', array_merge( |
105 | 105 | array_intersect_key( $this->getSettings(), $settings ), |
106 | 106 | $settings |
107 | - )); |
|
107 | + ) ); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function register() |
126 | 126 | { |
127 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
128 | - if( $this->app->gatekeeper->hasDependency( self::DEPENDENCY )) { |
|
127 | + if( (new Helper)->getCurrentScreen()->id != $this->hook )return; |
|
128 | + if( $this->app->gatekeeper->hasDependency( self::DEPENDENCY ) ) { |
|
129 | 129 | foreach( parent::register() as $metabox ) { |
130 | 130 | new RWMetaBox( $metabox, static::ID, $this ); |
131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | add_screen_option( 'layout_columns', [ |
134 | 134 | 'max' => 2, |
135 | 135 | 'default' => 2, |
136 | - ]); |
|
136 | + ] ); |
|
137 | 137 | $this->action( 'init' ); |
138 | 138 | } |
139 | 139 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | [$this, 'renderPage'], |
152 | 152 | 'dashicons-screenoptions', |
153 | 153 | 1313 |
154 | - ])); |
|
154 | + ] ) ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function renderFooterScript() |
171 | 171 | { |
172 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
172 | + if( (new Helper)->getCurrentScreen()->id != $this->hook )return; |
|
173 | 173 | $this->app->render( 'settings/script', [ |
174 | 174 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
175 | 175 | 'hook' => $this->hook, |
176 | 176 | 'id' => static::id(), |
177 | - ]); |
|
177 | + ] ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | 'columns' => get_current_screen()->get_columns(), |
188 | 188 | 'heading' => __( 'Site Settings', 'pollux' ), |
189 | 189 | 'id' => static::id(), |
190 | - ]); |
|
190 | + ] ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | ]; |
205 | 205 | $this->app->render( 'settings/submit', [ |
206 | 206 | 'reset' => __( 'Reset all', 'pollux' ), |
207 | - 'reset_url' => esc_url( add_query_arg( $query, admin_url( $pagenow ))), |
|
207 | + 'reset_url' => esc_url( add_query_arg( $query, admin_url( $pagenow ) ) ), |
|
208 | 208 | 'submit' => get_submit_button( __( 'Save', 'pollux' ), 'primary', 'submit', false ), |
209 | - ]); |
|
209 | + ] ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
219 | 219 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
220 | 220 | )return; |
221 | - if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
|
221 | + if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook ) ) { |
|
222 | 222 | update_option( static::id(), $this->getDefaults() ); |
223 | 223 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
224 | 224 | } |
225 | 225 | else { |
226 | - add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' )); |
|
226 | + add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ) ); |
|
227 | 227 | } |
228 | 228 | set_transient( 'settings_errors', get_settings_errors(), 30 ); |
229 | - wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() )); |
|
229 | + wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() ) ); |
|
230 | 230 | exit; |
231 | 231 | } |
232 | 232 | |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | */ |
237 | 237 | protected function filterArrayByKey( array $array, $key ) |
238 | 238 | { |
239 | - return array_filter( $array, function( $value ) use( $key ) { |
|
240 | - return !empty( $value[$key] ); |
|
239 | + return array_filter( $array, function( $value ) use($key) { |
|
240 | + return !empty($value[$key]); |
|
241 | 241 | }); |
242 | 242 | } |
243 | 243 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $fields = array_map( function( $field ) { |
253 | 253 | $field = wp_parse_args( $field, ['std' => ''] ); |
254 | 254 | return [$field['slug'] => $field['std']]; |
255 | - }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
|
255 | + }, $this->filterArrayByKey( $metabox['fields'], 'slug' ) ); |
|
256 | 256 | $metabox = [ |
257 | 257 | $metabox['slug'] => call_user_func_array( 'array_merge', $fields ), |
258 | 258 | ]; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | |
263 | 263 | protected function getSettings() |
264 | 264 | { |
265 | - return (array) SiteMeta::all(); |
|
265 | + return (array)SiteMeta::all(); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function init() |
40 | 40 | { |
41 | - if( !$this->canProceed() )return; |
|
41 | + if( !$this->canProceed() ) { |
|
42 | + return; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | $this->normalize( $this->app->config->{static::ID} ); |
44 | 46 | |
@@ -124,7 +126,9 @@ discard block |
||
124 | 126 | */ |
125 | 127 | public function register() |
126 | 128 | { |
127 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
129 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
130 | + return; |
|
131 | + } |
|
128 | 132 | if( $this->app->gatekeeper->hasDependency( self::DEPENDENCY )) { |
129 | 133 | foreach( parent::register() as $metabox ) { |
130 | 134 | new RWMetaBox( $metabox, static::ID, $this ); |
@@ -169,7 +173,9 @@ discard block |
||
169 | 173 | */ |
170 | 174 | public function renderFooterScript() |
171 | 175 | { |
172 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
176 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
177 | + return; |
|
178 | + } |
|
173 | 179 | $this->app->render( 'settings/script', [ |
174 | 180 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
175 | 181 | 'hook' => $this->hook, |
@@ -217,7 +223,9 @@ discard block |
||
217 | 223 | { |
218 | 224 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
219 | 225 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
220 | - )return; |
|
226 | + ) { |
|
227 | + return; |
|
228 | + } |
|
221 | 229 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
222 | 230 | update_option( static::id(), $this->getDefaults() ); |
223 | 231 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | add_action( 'pollux/archives/init', [$this, 'add_meta_boxes'] ); |
26 | 26 | add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
27 | - add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
27 | + add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
28 | 28 | add_filter( 'rwmb_normalize_field', [$this, '_normalize_field'] ); |
29 | 29 | } |
30 | 30 | |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function _get_field_meta( $meta, array $field, $saved ) |
38 | 38 | { |
39 | - if( !$this->is_edit_screen() || !empty(( new Helper )->toArray( $meta )) || empty( $field['slug'] )) { |
|
39 | + if( !$this->is_edit_screen() || !empty((new Helper)->toArray( $meta )) || empty($field['slug']) ) { |
|
40 | 40 | return $meta; |
41 | 41 | } |
42 | - $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
|
42 | + $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ($saved |
|
43 | 43 | ? $this->pollux_caller->getMetaValue( $field['slug'], $meta, $this->meta_box['slug'] ) |
44 | 44 | : $field['std'] |
45 | - )); |
|
45 | + ) ); |
|
46 | 46 | return $this->_normalize_field_meta( $meta, $field ); |
47 | 47 | } |
48 | 48 | |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function _normalize_field( array $field ) |
53 | 53 | { |
54 | - if( !empty( $field['multiple'] ) && $field['id'] == substr( $field['field_name'], 0, -2 )) { |
|
55 | - $parts = array_filter( explode( '-', $field['id'] )); |
|
54 | + if( !empty($field['multiple']) && $field['id'] == substr( $field['field_name'], 0, -2 ) ) { |
|
55 | + $parts = array_filter( explode( '-', $field['id'] ) ); |
|
56 | 56 | $first = array_shift( $parts ); |
57 | 57 | $field['field_name'] = array_reduce( $parts, function( $carry, $part ) { |
58 | 58 | return sprintf( '%s[%s]', $carry, $part ); |
59 | - }, $first ) . '[]'; |
|
59 | + }, $first ).'[]'; |
|
60 | 60 | } |
61 | 61 | return $field; |
62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function _normalize_field_meta( $meta, array $field ) |
69 | 69 | { |
70 | - if( !empty( $meta ) && is_array( $meta )) { |
|
70 | + if( !empty($meta) && is_array( $meta ) ) { |
|
71 | 71 | return $meta; |
72 | 72 | } |
73 | 73 | if( $field['clone'] ) { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | public function is_saved() |
111 | 111 | { |
112 | 112 | foreach( array_column( $this->fields, 'slug' ) as $field ) { |
113 | - if( !is_null( $this->pollux_caller->getMetaValue( $field, null, $this->meta_box['slug'] ))) { |
|
113 | + if( !is_null( $this->pollux_caller->getMetaValue( $field, null, $this->meta_box['slug'] ) ) ) { |
|
114 | 114 | return true; |
115 | 115 | } |
116 | 116 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public static function normalize( $metabox ) |
125 | 125 | { |
126 | - unset( $metabox['post_types'] ); |
|
126 | + unset($metabox['post_types']); |
|
127 | 127 | return wp_parse_args( $metabox, ['slug' => ''] ); |
128 | 128 | } |
129 | 129 | } |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function init() |
37 | 37 | { |
38 | - if( empty( $this->app->config->taxonomies ))return; |
|
38 | + if( empty($this->app->config->taxonomies) )return; |
|
39 | 39 | |
40 | 40 | $this->normalize(); |
41 | 41 | |
42 | - add_action( 'restrict_manage_posts', [ $this, 'printFilters'] ); |
|
43 | - add_action( 'init', [ $this, 'register'] ); |
|
44 | - add_filter( 'parse_query', [ $this, 'filterByTaxonomy'] ); |
|
42 | + add_action( 'restrict_manage_posts', [$this, 'printFilters'] ); |
|
43 | + add_action( 'init', [$this, 'register'] ); |
|
44 | + add_filter( 'parse_query', [$this, 'filterByTaxonomy'] ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function filterByTaxonomy( WP_Query $query ) |
52 | 52 | { |
53 | - if( !is_admin() || ( new Helper )->getCurrentScreen()->base != 'edit' )return; |
|
53 | + if( !is_admin() || (new Helper)->getCurrentScreen()->base != 'edit' )return; |
|
54 | 54 | $vars = &$query->query_vars; |
55 | 55 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
56 | - if( !isset( $vars[$taxonomy] ))return; |
|
57 | - if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
|
56 | + if( !isset($vars[$taxonomy]) )return; |
|
57 | + if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy ) ) { |
|
58 | 58 | $vars[$taxonomy] = $term->slug; |
59 | 59 | } |
60 | 60 | } |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | { |
70 | 70 | global $wp_query; |
71 | 71 | foreach( $this->taxonomies as $taxonomy => $args ) { |
72 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
73 | - $selected = isset( $wp_query->query[$taxonomy] ) |
|
72 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] ) )continue; |
|
73 | + $selected = isset($wp_query->query[$taxonomy]) |
|
74 | 74 | ? $wp_query->query[$taxonomy] |
75 | 75 | : false; |
76 | - wp_dropdown_categories([ |
|
76 | + wp_dropdown_categories( [ |
|
77 | 77 | 'hide_if_empty' => true, |
78 | 78 | 'name' => $taxonomy, |
79 | 79 | 'orderby' => 'name', |
80 | 80 | 'selected' => $selected, |
81 | 81 | 'show_option_all' => $args['labels']['all_items'], |
82 | 82 | 'taxonomy' => $taxonomy, |
83 | - ]); |
|
83 | + ] ); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | public function register() |
92 | 92 | { |
93 | 93 | array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
94 | - register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
|
94 | + register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ) ) ); |
|
95 | 95 | foreach( $args['post_types'] as $type ) { |
96 | 96 | register_taxonomy_for_object_type( $taxonomy, $type ); |
97 | 97 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function normalizeLabels( $labels, array $args ) |
122 | 122 | { |
123 | - return wp_parse_args( $labels, $this->setLabels( $args )); |
|
123 | + return wp_parse_args( $labels, $this->setLabels( $args ) ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | protected function normalizeMenuName( $menuname, array $args ) |
131 | 131 | { |
132 | - return empty( $menuname ) |
|
132 | + return empty($menuname) |
|
133 | 133 | ? $args['plural'] |
134 | 134 | : $menuname; |
135 | 135 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function normalizePostTypes( $types ) |
142 | 142 | { |
143 | - return ( new Helper )->toArray( $types ); |
|
143 | + return (new Helper)->toArray( $types ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function init() |
37 | 37 | { |
38 | - if( empty( $this->app->config->taxonomies ))return; |
|
38 | + if( empty( $this->app->config->taxonomies )) { |
|
39 | + return; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | $this->normalize(); |
41 | 43 | |
@@ -50,10 +52,14 @@ discard block |
||
50 | 52 | */ |
51 | 53 | public function filterByTaxonomy( WP_Query $query ) |
52 | 54 | { |
53 | - if( !is_admin() || ( new Helper )->getCurrentScreen()->base != 'edit' )return; |
|
55 | + if( !is_admin() || ( new Helper )->getCurrentScreen()->base != 'edit' ) { |
|
56 | + return; |
|
57 | + } |
|
54 | 58 | $vars = &$query->query_vars; |
55 | 59 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
56 | - if( !isset( $vars[$taxonomy] ))return; |
|
60 | + if( !isset( $vars[$taxonomy] )) { |
|
61 | + return; |
|
62 | + } |
|
57 | 63 | if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
58 | 64 | $vars[$taxonomy] = $term->slug; |
59 | 65 | } |
@@ -69,7 +75,9 @@ discard block |
||
69 | 75 | { |
70 | 76 | global $wp_query; |
71 | 77 | foreach( $this->taxonomies as $taxonomy => $args ) { |
72 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
78 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] )) { |
|
79 | + continue; |
|
80 | + } |
|
73 | 81 | $selected = isset( $wp_query->query[$taxonomy] ) |
74 | 82 | ? $wp_query->query[$taxonomy] |
75 | 83 | : false; |