@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | $generatedReview = []; |
| 75 | 75 | foreach( $review as $key => $value ) { |
| 76 | 76 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
| 77 | - if( !method_exists( $this, $method ))continue; |
|
| 77 | + if( !method_exists( $this, $method )) { |
|
| 78 | + continue; |
|
| 79 | + } |
|
| 78 | 80 | $generatedReview[$key] = $this->$method( $key, $value ); |
| 79 | 81 | } |
| 80 | 82 | return (object)$generatedReview; |
@@ -87,9 +89,13 @@ discard block |
||
| 87 | 89 | */ |
| 88 | 90 | protected function buildOptionAssignedTo( $key, $value ) |
| 89 | 91 | { |
| 90 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
| 92 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' )) { |
|
| 93 | + return; |
|
| 94 | + } |
|
| 91 | 95 | $post = get_post( intval( $value )); |
| 92 | - if( !( $post instanceof WP_Post ))return; |
|
| 96 | + if( !( $post instanceof WP_Post )) { |
|
| 97 | + return; |
|
| 98 | + } |
|
| 93 | 99 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 94 | 100 | 'href' => get_the_permalink( $post->ID ), |
| 95 | 101 | ]); |
@@ -104,7 +110,9 @@ discard block |
||
| 104 | 110 | */ |
| 105 | 111 | protected function buildOptionAuthor( $key, $value ) |
| 106 | 112 | { |
| 107 | - if( $this->isHidden( $key ))return; |
|
| 113 | + if( $this->isHidden( $key )) { |
|
| 114 | + return; |
|
| 115 | + } |
|
| 108 | 116 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
| 109 | 117 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
| 110 | 118 | : ''; |
@@ -118,7 +126,9 @@ discard block |
||
| 118 | 126 | */ |
| 119 | 127 | protected function buildOptionAvatar( $key, $value ) |
| 120 | 128 | { |
| 121 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
| 129 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) { |
|
| 130 | + return; |
|
| 131 | + } |
|
| 122 | 132 | $size = $this->getOption( 'settings.reviews.avatars.size', 36 ); |
| 123 | 133 | return $this->wrap( $key, glsr( Builder::class )->img([ |
| 124 | 134 | 'src' => $value, |
@@ -135,7 +145,9 @@ discard block |
||
| 135 | 145 | protected function buildOptionContent( $key, $value ) |
| 136 | 146 | { |
| 137 | 147 | $text = $this->normalizeText( $value ); |
| 138 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 148 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 139 | 151 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
| 140 | 152 | } |
| 141 | 153 | |
@@ -146,7 +158,9 @@ discard block |
||
| 146 | 158 | */ |
| 147 | 159 | protected function buildOptionDate( $key, $value ) |
| 148 | 160 | { |
| 149 | - if( $this->isHidden( $key ))return; |
|
| 161 | + if( $this->isHidden( $key )) { |
|
| 162 | + return; |
|
| 163 | + } |
|
| 150 | 164 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 151 | 165 | if( $dateFormat == 'relative' ) { |
| 152 | 166 | $date = glsr( Date::class )->relative( $value ); |
@@ -167,7 +181,9 @@ discard block |
||
| 167 | 181 | */ |
| 168 | 182 | protected function buildOptionRating( $key, $value ) |
| 169 | 183 | { |
| 170 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 184 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 185 | + return; |
|
| 186 | + } |
|
| 171 | 187 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 172 | 188 | 'rating' => $value, |
| 173 | 189 | ]); |
@@ -181,7 +197,9 @@ discard block |
||
| 181 | 197 | */ |
| 182 | 198 | protected function buildOptionResponse( $key, $value ) |
| 183 | 199 | { |
| 184 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 200 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 201 | + return; |
|
| 202 | + } |
|
| 185 | 203 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
| 186 | 204 | $text = $this->normalizeText( $value ); |
| 187 | 205 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -198,7 +216,9 @@ discard block |
||
| 198 | 216 | */ |
| 199 | 217 | protected function buildOptionTitle( $key, $value ) |
| 200 | 218 | { |
| 201 | - if( $this->isHidden( $key ))return; |
|
| 219 | + if( $this->isHidden( $key )) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 202 | 222 | if( empty( $value )) { |
| 203 | 223 | $value = __( 'No Title', 'site-reviews' ); |
| 204 | 224 | } |
@@ -210,7 +230,9 @@ discard block |
||
| 210 | 230 | */ |
| 211 | 231 | protected function generateSchema() |
| 212 | 232 | { |
| 213 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 233 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 234 | + return; |
|
| 235 | + } |
|
| 214 | 236 | glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args )); |
| 215 | 237 | } |
| 216 | 238 | |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $this->args = $args; |
| 36 | 36 | $this->reviews = glsr( Database::class )->getReviews( $args )->results; |
| 37 | - if( empty( $this->reviews ) && $this->isHidden( 'if_empty' ))return; |
|
| 37 | + if( empty( $this->reviews ) && $this->isHidden( 'if_empty' )) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 38 | 40 | $this->rating = glsr( Rating::class )->getAverage( $this->reviews ); |
| 39 | 41 | $this->generateSchema(); |
| 40 | 42 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | */ |
| 55 | 57 | protected function buildPercentage() |
| 56 | 58 | { |
| 57 | - if( $this->isHidden( 'bars' ))return; |
|
| 59 | + if( $this->isHidden( 'bars' )) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 58 | 62 | $range = range( Rating::MAX_RATING, 1 ); |
| 59 | 63 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews )); |
| 60 | 64 | $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->rating.'</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 | // 'number' => count( $this->reviews ), |
| 125 | 133 | 'rating' => $this->rating, |
@@ -132,7 +140,9 @@ discard block |
||
| 132 | 140 | */ |
| 133 | 141 | protected function buildText() |
| 134 | 142 | { |
| 135 | - if( $this->isHidden( 'summary' ))return; |
|
| 143 | + if( $this->isHidden( 'summary' )) { |
|
| 144 | + return; |
|
| 145 | + } |
|
| 136 | 146 | $count = count( $this->reviews ); |
| 137 | 147 | if( empty( $this->args['text'] )) { |
| 138 | 148 | $this->args['text'] = _nx( |
@@ -153,7 +163,9 @@ discard block |
||
| 153 | 163 | */ |
| 154 | 164 | protected function generateSchema() |
| 155 | 165 | { |
| 156 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 166 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 157 | 169 | glsr( Schema::class )->store( glsr( Schema::class )->buildSummary( $this->args )); |
| 158 | 170 | } |
| 159 | 171 | |