@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $this->getCounts(), |
67 | 67 | $review->review_type, |
68 | 68 | $review->rating |
69 | - )); |
|
69 | + ) ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function decreasePostCounts( Review $review ) |
76 | 76 | { |
77 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
77 | + if( empty($counts = $this->getPostCounts( $review->assigned_to )) )return; |
|
78 | 78 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
79 | 79 | $this->setPostCounts( $review->assigned_to, $counts ); |
80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function decreaseTermCounts( Review $review ) |
86 | 86 | { |
87 | 87 | foreach( $review->term_ids as $termId ) { |
88 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
88 | + if( empty($counts = $this->getTermCounts( $termId )) )continue; |
|
89 | 89 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
90 | 90 | $this->setTermCounts( $termId, $counts ); |
91 | 91 | } |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | public function flatten( array $reviewCounts, array $args = [] ) |
98 | 98 | { |
99 | 99 | $counts = []; |
100 | - array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) { |
|
101 | - $counts[$index] = isset( $counts[$index] ) |
|
100 | + array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) { |
|
101 | + $counts[$index] = isset($counts[$index]) |
|
102 | 102 | ? $num + $counts[$index] |
103 | 103 | : $num; |
104 | 104 | }); |
105 | 105 | $args = wp_parse_args( $args, [ |
106 | 106 | 'max' => Rating::MAX_RATING, |
107 | 107 | 'min' => Rating::MIN_RATING, |
108 | - ]); |
|
108 | + ] ); |
|
109 | 109 | foreach( $counts as $index => &$num ) { |
110 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
110 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue; |
|
111 | 111 | $num = 0; |
112 | 112 | } |
113 | 113 | return $counts; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'post_ids' => [], |
123 | 123 | 'term_ids' => [], |
124 | 124 | 'type' => 'local', |
125 | - ]); |
|
125 | + ] ); |
|
126 | 126 | $counts = []; |
127 | 127 | foreach( glsr( Polylang::class )->getPostIds( $args['post_ids'] ) as $postId ) { |
128 | 128 | $counts[] = $this->getPostCounts( $postId ); |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | foreach( $args['term_ids'] as $termId ) { |
131 | 131 | $counts[] = $this->getTermCounts( $termId ); |
132 | 132 | } |
133 | - if( empty( $counts )) { |
|
133 | + if( empty($counts) ) { |
|
134 | 134 | $counts[] = $this->getCounts(); |
135 | 135 | } |
136 | - return $this->normalize( array_column( $counts, $args['type'] )); |
|
136 | + return $this->normalize( array_column( $counts, $args['type'] ) ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function getPostCounts( $postId ) |
152 | 152 | { |
153 | - return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true )); |
|
153 | + return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) ); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function getTermCounts( $termId ) |
161 | 161 | { |
162 | - return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true )); |
|
162 | + return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) ); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function increaseCounts( Review $review ) |
179 | 179 | { |
180 | - if( empty( $counts = $this->getCounts() )) { |
|
180 | + if( empty($counts = $this->getCounts()) ) { |
|
181 | 181 | $counts = $this->buildCounts(); |
182 | 182 | } |
183 | 183 | $this->setCounts( $this->increaseRating( |
184 | 184 | $counts, |
185 | 185 | $review->review_type, |
186 | 186 | $review->rating |
187 | - )); |
|
187 | + ) ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function increasePostCounts( Review $review ) |
194 | 194 | { |
195 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
195 | + if( !(get_post( $review->assigned_to ) instanceof WP_Post) )return; |
|
196 | 196 | $counts = $this->getPostCounts( $review->assigned_to ); |
197 | - $counts = empty( $counts ) |
|
197 | + $counts = empty($counts) |
|
198 | 198 | ? $this->buildPostCounts( $review->assigned_to ) |
199 | 199 | : $this->increaseRating( $counts, $review->review_type, $review->rating ); |
200 | 200 | $this->setPostCounts( $review->assigned_to, $counts ); |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function increaseTermCounts( Review $review ) |
207 | 207 | { |
208 | - $termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids )); |
|
208 | + $termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) ); |
|
209 | 209 | foreach( $termIds as $termId ) { |
210 | 210 | $counts = $this->getTermCounts( $termId ); |
211 | - $counts = empty( $counts ) |
|
211 | + $counts = empty($counts) |
|
212 | 212 | ? $this->buildTermCounts( $termId ) |
213 | 213 | : $this->increaseRating( $counts, $review->review_type, $review->rating ); |
214 | 214 | $this->setTermCounts( $termId, $counts ); |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | { |
232 | 232 | $ratingCounts = glsr( CountsManager::class )->flatten( $reviewCounts ); |
233 | 233 | update_post_meta( $postId, static::META_COUNT, $reviewCounts ); |
234 | - update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
|
235 | - update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts )); |
|
234 | + update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) ); |
|
235 | + update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) ); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function setTermCounts( $termId, array $reviewCounts ) |
243 | 243 | { |
244 | - if( !term_exists( $termId ))return; |
|
244 | + if( !term_exists( $termId ) )return; |
|
245 | 245 | $ratingCounts = glsr( CountsManager::class )->flatten( $reviewCounts ); |
246 | 246 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
247 | - update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
|
248 | - update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts )); |
|
247 | + update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) ); |
|
248 | + update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) ); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | { |
257 | 257 | $counts = []; |
258 | 258 | $lastPostId = 0; |
259 | - while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) { |
|
260 | - $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
|
259 | + while( $reviews = $this->queryReviews( $args, $lastPostId, $limit ) ) { |
|
260 | + $types = array_keys( array_flip( array_column( $reviews, 'type' ) ) ); |
|
261 | 261 | foreach( $types as $type ) { |
262 | - if( isset( $counts[$type] ))continue; |
|
262 | + if( isset($counts[$type]) )continue; |
|
263 | 263 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
264 | 264 | } |
265 | 265 | foreach( $reviews as $review ) { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | protected function decreaseRating( array $reviewCounts, $type, $rating ) |
279 | 279 | { |
280 | - if( isset( $reviewCounts[$type][$rating] )) { |
|
280 | + if( isset($reviewCounts[$type][$rating]) ) { |
|
281 | 281 | $reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 ); |
282 | 282 | } |
283 | 283 | return $reviewCounts; |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | */ |
291 | 291 | protected function increaseRating( array $reviewCounts, $type, $rating ) |
292 | 292 | { |
293 | - if( !array_key_exists( $type, glsr()->reviewTypes )) { |
|
293 | + if( !array_key_exists( $type, glsr()->reviewTypes ) ) { |
|
294 | 294 | return $reviewCounts; |
295 | 295 | } |
296 | - if( !array_key_exists( $type, $reviewCounts )) { |
|
296 | + if( !array_key_exists( $type, $reviewCounts ) ) { |
|
297 | 297 | $reviewCounts[$type] = []; |
298 | 298 | } |
299 | 299 | $reviewCounts = $this->normalize( $reviewCounts ); |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | */ |
307 | 307 | protected function normalize( array $reviewCounts ) |
308 | 308 | { |
309 | - if( empty( $reviewCounts )) { |
|
309 | + if( empty($reviewCounts) ) { |
|
310 | 310 | $reviewCounts = [[]]; |
311 | 311 | } |
312 | 312 | foreach( $reviewCounts as &$counts ) { |
313 | 313 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
314 | - if( isset( $counts[$index] ))continue; |
|
314 | + if( isset($counts[$index]) )continue; |
|
315 | 315 | $counts[$index] = 0; |
316 | 316 | } |
317 | 317 | ksort( $counts ); |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | */ |
327 | 327 | protected function queryReviews( array $args = [], $lastPostId, $limit ) |
328 | 328 | { |
329 | - $args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' )); |
|
330 | - if( empty( array_filter( $args ))) { |
|
329 | + $args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ) ); |
|
330 | + if( empty(array_filter( $args )) ) { |
|
331 | 331 | return glsr( SqlQueries::class )->getReviewCounts( $lastPostId, $limit ); |
332 | 332 | } |
333 | - if( !empty( $args['post_id'] )) { |
|
333 | + if( !empty($args['post_id']) ) { |
|
334 | 334 | return glsr( SqlQueries::class )->getReviewPostCounts( $args['post_id'], $lastPostId, $limit ); |
335 | 335 | } |
336 | - if( !empty( $args['term_id'] )) { |
|
336 | + if( !empty($args['term_id']) ) { |
|
337 | 337 | return glsr( SqlQueries::class )->getReviewTermCounts( $args['term_id'], $lastPostId, $limit ); |
338 | 338 | } |
339 | 339 | } |
@@ -74,7 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function decreasePostCounts( Review $review ) |
76 | 76 | { |
77 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
77 | + if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
|
78 | + return; |
|
79 | + } |
|
78 | 80 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
79 | 81 | $this->setPostCounts( $review->assigned_to, $counts ); |
80 | 82 | } |
@@ -85,7 +87,9 @@ discard block |
||
85 | 87 | public function decreaseTermCounts( Review $review ) |
86 | 88 | { |
87 | 89 | foreach( $review->term_ids as $termId ) { |
88 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
90 | + if( empty( $counts = $this->getTermCounts( $termId ))) { |
|
91 | + continue; |
|
92 | + } |
|
89 | 93 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
90 | 94 | $this->setTermCounts( $termId, $counts ); |
91 | 95 | } |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | 'min' => Rating::MIN_RATING, |
108 | 112 | ]); |
109 | 113 | foreach( $counts as $index => &$num ) { |
110 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
114 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
115 | + continue; |
|
116 | + } |
|
111 | 117 | $num = 0; |
112 | 118 | } |
113 | 119 | return $counts; |
@@ -192,7 +198,9 @@ discard block |
||
192 | 198 | */ |
193 | 199 | public function increasePostCounts( Review $review ) |
194 | 200 | { |
195 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
201 | + if( !( get_post( $review->assigned_to ) instanceof WP_Post )) { |
|
202 | + return; |
|
203 | + } |
|
196 | 204 | $counts = $this->getPostCounts( $review->assigned_to ); |
197 | 205 | $counts = empty( $counts ) |
198 | 206 | ? $this->buildPostCounts( $review->assigned_to ) |
@@ -241,7 +249,9 @@ discard block |
||
241 | 249 | */ |
242 | 250 | public function setTermCounts( $termId, array $reviewCounts ) |
243 | 251 | { |
244 | - if( !term_exists( $termId ))return; |
|
252 | + if( !term_exists( $termId )) { |
|
253 | + return; |
|
254 | + } |
|
245 | 255 | $ratingCounts = glsr( CountsManager::class )->flatten( $reviewCounts ); |
246 | 256 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
247 | 257 | update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
@@ -259,7 +269,9 @@ discard block |
||
259 | 269 | while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) { |
260 | 270 | $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
261 | 271 | foreach( $types as $type ) { |
262 | - if( isset( $counts[$type] ))continue; |
|
272 | + if( isset( $counts[$type] )) { |
|
273 | + continue; |
|
274 | + } |
|
263 | 275 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
264 | 276 | } |
265 | 277 | foreach( $reviews as $review ) { |
@@ -311,7 +323,9 @@ discard block |
||
311 | 323 | } |
312 | 324 | foreach( $reviewCounts as &$counts ) { |
313 | 325 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
314 | - if( isset( $counts[$index] ))continue; |
|
326 | + if( isset( $counts[$index] )) { |
|
327 | + continue; |
|
328 | + } |
|
315 | 329 | $counts[$index] = 0; |
316 | 330 | } |
317 | 331 | ksort( $counts ); |
@@ -28,22 +28,22 @@ discard block |
||
28 | 28 | public function __construct( $input ) |
29 | 29 | { |
30 | 30 | $this->request = $input; |
31 | - $this->ajax_request = isset( $input['ajax_request'] ); |
|
31 | + $this->ajax_request = isset($input['ajax_request']); |
|
32 | 32 | $this->assigned_to = $this->getNumeric( 'assign_to' ); |
33 | - $this->author = sanitize_text_field( $this->get( 'name' )); |
|
34 | - $this->avatar = get_avatar_url( $this->get( 'email' )); |
|
35 | - $this->blacklisted = isset( $input['blacklisted'] ); |
|
36 | - $this->category = sanitize_key( $this->get( 'category' )); |
|
37 | - $this->content = sanitize_textarea_field( $this->get( 'content' )); |
|
33 | + $this->author = sanitize_text_field( $this->get( 'name' ) ); |
|
34 | + $this->avatar = get_avatar_url( $this->get( 'email' ) ); |
|
35 | + $this->blacklisted = isset($input['blacklisted']); |
|
36 | + $this->category = sanitize_key( $this->get( 'category' ) ); |
|
37 | + $this->content = sanitize_textarea_field( $this->get( 'content' ) ); |
|
38 | 38 | $this->custom = $this->getCustom(); |
39 | - $this->email = sanitize_email( $this->get( 'email' )); |
|
40 | - $this->form_id = sanitize_key( $this->get( 'form_id' )); |
|
39 | + $this->email = sanitize_email( $this->get( 'email' ) ); |
|
40 | + $this->form_id = sanitize_key( $this->get( 'form_id' ) ); |
|
41 | 41 | $this->ip_address = $this->get( 'ip_address' ); |
42 | - $this->post_id = intval( $this->get( 'post_id' )); |
|
43 | - $this->rating = intval( $this->get( 'rating' )); |
|
42 | + $this->post_id = intval( $this->get( 'post_id' ) ); |
|
43 | + $this->rating = intval( $this->get( 'rating' ) ); |
|
44 | 44 | $this->referer = $this->get( 'referer' ); |
45 | - $this->terms = !empty( $input['terms'] ); |
|
46 | - $this->title = sanitize_text_field( $this->get( 'title' )); |
|
45 | + $this->terms = !empty($input['terms']); |
|
46 | + $this->title = sanitize_text_field( $this->get( 'title' ) ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function get( $key ) |
54 | 54 | { |
55 | - return isset( $this->request[$key] ) |
|
55 | + return isset($this->request[$key]) |
|
56 | 56 | ? (string)$this->request[$key] |
57 | 57 | : ''; |
58 | 58 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | ]; |
70 | 70 | $custom = $this->request; |
71 | 71 | foreach( $unset as $value ) { |
72 | - unset( $custom[$value] ); |
|
72 | + unset($custom[$value]); |
|
73 | 73 | } |
74 | 74 | return $custom; |
75 | 75 | } |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | public function getPost( $postId ) |
14 | 14 | { |
15 | 15 | if( $this->isEnabled() ) { |
16 | - $polylangPostId = pll_get_post( $postId, pll_get_post_language( get_the_ID() )); |
|
16 | + $polylangPostId = pll_get_post( $postId, pll_get_post_language( get_the_ID() ) ); |
|
17 | 17 | } |
18 | - if( !empty( $polylangPostId )) { |
|
18 | + if( !empty($polylangPostId) ) { |
|
19 | 19 | $postId = $polylangPostId; |
20 | 20 | } |
21 | - return get_post( intval( $postId )); |
|
21 | + return get_post( intval( $postId ) ); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | foreach( $this->cleanIds( $postIds ) as $postId ) { |
34 | 34 | $newPostIds = array_merge( |
35 | 35 | $newPostIds, |
36 | - array_values( pll_get_post_translations( $postId )) |
|
36 | + array_values( pll_get_post_translations( $postId ) ) |
|
37 | 37 | ); |
38 | 38 | } |
39 | 39 | return $this->cleanIds( $newPostIds ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | protected function cleanIds( array $postIds ) |
75 | 75 | { |
76 | - return array_filter( array_unique( $postIds )); |
|
76 | + return array_filter( array_unique( $postIds ) ); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | 'templates/form/submit-button', |
51 | 51 | 'templates/reviews-form', |
52 | 52 | ]; |
53 | - if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) { |
|
53 | + if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) { |
|
54 | 54 | return $view; |
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->path( $possibleView.'.php' )))continue; |
|
58 | + if( !file_exists( glsr()->path( $possibleView.'.php' ) ) )continue; |
|
59 | 59 | return $possibleView; |
60 | 60 | } |
61 | 61 | return $view; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function modifyField( Builder $instance ) |
90 | 90 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
91 | + if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return; |
|
92 | 92 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 93 | } |
94 | 94 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function customize( Builder $instance ) |
107 | 107 | { |
108 | - $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
|
108 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
109 | 109 | $key = $instance->tag.'_'.$args['type']; |
110 | - $classes = !isset( $this->fields[$key] ) |
|
110 | + $classes = !isset($this->fields[$key]) |
|
111 | 111 | ? $this->fields[$instance->tag] |
112 | 112 | : $this->fields[$key]; |
113 | 113 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $args = wp_parse_args( $instance->args, [ |
142 | 142 | 'is_public' => false, |
143 | 143 | 'is_raw' => false, |
144 | - ]); |
|
144 | + ] ); |
|
145 | 145 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
146 | 146 | return false; |
147 | 147 | } |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->path( $possibleView.'.php' )))continue; |
|
58 | + if( !file_exists( glsr()->path( $possibleView.'.php' ))) { |
|
59 | + continue; |
|
60 | + } |
|
59 | 61 | return $possibleView; |
60 | 62 | } |
61 | 63 | return $view; |
@@ -88,7 +90,9 @@ discard block |
||
88 | 90 | */ |
89 | 91 | public function modifyField( Builder $instance ) |
90 | 92 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
93 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) { |
|
94 | + return; |
|
95 | + } |
|
92 | 96 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
93 | 97 | } |
94 | 98 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | array_walk( $filenames, function( $file ) { |
27 | 27 | $className = str_replace( '.php', '', $file ); |
28 | 28 | $version = str_replace( 'Upgrade_', '', $className ); |
29 | - if( version_compare( glsr()->version, $version, '<' ))return; |
|
29 | + if( version_compare( glsr()->version, $version, '<' ) )return; |
|
30 | 30 | glsr( 'Modules\\Upgrader\\'.$className ); |
31 | 31 | }); |
32 | 32 | $this->updateVersion(); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | public function updateVersion() |
39 | 39 | { |
40 | 40 | $currentVersion = glsr( OptionManager::class )->get( 'version' ); |
41 | - if( version_compare( $currentVersion, glsr()->version, '<' )) { |
|
41 | + if( version_compare( $currentVersion, glsr()->version, '<' ) ) { |
|
42 | 42 | glsr( OptionManager::class )->set( 'version', glsr()->version ); |
43 | 43 | } |
44 | 44 | if( $currentVersion != glsr()->version ) { |
@@ -19,14 +19,18 @@ |
||
19 | 19 | $filenames = []; |
20 | 20 | $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' ); |
21 | 21 | foreach( $iterator as $fileinfo ) { |
22 | - if( !$fileinfo->isFile() )continue; |
|
22 | + if( !$fileinfo->isFile() ) { |
|
23 | + continue; |
|
24 | + } |
|
23 | 25 | $filenames[] = $fileinfo->getFilename(); |
24 | 26 | } |
25 | 27 | natsort( $filenames ); |
26 | 28 | array_walk( $filenames, function( $file ) { |
27 | 29 | $className = str_replace( '.php', '', $file ); |
28 | 30 | $version = str_replace( 'Upgrade_', '', $className ); |
29 | - if( version_compare( glsr()->version, $version, '<' ))return; |
|
31 | + if( version_compare( glsr()->version, $version, '<' )) { |
|
32 | + return; |
|
33 | + } |
|
30 | 34 | glsr( 'Modules\\Upgrader\\'.$className ); |
31 | 35 | }); |
32 | 36 | $this->updateVersion(); |
@@ -87,7 +87,9 @@ |
||
87 | 87 | 'webhook' => 'slack', |
88 | 88 | ]; |
89 | 89 | foreach( $notifications as $old => $new ) { |
90 | - if( $this->oldSettings['settings.general.notification'] != $old )continue; |
|
90 | + if( $this->oldSettings['settings.general.notification'] != $old ) { |
|
91 | + continue; |
|
92 | + } |
|
91 | 93 | $this->newSettings['settings.general.notifications'][] = $new; |
92 | 94 | } |
93 | 95 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $this->newSettings['settings.submissions'][] = 'terms'; |
44 | 44 | $this->migrateNotificationSettings(); |
45 | 45 | $this->migrateRecaptchaSettings(); |
46 | - glsr( OptionManager::class )->set( glsr( Helper::class )->convertDotNotationArray( $this->newSettings )); |
|
46 | + glsr( OptionManager::class )->set( glsr( Helper::class )->convertDotNotationArray( $this->newSettings ) ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | protected function getOldSettings() |
63 | 63 | { |
64 | - $settings = glsr( Helper::class )->flattenArray( get_option( Application::ID.'-v2', [] )); |
|
64 | + $settings = glsr( Helper::class )->flattenArray( get_option( Application::ID.'-v2', [] ) ); |
|
65 | 65 | return wp_parse_args( $settings, [ |
66 | 66 | 'settings.general.notification' => '', |
67 | 67 | 'settings.general.webhook_url' => '', |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 'settings.reviews-form.recaptcha.key' => $this->newSettings['submissions.recaptcha.key'], |
75 | 75 | 'settings.reviews-form.recaptcha.secret' => $this->newSettings['submissions.recaptcha.secret'], |
76 | 76 | 'settings.reviews-form.recaptcha.position' => $this->newSettings['submissions.recaptcha.position'], |
77 | - ]); |
|
77 | + ] ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | protected function migrateRecaptchaSettings() |
100 | 100 | { |
101 | - if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] )) { |
|
101 | + if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] ) ) { |
|
102 | 102 | $this->newSettings['settings.submissions.recaptcha.integration'] == 'all'; |
103 | 103 | } |
104 | 104 | if( $this->oldSettings['settings.reviews-form.recaptcha.integration'] == 'invisible-recaptcha' ) { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'BadgePosition' => $this->oldSettings['settings.reviews-form.recaptcha.position'], |
107 | 107 | 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
108 | 108 | 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
109 | - ]); |
|
109 | + ] ); |
|
110 | 110 | $this->newSettings['settings.submissions.recaptcha.key'] = $invisibleRecaptchaOptions['SiteKey']; |
111 | 111 | $this->newSettings['settings.submissions.recaptcha.secret'] = $invisibleRecaptchaOptions['SecretKey']; |
112 | 112 | $this->newSettings['settings.submissions.recaptcha.position'] = $invisibleRecaptchaOptions['BadgePosition']; |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | public function build( array $args = [] ) |
35 | 35 | { |
36 | 36 | $this->args = $args; |
37 | - $counts = glsr( CountsManager::class )->get([ |
|
37 | + $counts = glsr( CountsManager::class )->get( [ |
|
38 | 38 | 'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ), |
39 | 39 | 'term_ids' => glsr( Helper::class )->convertStringToArray( $args['category'] ), |
40 | - ]); |
|
40 | + ] ); |
|
41 | 41 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
42 | 42 | 'min' => $args['rating'], |
43 | - ]); |
|
44 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
43 | + ] ); |
|
44 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) )return; |
|
45 | 45 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
46 | 46 | $this->generateSchema(); |
47 | 47 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | 'stars' => $this->buildStars(), |
54 | 54 | 'text' => $this->buildText(), |
55 | 55 | ], |
56 | - ]); |
|
56 | + ] ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | */ |
62 | 62 | protected function buildPercentage() |
63 | 63 | { |
64 | - if( $this->isHidden( 'bars' ))return; |
|
65 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
|
66 | - $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) { |
|
64 | + if( $this->isHidden( 'bars' ) )return; |
|
65 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) ); |
|
66 | + $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use($percentages) { |
|
67 | 67 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
68 | 68 | $background = $this->buildPercentageBackground( $percentages[$level] ); |
69 | 69 | $percent = $this->buildPercentagePercent( $percentages[$level] ); |
70 | 70 | return $carry.glsr( Builder::class )->div( $label.$background.$percent, [ |
71 | 71 | 'class' => 'glsr-bar', |
72 | - ]); |
|
72 | + ] ); |
|
73 | 73 | }); |
74 | 74 | return $this->wrap( 'percentage', $bars ); |
75 | 75 | } |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function buildPercentageBackground( $percent ) |
82 | 82 | { |
83 | - $backgroundPercent = glsr( Builder::class )->span([ |
|
83 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
84 | 84 | 'class' => 'glsr-bar-background-percent', |
85 | 85 | 'style' => 'width:'.$percent, |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
88 | 88 | } |
89 | 89 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | protected function buildRating() |
112 | 112 | { |
113 | - if( $this->isHidden( 'rating' ))return; |
|
113 | + if( $this->isHidden( 'rating' ) )return; |
|
114 | 114 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
115 | 115 | } |
116 | 116 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected function buildStars() |
121 | 121 | { |
122 | - if( $this->isHidden( 'stars' ))return; |
|
122 | + if( $this->isHidden( 'stars' ) )return; |
|
123 | 123 | $stars = glsr( Partial::class )->build( 'star-rating', ['rating' => $this->averageRating] ); |
124 | 124 | return $this->wrap( 'stars', $stars ); |
125 | 125 | } |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | */ |
130 | 130 | protected function buildText() |
131 | 131 | { |
132 | - if( $this->isHidden( 'summary' ))return; |
|
133 | - $count = intval( array_sum( $this->ratingCounts )); |
|
134 | - if( empty( $this->args['text'] )) { |
|
132 | + if( $this->isHidden( 'summary' ) )return; |
|
133 | + $count = intval( array_sum( $this->ratingCounts ) ); |
|
134 | + if( empty($this->args['text']) ) { |
|
135 | 135 | // @todo document this change |
136 | 136 | $this->args['text'] = _nx( |
137 | 137 | '{rating} out of {max} stars (based on {num} review)', |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | ); |
143 | 143 | } |
144 | 144 | $summary = str_replace( |
145 | - ['{rating}','{max}', '{num}'], |
|
145 | + ['{rating}', '{max}', '{num}'], |
|
146 | 146 | [$this->averageRating, Rating::MAX_RATING, $count], |
147 | 147 | $this->args['text'] |
148 | 148 | ); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | protected function generateSchema() |
156 | 156 | { |
157 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
157 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
158 | 158 | glsr( Schema::class )->store( |
159 | 159 | glsr( Schema::class )->buildSummary( $this->args ) |
160 | 160 | ); |
@@ -186,6 +186,6 @@ discard block |
||
186 | 186 | { |
187 | 187 | return glsr( Builder::class )->div( $value, [ |
188 | 188 | 'class' => 'glsr-summary-'.$key, |
189 | - ]); |
|
189 | + ] ); |
|
190 | 190 | } |
191 | 191 | } |
@@ -41,7 +41,9 @@ discard block |
||
41 | 41 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
42 | 42 | 'min' => $args['rating'], |
43 | 43 | ]); |
44 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
44 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' )) { |
|
45 | + return; |
|
46 | + } |
|
45 | 47 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
46 | 48 | $this->generateSchema(); |
47 | 49 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -61,7 +63,9 @@ discard block |
||
61 | 63 | */ |
62 | 64 | protected function buildPercentage() |
63 | 65 | { |
64 | - if( $this->isHidden( 'bars' ))return; |
|
66 | + if( $this->isHidden( 'bars' )) { |
|
67 | + return; |
|
68 | + } |
|
65 | 69 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
66 | 70 | $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) { |
67 | 71 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
@@ -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', ['rating' => $this->averageRating] ); |
124 | 132 | return $this->wrap( 'stars', $stars ); |
125 | 133 | } |
@@ -129,7 +137,9 @@ discard block |
||
129 | 137 | */ |
130 | 138 | protected function buildText() |
131 | 139 | { |
132 | - if( $this->isHidden( 'summary' ))return; |
|
140 | + if( $this->isHidden( 'summary' )) { |
|
141 | + return; |
|
142 | + } |
|
133 | 143 | $count = intval( array_sum( $this->ratingCounts )); |
134 | 144 | if( empty( $this->args['text'] )) { |
135 | 145 | // @todo document this change |
@@ -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( |
159 | 171 | glsr( Schema::class )->buildSummary( $this->args ) |
160 | 172 | ); |
@@ -20,7 +20,9 @@ |
||
20 | 20 | public function build( array $args = [] ) |
21 | 21 | { |
22 | 22 | $this->args = $this->normalize( $args ); |
23 | - if( $this->args['total'] < 2 )return; |
|
23 | + if( $this->args['total'] < 2 ) { |
|
24 | + return; |
|
25 | + } |
|
24 | 26 | return glsr( Template::class )->build( 'templates/pagination', [ |
25 | 27 | 'context' => [ |
26 | 28 | 'links' => apply_filters( 'site-reviews/paginate_links', $this->buildLinks(), $this->args ), |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'loader' => '<div class="glsr-loader"></div>', |
28 | 28 | 'screen_reader_text' => __( 'Site Reviews navigation', 'site-reviews' ), |
29 | 29 | ], |
30 | - ]); |
|
30 | + ] ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | */ |
36 | 36 | protected function buildLinks() |
37 | 37 | { |
38 | - $args = glsr( Style::class )->paginationArgs([ |
|
38 | + $args = glsr( Style::class )->paginationArgs( [ |
|
39 | 39 | 'current' => $this->args['paged'], |
40 | 40 | 'total' => $this->args['total'], |
41 | - ]); |
|
41 | + ] ); |
|
42 | 42 | if( is_front_page() ) { |
43 | - unset( $args['format'] ); |
|
43 | + unset($args['format']); |
|
44 | 44 | } |
45 | 45 | if( $args['type'] == 'array' ) { |
46 | 46 | $args['type'] = 'plain'; |
@@ -56,6 +56,6 @@ discard block |
||
56 | 56 | return wp_parse_args( $args, [ |
57 | 57 | 'paged' => glsr( QueryBuilder::class )->getPaged(), |
58 | 58 | 'total' => 1, |
59 | - ]); |
|
59 | + ] ); |
|
60 | 60 | } |
61 | 61 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'navigation' => $navigation, |
58 | 58 | 'reviews' => $this->buildReviews(), |
59 | 59 | ], |
60 | - ]); |
|
60 | + ] ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | $reviews = ''; |
69 | 69 | foreach( $this->reviews->results as $index => $result ) { |
70 | 70 | $this->current = $index; |
71 | - $reviews.= glsr( Template::class )->build( 'templates/review', [ |
|
71 | + $reviews .= glsr( Template::class )->build( 'templates/review', [ |
|
72 | 72 | 'context' => $this->buildReview( $result )->values, |
73 | - ]); |
|
73 | + ] ); |
|
74 | 74 | } |
75 | 75 | return $reviews; |
76 | 76 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $renderedFields = []; |
86 | 86 | foreach( $review as $key => $value ) { |
87 | 87 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
88 | - if( !method_exists( $this, $method ))continue; |
|
88 | + if( !method_exists( $this, $method ) )continue; |
|
89 | 89 | $renderedFields[$key] = $this->$method( $key, $value ); |
90 | 90 | } |
91 | 91 | $renderedFields = apply_filters( 'site-reviews/review/build/after', (array)$renderedFields ); |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | */ |
100 | 100 | protected function buildOptionAssignedTo( $key, $value ) |
101 | 101 | { |
102 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
102 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return; |
|
103 | 103 | $post = glsr( Polylang::class )->getPost( $value ); |
104 | - if( !( $post instanceof WP_Post ))return; |
|
104 | + if( !($post instanceof WP_Post) )return; |
|
105 | 105 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
106 | 106 | 'href' => get_the_permalink( $post->ID ), |
107 | - ]); |
|
107 | + ] ); |
|
108 | 108 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
109 | 109 | return $this->wrap( $key, '<span>'.$assignedTo.'</span>' ); |
110 | 110 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function buildOptionAuthor( $key, $value ) |
118 | 118 | { |
119 | - if( $this->isHidden( $key ))return; |
|
119 | + if( $this->isHidden( $key ) )return; |
|
120 | 120 | return $this->wrap( $key, '<span>'.$value.'</span>' ); |
121 | 121 | } |
122 | 122 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildOptionAvatar( $key, $value ) |
129 | 129 | { |
130 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
130 | + if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return; |
|
131 | 131 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
132 | - return $this->wrap( $key, glsr( Builder::class )->img([ |
|
132 | + return $this->wrap( $key, glsr( Builder::class )->img( [ |
|
133 | 133 | 'src' => $this->generateAvatar( $value ), |
134 | 134 | 'height' => $size, |
135 | 135 | 'width' => $size, |
136 | - ])); |
|
136 | + ] ) ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | protected function buildOptionContent( $key, $value ) |
145 | 145 | { |
146 | 146 | $text = $this->normalizeText( $value ); |
147 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
147 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
148 | 148 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
149 | 149 | } |
150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | protected function buildOptionDate( $key, $value ) |
157 | 157 | { |
158 | - if( $this->isHidden( $key ))return; |
|
158 | + if( $this->isHidden( $key ) )return; |
|
159 | 159 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
160 | 160 | if( $dateFormat == 'relative' ) { |
161 | 161 | $date = glsr( Date::class )->relative( $value ); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $format = $dateFormat == 'custom' |
165 | 165 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
166 | 166 | : (string)get_option( 'date_format' ); |
167 | - $date = date_i18n( $format, strtotime( $value )); |
|
167 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
168 | 168 | } |
169 | 169 | return $this->wrap( $key, '<span>'.$date.'</span>' ); |
170 | 170 | } |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function buildOptionRating( $key, $value ) |
178 | 178 | { |
179 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
179 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
180 | 180 | $rating = glsr( Partial::class )->build( 'star-rating', [ |
181 | 181 | 'rating' => $value, |
182 | - ]); |
|
182 | + ] ); |
|
183 | 183 | return $this->wrap( $key, $rating ); |
184 | 184 | } |
185 | 185 | |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | protected function buildOptionResponse( $key, $value ) |
192 | 192 | { |
193 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
194 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
193 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
194 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
195 | 195 | $text = $this->normalizeText( $value ); |
196 | 196 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
197 | 197 | return $this->wrap( $key, |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | protected function buildOptionTitle( $key, $value ) |
209 | 209 | { |
210 | - if( $this->isHidden( $key ))return; |
|
211 | - if( empty( $value )) { |
|
210 | + if( $this->isHidden( $key ) )return; |
|
211 | + if( empty($value) ) { |
|
212 | 212 | $value = __( 'No Title', 'site-reviews' ); |
213 | 213 | } |
214 | 214 | return $this->wrap( $key, '<h3>'.$value.'</h3>' ); |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | return $avatarUrl; |
226 | 226 | } |
227 | 227 | $authorIdOrEmail = get_the_author_meta( 'ID', $review->user_id ); |
228 | - if( empty( $authorIdOrEmail )) { |
|
228 | + if( empty($authorIdOrEmail) ) { |
|
229 | 229 | $authorIdOrEmail = $review->email; |
230 | 230 | } |
231 | - if( $newAvatar = get_avatar_url( $authorIdOrEmail )) { |
|
231 | + if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) { |
|
232 | 232 | return $newAvatar; |
233 | 233 | } |
234 | 234 | return $avatarUrl; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | protected function generateSchema() |
241 | 241 | { |
242 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
242 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
243 | 243 | glsr( Schema::class )->store( |
244 | 244 | glsr( Schema::class )->build( $this->args ) |
245 | 245 | ); |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | */ |
263 | 263 | protected function getExcerpt( $text ) |
264 | 264 | { |
265 | - $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 )); |
|
265 | + $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) ); |
|
266 | 266 | $split = extension_loaded( 'intl' ) |
267 | 267 | ? $this->getExcerptIntlSplit( $text, $limit ) |
268 | 268 | : $this->getExcerptSplit( $text, $limit ); |
269 | 269 | $hiddenText = substr( $text, $split ); |
270 | - if( !empty( $hiddenText )) { |
|
270 | + if( !empty($hiddenText) ) { |
|
271 | 271 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
272 | 272 | 'class' => 'glsr-hidden glsr-hidden-text', |
273 | 273 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
274 | 274 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
275 | - ]); |
|
276 | - $text = ltrim( substr( $text, 0, $split )).$showMore; |
|
275 | + ] ); |
|
276 | + $text = ltrim( substr( $text, 0, $split ) ).$showMore; |
|
277 | 277 | } |
278 | 278 | return nl2br( $text ); |
279 | 279 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $words = IntlRuleBasedBreakIterator::createWordInstance( '' ); |
289 | 289 | $words->setText( $text ); |
290 | 290 | $count = 0; |
291 | - foreach( $words as $offset ){ |
|
291 | + foreach( $words as $offset ) { |
|
292 | 292 | if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
293 | 293 | $count++; |
294 | 294 | if( $count != $limit )continue; |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | protected function getExcerptSplit( $text, $limit ) |
306 | 306 | { |
307 | 307 | if( str_word_count( $text, 0 ) > $limit ) { |
308 | - $words = array_keys( str_word_count( $text, 2 )); |
|
308 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
309 | 309 | return $words[$limit]; |
310 | 310 | } |
311 | 311 | return strlen( $text ); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | protected function getOption( $path, $fallback = '' ) |
320 | 320 | { |
321 | - if( array_key_exists( $path, $this->options )) { |
|
321 | + if( array_key_exists( $path, $this->options ) ) { |
|
322 | 322 | return $this->options[$path]; |
323 | 323 | } |
324 | 324 | return $fallback; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | protected function isHidden( $key, $path = '' ) |
333 | 333 | { |
334 | - $isOptionEnabled = !empty( $path ) |
|
334 | + $isOptionEnabled = !empty($path) |
|
335 | 335 | ? $this->isOptionEnabled( $path ) |
336 | 336 | : true; |
337 | 337 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | protected function isHiddenOrEmpty( $key, $value ) |
346 | 346 | { |
347 | - return $this->isHidden( $key ) || empty( $value ); |
|
347 | + return $this->isHidden( $key ) || empty($value); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -363,10 +363,10 @@ discard block |
||
363 | 363 | protected function normalizeText( $text ) |
364 | 364 | { |
365 | 365 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
366 | - $text = convert_smilies( strip_shortcodes( $text )); |
|
366 | + $text = convert_smilies( strip_shortcodes( $text ) ); |
|
367 | 367 | $text = str_replace( ']]>', ']]>', $text ); |
368 | 368 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
369 | - if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) { |
|
369 | + if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) { |
|
370 | 370 | $text = $this->getExcerpt( $text ); |
371 | 371 | } |
372 | 372 | return wptexturize( $text ); |
@@ -381,6 +381,6 @@ discard block |
||
381 | 381 | { |
382 | 382 | return glsr( Builder::class )->div( $value, [ |
383 | 383 | 'class' => 'glsr-review-'.$key, |
384 | - ]); |
|
384 | + ] ); |
|
385 | 385 | } |
386 | 386 | } |
@@ -85,7 +85,9 @@ discard block |
||
85 | 85 | $renderedFields = []; |
86 | 86 | foreach( $review as $key => $value ) { |
87 | 87 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
88 | - if( !method_exists( $this, $method ))continue; |
|
88 | + if( !method_exists( $this, $method )) { |
|
89 | + continue; |
|
90 | + } |
|
89 | 91 | $renderedFields[$key] = $this->$method( $key, $value ); |
90 | 92 | } |
91 | 93 | $renderedFields = apply_filters( 'site-reviews/review/build/after', (array)$renderedFields ); |
@@ -99,9 +101,13 @@ discard block |
||
99 | 101 | */ |
100 | 102 | protected function buildOptionAssignedTo( $key, $value ) |
101 | 103 | { |
102 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
104 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) { |
|
105 | + return; |
|
106 | + } |
|
103 | 107 | $post = glsr( Polylang::class )->getPost( $value ); |
104 | - if( !( $post instanceof WP_Post ))return; |
|
108 | + if( !( $post instanceof WP_Post )) { |
|
109 | + return; |
|
110 | + } |
|
105 | 111 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
106 | 112 | 'href' => get_the_permalink( $post->ID ), |
107 | 113 | ]); |
@@ -116,7 +122,9 @@ discard block |
||
116 | 122 | */ |
117 | 123 | protected function buildOptionAuthor( $key, $value ) |
118 | 124 | { |
119 | - if( $this->isHidden( $key ))return; |
|
125 | + if( $this->isHidden( $key )) { |
|
126 | + return; |
|
127 | + } |
|
120 | 128 | return $this->wrap( $key, '<span>'.$value.'</span>' ); |
121 | 129 | } |
122 | 130 | |
@@ -127,7 +135,9 @@ discard block |
||
127 | 135 | */ |
128 | 136 | protected function buildOptionAvatar( $key, $value ) |
129 | 137 | { |
130 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
138 | + if( $this->isHidden( $key, 'settings.reviews.avatars' )) { |
|
139 | + return; |
|
140 | + } |
|
131 | 141 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
132 | 142 | return $this->wrap( $key, glsr( Builder::class )->img([ |
133 | 143 | 'src' => $this->generateAvatar( $value ), |
@@ -144,7 +154,9 @@ discard block |
||
144 | 154 | protected function buildOptionContent( $key, $value ) |
145 | 155 | { |
146 | 156 | $text = $this->normalizeText( $value ); |
147 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
157 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
158 | + return; |
|
159 | + } |
|
148 | 160 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
149 | 161 | } |
150 | 162 | |
@@ -155,7 +167,9 @@ discard block |
||
155 | 167 | */ |
156 | 168 | protected function buildOptionDate( $key, $value ) |
157 | 169 | { |
158 | - if( $this->isHidden( $key ))return; |
|
170 | + if( $this->isHidden( $key )) { |
|
171 | + return; |
|
172 | + } |
|
159 | 173 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
160 | 174 | if( $dateFormat == 'relative' ) { |
161 | 175 | $date = glsr( Date::class )->relative( $value ); |
@@ -176,7 +190,9 @@ discard block |
||
176 | 190 | */ |
177 | 191 | protected function buildOptionRating( $key, $value ) |
178 | 192 | { |
179 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
193 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
194 | + return; |
|
195 | + } |
|
180 | 196 | $rating = glsr( Partial::class )->build( 'star-rating', [ |
181 | 197 | 'rating' => $value, |
182 | 198 | ]); |
@@ -190,7 +206,9 @@ discard block |
||
190 | 206 | */ |
191 | 207 | protected function buildOptionResponse( $key, $value ) |
192 | 208 | { |
193 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
209 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
210 | + return; |
|
211 | + } |
|
194 | 212 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
195 | 213 | $text = $this->normalizeText( $value ); |
196 | 214 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -207,7 +225,9 @@ discard block |
||
207 | 225 | */ |
208 | 226 | protected function buildOptionTitle( $key, $value ) |
209 | 227 | { |
210 | - if( $this->isHidden( $key ))return; |
|
228 | + if( $this->isHidden( $key )) { |
|
229 | + return; |
|
230 | + } |
|
211 | 231 | if( empty( $value )) { |
212 | 232 | $value = __( 'No Title', 'site-reviews' ); |
213 | 233 | } |
@@ -239,7 +259,9 @@ discard block |
||
239 | 259 | */ |
240 | 260 | protected function generateSchema() |
241 | 261 | { |
242 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
262 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
263 | + return; |
|
264 | + } |
|
243 | 265 | glsr( Schema::class )->store( |
244 | 266 | glsr( Schema::class )->build( $this->args ) |
245 | 267 | ); |
@@ -289,9 +311,13 @@ discard block |
||
289 | 311 | $words->setText( $text ); |
290 | 312 | $count = 0; |
291 | 313 | foreach( $words as $offset ){ |
292 | - if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
|
314 | + if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) { |
|
315 | + continue; |
|
316 | + } |
|
293 | 317 | $count++; |
294 | - if( $count != $limit )continue; |
|
318 | + if( $count != $limit ) { |
|
319 | + continue; |
|
320 | + } |
|
295 | 321 | return $offset; |
296 | 322 | } |
297 | 323 | return strlen( $text ); |