@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | 'templates/form/submit-button', |
51 | 51 | 'templates/reviews-form', |
52 | 52 | ]; |
53 | - if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) { |
|
53 | + if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) { |
|
54 | 54 | return $view; |
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
58 | + if( !file_exists( glsr()->file( $possibleView ) ) )continue; |
|
59 | 59 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 60 | } |
61 | 61 | return $view; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function modifyField( Builder $instance ) |
90 | 90 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
91 | + if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return; |
|
92 | 92 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 93 | } |
94 | 94 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function customize( Builder $instance ) |
107 | 107 | { |
108 | - $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
|
108 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
109 | 109 | $key = $instance->tag.'_'.$args['type']; |
110 | - $classes = !isset( $this->fields[$key] ) |
|
110 | + $classes = !isset($this->fields[$key]) |
|
111 | 111 | ? $this->fields[$instance->tag] |
112 | 112 | : $this->fields[$key]; |
113 | 113 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $args = wp_parse_args( $instance->args, [ |
142 | 142 | 'is_public' => false, |
143 | 143 | 'is_raw' => false, |
144 | - ]); |
|
144 | + ] ); |
|
145 | 145 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
146 | 146 | return false; |
147 | 147 | } |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
58 | + if( !file_exists( glsr()->file( $possibleView ))) { |
|
59 | + continue; |
|
60 | + } |
|
59 | 61 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 62 | } |
61 | 63 | return $view; |
@@ -88,7 +90,9 @@ discard block |
||
88 | 90 | */ |
89 | 91 | public function modifyField( Builder $instance ) |
90 | 92 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
93 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) { |
|
94 | + return; |
|
95 | + } |
|
92 | 96 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 97 | } |
94 | 98 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'is_valid' => true, |
28 | 28 | 'is_widget' => false, |
29 | 29 | 'path' => '', |
30 | - ]); |
|
30 | + ] ); |
|
31 | 31 | $this->normalize(); |
32 | 32 | } |
33 | 33 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | if( !$this->field['is_valid'] )return; |
48 | 48 | if( $this->field['is_raw'] ) { |
49 | - return glsr( Builder::class )->{$this->field['type']}( $this->field ); |
|
49 | + return glsr( Builder::class )->{$this->field['type']}($this->field); |
|
50 | 50 | } |
51 | 51 | if( !$this->field['is_setting'] ) { |
52 | 52 | return $this->buildField(); |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | 'class' => $this->getFieldClass(), |
76 | 76 | 'errors' => $this->getFieldErrors(), |
77 | 77 | 'field' => glsr( Builder::class )->raw( $this->field ), |
78 | - 'label' => glsr( Builder::class )->label([ |
|
78 | + 'label' => glsr( Builder::class )->label( [ |
|
79 | 79 | 'class' => 'glsr-'.$this->field['type'].'-label', |
80 | 80 | 'for' => $this->field['id'], |
81 | 81 | 'is_public' => $this->field['is_public'], |
82 | 82 | 'text' => $this->field['label'].'<span></span>', |
83 | 83 | 'type' => $this->field['type'], |
84 | - ]), |
|
84 | + ] ), |
|
85 | 85 | ], |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | return apply_filters( 'site-reviews/rendered/field', $field, $this->field['type'], $this->field ); |
88 | 88 | } |
89 | 89 | |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | return glsr( Template::class )->build( 'partials/form/table-row', [ |
96 | 96 | 'context' => [ |
97 | 97 | 'class' => $this->getFieldClass(), |
98 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
98 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
99 | 99 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
100 | 100 | ], |
101 | - ]); |
|
101 | + ] ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,16 +107,16 @@ discard block |
||
107 | 107 | protected function buildSettingMultiField() |
108 | 108 | { |
109 | 109 | $dependsOn = $this->getFieldDependsOn(); |
110 | - unset( $this->field['data-depends'] ); |
|
110 | + unset($this->field['data-depends']); |
|
111 | 111 | return glsr( Template::class )->build( 'partials/form/table-row-multiple', [ |
112 | 112 | 'context' => [ |
113 | 113 | 'class' => $this->getFieldClass(), |
114 | 114 | 'depends_on' => $dependsOn, |
115 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
115 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
116 | 116 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
117 | 117 | 'legend' => $this->field['legend'], |
118 | 118 | ], |
119 | - ]); |
|
119 | + ] ); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | protected function getFieldClass() |
126 | 126 | { |
127 | 127 | $classes = []; |
128 | - if( !empty( $this->field['errors'] )) { |
|
128 | + if( !empty($this->field['errors']) ) { |
|
129 | 129 | $classes[] = 'glsr-has-error'; |
130 | 130 | } |
131 | 131 | if( $this->field['is_hidden'] ) { |
132 | 132 | $classes[] = 'hidden'; |
133 | 133 | } |
134 | - if( !empty( $this->field['required'] )) { |
|
134 | + if( !empty($this->field['required']) ) { |
|
135 | 135 | $classes[] = 'glsr-required'; |
136 | 136 | } |
137 | 137 | $classes = apply_filters( 'site-reviews/rendered/field/classes', $classes, $this->field ); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | protected function getFieldDependsOn() |
145 | 145 | { |
146 | - return !empty( $this->field['data-depends'] ) |
|
146 | + return !empty($this->field['data-depends']) |
|
147 | 147 | ? $this->field['data-depends'] |
148 | 148 | : ''; |
149 | 149 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | protected function getFieldErrors() |
155 | 155 | { |
156 | - if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] ))return; |
|
156 | + if( empty($this->field['errors']) || !is_array( $this->field['errors'] ) )return; |
|
157 | 157 | $errors = array_reduce( $this->field['errors'], function( $carry, $error ) { |
158 | 158 | return $carry.glsr( Builder::class )->span( $error, ['class' => 'glsr-field-error'] ); |
159 | 159 | }); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'context' => [ |
162 | 162 | 'errors' => $errors, |
163 | 163 | ], |
164 | - ]); |
|
164 | + ] ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | 'name', 'type', |
185 | 185 | ]; |
186 | 186 | foreach( $requiredValues as $value ) { |
187 | - if( isset( $this->field[$value] ))continue; |
|
187 | + if( isset($this->field[$value]) )continue; |
|
188 | 188 | $missingValues[] = $value; |
189 | 189 | $this->field['is_valid'] = false; |
190 | 190 | } |
191 | - if( !empty( $missingValues )) { |
|
191 | + if( !empty($missingValues) ) { |
|
192 | 192 | glsr_log() |
193 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
193 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
194 | 194 | ->info( $this->field ); |
195 | 195 | } |
196 | 196 | return $this->field['is_valid']; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | if( !$this->isFieldValid() )return; |
205 | 205 | $this->field['path'] = $this->field['name']; |
206 | 206 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
207 | - if( class_exists( $className )) { |
|
207 | + if( class_exists( $className ) ) { |
|
208 | 208 | $this->field = array_merge( |
209 | 209 | wp_parse_args( $this->field, $className::defaults() ), |
210 | 210 | $className::required() |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | protected function normalizeFieldId() |
221 | 221 | { |
222 | - if( isset( $this->field['id'] ) || $this->field['is_raw'] )return; |
|
222 | + if( isset($this->field['id']) || $this->field['is_raw'] )return; |
|
223 | 223 | $this->field['id'] = glsr( Helper::class )->convertPathToId( |
224 | 224 | $this->field['path'], |
225 | 225 | $this->getFieldPrefix() |