@@ -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; |
@@ -191,7 +197,9 @@ discard block |
||
| 191 | 197 | */ |
| 192 | 198 | public function increasePostCounts( Review $review ) |
| 193 | 199 | { |
| 194 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
| 200 | + if( !( get_post( $review->assigned_to ) instanceof WP_Post )) { |
|
| 201 | + return; |
|
| 202 | + } |
|
| 195 | 203 | $counts = $this->getPostCounts( $review->assigned_to ); |
| 196 | 204 | $counts = empty( $counts ) |
| 197 | 205 | ? $this->buildPostCounts( $review->assigned_to ) |
@@ -240,7 +248,9 @@ discard block |
||
| 240 | 248 | */ |
| 241 | 249 | public function setTermCounts( $termId, array $reviewCounts ) |
| 242 | 250 | { |
| 243 | - if( !term_exists( $termId ))return; |
|
| 251 | + if( !term_exists( $termId )) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 244 | 254 | $ratingCounts = glsr( CountsManager::class )->flatten( $reviewCounts ); |
| 245 | 255 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
| 246 | 256 | update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
@@ -258,7 +268,9 @@ discard block |
||
| 258 | 268 | while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) { |
| 259 | 269 | $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
| 260 | 270 | foreach( $types as $type ) { |
| 261 | - if( isset( $counts[$type] ))continue; |
|
| 271 | + if( isset( $counts[$type] )) { |
|
| 272 | + continue; |
|
| 273 | + } |
|
| 262 | 274 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 263 | 275 | } |
| 264 | 276 | foreach( $reviews as $review ) { |
@@ -307,7 +319,9 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | foreach( $reviewCounts as &$counts ) { |
| 309 | 321 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
| 310 | - if( isset( $counts[$index] ))continue; |
|
| 322 | + if( isset( $counts[$index] )) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 311 | 325 | $counts[$index] = 0; |
| 312 | 326 | } |
| 313 | 327 | ksort( $counts ); |
@@ -111,7 +111,9 @@ discard block |
||
| 111 | 111 | $termIds = array_filter( array_map( 'trim', explode( ',', $commaSeparatedTermIds ))); |
| 112 | 112 | foreach( $termIds as $termId ) { |
| 113 | 113 | $term = get_term( $termId, Application::TAXONOMY ); |
| 114 | - if( !isset( $term->term_id ))continue; |
|
| 114 | + if( !isset( $term->term_id )) { |
|
| 115 | + continue; |
|
| 116 | + } |
|
| 115 | 117 | $terms[] = $term->term_id; |
| 116 | 118 | } |
| 117 | 119 | return $terms; |
@@ -123,7 +125,9 @@ discard block |
||
| 123 | 125 | */ |
| 124 | 126 | public function revert( $postId ) |
| 125 | 127 | { |
| 126 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
| 128 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 127 | 131 | delete_post_meta( $postId, '_edit_last' ); |
| 128 | 132 | $result = wp_update_post([ |
| 129 | 133 | 'ID' => $postId, |
@@ -141,7 +145,9 @@ discard block |
||
| 141 | 145 | */ |
| 142 | 146 | public function single( WP_Post $post ) |
| 143 | 147 | { |
| 144 | - if( $post->post_type != Application::POST_TYPE )return; |
|
| 148 | + if( $post->post_type != Application::POST_TYPE ) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 145 | 151 | $review = new Review( $post ); |
| 146 | 152 | return apply_filters( 'site-reviews/get/review', $review, $post ); |
| 147 | 153 | } |
@@ -166,7 +172,9 @@ discard block |
||
| 166 | 172 | protected function setTerms( $postId, $termIds ) |
| 167 | 173 | { |
| 168 | 174 | $terms = $this->normalizeTerms( $termIds ); |
| 169 | - if( empty( $terms ))return; |
|
| 175 | + if( empty( $terms )) { |
|
| 176 | + return; |
|
| 177 | + } |
|
| 170 | 178 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 171 | 179 | if( is_wp_error( $result )) { |
| 172 | 180 | glsr_log()->error( $result->get_error_message() ); |
@@ -25,7 +25,9 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | sort( $termIds ); |
| 27 | 27 | sort( $oldTermIds ); |
| 28 | - if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ))return; |
|
| 28 | + if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId )) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 29 | 31 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 30 | 32 | $ignoredTerms = array_intersect( $oldTermIds, $termIds ); |
| 31 | 33 | if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms )) { |
@@ -45,7 +47,9 @@ discard block |
||
| 45 | 47 | */ |
| 46 | 48 | public function onAfterCreate( $postData, $meta, $postId ) |
| 47 | 49 | { |
| 48 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 50 | + if( !$this->isReviewPostId( $postId )) { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 49 | 53 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 50 | 54 | glsr( CountsManager::class )->increase( $review ); |
| 51 | 55 | } |
@@ -57,7 +61,9 @@ discard block |
||
| 57 | 61 | */ |
| 58 | 62 | public function onBeforeDelete( $postId ) |
| 59 | 63 | { |
| 60 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 64 | + if( !$this->isReviewPostId( $postId )) { |
|
| 65 | + return; |
|
| 66 | + } |
|
| 61 | 67 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 62 | 68 | glsr( CountsManager::class )->decrease( $review ); |
| 63 | 69 | } |
@@ -74,9 +80,13 @@ discard block |
||
| 74 | 80 | { |
| 75 | 81 | if( !$this->isReviewPostId( $postId ) |
| 76 | 82 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 77 | - )return; |
|
| 83 | + ) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 78 | 86 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 79 | - if( $review->$metaKey == $metaValue )return; |
|
| 87 | + if( $review->$metaKey == $metaValue ) { |
|
| 88 | + return; |
|
| 89 | + } |
|
| 80 | 90 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 81 | 91 | call_user_func( [$this, $method], $review, $metaValue ); |
| 82 | 92 | } |
@@ -122,7 +132,9 @@ discard block |
||
| 122 | 132 | */ |
| 123 | 133 | public function onChangeStatus( $newStatus, $oldStatus, WP_Post $post ) |
| 124 | 134 | { |
| 125 | - if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 135 | + if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
| 136 | + return; |
|
| 137 | + } |
|
| 126 | 138 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
| 127 | 139 | if( $post->post_status == 'publish' ) { |
| 128 | 140 | glsr( CountsManager::class )->increase( $review ); |