@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function buildClassName( $name, $path = '' ) |
16 | 16 | { |
17 | - $className = array_map( 'strtolower', (array)preg_split( '/[-_]/', $name )); |
|
17 | + $className = array_map( 'strtolower', (array)preg_split( '/[-_]/', $name ) ); |
|
18 | 18 | $className = array_map( 'ucfirst', $className ); |
19 | 19 | $className = implode( '', $className ); |
20 | 20 | $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
21 | - return !empty( $path ) |
|
21 | + return !empty($path) |
|
22 | 22 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
23 | 23 | : $className; |
24 | 24 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function buildMethodName( $name, $prefix = '' ) |
32 | 32 | { |
33 | - return lcfirst( $prefix.$this->buildClassName( $name )); |
|
33 | + return lcfirst( $prefix.$this->buildClassName( $name ) ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function buildPropertyName( $name ) |
41 | 41 | { |
42 | - return lcfirst( $this->buildClassName( $name )); |
|
42 | + return lcfirst( $this->buildClassName( $name ) ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | { |
82 | 82 | $levels = explode( '.', $path ); |
83 | 83 | return array_reduce( $levels, function( $result, $value ) { |
84 | - return $result.= '['.$value.']'; |
|
84 | + return $result .= '['.$value.']'; |
|
85 | 85 | }, $prefix ); |
86 | 86 | } |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function dashCase( $string ) |
93 | 93 | { |
94 | - return str_replace( '_', '-', $this->snakeCase( $string )); |
|
94 | + return str_replace( '_', '-', $this->snakeCase( $string ) ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | { |
116 | 116 | $result = []; |
117 | 117 | foreach( $array as $key => $value ) { |
118 | - $newKey = $prefix.( empty( $prefix ) ? '' : '.' ).$key; |
|
119 | - if( $this->isIndexedArray( $value )) { |
|
118 | + $newKey = $prefix.(empty($prefix) ? '' : '.').$key; |
|
119 | + if( $this->isIndexedArray( $value ) ) { |
|
120 | 120 | $value = '['.implode( ', ', $value ).']'; |
121 | 121 | } |
122 | - if( is_array( $value )) { |
|
123 | - $result = array_merge( $result, $this->flattenArray( $value, $newKey )); |
|
122 | + if( is_array( $value ) ) { |
|
123 | + $result = array_merge( $result, $this->flattenArray( $value, $newKey ) ); |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | $result[$newKey] = $value; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | Whip::IPV4 => $cloudflareIps['v4'], |
140 | 140 | Whip::IPV6 => $cloudflareIps['v6'], |
141 | 141 | ], |
142 | - ]))->getValidIpAddress(); |
|
142 | + ] ))->getValidIpAddress(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | { |
153 | 153 | $keys = explode( '.', $path ); |
154 | 154 | foreach( $keys as $key ) { |
155 | - if( !isset( $values[$key] )) { |
|
155 | + if( !isset($values[$key]) ) { |
|
156 | 156 | return $fallback; |
157 | 157 | } |
158 | 158 | $values = $values[$key]; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function isIndexedArray( $array ) |
168 | 168 | { |
169 | - if( !is_array( $array ) || array_filter( $array, 'is_array' )) { |
|
169 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | $current = 0; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function prefixString( $string, $prefix = '' ) |
188 | 188 | { |
189 | - return $prefix.str_replace( $prefix, '', trim( $string )); |
|
189 | + return $prefix.str_replace( $prefix, '', trim( $string ) ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function snakeCase( $string ) |
234 | 234 | { |
235 | - if( !ctype_lower( $string )) { |
|
235 | + if( !ctype_lower( $string ) ) { |
|
236 | 236 | $string = preg_replace( '/\s+/u', '', $string ); |
237 | 237 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
238 | 238 | $string = mb_strtolower( $string, 'UTF-8' ); |
@@ -247,6 +247,6 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function startsWith( $needle, $haystack ) |
249 | 249 | { |
250 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
250 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
251 | 251 | } |
252 | 252 | } |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | public function __construct( $idBase, $name, $values ) |
16 | 16 | { |
17 | 17 | $controlOptions = $widgetOptions = []; |
18 | - if( isset( $values['class'] )) { |
|
18 | + if( isset($values['class']) ) { |
|
19 | 19 | $widgetOptions['classname'] = $values['class']; |
20 | 20 | } |
21 | - if( isset( $values['description'] )) { |
|
21 | + if( isset($values['description']) ) { |
|
22 | 22 | $widgetOptions['description'] = $values['description']; |
23 | 23 | } |
24 | - if( isset( $values['width'] )) { |
|
24 | + if( isset($values['width']) ) { |
|
25 | 25 | $controlOptions['width'] = $values['width']; |
26 | 26 | } |
27 | 27 | parent::__construct( $idBase, $name, $widgetOptions, $controlOptions ); |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | protected function renderField( $tag, array $args = [] ) |
35 | 35 | { |
36 | 36 | $args = $this->normalizeFieldAttributes( $tag, $args ); |
37 | - $field = glsr( Html::class )->build( ['is_widget' => true] )->{$tag}( $args['name'], $args ); |
|
37 | + $field = glsr( Html::class )->build( ['is_widget' => true] )->{$tag}($args['name'], $args); |
|
38 | 38 | echo glsr( Html::class )->build( ['is_widget' => true] )->div( $field, [ |
39 | 39 | 'class' => 'glsr-field', |
40 | - ]); |
|
40 | + ] ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | protected function normalizeFieldAttributes( $tag, array $args ) |
48 | 48 | { |
49 | - if( empty( $args['value'] )) { |
|
49 | + if( empty($args['value']) ) { |
|
50 | 50 | $args['value'] = $this->widgetArgs[$args['name']]; |
51 | 51 | } |
52 | - if( empty( $this->widgetArgs['options'] ) && in_array( $tag, ['checkbox', 'radio'] )) { |
|
52 | + if( empty($this->widgetArgs['options']) && in_array( $tag, ['checkbox', 'radio'] ) ) { |
|
53 | 53 | $args['checked'] = in_array( $args['value'], (array)$this->widgetArgs[$args['name']] ); |
54 | 54 | } |
55 | 55 | $args['id'] = $this->get_field_id( $args['name'] ); |
@@ -50,9 +50,9 @@ |
||
50 | 50 | */ |
51 | 51 | protected function normalize( array $data ) |
52 | 52 | { |
53 | - $data = wp_parse_args( $data, array_fill_keys( ['context', 'globals'], [] )); |
|
53 | + $data = wp_parse_args( $data, array_fill_keys( ['context', 'globals'], [] ) ); |
|
54 | 54 | foreach( $data as $key => $value ) { |
55 | - if( is_array( $value ))continue; |
|
55 | + if( is_array( $value ) )continue; |
|
56 | 56 | $data[$key] = []; |
57 | 57 | } |
58 | 58 | $data['template'] = $this; |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function __call( $method, $args ) |
61 | 61 | { |
62 | - $instance = new static( $this->globals ); |
|
62 | + $instance = new static($this->globals); |
|
63 | 63 | $instance->setTagFromMethod( $method ); |
64 | - call_user_func_array( [$instance, 'normalize'], $args += ['',''] ); |
|
64 | + call_user_func_array( [$instance, 'normalize'], $args += ['', ''] ); |
|
65 | 65 | $tags = array_merge( static::TAGS_FORM, static::TAGS_STRUCTURE, static::TAGS_TEXT ); |
66 | 66 | $generatedTag = in_array( $instance->tag, $tags ) |
67 | 67 | ? $instance->buildTag() |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | 'render' => 'is_bool', |
86 | 86 | 'tag' => 'is_string', |
87 | 87 | ]; |
88 | - if( !isset( $properties[$property] ) |
|
89 | - || empty( array_filter( [$value], $properties[$property] )) |
|
88 | + if( !isset($properties[$property]) |
|
89 | + || empty(array_filter( [$value], $properties[$property] )) |
|
90 | 90 | )return; |
91 | 91 | $this->$property = $value; |
92 | 92 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function getOpeningTag() |
106 | 106 | { |
107 | - $attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString(); |
|
107 | + $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString(); |
|
108 | 108 | return '<'.trim( $this->tag.' '.$attributes ).'>'; |
109 | 109 | } |
110 | 110 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | protected function buildCustomField() |
115 | 115 | { |
116 | 116 | $className = glsr( Helper::class )->buildClassName( $this->tag, __NAMESPACE__.'\Fields' ); |
117 | - if( !class_exists( $className )) { |
|
117 | + if( !class_exists( $className ) ) { |
|
118 | 118 | glsr_log()->error( 'Field missing: '.$className ); |
119 | 119 | return; |
120 | 120 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | protected function buildDefaultTag( $text = '' ) |
128 | 128 | { |
129 | - if( empty( $text )) { |
|
129 | + if( empty($text) ) { |
|
130 | 130 | $text = $this->args['text']; |
131 | 131 | } |
132 | 132 | return $this->getOpeningTag().$text.$this->getClosingTag(); |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function buildFieldDescription() |
139 | 139 | { |
140 | - if( empty( $this->args['description'] ))return; |
|
141 | - if( !empty( $this->globals['is_widget'] )) { |
|
140 | + if( empty($this->args['description']) )return; |
|
141 | + if( !empty($this->globals['is_widget']) ) { |
|
142 | 142 | return $this->small( $this->args['description'] ); |
143 | 143 | } |
144 | 144 | return $this->p( $this->args['description'], ['class' => 'description'] ); |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function buildFormInput() |
151 | 151 | { |
152 | - if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) { |
|
152 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
153 | 153 | return $this->buildFormLabel().$this->getOpeningTag(); |
154 | 154 | } |
155 | - return empty( $this->args['options'] ) |
|
155 | + return empty($this->args['options']) |
|
156 | 156 | ? $this->buildFormInputChoice() |
157 | 157 | : $this->buildFormInputMultiChoice(); |
158 | 158 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | 'name' => $this->args['name'].'[]', |
177 | 177 | 'text' => $this->args['options'][$key], |
178 | 178 | 'value' => $key, |
179 | - ])); |
|
179 | + ]) ); |
|
180 | 180 | }); |
181 | 181 | return $this->ul( $options, ['class' => $this->args['class']] ); |
182 | 182 | } |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function buildFormLabel() |
188 | 188 | { |
189 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
190 | - return $this->label([ |
|
189 | + if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return; |
|
190 | + return $this->label( [ |
|
191 | 191 | 'for' => $this->args['id'], |
192 | 192 | 'text' => $this->args['label'], |
193 | - ]); |
|
193 | + ] ); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | protected function buildFormSelectOptions() |
208 | 208 | { |
209 | 209 | return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
210 | - return $carry.$this->option([ |
|
210 | + return $carry.$this->option( [ |
|
211 | 211 | 'selected' => $this->args['value'] == $key, |
212 | 212 | 'text' => $this->args['options'][$key], |
213 | 213 | 'value' => $key, |
214 | - ]); |
|
214 | + ] ); |
|
215 | 215 | }); |
216 | 216 | } |
217 | 217 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | protected function buildTag() |
230 | 230 | { |
231 | - if( !in_array( $this->tag, static::TAGS_FORM )) { |
|
231 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
232 | 232 | return $this->buildDefaultTag(); |
233 | 233 | } |
234 | 234 | return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | */ |
241 | 241 | protected function normalize( ...$params ) |
242 | 242 | { |
243 | - if( is_string( $params[0] ) || is_numeric( $params[0] )) { |
|
243 | + if( is_string( $params[0] ) || is_numeric( $params[0] ) ) { |
|
244 | 244 | $this->setNameOrTextAttributeForTag( $params[0] ); |
245 | 245 | } |
246 | - if( is_array( $params[0] )) { |
|
246 | + if( is_array( $params[0] ) ) { |
|
247 | 247 | $this->args += $params[0]; |
248 | 248 | } |
249 | - else if( is_array( $params[1] )) { |
|
249 | + else if( is_array( $params[1] ) ) { |
|
250 | 250 | $this->args += $params[1]; |
251 | 251 | } |
252 | 252 | $this->args = glsr( BuilderDefaults::class )->merge( $this->args ); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | protected function setTagFromMethod( $method ) |
272 | 272 | { |
273 | 273 | $this->tag = strtolower( $method ); |
274 | - if( in_array( $this->tag, static::INPUT_TYPES )) { |
|
274 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
275 | 275 | $this->args['type'] = $this->tag; |
276 | 276 | $this->tag = 'input'; |
277 | 277 | } |
@@ -87,7 +87,9 @@ discard block |
||
87 | 87 | ]; |
88 | 88 | if( !isset( $properties[$property] ) |
89 | 89 | || empty( array_filter( [$value], $properties[$property] )) |
90 | - )return; |
|
90 | + ) { |
|
91 | + return; |
|
92 | + } |
|
91 | 93 | $this->$property = $value; |
92 | 94 | } |
93 | 95 | |
@@ -137,7 +139,9 @@ discard block |
||
137 | 139 | */ |
138 | 140 | protected function buildFieldDescription() |
139 | 141 | { |
140 | - if( empty( $this->args['description'] ))return; |
|
142 | + if( empty( $this->args['description'] )) { |
|
143 | + return; |
|
144 | + } |
|
141 | 145 | if( !empty( $this->globals['is_widget'] )) { |
142 | 146 | return $this->small( $this->args['description'] ); |
143 | 147 | } |
@@ -186,7 +190,9 @@ discard block |
||
186 | 190 | */ |
187 | 191 | protected function buildFormLabel() |
188 | 192 | { |
189 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
193 | + if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' ) { |
|
194 | + return; |
|
195 | + } |
|
190 | 196 | return $this->label([ |
191 | 197 | 'for' => $this->args['id'], |
192 | 198 | 'text' => $this->args['label'], |
@@ -13,7 +13,7 @@ |
||
13 | 13 | { |
14 | 14 | $defaults = wp_parse_args( $this->defaults(), [ |
15 | 15 | 'name' => $this->builder->args['text'], |
16 | - ]); |
|
16 | + ] ); |
|
17 | 17 | $this->builder->args = wp_parse_args( $this->builder->args, $defaults ); |
18 | 18 | $this->builder->tag = 'input'; |
19 | 19 | return $this->builder->getOpeningTag(); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | 'is_multi' => false, |
25 | 25 | 'is_valid' => true, |
26 | 26 | 'path' => '', |
27 | - ]); |
|
27 | + ] ); |
|
28 | 28 | $this->normalize(); |
29 | 29 | } |
30 | 30 | |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | return glsr( Template::class )->build( 'settings/form-table-row', [ |
42 | 42 | 'context' => [ |
43 | 43 | 'class' => $this->getFieldClass(), |
44 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
44 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
45 | 45 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
46 | 46 | ], |
47 | - ]); |
|
47 | + ] ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | 'context' => [ |
65 | 65 | 'class' => $this->getFieldClass(), |
66 | 66 | 'depends' => $this->getFieldDepends(), |
67 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
67 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
68 | 68 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
69 | 69 | 'legend' => $this->field['legend'], |
70 | 70 | ], |
71 | - ]); |
|
71 | + ] ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected function getFieldDepends() |
88 | 88 | { |
89 | - return !empty( $this->field['depends'] ) |
|
89 | + return !empty($this->field['depends']) |
|
90 | 90 | ? $this->field['depends'] |
91 | 91 | : ''; |
92 | 92 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | protected function isFieldHidden( $path, $expectedValue ) |
100 | 100 | { |
101 | 101 | $optionValue = glsr( OptionManager::class )->get( $path ); |
102 | - if( is_array( $optionValue )) { |
|
102 | + if( is_array( $optionValue ) ) { |
|
103 | 103 | return !in_array( $expectedValue, $optionValue ); |
104 | 104 | } |
105 | 105 | return $optionValue != $expectedValue; |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | 'label', 'name', 'type', |
117 | 117 | ]; |
118 | 118 | foreach( $requiredValues as $value ) { |
119 | - if( isset( $this->field[$value] ))continue; |
|
119 | + if( isset($this->field[$value]) )continue; |
|
120 | 120 | $missingValues[] = $value; |
121 | 121 | $isValid = $this->field['is_valid'] = false; |
122 | 122 | } |
123 | - if( !empty( $missingValues )) { |
|
123 | + if( !empty($missingValues) ) { |
|
124 | 124 | glsr_log() |
125 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
125 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
126 | 126 | ->info( $this->field ); |
127 | 127 | } |
128 | 128 | return $isValid; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $field = $this->field; |
138 | 138 | foreach( $field as $key => $value ) { |
139 | 139 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
140 | - if( !method_exists( $this, $methodName ))continue; |
|
140 | + if( !method_exists( $this, $methodName ) )continue; |
|
141 | 141 | $this->$methodName(); |
142 | 142 | } |
143 | 143 | $this->normalizeFieldId(); |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function normalizeDepends() |
152 | 152 | { |
153 | - if( empty( $this->field['depends'] ) || !is_array( $this->field['depends'] ))return; |
|
153 | + if( empty($this->field['depends']) || !is_array( $this->field['depends'] ) )return; |
|
154 | 154 | $path = key( $this->field['depends'] ); |
155 | 155 | $value = $this->field['depends'][$path]; |
156 | - $this->field['depends'] = json_encode([ |
|
156 | + $this->field['depends'] = json_encode( [ |
|
157 | 157 | 'name' => glsr( Helper::class )->convertPathToName( $path, Application::ID ), |
158 | 158 | 'value' => $value, |
159 | - ], JSON_HEX_APOS|JSON_HEX_QUOT ); |
|
159 | + ], JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
160 | 160 | $this->field['is_hidden'] = $this->isFieldHidden( $path, $value ); |
161 | 161 | } |
162 | 162 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | protected function normalizeFieldId() |
167 | 167 | { |
168 | - if( isset( $this->field['id'] ))return; |
|
168 | + if( isset($this->field['id']) )return; |
|
169 | 169 | $this->field['id'] = glsr( Helper::class )->convertNameToId( $this->field['name'] ); |
170 | 170 | } |
171 | 171 | |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | protected function normalizeFieldType() |
176 | 176 | { |
177 | 177 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], 'Modules\Html\Fields' ); |
178 | - if( class_exists( $className )) { |
|
178 | + if( class_exists( $className ) ) { |
|
179 | 179 | $this->field = array_merge( $this->field, glsr( $className )->defaults() ); |
180 | 180 | } |
181 | - if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES )) { |
|
181 | + if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES ) ) { |
|
182 | 182 | $this->field['is_multi'] = true; |
183 | 183 | } |
184 | 184 | } |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | */ |
189 | 189 | protected function normalizeFieldValue() |
190 | 190 | { |
191 | - if( isset( $this->field['value'] ))return; |
|
192 | - $defaultValue = isset( $this->field['default'] ) |
|
191 | + if( isset($this->field['value']) )return; |
|
192 | + $defaultValue = isset($this->field['default']) |
|
193 | 193 | ? $this->field['default'] |
194 | 194 | : ''; |
195 | 195 | $this->field['value'] = glsr( OptionManager::class )->get( $this->field['path'], $defaultValue ); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | protected function normalizeLabel() |
202 | 202 | { |
203 | 203 | $this->field['legend'] = $this->field['label']; |
204 | - unset( $this->field['label'] ); |
|
204 | + unset($this->field['label']); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function build() |
35 | 35 | { |
36 | - if( !$this->field['is_valid'] )return; |
|
36 | + if( !$this->field['is_valid'] ) { |
|
37 | + return; |
|
38 | + } |
|
37 | 39 | if( $this->field['is_multi'] ) { |
38 | 40 | return $this->buildMultiField(); |
39 | 41 | } |
@@ -116,7 +118,9 @@ discard block |
||
116 | 118 | 'label', 'name', 'type', |
117 | 119 | ]; |
118 | 120 | foreach( $requiredValues as $value ) { |
119 | - if( isset( $this->field[$value] ))continue; |
|
121 | + if( isset( $this->field[$value] )) { |
|
122 | + continue; |
|
123 | + } |
|
120 | 124 | $missingValues[] = $value; |
121 | 125 | $isValid = $this->field['is_valid'] = false; |
122 | 126 | } |
@@ -133,11 +137,15 @@ discard block |
||
133 | 137 | */ |
134 | 138 | protected function normalize() |
135 | 139 | { |
136 | - if( !$this->isFieldValid() )return; |
|
140 | + if( !$this->isFieldValid() ) { |
|
141 | + return; |
|
142 | + } |
|
137 | 143 | $field = $this->field; |
138 | 144 | foreach( $field as $key => $value ) { |
139 | 145 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
140 | - if( !method_exists( $this, $methodName ))continue; |
|
146 | + if( !method_exists( $this, $methodName )) { |
|
147 | + continue; |
|
148 | + } |
|
141 | 149 | $this->$methodName(); |
142 | 150 | } |
143 | 151 | $this->normalizeFieldId(); |
@@ -150,7 +158,9 @@ discard block |
||
150 | 158 | */ |
151 | 159 | protected function normalizeDepends() |
152 | 160 | { |
153 | - if( empty( $this->field['depends'] ) || !is_array( $this->field['depends'] ))return; |
|
161 | + if( empty( $this->field['depends'] ) || !is_array( $this->field['depends'] )) { |
|
162 | + return; |
|
163 | + } |
|
154 | 164 | $path = key( $this->field['depends'] ); |
155 | 165 | $value = $this->field['depends'][$path]; |
156 | 166 | $this->field['depends'] = json_encode([ |
@@ -165,7 +175,9 @@ discard block |
||
165 | 175 | */ |
166 | 176 | protected function normalizeFieldId() |
167 | 177 | { |
168 | - if( isset( $this->field['id'] ))return; |
|
178 | + if( isset( $this->field['id'] )) { |
|
179 | + return; |
|
180 | + } |
|
169 | 181 | $this->field['id'] = glsr( Helper::class )->convertNameToId( $this->field['name'] ); |
170 | 182 | } |
171 | 183 | |
@@ -188,7 +200,9 @@ discard block |
||
188 | 200 | */ |
189 | 201 | protected function normalizeFieldValue() |
190 | 202 | { |
191 | - if( isset( $this->field['value'] ))return; |
|
203 | + if( isset( $this->field['value'] )) { |
|
204 | + return; |
|
205 | + } |
|
192 | 206 | $defaultValue = isset( $this->field['default'] ) |
193 | 207 | ? $this->field['default'] |
194 | 208 | : ''; |
@@ -15,17 +15,17 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function renderFields( $id ) |
17 | 17 | { |
18 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
18 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
19 | 19 | $rows = ''; |
20 | 20 | foreach( $fields as $name => $field ) { |
21 | 21 | $field = wp_parse_args( $field, ['name' => $name] ); |
22 | - $rows.= (new Field( $field ))->build(); |
|
22 | + $rows .= (new Field( $field ))->build(); |
|
23 | 23 | } |
24 | 24 | glsr( Template::class )->render( 'pages/settings/'.$id, [ |
25 | 25 | 'context' => [ |
26 | 26 | 'rows' => $rows, |
27 | 27 | ], |
28 | - ]); |
|
28 | + ] ); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | protected function getSettingFields( $path ) |
35 | 35 | { |
36 | 36 | $settings = glsr( DefaultsManager::class )->settings(); |
37 | - return array_filter( $settings, function( $key ) use( $path ) { |
|
37 | + return array_filter( $settings, function( $key ) use($path) { |
|
38 | 38 | return glsr( Helper::class )->startsWith( $path, $key ); |
39 | 39 | }, ARRAY_FILTER_USE_KEY ); |
40 | 40 | } |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | { |
23 | 23 | global $menu, $typenow; |
24 | 24 | foreach( $menu as $key => $value ) { |
25 | - if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
25 | + if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
26 | 26 | $postCount = wp_count_posts( Application::POST_TYPE ); |
27 | 27 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
28 | 28 | 'class' => 'pending-count', |
29 | - ]); |
|
29 | + ] ); |
|
30 | 30 | $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [ |
31 | 31 | 'class' => 'awaiting-mod count-'.$postCount->pending, |
32 | - ]); |
|
32 | + ] ); |
|
33 | 33 | $menu[$key][0] .= $awaitingModeration; |
34 | 34 | if( $typenow === Application::POST_TYPE ) { |
35 | - $menu[$key][4].= ' current'; |
|
35 | + $menu[$key][4] .= ' current'; |
|
36 | 36 | } |
37 | 37 | break; |
38 | 38 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | 'tools' => __( 'Tools', 'site-reviews' ), |
50 | 50 | 'documentation' => __( 'Documentation', 'site-reviews' ), |
51 | 51 | 'addons' => __( 'Add-Ons', 'site-reviews' ), |
52 | - ]); |
|
52 | + ] ); |
|
53 | 53 | foreach( $pages as $slug => $title ) { |
54 | 54 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
55 | 55 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
56 | - if( !is_callable( $callback ))continue; |
|
56 | + if( !is_callable( $callback ) )continue; |
|
57 | 57 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, Application::CAPABILITY, $slug, $callback ); |
58 | 58 | } |
59 | 59 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $this->renderPage( 'addons', [ |
69 | 69 | 'template' => glsr( Template::class ), |
70 | - ]); |
|
70 | + ] ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | 'shortcodes' => __( 'Shortcodes', 'site-reviews' ), |
84 | 84 | 'hooks' => __( 'Hooks', 'site-reviews' ), |
85 | 85 | 'functions' => __( 'Functions', 'site-reviews' ), |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | $this->renderPage( 'documentation', [ |
88 | 88 | 'tabs' => $tabs, |
89 | - ]); |
|
89 | + ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | 'schema' => __( 'Schema', 'site-reviews' ), |
104 | 104 | 'translations' => __( 'Translations', 'site-reviews' ), |
105 | 105 | 'licenses' => __( 'Licenses', 'site-reviews' ), |
106 | - ]); |
|
107 | - if( !apply_filters( 'site-reviews/addon/licenses', false )) { |
|
108 | - unset( $tabs['licenses'] ); |
|
106 | + ] ); |
|
107 | + if( !apply_filters( 'site-reviews/addon/licenses', false ) ) { |
|
108 | + unset($tabs['licenses']); |
|
109 | 109 | } |
110 | 110 | $this->renderPage( 'settings', [ |
111 | 111 | 'form' => glsr( Form::class ), |
112 | 112 | 'tabs' => $tabs, |
113 | - ]); |
|
113 | + ] ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'import-export' => __( 'Import/Export', 'site-reviews' ), |
125 | 125 | 'logging' => __( 'Logging', 'site-reviews' ), |
126 | 126 | 'system-info' => __( 'System Info', 'site-reviews' ), |
127 | - ]); |
|
127 | + ] ); |
|
128 | 128 | $this->renderPage( 'tools', [ |
129 | 129 | 'data' => [ |
130 | 130 | 'id' => Application::ID, |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ], |
135 | 135 | 'html' => glsr( Html::class ), |
136 | 136 | 'tabs' => $tabs, |
137 | - ]); |
|
137 | + ] ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |