@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | $this->sendNotification( $postId ); |
| 35 | 35 | do_action( 'site-reviews/local/review/submitted', $postId, $command ); |
| 36 | 36 | glsr( Session::class )->set( $command->form_id.'message', __( 'Your review has been submitted!', 'site-reviews' )); |
| 37 | - if( $command->ajax_request )return; |
|
| 37 | + if( $command->ajax_request ) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 38 | 40 | wp_safe_redirect( $command->referrer ); |
| 39 | 41 | exit; |
| 40 | 42 | } |
@@ -100,7 +102,9 @@ discard block |
||
| 100 | 102 | protected function sendNotification( $postId ) |
| 101 | 103 | { |
| 102 | 104 | $notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' ); |
| 103 | - if( !in_array( $notificationType, ['default','custom','webhook'] ))return; |
|
| 105 | + if( !in_array( $notificationType, ['default','custom','webhook'] )) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 104 | 108 | $assignedToTitle = get_the_title( (int)$this->command->assigned_to ); |
| 105 | 109 | $notificationSubject = _nx( |
| 106 | 110 | 'New %s-star review', |
@@ -148,7 +152,9 @@ discard block |
||
| 148 | 152 | */ |
| 149 | 153 | protected function sendWebhookNotification( array $args ) |
| 150 | 154 | { |
| 151 | - if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )))return; |
|
| 155 | + if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' ))) { |
|
| 156 | + return; |
|
| 157 | + } |
|
| 152 | 158 | $notification = $this->createWebhookNotification( $args ); |
| 153 | 159 | $result = wp_remote_post( $endpoint, [ |
| 154 | 160 | 'blocking' => false, |
@@ -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 = intval( 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 | ); |