@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | foreach( $this->reviews as $index => $review ) { |
86 | 86 | $renderedReviews[] = glsr( Template::class )->build( 'templates/review', [ |
87 | 87 | 'context' => $this->buildReview( $review )->values, |
88 | - ]); |
|
88 | + ] ); |
|
89 | 89 | } |
90 | 90 | return new ReviewsHtml( $renderedReviews, $this->reviews->max_num_pages, $this->args ); |
91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function generateSchema() |
97 | 97 | { |
98 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
98 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
99 | 99 | glsr( Schema::class )->store( |
100 | 100 | glsr( Schema::class )->build( $this->args ) |
101 | 101 | ); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function isHidden( $key, $path = '' ) |
110 | 110 | { |
111 | - $isOptionEnabled = !empty( $path ) |
|
111 | + $isOptionEnabled = !empty($path) |
|
112 | 112 | ? $this->isOptionEnabled( $path ) |
113 | 113 | : true; |
114 | 114 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function buildOptionAssignedTo( $key, $value ) |
123 | 123 | { |
124 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
124 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return; |
|
125 | 125 | $post = glsr( Polylang::class )->getPost( $value ); |
126 | - if( !( $post instanceof WP_Post ))return; |
|
126 | + if( !($post instanceof WP_Post) )return; |
|
127 | 127 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
128 | 128 | 'href' => get_the_permalink( $post->ID ), |
129 | - ]); |
|
129 | + ] ); |
|
130 | 130 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
131 | 131 | return '<span>'.$assignedTo.'</span>'; |
132 | 132 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function buildOptionAuthor( $key, $value ) |
140 | 140 | { |
141 | - if( $this->isHidden( $key ))return; |
|
141 | + if( $this->isHidden( $key ) )return; |
|
142 | 142 | return '<span>'.$value.'</span>'; |
143 | 143 | } |
144 | 144 | |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function buildOptionAvatar( $key, $value ) |
151 | 151 | { |
152 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
152 | + if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return; |
|
153 | 153 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
154 | - return glsr( Builder::class )->img([ |
|
154 | + return glsr( Builder::class )->img( [ |
|
155 | 155 | 'height' => $size, |
156 | 156 | 'src' => $this->generateAvatar( $value ), |
157 | 157 | 'style' => sprintf( 'width:%1$spx; height:%1$spx;', $size ), |
158 | 158 | 'width' => $size, |
159 | - ]); |
|
159 | + ] ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | protected function buildOptionContent( $key, $value ) |
168 | 168 | { |
169 | 169 | $text = $this->normalizeText( $value ); |
170 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
170 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
171 | 171 | return '<p>'.$text.'</p>'; |
172 | 172 | } |
173 | 173 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | protected function buildOptionDate( $key, $value ) |
180 | 180 | { |
181 | - if( $this->isHidden( $key ))return; |
|
181 | + if( $this->isHidden( $key ) )return; |
|
182 | 182 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
183 | 183 | if( $dateFormat == 'relative' ) { |
184 | 184 | $date = glsr( Date::class )->relative( $value ); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $format = $dateFormat == 'custom' |
188 | 188 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
189 | 189 | : (string)get_option( 'date_format' ); |
190 | - $date = date_i18n( $format, strtotime( $value )); |
|
190 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
191 | 191 | } |
192 | 192 | return '<span>'.$date.'</span>'; |
193 | 193 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | protected function buildOptionRating( $key, $value ) |
201 | 201 | { |
202 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
202 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
203 | 203 | return glsr_star_rating( $value ); |
204 | 204 | } |
205 | 205 | |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | */ |
211 | 211 | protected function buildOptionResponse( $key, $value ) |
212 | 212 | { |
213 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
214 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
213 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
214 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
215 | 215 | $text = $this->normalizeText( $value ); |
216 | 216 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
217 | 217 | $response = glsr( Builder::class )->div( $text, ['class' => 'glsr-review-response-inner'] ); |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function buildOptionTitle( $key, $value ) |
228 | 228 | { |
229 | - if( $this->isHidden( $key ))return; |
|
230 | - if( empty( $value )) { |
|
229 | + if( $this->isHidden( $key ) )return; |
|
230 | + if( empty($value) ) { |
|
231 | 231 | $value = __( 'No Title', 'site-reviews' ); |
232 | 232 | } |
233 | 233 | return '<h3>'.$value.'</h3>'; |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | return $avatarUrl; |
244 | 244 | } |
245 | 245 | $authorIdOrEmail = get_the_author_meta( 'ID', $this->current->user_id ); |
246 | - if( empty( $authorIdOrEmail )) { |
|
246 | + if( empty($authorIdOrEmail) ) { |
|
247 | 247 | $authorIdOrEmail = $this->current->email; |
248 | 248 | } |
249 | - if( $newAvatar = get_avatar_url( $authorIdOrEmail )) { |
|
249 | + if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) { |
|
250 | 250 | return $newAvatar; |
251 | 251 | } |
252 | 252 | return $avatarUrl; |
@@ -258,18 +258,18 @@ discard block |
||
258 | 258 | */ |
259 | 259 | protected function getExcerpt( $text ) |
260 | 260 | { |
261 | - $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 )); |
|
261 | + $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) ); |
|
262 | 262 | $split = extension_loaded( 'intl' ) |
263 | 263 | ? $this->getExcerptIntlSplit( $text, $limit ) |
264 | 264 | : $this->getExcerptSplit( $text, $limit ); |
265 | 265 | $hiddenText = substr( $text, $split ); |
266 | - if( !empty( $hiddenText )) { |
|
266 | + if( !empty($hiddenText) ) { |
|
267 | 267 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
268 | 268 | 'class' => 'glsr-hidden glsr-hidden-text', |
269 | 269 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
270 | 270 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
271 | - ]); |
|
272 | - $text = ltrim( substr( $text, 0, $split )).$showMore; |
|
271 | + ] ); |
|
272 | + $text = ltrim( substr( $text, 0, $split ) ).$showMore; |
|
273 | 273 | } |
274 | 274 | return $text; |
275 | 275 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $words = IntlRuleBasedBreakIterator::createWordInstance( '' ); |
285 | 285 | $words->setText( $text ); |
286 | 286 | $count = 0; |
287 | - foreach( $words as $offset ){ |
|
287 | + foreach( $words as $offset ) { |
|
288 | 288 | if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
289 | 289 | $count++; |
290 | 290 | if( $count != $limit )continue; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | protected function getExcerptSplit( $text, $limit ) |
302 | 302 | { |
303 | 303 | if( str_word_count( $text, 0 ) > $limit ) { |
304 | - $words = array_keys( str_word_count( $text, 2 )); |
|
304 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
305 | 305 | return $words[$limit]; |
306 | 306 | } |
307 | 307 | return strlen( $text ); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | protected function getOption( $path, $fallback = '' ) |
316 | 316 | { |
317 | - if( array_key_exists( $path, $this->options )) { |
|
317 | + if( array_key_exists( $path, $this->options ) ) { |
|
318 | 318 | return $this->options[$path]; |
319 | 319 | } |
320 | 320 | return $fallback; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | */ |
328 | 328 | protected function isHiddenOrEmpty( $key, $value ) |
329 | 329 | { |
330 | - return $this->isHidden( $key ) || empty( $value ); |
|
330 | + return $this->isHidden( $key ) || empty($value); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -346,13 +346,13 @@ discard block |
||
346 | 346 | protected function normalizeText( $text ) |
347 | 347 | { |
348 | 348 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
349 | - $text = convert_smilies( strip_shortcodes( $text )); |
|
349 | + $text = convert_smilies( strip_shortcodes( $text ) ); |
|
350 | 350 | $text = str_replace( ']]>', ']]>', $text ); |
351 | 351 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
352 | - if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) { |
|
352 | + if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) { |
|
353 | 353 | $text = $this->getExcerpt( $text ); |
354 | 354 | } |
355 | - return wptexturize( nl2br( $text )); |
|
355 | + return wptexturize( nl2br( $text ) ); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -361,12 +361,12 @@ discard block |
||
361 | 361 | protected function wrap( array &$renderedFields, Review $review ) |
362 | 362 | { |
363 | 363 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
364 | - array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
|
364 | + array_walk( $renderedFields, function( &$value, $key ) use($review) { |
|
365 | 365 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
366 | - if( empty( $value ))return; |
|
366 | + if( empty($value) )return; |
|
367 | 367 | $value = glsr( Builder::class )->div( $value, [ |
368 | 368 | 'class' => 'glsr-review-'.$key, |
369 | - ]); |
|
369 | + ] ); |
|
370 | 370 | }); |
371 | 371 | } |
372 | 372 | } |