@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function __construct( Utility $utility ) |
| 14 | 14 | { |
| 15 | - $this->utility = $utility; |
|
| 15 | + $this->utility = $utility; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function capture() |
@@ -47,24 +47,24 @@ discard block |
||
| 47 | 47 | public function printFiltersFor( $hook = '' ) |
| 48 | 48 | { |
| 49 | 49 | global $wp_filter; |
| 50 | - if( empty( $hook ) || !isset( $wp_filter[$hook] ))return; |
|
| 51 | - $this->printF( $wp_filter[ $hook ] ); |
|
| 50 | + if( empty( $hook ) || !isset( $wp_filter[$hook] ) )return; |
|
| 51 | + $this->printF( $wp_filter[$hook] ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function printTemplatePaths() |
| 55 | 55 | { |
| 56 | - if( $this->isDev() && ( DEV == 'templates' || DEV === true )) { |
|
| 56 | + if( $this->isDev() && ( DEV == 'templates' || DEV === true ) ) { |
|
| 57 | 57 | $templates = array_map( function( $key, $value ) { |
| 58 | 58 | return sprintf( '[%s] => %s', $key, $value ); |
| 59 | 59 | }, array_keys( $this->templatePaths ), $this->templatePaths ); |
| 60 | - $this->printF( implode( "\n", $templates )); |
|
| 60 | + $this->printF( implode( "\n", $templates ) ); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function storeTemplatePath( $template ) |
| 65 | 65 | { |
| 66 | - if( is_string( $template )) { |
|
| 67 | - $this->templatePaths[] = $this->utility->trimLeft( $template, trailingslashit( WP_CONTENT_DIR )); |
|
| 66 | + if( is_string( $template ) ) { |
|
| 67 | + $this->templatePaths[] = $this->utility->trimLeft( $template, trailingslashit( WP_CONTENT_DIR ) ); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | if( $args == 1 ) { |
| 76 | 76 | printf( '<div class="print__r"><pre>%s</pre></div>', |
| 77 | - htmlspecialchars( print_r( func_get_arg(0), true ), ENT_QUOTES, 'UTF-8' ) |
|
| 77 | + htmlspecialchars( print_r( func_get_arg( 0 ), true ), ENT_QUOTES, 'UTF-8' ) |
|
| 78 | 78 | ); |
| 79 | 79 | } |
| 80 | 80 | else if( $args > 1 ) { |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use GeminiLabs\Castor\Helpers\Utility; |
| 6 | 6 | |
| 7 | -class Development |
|
| 8 | -{ |
|
| 7 | +class Development { |
|
| 9 | 8 | public $templatePaths = []; |
| 10 | 9 | |
| 11 | 10 | protected $utility; |
@@ -47,7 +46,9 @@ discard block |
||
| 47 | 46 | public function printFiltersFor( $hook = '' ) |
| 48 | 47 | { |
| 49 | 48 | global $wp_filter; |
| 50 | - if( empty( $hook ) || !isset( $wp_filter[$hook] ))return; |
|
| 49 | + if( empty( $hook ) || !isset( $wp_filter[$hook] )) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 51 | 52 | $this->printF( $wp_filter[ $hook ] ); |
| 52 | 53 | } |
| 53 | 54 | |
@@ -11,13 +11,13 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | public function render() |
| 13 | 13 | { |
| 14 | - if( isset( $this->args['name'] )) { |
|
| 14 | + if( isset( $this->args['name'] ) ) { |
|
| 15 | 15 | $this->args['name'] = 'submit'; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - return parent::render([ |
|
| 18 | + return parent::render( [ |
|
| 19 | 19 | 'class' => 'button button-primary', |
| 20 | 20 | 'type' => 'submit', |
| 21 | - ]); |
|
| 21 | + ] ); |
|
| 22 | 22 | } |
| 23 | 23 | } |
@@ -4,8 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use GeminiLabs\Castor\Forms\Fields\Text; |
| 6 | 6 | |
| 7 | -class Submit extends Text |
|
| 8 | -{ |
|
| 7 | +class Submit extends Text { |
|
| 9 | 8 | /** |
| 10 | 9 | * @return string |
| 11 | 10 | */ |
@@ -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 Normalize; |
| 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 | |
@@ -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 ); |
@@ -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 | */ |