@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use Exception; |
6 | 6 | use GeminiLabs\Castor\Services\Normalizer; |
7 | 7 | |
8 | -abstract class Base |
|
9 | -{ |
|
8 | +abstract class Base { |
|
10 | 9 | /** |
11 | 10 | * @var array |
12 | 11 | */ |
@@ -71,7 +70,9 @@ discard block |
||
71 | 70 | */ |
72 | 71 | public function generateDescription( $paragraph = true ) |
73 | 72 | { |
74 | - if( !isset( $this->args['desc'] ) || !$this->args['desc'] )return; |
|
73 | + if( !isset( $this->args['desc'] ) || !$this->args['desc'] ) { |
|
74 | + return; |
|
75 | + } |
|
75 | 76 | |
76 | 77 | $tag = ( !!$paragraph || $paragraph == 'p' ) ? 'p' : 'span'; |
77 | 78 | |
@@ -85,7 +86,9 @@ discard block |
||
85 | 86 | */ |
86 | 87 | public function generateLabel() |
87 | 88 | { |
88 | - if( empty( $this->args['label'] ))return; |
|
89 | + if( empty( $this->args['label'] )) { |
|
90 | + return; |
|
91 | + } |
|
89 | 92 | |
90 | 93 | $for = !!$this->args['id'] |
91 | 94 | ? " for=\"{$this->args['id']}\"" |
@@ -144,7 +147,9 @@ discard block |
||
144 | 147 | |
145 | 148 | if( $method === 'singleInput' ) { |
146 | 149 | |
147 | - if( !isset( $this->args['options'] ) || empty( $this->args['options'] ))return; |
|
150 | + if( !isset( $this->args['options'] ) || empty( $this->args['options'] )) { |
|
151 | + return; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // hack to make sure unset single checkbox values start at 1 instead of 0 |
150 | 155 | if( key( $this->args['options'] ) === 0 ) { |
@@ -187,7 +192,9 @@ discard block |
||
187 | 192 | { |
188 | 193 | // similar to array_merge except overwrite empty values |
189 | 194 | foreach( $defaults as $key => $value ) { |
190 | - if( isset( $this->args[ $key ] ) && !empty( $this->args[ $key ] ))continue; |
|
195 | + if( isset( $this->args[ $key ] ) && !empty( $this->args[ $key ] )) { |
|
196 | + continue; |
|
197 | + } |
|
191 | 198 | $this->args[ $key ] = $value; |
192 | 199 | } |
193 | 200 | |
@@ -210,7 +217,9 @@ discard block |
||
210 | 217 | { |
211 | 218 | $args = $this->multiInputArgs( $type, $optionKey, $number ); |
212 | 219 | |
213 | - if( !$args )return; |
|
220 | + if( !$args ) { |
|
221 | + return; |
|
222 | + } |
|
214 | 223 | |
215 | 224 | $attributes = ''; |
216 | 225 | |
@@ -261,7 +270,9 @@ discard block |
||
261 | 270 | |
262 | 271 | $args = wp_parse_args( $args, $defaults ); |
263 | 272 | |
264 | - if( !isset( $label ) || $args['name'] === '' )return; |
|
273 | + if( !isset( $label ) || $args['name'] === '' ) { |
|
274 | + return; |
|
275 | + } |
|
265 | 276 | |
266 | 277 | $args['id'] = $this->args['id'] . "-{$number}"; |
267 | 278 | $args['name'] = $this->args['name'] . ( $type === 'checkbox' && $this->multi ? '[]' : '' ); |
@@ -331,7 +342,9 @@ discard block |
||
331 | 342 | |
332 | 343 | $args = $this->multiInputArgs( $type, $optionKey, 1 ); |
333 | 344 | |
334 | - if( !$args )return; |
|
345 | + if( !$args ) { |
|
346 | + return; |
|
347 | + } |
|
335 | 348 | |
336 | 349 | $atts = $this->normalize(); |
337 | 350 | $atts = wp_parse_args( $args['attributes'], $atts ); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | case 'outside': |
60 | 60 | return $this->$property; |
61 | 61 | } |
62 | - throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property )); |
|
62 | + throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property ) ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function generateLabel() |
87 | 87 | { |
88 | - if( empty( $this->args['label'] ))return; |
|
88 | + if( empty( $this->args['label'] ) )return; |
|
89 | 89 | |
90 | 90 | $for = !!$this->args['id'] |
91 | 91 | ? " for=\"{$this->args['id']}\"" |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | */ |
111 | 111 | protected function camelCase( $value ) |
112 | 112 | { |
113 | - $value = ucwords( str_replace( ['-', '_'], ' ', $value )); |
|
113 | + $value = ucwords( str_replace( ['-', '_'], ' ', $value ) ); |
|
114 | 114 | |
115 | - return lcfirst( str_replace( ' ', '', $value )); |
|
115 | + return lcfirst( str_replace( ' ', '', $value ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | if( $method === 'singleInput' ) { |
146 | 146 | |
147 | - if( !isset( $this->args['options'] ) || empty( $this->args['options'] ))return; |
|
147 | + if( !isset( $this->args['options'] ) || empty( $this->args['options'] ) )return; |
|
148 | 148 | |
149 | 149 | // hack to make sure unset single checkbox values start at 1 instead of 0 |
150 | 150 | if( key( $this->args['options'] ) === 0 ) { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | |
174 | 174 | $normalize = new Normalizer; |
175 | 175 | |
176 | - return ( $this->element && method_exists( $normalize, $this->element )) |
|
176 | + return ( $this->element && method_exists( $normalize, $this->element ) ) |
|
177 | 177 | ? $normalize->{$this->element}( $args, $implode ) |
178 | 178 | : ( !!$implode ? '' : [] ); |
179 | 179 | } |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | { |
188 | 188 | // similar to array_merge except overwrite empty values |
189 | 189 | foreach( $defaults as $key => $value ) { |
190 | - if( isset( $this->args[ $key ] ) && !empty( $this->args[ $key ] ))continue; |
|
191 | - $this->args[ $key ] = $value; |
|
190 | + if( isset( $this->args[$key] ) && !empty( $this->args[$key] ) )continue; |
|
191 | + $this->args[$key] = $value; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $attributes = $this->args['attributes']; |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | |
247 | 247 | $args = []; |
248 | 248 | |
249 | - $value = $this->args['options'][ $optionName ]; |
|
249 | + $value = $this->args['options'][$optionName]; |
|
250 | 250 | |
251 | - if( is_array( $value )) { |
|
251 | + if( is_array( $value ) ) { |
|
252 | 252 | $args = $value; |
253 | 253 | } |
254 | 254 | |
255 | - if( is_string( $value )) { |
|
255 | + if( is_string( $value ) ) { |
|
256 | 256 | $label = $value; |
257 | 257 | } |
258 | 258 | |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | |
264 | 264 | if( !isset( $label ) || $args['name'] === '' )return; |
265 | 265 | |
266 | - $args['id'] = $this->args['id'] . "-{$number}"; |
|
267 | - $args['name'] = $this->args['name'] . ( $type === 'checkbox' && $this->multi ? '[]' : '' ); |
|
266 | + $args['id'] = $this->args['id']."-{$number}"; |
|
267 | + $args['name'] = $this->args['name'].( $type === 'checkbox' && $this->multi ? '[]' : '' ); |
|
268 | 268 | |
269 | 269 | $args = array_filter( $args, function( $value ) { |
270 | 270 | return $value !== ''; |
271 | 271 | }); |
272 | 272 | |
273 | - if( is_array( $this->args['value'] )) { |
|
274 | - if( in_array( $args['value'], $this->args['value'] )) { |
|
273 | + if( is_array( $this->args['value'] ) ) { |
|
274 | + if( in_array( $args['value'], $this->args['value'] ) ) { |
|
275 | 275 | $this->args['default'] = $args['value']; |
276 | 276 | } |
277 | 277 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | return sprintf( '<option value="%s"%s>%s</option>', |
315 | 315 | $optionKey, |
316 | 316 | selected( $this->args['value'], $optionKey, false ), |
317 | - $this->args['options'][ $optionKey ] |
|
317 | + $this->args['options'][$optionKey] |
|
318 | 318 | ); |
319 | 319 | } |
320 | 320 |
@@ -3,8 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use GeminiLabs\Castor\Forms\Fields\Base; |
5 | 5 | |
6 | -class Radio extends Base |
|
7 | -{ |
|
6 | +class Radio extends Base { |
|
8 | 7 | protected $multi = true; |
9 | 8 | protected $element = 'input'; |
10 | 9 |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use GeminiLabs\Castor\Forms\Fields\Base; |
6 | 6 | |
7 | -class Checkbox extends Base |
|
8 | -{ |
|
7 | +class Checkbox extends Base { |
|
9 | 8 | protected $element = 'input'; |
10 | 9 | |
11 | 10 | public function __construct( array $args = [] ) |
@@ -11,9 +11,9 @@ |
||
11 | 11 | */ |
12 | 12 | public function render() |
13 | 13 | { |
14 | - return parent::render([ |
|
14 | + return parent::render( [ |
|
15 | 15 | 'class' => 'regular-text ltr', |
16 | 16 | 'type' => 'email', |
17 | - ]); |
|
17 | + ] ); |
|
18 | 18 | } |
19 | 19 | } |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use GeminiLabs\Castor\Forms\Fields\Text; |
6 | 6 | |
7 | -class Email extends Text |
|
8 | -{ |
|
7 | +class Email extends Text { |
|
9 | 8 | /** |
10 | 9 | * @return string |
11 | 10 | */ |
@@ -11,9 +11,9 @@ |
||
11 | 11 | */ |
12 | 12 | public function render() |
13 | 13 | { |
14 | - return parent::render([ |
|
14 | + return parent::render( [ |
|
15 | 15 | 'class' => 'regular-text code', |
16 | 16 | 'type' => 'url', |
17 | - ]); |
|
17 | + ] ); |
|
18 | 18 | } |
19 | 19 | } |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use GeminiLabs\Castor\Forms\Fields\Text; |
6 | 6 | |
7 | -class Url extends Text |
|
8 | -{ |
|
7 | +class Url extends Text { |
|
9 | 8 | /** |
10 | 9 | * @return string |
11 | 10 | */ |
@@ -16,7 +16,7 @@ |
||
16 | 16 | $defaults = wp_parse_args( $defaults, [ |
17 | 17 | 'class' => 'regular-text', |
18 | 18 | 'type' => 'text', |
19 | - ]); |
|
19 | + ] ); |
|
20 | 20 | |
21 | 21 | return sprintf( '<input %s/>%s', |
22 | 22 | $this->implodeAttributes( $defaults ), |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use GeminiLabs\Castor\Forms\Fields\Base; |
6 | 6 | |
7 | -class Text extends Base |
|
8 | -{ |
|
7 | +class Text extends Base { |
|
9 | 8 | protected $element = 'input'; |
10 | 9 | |
11 | 10 | /** |
@@ -11,10 +11,10 @@ |
||
11 | 11 | */ |
12 | 12 | public function render() |
13 | 13 | { |
14 | - return parent::render([ |
|
14 | + return parent::render( [ |
|
15 | 15 | 'class' => 'small-text', |
16 | 16 | 'min' => '0', |
17 | 17 | 'type' => 'number', |
18 | - ]); |
|
18 | + ] ); |
|
19 | 19 | } |
20 | 20 | } |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use GeminiLabs\Castor\Forms\Fields\Text; |
6 | 6 | |
7 | -class Number extends Text |
|
8 | -{ |
|
7 | +class Number extends Text { |
|
9 | 8 | /** |
10 | 9 | * @return string |
11 | 10 | */ |
@@ -11,21 +11,21 @@ |
||
11 | 11 | */ |
12 | 12 | public function render() |
13 | 13 | { |
14 | - if( isset( $this->args['label'] )) { |
|
14 | + if( isset( $this->args['label'] ) ) { |
|
15 | 15 | unset( $this->args['label'] ); |
16 | 16 | } |
17 | 17 | |
18 | - if( isset( $this->args['desc'] )) { |
|
18 | + if( isset( $this->args['desc'] ) ) { |
|
19 | 19 | unset( $this->args['desc'] ); |
20 | 20 | } |
21 | 21 | |
22 | - if( isset( $this->args['id'] )) { |
|
22 | + if( isset( $this->args['id'] ) ) { |
|
23 | 23 | unset( $this->args['id'] ); |
24 | 24 | } |
25 | 25 | |
26 | - return parent::render([ |
|
26 | + return parent::render( [ |
|
27 | 27 | 'class' => '', |
28 | 28 | 'type' => 'hidden', |
29 | - ]); |
|
29 | + ] ); |
|
30 | 30 | } |
31 | 31 | } |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use GeminiLabs\Castor\Forms\Fields\Text; |
6 | 6 | |
7 | -class Hidden extends Text |
|
8 | -{ |
|
7 | +class Hidden extends Text { |
|
9 | 8 | /** |
10 | 9 | * @return string |
11 | 10 | */ |
@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | $defaults = wp_parse_args( $defaults, [ |
17 | 17 | 'type' => 'select', |
18 | - ]); |
|
18 | + ] ); |
|
19 | 19 | |
20 | 20 | return sprintf( '<select %s>%s</select>%s', |
21 | 21 | $this->implodeAttributes( $defaults ), |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use GeminiLabs\Castor\Forms\Fields\Base; |
6 | 6 | |
7 | -class Select extends Base |
|
8 | -{ |
|
7 | +class Select extends Base { |
|
9 | 8 | protected $element = 'select'; |
10 | 9 | |
11 | 10 | /** |