@@ -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 | glsr_debug( $args ); |
@@ -55,7 +57,9 @@ discard block |
||
55 | 57 | */ |
56 | 58 | protected function buildPercentage() |
57 | 59 | { |
58 | - if( $this->isHidden( 'bars' ))return; |
|
60 | + if( $this->isHidden( 'bars' )) { |
|
61 | + return; |
|
62 | + } |
|
59 | 63 | $range = range( Rating::MAX_RATING, 1 ); |
60 | 64 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews )); |
61 | 65 | $bars = array_reduce( $range, function( $carry, $level ) use( $percentages ) { |
@@ -111,7 +115,9 @@ discard block |
||
111 | 115 | */ |
112 | 116 | protected function buildRating() |
113 | 117 | { |
114 | - if( $this->isHidden( 'rating' ))return; |
|
118 | + if( $this->isHidden( 'rating' )) { |
|
119 | + return; |
|
120 | + } |
|
115 | 121 | return $this->wrap( 'rating', '<span>'.$this->rating.'</span>' ); |
116 | 122 | } |
117 | 123 | |
@@ -120,7 +126,9 @@ discard block |
||
120 | 126 | */ |
121 | 127 | protected function buildStars() |
122 | 128 | { |
123 | - if( $this->isHidden( 'stars' ))return; |
|
129 | + if( $this->isHidden( 'stars' )) { |
|
130 | + return; |
|
131 | + } |
|
124 | 132 | $stars = glsr( Partial::class )->build( 'star-rating', [ |
125 | 133 | 'number' => count( $this->reviews ), |
126 | 134 | 'rating' => $this->rating, |
@@ -133,7 +141,9 @@ discard block |
||
133 | 141 | */ |
134 | 142 | protected function buildText() |
135 | 143 | { |
136 | - if( $this->isHidden( 'summary' ))return; |
|
144 | + if( $this->isHidden( 'summary' )) { |
|
145 | + return; |
|
146 | + } |
|
137 | 147 | $count = count( $this->reviews ); |
138 | 148 | if( empty( $this->args['text'] )) { |
139 | 149 | $this->args['text'] = _nx( |
@@ -154,7 +164,9 @@ discard block |
||
154 | 164 | */ |
155 | 165 | protected function generateSchema() |
156 | 166 | { |
157 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
167 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
168 | + return; |
|
169 | + } |
|
158 | 170 | glsr( Schema::class )->store( glsr( Schema::class )->buildSummary( $this->args )); |
159 | 171 | } |
160 | 172 |
@@ -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 |