@@ -35,7 +35,9 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function compose( Review $review, array $notification ) |
| 37 | 37 | { |
| 38 | - if( empty( $this->endpoint ))return; |
|
| 38 | + if( empty( $this->endpoint )) { |
|
| 39 | + return; |
|
| 40 | + } |
|
| 39 | 41 | $args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification ); |
| 40 | 42 | $this->review = $review; |
| 41 | 43 | $notification = [ |
@@ -21,7 +21,9 @@ |
||
| 21 | 21 | if( !class_exists( 'GL_Plugin_Check_v3' )) { |
| 22 | 22 | require_once __DIR__.'/activate.php'; |
| 23 | 23 | } |
| 24 | -if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() )return; |
|
| 24 | +if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() ) { |
|
| 25 | + return; |
|
| 26 | +} |
|
| 25 | 27 | require_once __DIR__.'/autoload.php'; |
| 26 | 28 | require_once __DIR__.'/compatibility.php'; |
| 27 | 29 | require_once __DIR__.'/deprecated.php'; |
@@ -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(), |
@@ -146,7 +148,9 @@ discard block |
||
| 146 | 148 | protected function sendToEmail( array $args ) |
| 147 | 149 | { |
| 148 | 150 | $email = $this->buildEmail( $args ); |
| 149 | - if( !$this->email )return; |
|
| 151 | + if( !$this->email ) { |
|
| 152 | + return; |
|
| 153 | + } |
|
| 150 | 154 | if( empty( $email->to )) { |
| 151 | 155 | glsr_log()->error( 'Email notification was not sent: missing email address' ); |
| 152 | 156 | return; |
@@ -161,7 +165,9 @@ discard block |
||
| 161 | 165 | */ |
| 162 | 166 | protected function sendToSlack( array $args ) |
| 163 | 167 | { |
| 164 | - if( !$this->slack )return; |
|
| 168 | + if( !$this->slack ) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 165 | 171 | $notification = $this->buildSlackNotification( $args ); |
| 166 | 172 | $result = $notification->send(); |
| 167 | 173 | if( is_wp_error( $result )) { |
@@ -37,7 +37,9 @@ |
||
| 37 | 37 | $lines = explode( "\n", $blacklist ); |
| 38 | 38 | foreach( (array)$lines as $line ) { |
| 39 | 39 | $line = trim( $line ); |
| 40 | - if( empty( $line ) || 256 < strlen( $line ))continue; |
|
| 40 | + if( empty( $line ) || 256 < strlen( $line )) { |
|
| 41 | + continue; |
|
| 42 | + } |
|
| 41 | 43 | $pattern = sprintf( '#%s#i', preg_quote( $line, '#' )); |
| 42 | 44 | if( preg_match( $pattern, $target )) { |
| 43 | 45 | return true; |
@@ -69,7 +69,9 @@ discard block |
||
| 69 | 69 | $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
| 70 | 70 | $this->modified = $this->isModified( $properties ); |
| 71 | 71 | array_walk( $properties, function( $value, $key ) { |
| 72 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
| 72 | + if( !property_exists( $this, $key ) || isset( $this->$key )) { |
|
| 73 | + return; |
|
| 74 | + } |
|
| 73 | 75 | $this->$key = maybe_unserialize( $value ); |
| 74 | 76 | }); |
| 75 | 77 | } |
@@ -80,7 +82,9 @@ discard block |
||
| 80 | 82 | protected function setTermIds( WP_Post $post ) |
| 81 | 83 | { |
| 82 | 84 | $this->term_ids = []; |
| 83 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
| 85 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ))) { |
|
| 86 | + return; |
|
| 87 | + } |
|
| 84 | 88 | foreach( $terms as $term ) { |
| 85 | 89 | $this->term_ids[] = $term->term_id; |
| 86 | 90 | } |
@@ -13,7 +13,9 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function __call( $name, array $args = [] ) |
| 15 | 15 | { |
| 16 | - if( !method_exists( $this, $name ))return; |
|
| 16 | + if( !method_exists( $this, $name )) { |
|
| 17 | + return; |
|
| 18 | + } |
|
| 17 | 19 | $defaults = call_user_func_array( [$this, $name], $args ); |
| 18 | 20 | $hookName = (new ReflectionClass( $this ))->getShortName(); |
| 19 | 21 | $hookName = str_replace( 'Defaults', '', $hookName ); |
@@ -17,9 +17,13 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | $queries = []; |
| 19 | 19 | foreach( $keys as $key ) { |
| 20 | - if( !array_key_exists( $key, $values ))continue; |
|
| 20 | + if( !array_key_exists( $key, $values )) { |
|
| 21 | + continue; |
|
| 22 | + } |
|
| 21 | 23 | $methodName = glsr( Helper::class )->buildMethodName( $key, __FUNCTION__ ); |
| 22 | - if( !method_exists( $this, $methodName ))continue; |
|
| 24 | + if( !method_exists( $this, $methodName )) { |
|
| 25 | + continue; |
|
| 26 | + } |
|
| 23 | 27 | $query = call_user_func( [$this, $methodName], $values[$key] ); |
| 24 | 28 | if( is_array( $query )) { |
| 25 | 29 | $queries[] = $query; |
@@ -36,7 +40,9 @@ discard block |
||
| 36 | 40 | $string = ''; |
| 37 | 41 | $values = array_filter( $values ); |
| 38 | 42 | foreach( $conditions as $key => $value ) { |
| 39 | - if( !isset( $values[$key] ))continue; |
|
| 43 | + if( !isset( $values[$key] )) { |
|
| 44 | + continue; |
|
| 45 | + } |
|
| 40 | 46 | $values[$key] = implode( ',', (array)$values[$key] ); |
| 41 | 47 | $string .= strpos( $value, '%s' ) !== false |
| 42 | 48 | ? sprintf( $value, strval( $values[$key] )) |
@@ -110,7 +116,9 @@ discard block |
||
| 110 | 116 | */ |
| 111 | 117 | protected function buildQueryAssignedTo( $value ) |
| 112 | 118 | { |
| 113 | - if( empty( $value ))return; |
|
| 119 | + if( empty( $value )) { |
|
| 120 | + return; |
|
| 121 | + } |
|
| 114 | 122 | $postIds = glsr( Helper::class )->convertStringToArray( $value, 'is_numeric' ); |
| 115 | 123 | return [ |
| 116 | 124 | 'compare' => 'IN', |
@@ -125,7 +133,9 @@ discard block |
||
| 125 | 133 | */ |
| 126 | 134 | protected function buildQueryCategory( $value ) |
| 127 | 135 | { |
| 128 | - if( empty( $value ))return; |
|
| 136 | + if( empty( $value )) { |
|
| 137 | + return; |
|
| 138 | + } |
|
| 129 | 139 | return [ |
| 130 | 140 | 'field' => 'term_id', |
| 131 | 141 | 'taxonomy' => Application::TAXONOMY, |
@@ -139,7 +149,9 @@ discard block |
||
| 139 | 149 | */ |
| 140 | 150 | protected function buildQueryRating( $value ) |
| 141 | 151 | { |
| 142 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
| 152 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ))) { |
|
| 153 | + return; |
|
| 154 | + } |
|
| 143 | 155 | return [ |
| 144 | 156 | 'compare' => '>=', |
| 145 | 157 | 'key' => 'rating', |
@@ -153,7 +165,9 @@ discard block |
||
| 153 | 165 | */ |
| 154 | 166 | protected function buildQueryType( $value ) |
| 155 | 167 | { |
| 156 | - if( in_array( $value, ['','all'] ))return; |
|
| 168 | + if( in_array( $value, ['','all'] )) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 157 | 171 | return [ |
| 158 | 172 | 'key' => 'review_type', |
| 159 | 173 | 'value' => $value, |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
| 42 | 42 | 'min' => $args['rating'], |
| 43 | 43 | ]); |
| 44 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
| 44 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' )) { |
|
| 45 | + return; |
|
| 46 | + } |
|
| 45 | 47 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
| 46 | 48 | $this->generateSchema(); |
| 47 | 49 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -61,7 +63,9 @@ discard block |
||
| 61 | 63 | */ |
| 62 | 64 | protected function buildPercentage() |
| 63 | 65 | { |
| 64 | - if( $this->isHidden( 'bars' ))return; |
|
| 66 | + if( $this->isHidden( 'bars' )) { |
|
| 67 | + return; |
|
| 68 | + } |
|
| 65 | 69 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
| 66 | 70 | $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) { |
| 67 | 71 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
@@ -110,7 +114,9 @@ discard block |
||
| 110 | 114 | */ |
| 111 | 115 | protected function buildRating() |
| 112 | 116 | { |
| 113 | - if( $this->isHidden( 'rating' ))return; |
|
| 117 | + if( $this->isHidden( 'rating' )) { |
|
| 118 | + return; |
|
| 119 | + } |
|
| 114 | 120 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
| 115 | 121 | } |
| 116 | 122 | |
@@ -119,7 +125,9 @@ discard block |
||
| 119 | 125 | */ |
| 120 | 126 | protected function buildStars() |
| 121 | 127 | { |
| 122 | - if( $this->isHidden( 'stars' ))return; |
|
| 128 | + if( $this->isHidden( 'stars' )) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 123 | 131 | $stars = glsr( Partial::class )->build( 'star-rating', ['rating' => $this->averageRating] ); |
| 124 | 132 | return $this->wrap( 'stars', $stars ); |
| 125 | 133 | } |
@@ -129,7 +137,9 @@ discard block |
||
| 129 | 137 | */ |
| 130 | 138 | protected function buildText() |
| 131 | 139 | { |
| 132 | - if( $this->isHidden( 'summary' ))return; |
|
| 140 | + if( $this->isHidden( 'summary' )) { |
|
| 141 | + return; |
|
| 142 | + } |
|
| 133 | 143 | $count = intval( array_sum( $this->ratingCounts )); |
| 134 | 144 | if( empty( $this->args['text'] )) { |
| 135 | 145 | // @todo document this change |
@@ -154,7 +164,9 @@ discard block |
||
| 154 | 164 | */ |
| 155 | 165 | protected function generateSchema() |
| 156 | 166 | { |
| 157 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 167 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 168 | + return; |
|
| 169 | + } |
|
| 158 | 170 | glsr( Schema::class )->store( |
| 159 | 171 | glsr( Schema::class )->buildSummary( $this->args ) |
| 160 | 172 | ); |
@@ -20,7 +20,9 @@ |
||
| 20 | 20 | public function build( array $args = [] ) |
| 21 | 21 | { |
| 22 | 22 | $this->args = $this->normalize( $args ); |
| 23 | - if( $this->args['total'] < 2 )return; |
|
| 23 | + if( $this->args['total'] < 2 ) { |
|
| 24 | + return; |
|
| 25 | + } |
|
| 24 | 26 | return glsr( Template::class )->build( 'templates/pagination', [ |
| 25 | 27 | 'context' => [ |
| 26 | 28 | 'links' => apply_filters( 'site-reviews/paginate_links', $this->buildLinks(), $this->args ), |