@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function onBeforeDeleteReview( $postId ) |
| 23 | 23 | { |
| 24 | - if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return; |
|
| 24 | + if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) { |
|
| 25 | + return; |
|
| 26 | + } |
|
| 25 | 27 | $review = get_post( $postId ); |
| 26 | 28 | $review->post_status = 'deleted'; // change post_status first! |
| 27 | 29 | $this->updateAssignedToPost( $review ); |
@@ -37,7 +39,9 @@ discard block |
||
| 37 | 39 | public function onBeforeUpdateReview( WP_Post $review, $metaKey, $newValue ) |
| 38 | 40 | { |
| 39 | 41 | $previousValue = get_post_meta( $review->ID, $metaKey, true ); |
| 40 | - if( $previousValue == $newValue )return; |
|
| 42 | + if( $previousValue == $newValue ) { |
|
| 43 | + return; |
|
| 44 | + } |
|
| 41 | 45 | $this->decreaseReviewCount( $review ); |
| 42 | 46 | $this->increaseReviewCount( $review, [$metaKey => $newValue] ); |
| 43 | 47 | } |
@@ -50,7 +54,9 @@ discard block |
||
| 50 | 54 | */ |
| 51 | 55 | public function onCreateReview( $postData, $meta, $postId ) |
| 52 | 56 | { |
| 53 | - if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return; |
|
| 57 | + if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) { |
|
| 58 | + return; |
|
| 59 | + } |
|
| 54 | 60 | $review = get_post( $postId ); |
| 55 | 61 | $this->updateAssignedToPost( $review ); |
| 56 | 62 | $this->increaseReviewCount( $review ); |
@@ -86,7 +92,9 @@ discard block |
||
| 86 | 92 | */ |
| 87 | 93 | public function saveAssignedToMetabox( $postId ) |
| 88 | 94 | { |
| 89 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 95 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 90 | 98 | $assignedTo = glsr( Helper::class )->filterInput( 'assigned_to' ); |
| 91 | 99 | $assignedTo || $assignedTo = ''; |
| 92 | 100 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -101,7 +109,9 @@ discard block |
||
| 101 | 109 | */ |
| 102 | 110 | public function saveResponseMetabox( $postId ) |
| 103 | 111 | { |
| 104 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
| 112 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) { |
|
| 113 | + return; |
|
| 114 | + } |
|
| 105 | 115 | $response = glsr( Helper::class )->filterInput( 'response' ); |
| 106 | 116 | $response || $response = ''; |
| 107 | 117 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
@@ -135,10 +145,14 @@ discard block |
||
| 135 | 145 | ]); |
| 136 | 146 | if( !array_key_exists( $meta['review_type'], glsr()->reviewTypes ) |
| 137 | 147 | || intval( $meta['rating'] ) > Rating::MAX_RATING |
| 138 | - )return; |
|
| 148 | + ) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 139 | 151 | $counts = glsr( OptionManager::class )->get( 'counts.'.$meta['review_type'], [] ); |
| 140 | 152 | foreach( range( 0, Rating::MAX_RATING ) as $rating ) { |
| 141 | - if( isset( $counts[$rating] ))continue; |
|
| 153 | + if( isset( $counts[$rating] )) { |
|
| 154 | + continue; |
|
| 155 | + } |
|
| 142 | 156 | $counts[$rating] = 0; |
| 143 | 157 | } |
| 144 | 158 | ksort( $counts ); |
@@ -151,7 +165,9 @@ discard block |
||
| 151 | 165 | protected function setReviewCounts( WP_Post $review, array $counts ) |
| 152 | 166 | { |
| 153 | 167 | $type = strval( get_post_meta( $review->ID, 'review_type', true )); |
| 154 | - if( !array_key_exists( $type, glsr()->reviewTypes ))return; |
|
| 168 | + if( !array_key_exists( $type, glsr()->reviewTypes )) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 155 | 171 | glsr( OptionManager::class )->set( 'counts.'.$type, $counts ); |
| 156 | 172 | } |
| 157 | 173 | |
@@ -202,9 +218,13 @@ discard block |
||
| 202 | 218 | */ |
| 203 | 219 | protected function updateAssignedToPost( WP_Post $review ) |
| 204 | 220 | { |
| 205 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
| 221 | + if( !( $postId = $this->getAssignedToPostId( $review->ID ))) { |
|
| 222 | + return; |
|
| 223 | + } |
|
| 206 | 224 | $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 207 | - if( empty( $reviewIds ))return; |
|
| 225 | + if( empty( $reviewIds )) { |
|
| 226 | + return; |
|
| 227 | + } |
|
| 208 | 228 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
| 209 | 229 | $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 210 | 230 | if( empty( $updatedReviewIds )) { |