@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | foreach( glsr( ReviewManager::class )->get( $this->args )->results as $review ) { |
| 35 | 35 | // Only include critic reviews that have been directly produced by your site, not reviews from third- party sites or syndicated reviews. |
| 36 | 36 | // @see https://developers.google.com/search/docs/data-types/review |
| 37 | - if( $review->review_type != 'local' )continue; |
|
| 37 | + if( $review->review_type != 'local' ) { |
|
| 38 | + continue; |
|
| 39 | + } |
|
| 38 | 40 | $reviews[] = $this->buildReview( $review ); |
| 39 | 41 | } |
| 40 | 42 | if( !empty( $reviews )) { |
@@ -79,7 +81,9 @@ discard block |
||
| 79 | 81 | */ |
| 80 | 82 | public function render() |
| 81 | 83 | { |
| 82 | - if( is_null( glsr()->schemas ))return; |
|
| 84 | + if( is_null( glsr()->schemas )) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 83 | 87 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 84 | 88 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 85 | 89 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -131,7 +135,9 @@ discard block |
||
| 131 | 135 | { |
| 132 | 136 | foreach( $values as $value ) { |
| 133 | 137 | $option = $this->getSchemaOptionValue( $value ); |
| 134 | - if( empty( $option ))continue; |
|
| 138 | + if( empty( $option )) { |
|
| 139 | + continue; |
|
| 140 | + } |
|
| 135 | 141 | $schema->$value( $option ); |
| 136 | 142 | } |
| 137 | 143 | return $schema; |
@@ -237,7 +243,9 @@ discard block |
||
| 237 | 243 | if( $value != $fallback ) { |
| 238 | 244 | return $value; |
| 239 | 245 | } |
| 240 | - if( !is_single() && !is_page() )return; |
|
| 246 | + if( !is_single() && !is_page() ) { |
|
| 247 | + return; |
|
| 248 | + } |
|
| 241 | 249 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
| 242 | 250 | if( method_exists( $this, $method )) { |
| 243 | 251 | return $this->$method(); |
@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
| 41 | 41 | 'min' => $args['rating'], |
| 42 | 42 | ]); |
| 43 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
| 43 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' )) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 44 | 46 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
| 45 | 47 | $this->generateSchema(); |
| 46 | 48 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -60,7 +62,9 @@ discard block |
||
| 60 | 62 | */ |
| 61 | 63 | protected function buildPercentage() |
| 62 | 64 | { |
| 63 | - if( $this->isHidden( 'bars' ))return; |
|
| 65 | + if( $this->isHidden( 'bars' )) { |
|
| 66 | + return; |
|
| 67 | + } |
|
| 64 | 68 | $range = range( Rating::MAX_RATING, 1 ); |
| 65 | 69 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
| 66 | 70 | $bars = array_reduce( $range, function( $carry, $level ) use( $percentages ) { |
@@ -110,7 +114,9 @@ discard block |
||
| 110 | 114 | */ |
| 111 | 115 | protected function buildRating() |
| 112 | 116 | { |
| 113 | - if( $this->isHidden( 'rating' ))return; |
|
| 117 | + if( $this->isHidden( 'rating' )) { |
|
| 118 | + return; |
|
| 119 | + } |
|
| 114 | 120 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
| 115 | 121 | } |
| 116 | 122 | |
@@ -119,7 +125,9 @@ discard block |
||
| 119 | 125 | */ |
| 120 | 126 | protected function buildStars() |
| 121 | 127 | { |
| 122 | - if( $this->isHidden( 'stars' ))return; |
|
| 128 | + if( $this->isHidden( 'stars' )) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 123 | 131 | $stars = glsr( Partial::class )->build( 'star-rating', [ |
| 124 | 132 | 'rating' => $this->averageRating, |
| 125 | 133 | ]); |
@@ -131,7 +139,9 @@ discard block |
||
| 131 | 139 | */ |
| 132 | 140 | protected function buildText() |
| 133 | 141 | { |
| 134 | - if( $this->isHidden( 'summary' ))return; |
|
| 142 | + if( $this->isHidden( 'summary' )) { |
|
| 143 | + return; |
|
| 144 | + } |
|
| 135 | 145 | $count = intval( array_sum( $this->ratingCounts )); |
| 136 | 146 | if( empty( $this->args['text'] )) { |
| 137 | 147 | // @todo document this change |
@@ -156,7 +166,9 @@ discard block |
||
| 156 | 166 | */ |
| 157 | 167 | protected function generateSchema() |
| 158 | 168 | { |
| 159 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 169 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 170 | + return; |
|
| 171 | + } |
|
| 160 | 172 | glsr( Schema::class )->store( |
| 161 | 173 | glsr( Schema::class )->buildSummary( $this->args ) |
| 162 | 174 | ); |
@@ -73,7 +73,9 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function decreasePostCounts( Review $review ) |
| 75 | 75 | { |
| 76 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
| 76 | + if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 77 | 79 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
| 78 | 80 | $this->setPostCounts( $review->assigned_to, $counts ); |
| 79 | 81 | } |
@@ -84,7 +86,9 @@ discard block |
||
| 84 | 86 | public function decreaseTermCounts( Review $review ) |
| 85 | 87 | { |
| 86 | 88 | foreach( $review->term_ids as $termId ) { |
| 87 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
| 89 | + if( empty( $counts = $this->getTermCounts( $termId ))) { |
|
| 90 | + continue; |
|
| 91 | + } |
|
| 88 | 92 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
| 89 | 93 | $this->setTermCounts( $termId, $counts ); |
| 90 | 94 | } |
@@ -106,7 +110,9 @@ discard block |
||
| 106 | 110 | 'min' => Rating::MIN_RATING, |
| 107 | 111 | ]); |
| 108 | 112 | foreach( $counts as $index => &$num ) { |
| 109 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
| 113 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
| 114 | + continue; |
|
| 115 | + } |
|
| 110 | 116 | $num = 0; |
| 111 | 117 | } |
| 112 | 118 | return $counts; |
@@ -128,7 +134,9 @@ discard block |
||
| 128 | 134 | } |
| 129 | 135 | foreach( $args['term_ids'] as $termId ) { |
| 130 | 136 | $term = get_term( $termId, Application::TAXONOMY ); |
| 131 | - if( !isset( $term->term_id ))continue; |
|
| 137 | + if( !isset( $term->term_id )) { |
|
| 138 | + continue; |
|
| 139 | + } |
|
| 132 | 140 | $counts[] = $this->getTermCounts( $termId ); |
| 133 | 141 | } |
| 134 | 142 | if( empty( $counts )) { |
@@ -193,7 +201,9 @@ discard block |
||
| 193 | 201 | */ |
| 194 | 202 | public function increasePostCounts( Review $review ) |
| 195 | 203 | { |
| 196 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
| 204 | + if( !( get_post( $review->assigned_to ) instanceof WP_Post )) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 197 | 207 | if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
| 198 | 208 | $counts = $this->buildPostCounts( $review->assigned_to ); |
| 199 | 209 | } |
@@ -207,7 +217,9 @@ discard block |
||
| 207 | 217 | public function increaseTermCounts( Review $review ) |
| 208 | 218 | { |
| 209 | 219 | foreach( $review->term_ids as $termId ) { |
| 210 | - if( !( get_term( $termId, Application::TAXONOMY ) instanceof WP_Term ))continue; |
|
| 220 | + if( !( get_term( $termId, Application::TAXONOMY ) instanceof WP_Term )) { |
|
| 221 | + continue; |
|
| 222 | + } |
|
| 211 | 223 | if( empty( $counts = $this->getTermCounts( $termId ))) { |
| 212 | 224 | $counts = $this->buildTermCounts( $termId ); |
| 213 | 225 | } |
@@ -242,7 +254,9 @@ discard block |
||
| 242 | 254 | */ |
| 243 | 255 | public function setTermCounts( $termId, array $reviewCounts ) |
| 244 | 256 | { |
| 245 | - if( !term_exists( $termId ))return; |
|
| 257 | + if( !term_exists( $termId )) { |
|
| 258 | + return; |
|
| 259 | + } |
|
| 246 | 260 | $ratingCounts = glsr( CountsManager::class )->flatten( $reviewCounts ); |
| 247 | 261 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
| 248 | 262 | update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
@@ -260,7 +274,9 @@ discard block |
||
| 260 | 274 | while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) { |
| 261 | 275 | $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
| 262 | 276 | foreach( $types as $type ) { |
| 263 | - if( isset( $counts[$type] ))continue; |
|
| 277 | + if( isset( $counts[$type] )) { |
|
| 278 | + continue; |
|
| 279 | + } |
|
| 264 | 280 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 265 | 281 | } |
| 266 | 282 | foreach( $reviews as $review ) { |
@@ -309,7 +325,9 @@ discard block |
||
| 309 | 325 | { |
| 310 | 326 | foreach( $reviewCounts as &$counts ) { |
| 311 | 327 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
| 312 | - if( isset( $counts[$index] ))continue; |
|
| 328 | + if( isset( $counts[$index] )) { |
|
| 329 | + continue; |
|
| 330 | + } |
|
| 313 | 331 | $counts[$index] = 0; |
| 314 | 332 | } |
| 315 | 333 | ksort( $counts ); |