@@ -90,7 +90,9 @@ |
||
| 90 | 90 | { |
| 91 | 91 | $total = array_sum( $ratingCounts ); |
| 92 | 92 | foreach( $ratingCounts as $index => $count ) { |
| 93 | - if( empty( $count ))continue; |
|
| 93 | + if( empty( $count )) { |
|
| 94 | + continue; |
|
| 95 | + } |
|
| 94 | 96 | $ratingCounts[$index] = $count / $total * 100; |
| 95 | 97 | } |
| 96 | 98 | return $this->getRoundedPercentages( $ratingCounts ); |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | // get rating counts |
| 37 | 37 | $this->ratingCounts = [0,0,0,0,0,0]; |
| 38 | 38 | |
| 39 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
| 39 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' )) { |
|
| 40 | + return; |
|
| 41 | + } |
|
| 40 | 42 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
| 41 | 43 | $this->generateSchema(); |
| 42 | 44 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -56,7 +58,9 @@ discard block |
||
| 56 | 58 | */ |
| 57 | 59 | protected function buildPercentage() |
| 58 | 60 | { |
| 59 | - if( $this->isHidden( 'bars' ))return; |
|
| 61 | + if( $this->isHidden( 'bars' )) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 60 | 64 | $range = range( Rating::MAX_RATING, 1 ); |
| 61 | 65 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
| 62 | 66 | $bars = array_reduce( $range, function( $carry, $level ) use( $percentages ) { |
@@ -106,7 +110,9 @@ discard block |
||
| 106 | 110 | */ |
| 107 | 111 | protected function buildRating() |
| 108 | 112 | { |
| 109 | - if( $this->isHidden( 'rating' ))return; |
|
| 113 | + if( $this->isHidden( 'rating' )) { |
|
| 114 | + return; |
|
| 115 | + } |
|
| 110 | 116 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
| 111 | 117 | } |
| 112 | 118 | |
@@ -115,7 +121,9 @@ discard block |
||
| 115 | 121 | */ |
| 116 | 122 | protected function buildStars() |
| 117 | 123 | { |
| 118 | - if( $this->isHidden( 'stars' ))return; |
|
| 124 | + if( $this->isHidden( 'stars' )) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 119 | 127 | $stars = glsr( Partial::class )->build( 'star-rating', [ |
| 120 | 128 | 'rating' => $this->averageRating, |
| 121 | 129 | ]); |
@@ -127,7 +135,9 @@ discard block |
||
| 127 | 135 | */ |
| 128 | 136 | protected function buildText() |
| 129 | 137 | { |
| 130 | - if( $this->isHidden( 'summary' ))return; |
|
| 138 | + if( $this->isHidden( 'summary' )) { |
|
| 139 | + return; |
|
| 140 | + } |
|
| 131 | 141 | $count = array_sum( $this->ratingCounts ); |
| 132 | 142 | if( empty( $this->args['text'] )) { |
| 133 | 143 | // @todo document this change |
@@ -152,7 +162,9 @@ discard block |
||
| 152 | 162 | */ |
| 153 | 163 | protected function generateSchema() |
| 154 | 164 | { |
| 155 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 165 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 166 | + return; |
|
| 167 | + } |
|
| 156 | 168 | glsr( Schema::class )->store( |
| 157 | 169 | glsr( Schema::class )->buildSummary( $this->args ) |
| 158 | 170 | ); |
@@ -16,9 +16,13 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | $queries = []; |
| 18 | 18 | foreach( $keys as $key ) { |
| 19 | - if( !array_key_exists( $key, $values ))continue; |
|
| 19 | + if( !array_key_exists( $key, $values )) { |
|
| 20 | + continue; |
|
| 21 | + } |
|
| 20 | 22 | $methodName = glsr( Helper::class )->buildMethodName( $key, __FUNCTION__ ); |
| 21 | - if( !method_exists( $this, $methodName ))continue; |
|
| 23 | + if( !method_exists( $this, $methodName )) { |
|
| 24 | + continue; |
|
| 25 | + } |
|
| 22 | 26 | $query = call_user_func( [$this, $methodName], $values[$key] ); |
| 23 | 27 | if( is_array( $query )) { |
| 24 | 28 | $queries[] = $query; |
@@ -35,7 +39,9 @@ discard block |
||
| 35 | 39 | $string = ''; |
| 36 | 40 | $values = array_filter( $values ); |
| 37 | 41 | foreach( $conditions as $key => $value ) { |
| 38 | - if( !isset( $values[$key] ))continue; |
|
| 42 | + if( !isset( $values[$key] )) { |
|
| 43 | + continue; |
|
| 44 | + } |
|
| 39 | 45 | $values[$key] = implode( ',', (array)$values[$key] ); |
| 40 | 46 | $string .= strpos( $value, '%s' ) !== false |
| 41 | 47 | ? sprintf( $value, strval( $values[$key] )) |
@@ -109,7 +115,9 @@ discard block |
||
| 109 | 115 | */ |
| 110 | 116 | protected function buildQueryAssignedTo( $value ) |
| 111 | 117 | { |
| 112 | - if( empty( $value ))return; |
|
| 118 | + if( empty( $value )) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 113 | 121 | return [ |
| 114 | 122 | 'compare' => 'IN', |
| 115 | 123 | 'key' => 'assigned_to', |
@@ -123,7 +131,9 @@ discard block |
||
| 123 | 131 | */ |
| 124 | 132 | protected function buildQueryCategory( $value ) |
| 125 | 133 | { |
| 126 | - if( empty( $value ))return; |
|
| 134 | + if( empty( $value )) { |
|
| 135 | + return; |
|
| 136 | + } |
|
| 127 | 137 | return [ |
| 128 | 138 | 'field' => 'term_id', |
| 129 | 139 | 'taxonomy' => Application::TAXONOMY, |
@@ -137,7 +147,9 @@ discard block |
||
| 137 | 147 | */ |
| 138 | 148 | protected function buildQueryRating( $value ) |
| 139 | 149 | { |
| 140 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
| 150 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ))) { |
|
| 151 | + return; |
|
| 152 | + } |
|
| 141 | 153 | return [ |
| 142 | 154 | 'compare' => '>=', |
| 143 | 155 | 'key' => 'rating', |
@@ -151,7 +163,9 @@ discard block |
||
| 151 | 163 | */ |
| 152 | 164 | protected function buildQueryType( $value ) |
| 153 | 165 | { |
| 154 | - if( in_array( $value, ['','all'] ))return; |
|
| 166 | + if( in_array( $value, ['','all'] )) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 155 | 169 | return [ |
| 156 | 170 | 'key' => 'review_type', |
| 157 | 171 | 'value' => $value, |
@@ -18,7 +18,9 @@ discard block |
||
| 18 | 18 | while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $args, $greaterThanId, $limit )) { |
| 19 | 19 | $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
| 20 | 20 | foreach( $types as $type ) { |
| 21 | - if( isset( $counts[$type] ))continue; |
|
| 21 | + if( isset( $counts[$type] )) { |
|
| 22 | + continue; |
|
| 23 | + } |
|
| 22 | 24 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 23 | 25 | } |
| 24 | 26 | foreach( $reviews as $review ) { |
@@ -77,7 +79,9 @@ discard block |
||
| 77 | 79 | array_walk( $counts, function( &$ratings ) use( $args ) { |
| 78 | 80 | $ratings[0] = 0; |
| 79 | 81 | foreach( $ratings as $index => &$num ) { |
| 80 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
| 82 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
| 83 | + continue; |
|
| 84 | + } |
|
| 81 | 85 | $num = 0; |
| 82 | 86 | } |
| 83 | 87 | }); |
@@ -99,7 +103,9 @@ discard block |
||
| 99 | 103 | { |
| 100 | 104 | foreach( $reviewCounts as $type => &$counts ) { |
| 101 | 105 | foreach( range( 0, Rating::MAX_RATING ) as $rating ) { |
| 102 | - if( isset( $counts[$rating] ))continue; |
|
| 106 | + if( isset( $counts[$rating] )) { |
|
| 107 | + continue; |
|
| 108 | + } |
|
| 103 | 109 | $counts[$rating] = 0; |
| 104 | 110 | } |
| 105 | 111 | ksort( $counts ); |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | if( empty( $assignedTo )) { |
| 24 | 24 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
| 25 | 25 | } |
| 26 | - if( empty( $assignedTo ))return; |
|
| 26 | + if( empty( $assignedTo )) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 27 | 29 | $assignedPost = get_post( $assignedTo ); |
| 28 | 30 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
| 29 | 31 | return $assignedPost; |
@@ -112,7 +114,9 @@ discard block |
||
| 112 | 114 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
| 113 | 115 | $search = new WP_Query( $args ); |
| 114 | 116 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
| 115 | - if( !$search->have_posts() )return; |
|
| 117 | + if( !$search->have_posts() ) { |
|
| 118 | + return; |
|
| 119 | + } |
|
| 116 | 120 | $results = ''; |
| 117 | 121 | while( $search->have_posts() ) { |
| 118 | 122 | $search->the_post(); |
@@ -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, [ |
@@ -146,7 +156,9 @@ discard block |
||
| 146 | 156 | protected function setReviewCounts( WP_Post $review, array $counts ) |
| 147 | 157 | { |
| 148 | 158 | $type = strval( get_post_meta( $review->ID, 'review_type', true )); |
| 149 | - if( !array_key_exists( $type, glsr()->reviewTypes ))return; |
|
| 159 | + if( !array_key_exists( $type, glsr()->reviewTypes )) { |
|
| 160 | + return; |
|
| 161 | + } |
|
| 150 | 162 | glsr( OptionManager::class )->set( 'counts.'.$type, $counts ); |
| 151 | 163 | } |
| 152 | 164 | |
@@ -197,9 +209,13 @@ discard block |
||
| 197 | 209 | */ |
| 198 | 210 | protected function updateAssignedToPost( WP_Post $review ) |
| 199 | 211 | { |
| 200 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
| 212 | + if( !( $postId = $this->getAssignedToPostId( $review->ID ))) { |
|
| 213 | + return; |
|
| 214 | + } |
|
| 201 | 215 | $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 202 | - if( empty( $reviewIds ))return; |
|
| 216 | + if( empty( $reviewIds )) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 203 | 219 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
| 204 | 220 | $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 205 | 221 | if( empty( $updatedReviewIds )) { |