@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | sort( $newTTIds ); |
| 28 | 28 | sort( $oldTTIds ); |
| 29 | - if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId ))return; |
|
| 29 | + if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId )) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 30 | 32 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 31 | 33 | $ignoredIds = array_intersect( $oldTTIds, $newTTIds ); |
| 32 | 34 | $decreasedIds = array_diff( $oldTTIds, $ignoredIds ); |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | */ |
| 49 | 51 | public function onAfterChangeStatus( $newStatus, $oldStatus, $post ) |
| 50 | 52 | { |
| 51 | - if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 53 | + if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
| 54 | + return; |
|
| 55 | + } |
|
| 52 | 56 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
| 53 | 57 | if( $post->post_status == 'publish' ) { |
| 54 | 58 | glsr( CountsManager::class )->increase( $review ); |
@@ -64,7 +68,9 @@ discard block |
||
| 64 | 68 | */ |
| 65 | 69 | public function onAfterCreate( Review $review ) |
| 66 | 70 | { |
| 67 | - if( $review->status !== 'publish' )return; |
|
| 71 | + if( $review->status !== 'publish' ) { |
|
| 72 | + return; |
|
| 73 | + } |
|
| 68 | 74 | glsr( CountsManager::class )->increase( $review ); |
| 69 | 75 | } |
| 70 | 76 | |
@@ -75,7 +81,9 @@ discard block |
||
| 75 | 81 | */ |
| 76 | 82 | public function onBeforeDelete( $postId ) |
| 77 | 83 | { |
| 78 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 84 | + if( !$this->isReviewPostId( $postId )) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 79 | 87 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 80 | 88 | glsr( CountsManager::class )->decrease( $review ); |
| 81 | 89 | } |
@@ -92,9 +100,13 @@ discard block |
||
| 92 | 100 | { |
| 93 | 101 | if( !$this->isReviewPostId( $postId ) |
| 94 | 102 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 95 | - )return; |
|
| 103 | + ) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 96 | 106 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 97 | - if( $review->$metaKey == $metaValue )return; |
|
| 107 | + if( $review->$metaKey == $metaValue ) { |
|
| 108 | + return; |
|
| 109 | + } |
|
| 98 | 110 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 99 | 111 | call_user_func( [$this, $method], $review, $metaValue ); |
| 100 | 112 | } |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function renderTaxonomyFilter() |
| 37 | 37 | { |
| 38 | - if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ))return; |
|
| 38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY )) { |
|
| 39 | + return; |
|
| 40 | + } |
|
| 39 | 41 | echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
| 40 | 42 | 'class' => 'screen-reader-text', |
| 41 | 43 | 'for' => Application::TAXONOMY, |
@@ -67,7 +69,9 @@ discard block |
||
| 67 | 69 | */ |
| 68 | 70 | public function restrictTermSelection( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds ) |
| 69 | 71 | { |
| 70 | - if( $taxonomy != Application::TAXONOMY || count( $newTTIds ) <= 1 )return; |
|
| 72 | + if( $taxonomy != Application::TAXONOMY || count( $newTTIds ) <= 1 ) { |
|
| 73 | + return; |
|
| 74 | + } |
|
| 71 | 75 | $diff = array_diff( $newTTIds, $oldTTIds ); |
| 72 | 76 | if( empty( $newTerm = array_shift( $diff ))) { |
| 73 | 77 | $newTerm = array_shift( $newTTIds ); |
@@ -72,7 +72,9 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function send() |
| 74 | 74 | { |
| 75 | - if( !$this->message || !$this->subject || !$this->to )return; |
|
| 75 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 76 | 78 | add_action( 'wp_mail_failed', [$this, 'logMailError']); |
| 77 | 79 | $sent = wp_mail( |
| 78 | 80 | $this->to, |
@@ -92,8 +94,12 @@ discard block |
||
| 92 | 94 | */ |
| 93 | 95 | public function buildPlainTextMessage( PHPMailer $phpmailer ) |
| 94 | 96 | { |
| 95 | - if( empty( $this->email ))return; |
|
| 96 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 97 | + if( empty( $this->email )) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 100 | + if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody )) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 97 | 103 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 98 | 104 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 99 | 105 | } |
@@ -43,7 +43,9 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function send( Review $review ) |
| 45 | 45 | { |
| 46 | - if( empty( $this->types ))return; |
|
| 46 | + if( empty( $this->types )) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 47 | 49 | $this->review = $review; |
| 48 | 50 | $args = [ |
| 49 | 51 | 'link' => $this->getLink(), |
@@ -158,7 +160,9 @@ discard block |
||
| 158 | 160 | */ |
| 159 | 161 | protected function sendToSlack( array $args ) |
| 160 | 162 | { |
| 161 | - if( !$this->slack )return; |
|
| 163 | + if( !$this->slack ) { |
|
| 164 | + return; |
|
| 165 | + } |
|
| 162 | 166 | $notification = $this->buildSlackNotification( $args ); |
| 163 | 167 | $result = $notification->send(); |
| 164 | 168 | if( is_wp_error( $result )) { |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | $types = array_unique( array_merge( ['local'], $types )); |
| 35 | 35 | foreach( $types as $type ) { |
| 36 | 36 | $type = $this->normalizeType( $type ); |
| 37 | - if( isset( $counts[$type] ))continue; |
|
| 37 | + if( isset( $counts[$type] )) { |
|
| 38 | + continue; |
|
| 39 | + } |
|
| 38 | 40 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 39 | 41 | } |
| 40 | 42 | foreach( $query->reviews as $review ) { |
@@ -109,7 +111,9 @@ discard block |
||
| 109 | 111 | */ |
| 110 | 112 | public function decreasePostCounts( Review $review ) |
| 111 | 113 | { |
| 112 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
| 114 | + if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
|
| 115 | + return; |
|
| 116 | + } |
|
| 113 | 117 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
| 114 | 118 | $this->setPostCounts( $review->assigned_to, $counts ); |
| 115 | 119 | } |
@@ -120,7 +124,9 @@ discard block |
||
| 120 | 124 | public function decreaseTermCounts( Review $review ) |
| 121 | 125 | { |
| 122 | 126 | foreach( $review->term_ids as $termId ) { |
| 123 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
| 127 | + if( empty( $counts = $this->getTermCounts( $termId ))) { |
|
| 128 | + continue; |
|
| 129 | + } |
|
| 124 | 130 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
| 125 | 131 | $this->setTermCounts( $termId, $counts ); |
| 126 | 132 | } |
@@ -140,7 +146,9 @@ discard block |
||
| 140 | 146 | 'min' => Rating::MIN_RATING, |
| 141 | 147 | ]); |
| 142 | 148 | foreach( $counts as $index => &$num ) { |
| 143 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
| 149 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
| 150 | + continue; |
|
| 151 | + } |
|
| 144 | 152 | $num = 0; |
| 145 | 153 | } |
| 146 | 154 | return $counts; |
@@ -229,7 +237,9 @@ discard block |
||
| 229 | 237 | */ |
| 230 | 238 | public function increasePostCounts( Review $review ) |
| 231 | 239 | { |
| 232 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
| 240 | + if( !( get_post( $review->assigned_to ) instanceof WP_Post )) { |
|
| 241 | + return; |
|
| 242 | + } |
|
| 233 | 243 | $counts = $this->getPostCounts( $review->assigned_to ); |
| 234 | 244 | $counts = empty( $counts ) |
| 235 | 245 | ? $this->buildPostCounts( $review->assigned_to ) |
@@ -279,7 +289,9 @@ discard block |
||
| 279 | 289 | public function setTermCounts( $termId, array $reviewCounts ) |
| 280 | 290 | { |
| 281 | 291 | $term = get_term( $termId, Application::TAXONOMY ); |
| 282 | - if( !isset( $term->term_id ))return; |
|
| 292 | + if( !isset( $term->term_id )) { |
|
| 293 | + return; |
|
| 294 | + } |
|
| 283 | 295 | $ratingCounts = $this->flatten( $reviewCounts ); |
| 284 | 296 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
| 285 | 297 | update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
@@ -335,7 +347,9 @@ discard block |
||
| 335 | 347 | } |
| 336 | 348 | foreach( $reviewCounts as &$counts ) { |
| 337 | 349 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
| 338 | - if( isset( $counts[$index] ))continue; |
|
| 350 | + if( isset( $counts[$index] )) { |
|
| 351 | + continue; |
|
| 352 | + } |
|
| 339 | 353 | $counts[$index] = 0; |
| 340 | 354 | } |
| 341 | 355 | ksort( $counts ); |