@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | 'is_valid' => true, |
| 26 | 26 | 'is_widget' => false, |
| 27 | 27 | 'path' => '', |
| 28 | - ]); |
|
| 28 | + ] ); |
|
| 29 | 29 | $this->normalize(); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | return glsr( Template::class )->build( 'partials/form/field', [ |
| 72 | 72 | 'context' => [ |
| 73 | 73 | 'class' => $this->getFieldClass(), |
| 74 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 74 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 75 | 75 | ], |
| 76 | - ]); |
|
| 76 | + ] ); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | return glsr( Template::class )->build( 'partials/form/table-row', [ |
| 85 | 85 | 'context' => [ |
| 86 | 86 | 'class' => $this->getFieldClass(), |
| 87 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 87 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 88 | 88 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
| 89 | 89 | ], |
| 90 | - ]); |
|
| 90 | + ] ); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -96,16 +96,16 @@ discard block |
||
| 96 | 96 | protected function buildSettingMultiField() |
| 97 | 97 | { |
| 98 | 98 | $dependsOn = $this->getFieldDependsOn(); |
| 99 | - unset( $this->field['data-depends'] ); |
|
| 99 | + unset($this->field['data-depends']); |
|
| 100 | 100 | return glsr( Template::class )->build( 'partials/form/table-row-multiple', [ |
| 101 | 101 | 'context' => [ |
| 102 | 102 | 'class' => $this->getFieldClass(), |
| 103 | 103 | 'depends_on' => $dependsOn, |
| 104 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 104 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 105 | 105 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
| 106 | 106 | 'legend' => $this->field['legend'], |
| 107 | 107 | ], |
| 108 | - ]); |
|
| 108 | + ] ); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | if( $this->field['is_hidden'] ) { |
| 118 | 118 | $classes[] = 'hidden'; |
| 119 | 119 | } |
| 120 | - if( !empty( $this->field['required'] )) { |
|
| 120 | + if( !empty($this->field['required']) ) { |
|
| 121 | 121 | $classes[] = 'glsr-required'; |
| 122 | 122 | } |
| 123 | 123 | return implode( ' ', $classes ); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function getFieldDependsOn() |
| 130 | 130 | { |
| 131 | - return !empty( $this->field['data-depends'] ) |
|
| 131 | + return !empty($this->field['data-depends']) |
|
| 132 | 132 | ? $this->field['data-depends'] |
| 133 | 133 | : ''; |
| 134 | 134 | } |
@@ -153,13 +153,13 @@ discard block |
||
| 153 | 153 | 'name', 'type', |
| 154 | 154 | ]; |
| 155 | 155 | foreach( $requiredValues as $value ) { |
| 156 | - if( isset( $this->field[$value] ))continue; |
|
| 156 | + if( isset($this->field[$value]) )continue; |
|
| 157 | 157 | $missingValues[] = $value; |
| 158 | 158 | $this->field['is_valid'] = false; |
| 159 | 159 | } |
| 160 | - if( !empty( $missingValues )) { |
|
| 160 | + if( !empty($missingValues) ) { |
|
| 161 | 161 | glsr_log() |
| 162 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
| 162 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
| 163 | 163 | ->info( $this->field ); |
| 164 | 164 | } |
| 165 | 165 | return $this->field['is_valid']; |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | if( !$this->isFieldValid() )return; |
| 174 | 174 | $this->field['path'] = $this->field['name']; |
| 175 | 175 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
| 176 | - if( class_exists( $className )) { |
|
| 176 | + if( class_exists( $className ) ) { |
|
| 177 | 177 | $this->field = array_merge( |
| 178 | 178 | wp_parse_args( $this->field, $className::defaults() ), |
| 179 | 179 | $className::required() |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | protected function normalizeFieldId() |
| 190 | 190 | { |
| 191 | - if( isset( $this->field['id'] ) || $this->field['is_raw'] )return; |
|
| 191 | + if( isset($this->field['id']) || $this->field['is_raw'] )return; |
|
| 192 | 192 | $this->field['id'] = glsr( Helper::class )->convertPathToId( |
| 193 | 193 | $this->field['path'], |
| 194 | 194 | $this->getFieldPrefix() |
@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function build() |
| 44 | 44 | { |
| 45 | - if( !$this->field['is_valid'] )return; |
|
| 45 | + if( !$this->field['is_valid'] ) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 46 | 48 | if( $this->field['is_raw'] ) { |
| 47 | 49 | return glsr( Builder::class )->hidden( $this->field ); |
| 48 | 50 | } |
@@ -153,7 +155,9 @@ discard block |
||
| 153 | 155 | 'name', 'type', |
| 154 | 156 | ]; |
| 155 | 157 | foreach( $requiredValues as $value ) { |
| 156 | - if( isset( $this->field[$value] ))continue; |
|
| 158 | + if( isset( $this->field[$value] )) { |
|
| 159 | + continue; |
|
| 160 | + } |
|
| 157 | 161 | $missingValues[] = $value; |
| 158 | 162 | $this->field['is_valid'] = false; |
| 159 | 163 | } |
@@ -170,7 +174,9 @@ discard block |
||
| 170 | 174 | */ |
| 171 | 175 | protected function normalize() |
| 172 | 176 | { |
| 173 | - if( !$this->isFieldValid() )return; |
|
| 177 | + if( !$this->isFieldValid() ) { |
|
| 178 | + return; |
|
| 179 | + } |
|
| 174 | 180 | $this->field['path'] = $this->field['name']; |
| 175 | 181 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
| 176 | 182 | if( class_exists( $className )) { |
@@ -188,7 +194,9 @@ discard block |
||
| 188 | 194 | */ |
| 189 | 195 | protected function normalizeFieldId() |
| 190 | 196 | { |
| 191 | - if( isset( $this->field['id'] ) || $this->field['is_raw'] )return; |
|
| 197 | + if( isset( $this->field['id'] ) || $this->field['is_raw'] ) { |
|
| 198 | + return; |
|
| 199 | + } |
|
| 192 | 200 | $this->field['id'] = glsr( Helper::class )->convertPathToId( |
| 193 | 201 | $this->field['path'], |
| 194 | 202 | $this->getFieldPrefix() |