@@ -108,7 +108,9 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function render() |
110 | 110 | { |
111 | - if( is_null( glsr()->schemas ))return; |
|
111 | + if( is_null( glsr()->schemas )) { |
|
112 | + return; |
|
113 | + } |
|
112 | 114 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
113 | 115 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
114 | 116 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -181,7 +183,9 @@ discard block |
||
181 | 183 | if( $value != $fallback ) { |
182 | 184 | return $value; |
183 | 185 | } |
184 | - if( !is_single() && !is_page() )return; |
|
186 | + if( !is_single() && !is_page() ) { |
|
187 | + return; |
|
188 | + } |
|
185 | 189 | switch( $option ) { |
186 | 190 | case 'description': |
187 | 191 | return get_the_excerpt(); |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | // 'is_test' => 1, |
31 | 31 | ]; |
32 | 32 | foreach( $_SERVER as $key => $value ) { |
33 | - if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ))continue; |
|
33 | + if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] )) { |
|
34 | + continue; |
|
35 | + } |
|
34 | 36 | $submission[$key] = $value; |
35 | 37 | } |
36 | 38 | return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review )); |
@@ -56,12 +58,16 @@ discard block |
||
56 | 58 | { |
57 | 59 | $query = []; |
58 | 60 | foreach( $data as $key => $value ) { |
59 | - if( is_array( $value ) || is_object( $value ))continue; |
|
61 | + if( is_array( $value ) || is_object( $value )) { |
|
62 | + continue; |
|
63 | + } |
|
60 | 64 | if( $value === false ) { |
61 | 65 | $value = '0'; |
62 | 66 | } |
63 | 67 | $value = trim( $value ); |
64 | - if( !strlen( $value ))continue; |
|
68 | + if( !strlen( $value )) { |
|
69 | + continue; |
|
70 | + } |
|
65 | 71 | $query[] = urlencode( $key ).'='.urlencode( $value ); |
66 | 72 | } |
67 | 73 | return implode( '&', $query ); |
@@ -15,7 +15,9 @@ |
||
15 | 15 | natsort( $routines ); |
16 | 16 | array_walk( $routines, function( $routine ) { |
17 | 17 | $version = str_replace( strtolower( __CLASS__ ).'_', '', $routine ); |
18 | - if( version_compare( glsr()->version, $version, '>=' ))return; |
|
18 | + if( version_compare( glsr()->version, $version, '>=' )) { |
|
19 | + return; |
|
20 | + } |
|
19 | 21 | call_user_func( [$this, $routine] ); |
20 | 22 | }); |
21 | 23 | } |
@@ -89,7 +89,10 @@ discard block |
||
89 | 89 | return true; |
90 | 90 | } |
91 | 91 | $recaptchaResponse = filter_input( INPUT_POST, 'g-recaptcha-response' ); |
92 | - if( empty( $recaptchaResponse ))return; //if response is empty we need to return null |
|
92 | + if( empty( $recaptchaResponse )) { |
|
93 | + return; |
|
94 | + } |
|
95 | + //if response is empty we need to return null |
|
93 | 96 | if( $integration == 'custom' ) { |
94 | 97 | return $this->isRecaptchaValid( $recaptchaResponse ); |
95 | 98 | } |
@@ -161,8 +164,12 @@ discard block |
||
161 | 164 | */ |
162 | 165 | protected function validateAkismet() |
163 | 166 | { |
164 | - if( !empty( $this->error ))return; |
|
165 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
167 | + if( !empty( $this->error )) { |
|
168 | + return; |
|
169 | + } |
|
170 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
171 | + return; |
|
172 | + } |
|
166 | 173 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
167 | 174 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
168 | 175 | } |
@@ -172,13 +179,16 @@ discard block |
||
172 | 179 | */ |
173 | 180 | protected function validateBlacklist() |
174 | 181 | { |
175 | - if( !empty( $this->error ))return; |
|
176 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
182 | + if( !empty( $this->error )) { |
|
183 | + return; |
|
184 | + } |
|
185 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
186 | + return; |
|
187 | + } |
|
177 | 188 | $blacklistAction = glsr_get_option( 'reviews-form.blacklist.action' ); |
178 | 189 | if( $blacklistAction == 'unapprove' ) { |
179 | 190 | $this->request['blacklisted'] = true; |
180 | - } |
|
181 | - else if( $blacklistAction == 'reject' ) { |
|
191 | + } else if( $blacklistAction == 'reject' ) { |
|
182 | 192 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
183 | 193 | $this->error = __( 'Your review cannot be submitted at this time.', 'site-reviews' ); |
184 | 194 | } |
@@ -189,9 +199,13 @@ discard block |
||
189 | 199 | */ |
190 | 200 | protected function validateCustom() |
191 | 201 | { |
192 | - if( !empty( $this->error ))return; |
|
202 | + if( !empty( $this->error )) { |
|
203 | + return; |
|
204 | + } |
|
193 | 205 | $validated = apply_filters( 'site-reviews/validate/review/submission', true, $this->request ); |
194 | - if( $validated === true )return; |
|
206 | + if( $validated === true ) { |
|
207 | + return; |
|
208 | + } |
|
195 | 209 | $this->setSessionValues( 'errors', [] ); |
196 | 210 | $this->setSessionValues( 'values', $this->request ); |
197 | 211 | $this->error = is_string( $validated ) |
@@ -204,8 +218,12 @@ discard block |
||
204 | 218 | */ |
205 | 219 | protected function validateHoneyPot( array $request ) |
206 | 220 | { |
207 | - if( !empty( $this->error ))return; |
|
208 | - if( empty( $request['gotcha'] ))return; |
|
221 | + if( !empty( $this->error )) { |
|
222 | + return; |
|
223 | + } |
|
224 | + if( empty( $request['gotcha'] )) { |
|
225 | + return; |
|
226 | + } |
|
209 | 227 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
210 | 228 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
211 | 229 | } |
@@ -215,13 +233,14 @@ discard block |
||
215 | 233 | */ |
216 | 234 | protected function validateRecaptcha( array $request ) |
217 | 235 | { |
218 | - if( !empty( $this->error ))return; |
|
236 | + if( !empty( $this->error )) { |
|
237 | + return; |
|
238 | + } |
|
219 | 239 | $isValid = $this->isRecaptchaResponseValid(); |
220 | 240 | if( is_null( $isValid )) { |
221 | 241 | $this->setSessionValues( 'recaptcha', true ); |
222 | 242 | $this->recaptchaIsUnset = true; |
223 | - } |
|
224 | - else if( !$isValid ) { |
|
243 | + } else if( !$isValid ) { |
|
225 | 244 | $this->setSessionValues( 'errors', [] ); |
226 | 245 | $this->setSessionValues( 'recaptcha', 'reset' ); |
227 | 246 | $this->error = __( 'The reCAPTCHA verification failed. Please notify the site administrator.', 'site-reviews' ); |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | $counts = array_fill_keys( [5,4,3,2,1], [] ); |
64 | 64 | array_walk( $counts, function( &$count, $key ) use( $reviews ) { |
65 | 65 | $count = count( array_filter( $reviews, function( $review ) use( $key ) { |
66 | - if( !isset( $review->rating ))return; |
|
66 | + if( !isset( $review->rating )) { |
|
67 | + return; |
|
68 | + } |
|
67 | 69 | return $review->rating == $key; |
68 | 70 | })); |
69 | 71 | }); |
@@ -83,7 +85,9 @@ discard block |
||
83 | 85 | public function getLowerBound( array $upDownRatings, $confidencePercentage = 95 ) |
84 | 86 | { |
85 | 87 | $numRatings = count( $upDownRatings ); |
86 | - if( !$numRatings )return 0; |
|
88 | + if( !$numRatings ) { |
|
89 | + return 0; |
|
90 | + } |
|
87 | 91 | $positiveRatings = count( array_filter( $upDownRatings, function( $value ) { |
88 | 92 | return $value > 0; |
89 | 93 | })); |
@@ -42,7 +42,9 @@ |
||
42 | 42 | $options = $this->all(); |
43 | 43 | $pointer = &$options; |
44 | 44 | foreach( $keys as $key ) { |
45 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
45 | + if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] )) { |
|
46 | + continue; |
|
47 | + } |
|
46 | 48 | $pointer = &$pointer[$key]; |
47 | 49 | } |
48 | 50 | unset( $pointer[$last] ); |
@@ -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, $prefix = __METHOD__ ); |
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; |
@@ -90,7 +94,9 @@ discard block |
||
90 | 94 | */ |
91 | 95 | protected function buildQueryAssignedTo( $value ) |
92 | 96 | { |
93 | - if( empty( $value ))return; |
|
97 | + if( empty( $value )) { |
|
98 | + return; |
|
99 | + } |
|
94 | 100 | return [ |
95 | 101 | 'compare' => 'IN', |
96 | 102 | 'key' => 'assigned_to', |
@@ -104,7 +110,9 @@ discard block |
||
104 | 110 | */ |
105 | 111 | protected function buildQueryCategory( $value ) |
106 | 112 | { |
107 | - if( empty( $value ))return; |
|
113 | + if( empty( $value )) { |
|
114 | + return; |
|
115 | + } |
|
108 | 116 | return [ |
109 | 117 | 'field' => 'term_id', |
110 | 118 | 'taxonomy' => Application::TAXONOMY, |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | */ |
119 | 127 | protected function buildQueryRating( $value ) |
120 | 128 | { |
121 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
129 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ))) { |
|
130 | + return; |
|
131 | + } |
|
122 | 132 | return [ |
123 | 133 | 'compare' => '>=', |
124 | 134 | 'key' => 'rating', |
@@ -132,7 +142,9 @@ discard block |
||
132 | 142 | */ |
133 | 143 | protected function buildQueryType( $value ) |
134 | 144 | { |
135 | - if( in_array( $value, ['','all'] ))return; |
|
145 | + if( in_array( $value, ['','all'] )) { |
|
146 | + return; |
|
147 | + } |
|
136 | 148 | return [ |
137 | 149 | 'key' => 'review_type', |
138 | 150 | 'value' => $value, |
@@ -38,7 +38,9 @@ |
||
38 | 38 | protected function normalize( array $settings ) |
39 | 39 | { |
40 | 40 | array_walk( $settings, function( &$setting ) { |
41 | - if( isset( $setting['default'] ))return; |
|
41 | + if( isset( $setting['default'] )) { |
|
42 | + return; |
|
43 | + } |
|
42 | 44 | $setting['default'] = null; |
43 | 45 | }); |
44 | 46 | return $settings; |
@@ -16,7 +16,9 @@ |
||
16 | 16 | $ipAddresses = array_fill_keys( ['v4', 'v6'], [] ); |
17 | 17 | foreach( array_keys( $ipAddresses ) as $version ) { |
18 | 18 | $response = wp_remote_get( 'https://www.cloudflare.com/ips-'.$version ); |
19 | - if( is_wp_error( $response ))continue; |
|
19 | + if( is_wp_error( $response )) { |
|
20 | + continue; |
|
21 | + } |
|
20 | 22 | $ipAddresses[$version] = array_filter( explode( PHP_EOL, wp_remote_retrieve_body( $response ))); |
21 | 23 | } |
22 | 24 | wp_cache_set( glsr()->id, $ipAddresses, '_cloudflare_ips' ); |