@@ -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 | /** |
@@ -17,7 +17,7 @@ |
||
17 | 17 | 'class' => 'large-text', |
18 | 18 | 'rows' => 3, |
19 | 19 | 'type' => 'textarea', |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | |
22 | 22 | return sprintf( '<textarea %s>%s</textarea>%s', |
23 | 23 | $this->implodeAttributes( $defaults ), |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use GeminiLabs\Castor\Forms\Fields\Base; |
6 | 6 | |
7 | -class Textarea extends Base |
|
8 | -{ |
|
7 | +class Textarea extends Base { |
|
9 | 8 | protected $element = 'textarea'; |
10 | 9 | |
11 | 10 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | case 'fields': |
57 | 57 | return $this->$property; |
58 | 58 | } |
59 | - throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property )); |
|
59 | + throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property ) ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->$property = $value; |
76 | 76 | break; |
77 | 77 | default: |
78 | - throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property )); |
|
78 | + throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property ) ); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | if( $multi ) { |
196 | 196 | if( $depends = $formField->getDataDepends() ) { |
197 | - $depends = sprintf( ' data-depends=\'%s\'', json_encode( $depends )); |
|
197 | + $depends = sprintf( ' data-depends=\'%s\'', json_encode( $depends ) ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | $legend = $label ? sprintf( $stringLegend, $label ) : ''; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | ? sprintf( $outsideRendered, $rendered ) |
206 | 206 | : sprintf( $stringRendered, $hiddenClass, $label, $rendered ); |
207 | 207 | |
208 | - return $carry . $renderedField; |
|
208 | + return $carry.$renderedField; |
|
209 | 209 | }); |
210 | 210 | |
211 | 211 | return sprintf( '<table class="form-table"><tbody>%s</tbody></table>%s', $fields, $hiddenFields ); |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | { |
221 | 221 | $args = $this->args['submit']; |
222 | 222 | |
223 | - is_array( $args ) ?: $args = ['text' => $args ]; |
|
223 | + is_array( $args ) ?: $args = ['text' => $args]; |
|
224 | 224 | |
225 | - $args = shortcode_atts([ |
|
225 | + $args = shortcode_atts( [ |
|
226 | 226 | 'text' => __( 'Save Changes', 'site-reviews' ), |
227 | 227 | 'type' => 'primary', |
228 | 228 | 'name' => 'submit', |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | */ |
245 | 245 | protected function isFieldHidden( $field ) |
246 | 246 | { |
247 | - if( !( $dependsOn = $field->getDataDepends() ))return; |
|
247 | + if( !( $dependsOn = $field->getDataDepends() ) )return; |
|
248 | 248 | |
249 | 249 | foreach( $this->fields as $formField ) { |
250 | 250 | if( $dependsOn['name'] !== $formField->args['name'] )continue; |
251 | 251 | |
252 | - if( is_array( $dependsOn['value'] )) { |
|
252 | + if( is_array( $dependsOn['value'] ) ) { |
|
253 | 253 | return !in_array( $formField->args['value'], $dependsOn['value'] ); |
254 | 254 | } |
255 | 255 |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | use GeminiLabs\Castor\Forms\Field; |
7 | 7 | use GeminiLabs\Castor\Services\Normalizer; |
8 | 8 | |
9 | -class Form |
|
10 | -{ |
|
9 | +class Form { |
|
11 | 10 | /** |
12 | 11 | * @var array |
13 | 12 | */ |
@@ -244,10 +243,14 @@ discard block |
||
244 | 243 | */ |
245 | 244 | protected function isFieldHidden( $field ) |
246 | 245 | { |
247 | - if( !( $dependsOn = $field->getDataDepends() ))return; |
|
246 | + if( !( $dependsOn = $field->getDataDepends() )) { |
|
247 | + return; |
|
248 | + } |
|
248 | 249 | |
249 | 250 | foreach( $this->fields as $formField ) { |
250 | - if( $dependsOn['name'] !== $formField->args['name'] )continue; |
|
251 | + if( $dependsOn['name'] !== $formField->args['name'] ) { |
|
252 | + continue; |
|
253 | + } |
|
251 | 254 | |
252 | 255 | if( is_array( $dependsOn['value'] )) { |
253 | 256 | return !in_array( $formField->args['value'], $dependsOn['value'] ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | case 'dependencies': |
34 | 34 | return $this->$property; |
35 | 35 | } |
36 | - throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property )); |
|
36 | + throw new Exception( sprintf( 'Invalid %s property: %s', __CLASS__, $property ) ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function getField( array $args = [] ) |
46 | 46 | { |
47 | - if( empty( $args )) { |
|
47 | + if( empty( $args ) ) { |
|
48 | 48 | $args = $this->args; |
49 | 49 | } |
50 | 50 | |
51 | - $className = sprintf( 'GeminiLabs\Castor\Forms\Fields\%s', ucfirst( $args['type'] )); |
|
51 | + $className = sprintf( 'GeminiLabs\Castor\Forms\Fields\%s', ucfirst( $args['type'] ) ); |
|
52 | 52 | |
53 | - if( !class_exists( $className )) { |
|
53 | + if( !class_exists( $className ) ) { |
|
54 | 54 | throw new ReflectionException( "Class does not exist: {$className}" ); |
55 | 55 | } |
56 | 56 | |
57 | - return (new $className( $args )); |
|
57 | + return ( new $className( $args ) ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $renderedString = '%s'; |
127 | 127 | |
128 | 128 | if( ( isset( $field->args['required'] ) && $field->args['required'] ) |
129 | - || ( isset( $field->args['attributes']['required'] ) || in_array( 'required', $field->args['attributes'] )) ) { |
|
129 | + || ( isset( $field->args['attributes']['required'] ) || in_array( 'required', $field->args['attributes'] ) ) ) { |
|
130 | 130 | $class .= ' glsr-required'; |
131 | 131 | } |
132 | 132 | |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | $rendered = sprintf( $renderedString, |
138 | - $this->args['before'] . |
|
139 | - $field->generateLabel() . |
|
140 | - $field->render() . |
|
141 | - $this->args['after'] . |
|
138 | + $this->args['before']. |
|
139 | + $field->generateLabel(). |
|
140 | + $field->render(). |
|
141 | + $this->args['after']. |
|
142 | 142 | $this->args['errors'] |
143 | 143 | ); |
144 | 144 | |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | { |
173 | 173 | $args = $this->args; |
174 | 174 | |
175 | - if( !array_key_exists( $atts['name'], $args['errors'] )) { |
|
175 | + if( !array_key_exists( $atts['name'], $args['errors'] ) ) { |
|
176 | 176 | $this->args['errors'] = ''; // set to an empty string |
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | - $field_errors = $args['errors'][ $atts['name'] ]; |
|
180 | + $field_errors = $args['errors'][$atts['name']]; |
|
181 | 181 | |
182 | 182 | $errors = array_reduce( $field_errors['errors'], function( $carry, $error ) { |
183 | - return $carry . sprintf( '<span>%s</span> ', $error ); |
|
183 | + return $carry.sprintf( '<span>%s</span> ', $error ); |
|
184 | 184 | }); |
185 | 185 | |
186 | 186 | $this->args['errors'] = sprintf( '<span class="glsr-field-errors">%s</span>', $errors ); |
@@ -193,17 +193,17 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function parseAttributes( array $args ) |
195 | 195 | { |
196 | - if( empty( $args['attributes'] )) { |
|
196 | + if( empty( $args['attributes'] ) ) { |
|
197 | 197 | return []; |
198 | 198 | } |
199 | 199 | |
200 | 200 | $attributes = (array) $args['attributes']; |
201 | 201 | |
202 | 202 | foreach( $attributes as $key => $value ) { |
203 | - if( is_string( $key ))continue; |
|
204 | - unset( $attributes[ $key ] ); |
|
205 | - if( !isset( $attributes[ $value ] )) { |
|
206 | - $attributes[ $value ] = ''; |
|
203 | + if( is_string( $key ) )continue; |
|
204 | + unset( $attributes[$key] ); |
|
205 | + if( !isset( $attributes[$value] ) ) { |
|
206 | + $attributes[$value] = ''; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | !$args['suffix'] ?: $args['suffix'] = "-{$args['suffix']}"; |
223 | 223 | |
224 | - return str_replace( ['[]','[',']','.'], ['','-','','-'], $this->parseName( $args ) . $args['suffix'] ); |
|
224 | + return str_replace( ['[]', '[', ']', '.'], ['', '-', '', '-'], $this->parseName( $args ).$args['suffix'] ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -329,21 +329,21 @@ discard block |
||
329 | 329 | */ |
330 | 330 | protected function setDataDepends() |
331 | 331 | { |
332 | - if( !( $depends = $this->args['depends'] ))return; |
|
332 | + if( !( $depends = $this->args['depends'] ) )return; |
|
333 | 333 | |
334 | 334 | $name = $depends; |
335 | 335 | $value = true; |
336 | 336 | |
337 | - if( is_array( $depends )) { |
|
337 | + if( is_array( $depends ) ) { |
|
338 | 338 | reset( $depends ); |
339 | 339 | $name = key( $depends ); |
340 | - $value = $depends[ $name ]; |
|
340 | + $value = $depends[$name]; |
|
341 | 341 | } |
342 | 342 | |
343 | - $name = $this->parseName([ |
|
343 | + $name = $this->parseName( [ |
|
344 | 344 | 'name' => $name, |
345 | 345 | 'prefix' => $this->args['prefix'], |
346 | - ]); |
|
346 | + ] ); |
|
347 | 347 | |
348 | 348 | return $this->args['attributes']['data-depends'] = [ |
349 | 349 | 'name' => $name, |
@@ -2,8 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace GeminiLabs\Castor\Forms; |
4 | 4 | |
5 | -class Field |
|
6 | -{ |
|
5 | +class Field { |
|
7 | 6 | /** |
8 | 7 | * @var array |
9 | 8 | */ |
@@ -116,7 +115,9 @@ discard block |
||
116 | 115 | */ |
117 | 116 | public function render( $print = true ) |
118 | 117 | { |
119 | - if( $this->args['render'] === false )return; |
|
118 | + if( $this->args['render'] === false ) { |
|
119 | + return; |
|
120 | + } |
|
120 | 121 | |
121 | 122 | $field = $this->getField(); |
122 | 123 | |
@@ -200,7 +201,9 @@ discard block |
||
200 | 201 | $attributes = (array) $args['attributes']; |
201 | 202 | |
202 | 203 | foreach( $attributes as $key => $value ) { |
203 | - if( is_string( $key ))continue; |
|
204 | + if( is_string( $key )) { |
|
205 | + continue; |
|
206 | + } |
|
204 | 207 | unset( $attributes[ $key ] ); |
205 | 208 | if( !isset( $attributes[ $value ] )) { |
206 | 209 | $attributes[ $value ] = ''; |
@@ -217,7 +220,9 @@ discard block |
||
217 | 220 | */ |
218 | 221 | protected function parseId( array $args ) |
219 | 222 | { |
220 | - if( isset( $args['id'] ) && !$args['id'] )return; |
|
223 | + if( isset( $args['id'] ) && !$args['id'] ) { |
|
224 | + return; |
|
225 | + } |
|
221 | 226 | |
222 | 227 | !$args['suffix'] ?: $args['suffix'] = "-{$args['suffix']}"; |
223 | 228 | |
@@ -329,7 +334,9 @@ discard block |
||
329 | 334 | */ |
330 | 335 | protected function setDataDepends() |
331 | 336 | { |
332 | - if( !( $depends = $this->args['depends'] ))return; |
|
337 | + if( !( $depends = $this->args['depends'] )) { |
|
338 | + return; |
|
339 | + } |
|
333 | 340 | |
334 | 341 | $name = $depends; |
335 | 342 | $value = true; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct() |
14 | 14 | { |
15 | - $this->assets = sprintf( '%s/assets/', dirname( __DIR__ )); |
|
15 | + $this->assets = sprintf( '%s/assets/', dirname( __DIR__ ) ); |
|
16 | 16 | Facade::clearResolvedInstances(); |
17 | 17 | Facade::setFacadeApplication( $this ); |
18 | 18 | $this->registerAliases(); |
@@ -24,21 +24,21 @@ discard block |
||
24 | 24 | $controller = $this->make( 'Controller' ); |
25 | 25 | |
26 | 26 | // Action hooks |
27 | - add_action( 'after_setup_theme', [$controller, 'afterSetupTheme'], 20 ); |
|
28 | - add_action( 'login_head', [$controller, 'loadAdminFavicon'] ); |
|
29 | - add_action( 'admin_head', [$controller, 'loadAdminFavicon'] ); |
|
30 | - add_action( 'login_head', [$controller, 'login'] ); |
|
31 | - add_action( 'admin_enqueue_scripts', [$controller, 'registerAdminAssets'] ); |
|
32 | - add_action( 'wp_enqueue_scripts', [$controller, 'registerAssets'] ); |
|
33 | - add_action( 'customize_register', [$controller, 'registerCustomizer'] ); |
|
27 | + add_action( 'after_setup_theme', [$controller, 'afterSetupTheme'], 20 ); |
|
28 | + add_action( 'login_head', [$controller, 'loadAdminFavicon'] ); |
|
29 | + add_action( 'admin_head', [$controller, 'loadAdminFavicon'] ); |
|
30 | + add_action( 'login_head', [$controller, 'login'] ); |
|
31 | + add_action( 'admin_enqueue_scripts', [$controller, 'registerAdminAssets'] ); |
|
32 | + add_action( 'wp_enqueue_scripts', [$controller, 'registerAssets'] ); |
|
33 | + add_action( 'customize_register', [$controller, 'registerCustomizer'] ); |
|
34 | 34 | add_action( 'customize_preview_init', [$controller, 'registerCustomizerAssets'] ); |
35 | - add_action( 'widgets_init', [$controller, 'registerSidebars'] ); |
|
35 | + add_action( 'widgets_init', [$controller, 'registerSidebars'] ); |
|
36 | 36 | |
37 | 37 | // Filter hooks |
38 | - add_filter( 'body_class', [$controller, 'filterBodyClasses'] ); |
|
39 | - add_filter( 'template_include', [$controller, 'filterTemplate'] ); |
|
40 | - add_filter( 'login_headertitle', [$controller, 'filterLoginTitle'] ); |
|
41 | - add_filter( 'login_headerurl', [$controller, 'filterLoginUrl'] ); |
|
38 | + add_filter( 'body_class', [$controller, 'filterBodyClasses'] ); |
|
39 | + add_filter( 'template_include', [$controller, 'filterTemplate'] ); |
|
40 | + add_filter( 'login_headertitle', [$controller, 'filterLoginTitle'] ); |
|
41 | + add_filter( 'login_headerurl', [$controller, 'filterLoginUrl'] ); |
|
42 | 42 | |
43 | 43 | foreach( $this->getTemplateTypes() as $type ) { |
44 | 44 | add_filter( "{$type}_template_hierarchy", [$controller, 'filterTemplateHierarchy'] ); |
@@ -6,8 +6,7 @@ |
||
6 | 6 | use GeminiLabs\Castor\Container; |
7 | 7 | use GeminiLabs\Castor\Facade; |
8 | 8 | |
9 | -final class Application extends Container |
|
10 | -{ |
|
9 | +final class Application extends Container { |
|
11 | 10 | public $assets; |
12 | 11 | |
13 | 12 | public function __construct() |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | { |
33 | 33 | $args = wp_parse_args( $args, [ |
34 | 34 | 'embed_type' => '', |
35 | - ]); |
|
35 | + ] ); |
|
36 | 36 | $request = $this->oembed->fetch( $this->oembed->get_provider( $url ), $url, [ |
37 | 37 | 'width' => 1280, |
38 | 38 | 'height' => 1280, |
39 | - ]); |
|
39 | + ] ); |
|
40 | 40 | if( $request === false )return; |
41 | 41 | if( !empty( $args['embed_type'] ) && $args['embed_type'] != $request->type )return; |
42 | 42 | return $this->modifyRequest( $request, $args ); |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | ? $this->$providerName |
57 | 57 | : []; |
58 | 58 | |
59 | - $method = $this->utility->buildMethodName( $providerName . '_request', 'modify' ); |
|
59 | + $method = $this->utility->buildMethodName( $providerName.'_request', 'modify' ); |
|
60 | 60 | |
61 | - if( method_exists( $this, $method )) { |
|
61 | + if( method_exists( $this, $method ) ) { |
|
62 | 62 | return call_user_func( [$this, $method], $request, array_intersect_key( |
63 | 63 | $args, |
64 | 64 | array_flip( $provider ) |
65 | - )); |
|
65 | + ) ); |
|
66 | 66 | } |
67 | 67 | return $request; |
68 | 68 | } |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | protected function modifyYoutubeRequest( $request, array $args ) |
71 | 71 | { |
72 | 72 | $html = $this->domLoad( $request->html ); |
73 | - $node = $html->getElementsByTagName( 'iframe' )->item(0); |
|
73 | + $node = $html->getElementsByTagName( 'iframe' )->item( 0 ); |
|
74 | 74 | $url = $node->getAttribute( 'src' ); |
75 | 75 | |
76 | 76 | if( isset( $args['fs'] ) && $args['fs'] == 0 ) { |
77 | 77 | $node->removeAttribute( 'allowfullscreen' ); |
78 | 78 | } |
79 | 79 | |
80 | - $args['origin'] = urlencode( get_bloginfo( 'url' )); |
|
80 | + $args['origin'] = urlencode( get_bloginfo( 'url' ) ); |
|
81 | 81 | |
82 | 82 | $node->setAttribute( 'class', 'video-embed' ); |
83 | 83 | $node->setAttribute( 'src', |
84 | - add_query_arg( $args, remove_query_arg( 'feature', $url )) |
|
84 | + add_query_arg( $args, remove_query_arg( 'feature', $url ) ) |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | $request->html = $html->saveHTML( $node ); |
@@ -5,8 +5,7 @@ discard block |
||
5 | 5 | use GeminiLabs\Castor\Helpers\Utility; |
6 | 6 | use DomDocument; |
7 | 7 | |
8 | -class Oembed |
|
9 | -{ |
|
8 | +class Oembed { |
|
10 | 9 | public $oembed; |
11 | 10 | public $utility; |
12 | 11 | |
@@ -37,8 +36,12 @@ discard block |
||
37 | 36 | 'width' => 1280, |
38 | 37 | 'height' => 1280, |
39 | 38 | ]); |
40 | - if( $request === false )return; |
|
41 | - if( !empty( $args['embed_type'] ) && $args['embed_type'] != $request->type )return; |
|
39 | + if( $request === false ) { |
|
40 | + return; |
|
41 | + } |
|
42 | + if( !empty( $args['embed_type'] ) && $args['embed_type'] != $request->type ) { |
|
43 | + return; |
|
44 | + } |
|
42 | 45 | return $this->modifyRequest( $request, $args ); |
43 | 46 | } |
44 | 47 |
@@ -2,19 +2,19 @@ |
||
2 | 2 | |
3 | 3 | global $wp_version; |
4 | 4 | |
5 | -if( !is_admin() && version_compare( '7.0', phpversion(), '>' )) { |
|
5 | +if( !is_admin() && version_compare( '7.0', phpversion(), '>' ) ) { |
|
6 | 6 | wp_die( |
7 | 7 | __( 'You must be using PHP 7.0.0 or greater.', 'castor' ), |
8 | 8 | __( 'Unsupported PHP version', 'castor' ) |
9 | 9 | ); |
10 | 10 | } |
11 | -if( !is_admin() && version_compare( '4.7', $wp_version, '>' )) { |
|
11 | +if( !is_admin() && version_compare( '4.7', $wp_version, '>' ) ) { |
|
12 | 12 | wp_die( |
13 | 13 | __( 'You must be using WordPress 4.7.0 or greater.', 'castor' ), |
14 | 14 | __( 'Unsupported WordPress version', 'castor' ) |
15 | 15 | ); |
16 | 16 | } |
17 | -if( is_customize_preview() && filter_input( INPUT_GET, 'theme' )) { |
|
17 | +if( is_customize_preview() && filter_input( INPUT_GET, 'theme' ) ) { |
|
18 | 18 | wp_die( |
19 | 19 | __( 'Theme must be activated prior to using the customizer.', 'castor' ) |
20 | 20 | ); |