@@ -17,7 +17,7 @@ |
||
17 | 17 | 'style' => 'display:none!important', |
18 | 18 | 'tabindex' => '-1', |
19 | 19 | 'type' => 'text', |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | $this->builder->tag = 'input'; |
22 | 22 | return $this->builder->getOpeningTag(); |
23 | 23 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | 'no' => __( 'No', 'site-reviews' ), |
18 | 18 | 'yes' => __( 'Yes', 'site-reviews' ), |
19 | 19 | ], |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | $this->builder->tag = 'input'; |
22 | 22 | return $this->builder->buildFormInput(); |
23 | 23 | } |
@@ -91,7 +91,9 @@ discard block |
||
91 | 91 | ]; |
92 | 92 | if( !isset( $properties[$property] ) |
93 | 93 | || empty( array_filter( [$value], $properties[$property] )) |
94 | - )return; |
|
94 | + ) { |
|
95 | + return; |
|
96 | + } |
|
95 | 97 | $this->$property = $value; |
96 | 98 | } |
97 | 99 | |
@@ -188,7 +190,9 @@ discard block |
||
188 | 190 | */ |
189 | 191 | protected function buildFormLabel() |
190 | 192 | { |
191 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
193 | + if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' ) { |
|
194 | + return; |
|
195 | + } |
|
192 | 196 | return $this->label([ |
193 | 197 | 'for' => $this->args['id'], |
194 | 198 | 'text' => $this->args['label'], |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $instance = new static(); |
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,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function buildFieldDescription() |
139 | 139 | { |
140 | - if( !empty( $this->args['description'] )) { |
|
140 | + if( !empty($this->args['description']) ) { |
|
141 | 141 | return $this->small( $this->args['description'] ); |
142 | 142 | } |
143 | 143 | } |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function buildFormInput() |
149 | 149 | { |
150 | - if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) { |
|
150 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
151 | 151 | return $this->buildFormLabel().$this->getOpeningTag(); |
152 | 152 | } |
153 | - return empty( $this->args['options'] ) |
|
153 | + return empty($this->args['options']) |
|
154 | 154 | ? $this->buildFormInputChoice() |
155 | 155 | : $this->buildFormInputMultiChoice(); |
156 | 156 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | 'name' => $this->args['name'].'[]', |
175 | 175 | 'text' => $this->args['options'][$key], |
176 | 176 | 'value' => $key, |
177 | - ])); |
|
177 | + ]) ); |
|
178 | 178 | }); |
179 | 179 | return $this->ul( $options ); |
180 | 180 | } |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | */ |
185 | 185 | protected function buildFormLabel() |
186 | 186 | { |
187 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
188 | - return $this->label([ |
|
187 | + if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return; |
|
188 | + return $this->label( [ |
|
189 | 189 | 'for' => $this->args['id'], |
190 | 190 | 'text' => $this->args['label'], |
191 | - ]); |
|
191 | + ] ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | protected function buildFormSelectOptions() |
206 | 206 | { |
207 | 207 | return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
208 | - return $carry.$this->option([ |
|
208 | + return $carry.$this->option( [ |
|
209 | 209 | 'selected' => $this->args['value'] == $key, |
210 | 210 | 'text' => $this->args['options'][$key], |
211 | 211 | 'value' => $key, |
212 | - ]); |
|
212 | + ] ); |
|
213 | 213 | }); |
214 | 214 | } |
215 | 215 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function buildTag() |
228 | 228 | { |
229 | - if( !in_array( $this->tag, static::TAGS_FORM )) { |
|
229 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
230 | 230 | return $this->buildDefaultTag(); |
231 | 231 | } |
232 | 232 | return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | */ |
239 | 239 | protected function normalize( ...$params ) |
240 | 240 | { |
241 | - if( glsr( Helper::class )->isStringOrNumeric( $params[0] )) { |
|
241 | + if( glsr( Helper::class )->isStringOrNumeric( $params[0] ) ) { |
|
242 | 242 | $this->setNameOrTextAttributeForTag( $params[0] ); |
243 | 243 | } |
244 | - if( is_array( $params[0] )) { |
|
244 | + if( is_array( $params[0] ) ) { |
|
245 | 245 | $this->args += $params[0]; |
246 | 246 | } |
247 | - else if( is_array( $params[1] )) { |
|
247 | + else if( is_array( $params[1] ) ) { |
|
248 | 248 | $this->args += $params[1]; |
249 | 249 | } |
250 | 250 | $this->args = glsr( BuilderDefaults::class )->merge( $this->args ); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | protected function setTagFromMethod( $method ) |
270 | 270 | { |
271 | 271 | $this->tag = strtolower( $method ); |
272 | - if( in_array( $this->tag, static::INPUT_TYPES )) { |
|
272 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
273 | 273 | $this->args['type'] = $this->tag; |
274 | 274 | $this->tag = 'input'; |
275 | 275 | } |
@@ -14,14 +14,14 @@ |
||
14 | 14 | { |
15 | 15 | $partial = glsr( Html::class )->buildTemplate( 'templates/reviews-form', [ |
16 | 16 | 'globals' => $args, |
17 | - ]); |
|
17 | + ] ); |
|
18 | 18 | $form = glsr( Builder::class )->form( $partial, [ |
19 | 19 | 'class' => 'glsr-form', |
20 | 20 | 'id' => $args['id'], |
21 | 21 | 'method' => 'post', |
22 | - ]); |
|
22 | + ] ); |
|
23 | 23 | return glsr( Builder::class )->div( $form, [ |
24 | 24 | 'class' => 'glsr-form-wrap '.$args['class'], |
25 | - ]); |
|
25 | + ] ); |
|
26 | 26 | } |
27 | 27 | } |
@@ -15,11 +15,11 @@ |
||
15 | 15 | public function build( $name, array $args = [] ) |
16 | 16 | { |
17 | 17 | $roundedRating = floor( round( $args['rating'], 1 ) * 2 ) / 2; |
18 | - $percentage = glsr( Builder::class )->span([ |
|
19 | - 'style' => 'width:'.( $roundedRating / Rating::MAX_RATING * 100 ).'%;', |
|
20 | - ]); |
|
18 | + $percentage = glsr( Builder::class )->span( [ |
|
19 | + 'style' => 'width:'.($roundedRating / Rating::MAX_RATING * 100).'%;', |
|
20 | + ] ); |
|
21 | 21 | return glsr( Builder::class )->span( $percentage, [ |
22 | 22 | 'class' => 'glsr-star-rating', |
23 | - ]); |
|
23 | + ] ); |
|
24 | 24 | } |
25 | 25 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | public function build( $partialPath, array $args = [] ) |
14 | 14 | { |
15 | 15 | $className = glsr( Helper::class )->buildClassName( $partialPath, 'Modules\Html\Partials' ); |
16 | - if( !class_exists( $className )) { |
|
16 | + if( !class_exists( $className ) ) { |
|
17 | 17 | glsr_log()->error( 'Partial missing: '.$className ); |
18 | 18 | return; |
19 | 19 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function get() |
110 | 110 | { |
111 | - return empty( $this->log ) |
|
111 | + return empty($this->log) |
|
112 | 112 | ? __( 'Log is empty', 'site-reviews' ) |
113 | 113 | : $this->log; |
114 | 114 | } |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
136 | 136 | $constants = (array)apply_filters( Application::ID.'/log-levels', $constants ); |
137 | - if( in_array( $level, $constants, true )) { |
|
137 | + if( in_array( $level, $constants, true ) ) { |
|
138 | 138 | $entry = $this->buildLogEntry( $level, $message, $context ); |
139 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
139 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
140 | 140 | $this->reset(); |
141 | 141 | } |
142 | 142 | return $this; |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | protected function getDebugInformation() |
187 | 187 | { |
188 | 188 | $caller = debug_backtrace( false, 6 ); |
189 | - $index = array_search( 'log', array_column( $caller, 'function' )); |
|
189 | + $index = array_search( 'log', array_column( $caller, 'function' ) ); |
|
190 | 190 | if( $index === false |
191 | - || !isset( $caller[$index+2]['class'] ) |
|
192 | - || !isset( $caller[$index+2]['function'] ) |
|
191 | + || !isset($caller[$index + 2]['class']) |
|
192 | + || !isset($caller[$index + 2]['function']) |
|
193 | 193 | )return; |
194 | 194 | return sprintf( '[%s()->%s:%s] ', |
195 | - $caller[$index+2]['class'], |
|
196 | - $caller[$index+2]['function'], |
|
197 | - $caller[$index+1]['line'] |
|
195 | + $caller[$index + 2]['class'], |
|
196 | + $caller[$index + 2]['function'], |
|
197 | + $caller[$index + 1]['line'] |
|
198 | 198 | ); |
199 | 199 | } |
200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function interpolate( $message, $context = [] ) |
208 | 208 | { |
209 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
209 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
210 | 210 | return print_r( $message, true ); |
211 | 211 | } |
212 | 212 | $replace = []; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | if( $value instanceof DateTime ) { |
235 | 235 | $value = $value->format( 'Y-m-d H:i:s' ); |
236 | 236 | } |
237 | - else if( $this->isObjectOrArray( $value )) { |
|
237 | + else if( $this->isObjectOrArray( $value ) ) { |
|
238 | 238 | $value = json_encode( $value ); |
239 | 239 | } |
240 | 240 | return (string)$value; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $this->clear(); |
251 | 251 | file_put_contents( |
252 | 252 | $this->file, |
253 | - $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' )) |
|
253 | + $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' ) ) |
|
254 | 254 | ); |
255 | 255 | } |
256 | 256 | } |
@@ -190,7 +190,9 @@ |
||
190 | 190 | if( $index === false |
191 | 191 | || !isset( $caller[$index+2]['class'] ) |
192 | 192 | || !isset( $caller[$index+2]['function'] ) |
193 | - )return; |
|
193 | + ) { |
|
194 | + return; |
|
195 | + } |
|
194 | 196 | return sprintf( '[%s()->%s:%s] ', |
195 | 197 | $caller[$index+2]['class'], |
196 | 198 | $caller[$index+2]['function'], |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public function __construct( $input ) |
11 | 11 | { |
12 | 12 | $this->id = $input['id']; |
13 | - $this->pinned = isset( $input['pinned'] ) |
|
13 | + $this->pinned = isset($input['pinned']) |
|
14 | 14 | ? wp_validate_boolean( $input['pinned'] ) |
15 | 15 | : null; |
16 | 16 | } |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function getReviewCounts( $metaKey ) |
25 | 25 | { |
26 | - return (array) $this->db->get_results(" |
|
26 | + return (array)$this->db->get_results( " |
|
27 | 27 | SELECT m.meta_value AS name, COUNT(*) num_posts |
28 | 28 | FROM {$this->db->posts} AS p |
29 | 29 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
30 | 30 | WHERE p.post_type = '{$this->postType}' AND m.meta_key = '{$metaKey}' |
31 | 31 | GROUP BY name |
32 | - "); |
|
32 | + " ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function getReviewPostId( $metaReviewId ) |
40 | 40 | { |
41 | - $postId = $this->db->get_var(" |
|
41 | + $postId = $this->db->get_var( " |
|
42 | 42 | SELECT p.ID |
43 | 43 | FROM {$this->db->posts} AS p |
44 | 44 | INNER JOIN {$this->db->postmeta} AS pm ON p.ID = pm.post_id |
45 | 45 | WHERE p.post_type = '{$this->postType}' |
46 | 46 | AND pm.meta_key = 'review_id' |
47 | 47 | AND pm.meta_value = '{$metaReviewId}' |
48 | - "); |
|
48 | + " ); |
|
49 | 49 | return intval( $postId ); |
50 | 50 | } |
51 | 51 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getReviewIdsByType( $metaReviewType ) |
57 | 57 | { |
58 | - $query = $this->db->get_col(" |
|
58 | + $query = $this->db->get_col( " |
|
59 | 59 | SELECT m1.meta_value AS review_id |
60 | 60 | FROM {$this->db->posts} AS p |
61 | 61 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | AND m1.meta_key = 'review_id' |
65 | 65 | AND m2.meta_key = 'review_type' |
66 | 66 | AND m2.meta_value = '{$metaReviewType}' |
67 | - "); |
|
68 | - return array_keys( array_flip( $query )); |
|
67 | + " ); |
|
68 | + return array_keys( array_flip( $query ) ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | $queryBuilder = glsr( QueryBuilder::class ); |
79 | 79 | $keys = $queryBuilder->buildSqlOr( $keys, "pm.meta_key = '%s'" ); |
80 | 80 | $status = $queryBuilder->buildSqlOr( $status, "p.post_status = '%s'" ); |
81 | - return $this->db->get_col(" |
|
81 | + return $this->db->get_col( " |
|
82 | 82 | SELECT DISTINCT pm.meta_value FROM {$this->db->postmeta} pm |
83 | 83 | LEFT JOIN {$this->db->posts} p ON p.ID = pm.post_id |
84 | 84 | WHERE p.post_type = '{$this->postType}' |
85 | 85 | AND ({$keys}) |
86 | 86 | AND ({$status}) |
87 | 87 | ORDER BY pm.meta_value |
88 | - "); |
|
88 | + " ); |
|
89 | 89 | } |
90 | 90 | } |