@@ -115,7 +115,9 @@ discard block |
||
115 | 115 | protected function sendNotification( $post_id, Command $command ) |
116 | 116 | { |
117 | 117 | $notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' ); |
118 | - if( !in_array( $notificationType, ['default','custom','webhook'] ))return; |
|
118 | + if( !in_array( $notificationType, ['default','custom','webhook'] )) { |
|
119 | + return; |
|
120 | + } |
|
119 | 121 | $assignedToTitle = get_the_title( (int) $command->assignedTo ); |
120 | 122 | $notificationSubject = _nx( |
121 | 123 | 'New %s-star review', |
@@ -162,7 +164,9 @@ discard block |
||
162 | 164 | */ |
163 | 165 | protected function sendWebhookNotification( Command $command, array $args ) |
164 | 166 | { |
165 | - if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )))return; |
|
167 | + if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' ))) { |
|
168 | + return; |
|
169 | + } |
|
166 | 170 | $notification = $this->createWebhookNotification( $command, $args ); |
167 | 171 | $result = wp_remote_post( $endpoint, [ |
168 | 172 | 'method' => 'POST', |
@@ -57,9 +57,13 @@ discard block |
||
57 | 57 | protected function generateFields( array $fields ) |
58 | 58 | { |
59 | 59 | $generatedFields = array_map( function( $field ) { |
60 | - if( empty( $field ))return; |
|
60 | + if( empty( $field )) { |
|
61 | + return; |
|
62 | + } |
|
61 | 63 | $field = $this->normalize( $field ); |
62 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
64 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ))) { |
|
65 | + return; |
|
66 | + } |
|
63 | 67 | return $this->$method( $field ); |
64 | 68 | }, $fields ); |
65 | 69 | return array_values( array_filter( $generatedFields )); |
@@ -74,7 +78,9 @@ discard block |
||
74 | 78 | if( !empty( $this->errors )) { |
75 | 79 | $errors = []; |
76 | 80 | foreach( $this->required as $name => $alert ) { |
77 | - if( false !== array_search( $name, array_column( $fields, 'name' )))continue; |
|
81 | + if( false !== array_search( $name, array_column( $fields, 'name' ))) { |
|
82 | + continue; |
|
83 | + } |
|
78 | 84 | $errors[] = $this->errors[$name]; |
79 | 85 | } |
80 | 86 | $this->errors = $errors; |
@@ -118,7 +124,9 @@ discard block |
||
118 | 124 | */ |
119 | 125 | protected function normalizeContainer( array $field ) |
120 | 126 | { |
121 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
127 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field )) { |
|
128 | + return; |
|
129 | + } |
|
122 | 130 | $field['items'] = $this->generateFields( $field['items'] ); |
123 | 131 | return $field; |
124 | 132 | } |
@@ -128,7 +136,9 @@ discard block |
||
128 | 136 | */ |
129 | 137 | protected function normalizeField( array $field, array $defaults ) |
130 | 138 | { |
131 | - if( !$this->validate( $field ))return; |
|
139 | + if( !$this->validate( $field )) { |
|
140 | + return; |
|
141 | + } |
|
132 | 142 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
133 | 143 | return $value !== ''; |
134 | 144 | }); |
@@ -149,7 +159,9 @@ discard block |
||
149 | 159 | 'type' => '', |
150 | 160 | 'value' => '', |
151 | 161 | ]); |
152 | - if( !is_array( $listbox ))return; |
|
162 | + if( !is_array( $listbox )) { |
|
163 | + return; |
|
164 | + } |
|
153 | 165 | if( !array_key_exists( '', $listbox['options'] )) { |
154 | 166 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
155 | 167 | } |
@@ -30,7 +30,9 @@ |
||
30 | 30 | { |
31 | 31 | $diff = time() - strtotime( $date ); |
32 | 32 | foreach( static::$TIME_PERIODS as $i => $timePeriod ) { |
33 | - if( $diff > $timePeriod[0] )continue; |
|
33 | + if( $diff > $timePeriod[0] ) { |
|
34 | + continue; |
|
35 | + } |
|
34 | 36 | $unit = intval( floor( $diff / $timePeriod[1] )); |
35 | 37 | $relativeDates = [ |
36 | 38 | _n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ), |
@@ -161,7 +161,9 @@ discard block |
||
161 | 161 | if( !empty( $sessions )) { |
162 | 162 | $now = time(); |
163 | 163 | foreach( $sessions as $session ) { |
164 | - if( $now <= $session->expiration )continue; |
|
164 | + if( $now <= $session->expiration ) { |
|
165 | + continue; |
|
166 | + } |
|
165 | 167 | $expiredSessions[] = $session->name; |
166 | 168 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
167 | 169 | } |
@@ -204,7 +206,9 @@ discard block |
||
204 | 206 | */ |
205 | 207 | protected function setCookie() |
206 | 208 | { |
207 | - if( headers_sent() )return; |
|
209 | + if( headers_sent() ) { |
|
210 | + return; |
|
211 | + } |
|
208 | 212 | $cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset; |
209 | 213 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
210 | 214 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -171,8 +171,12 @@ discard block |
||
171 | 171 | */ |
172 | 172 | protected function validateAkismet() |
173 | 173 | { |
174 | - if( !empty( $this->error ))return; |
|
175 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
174 | + if( !empty( $this->error )) { |
|
175 | + return; |
|
176 | + } |
|
177 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
178 | + return; |
|
179 | + } |
|
176 | 180 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
177 | 181 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
178 | 182 | } |
@@ -182,8 +186,12 @@ discard block |
||
182 | 186 | */ |
183 | 187 | protected function validateBlacklist() |
184 | 188 | { |
185 | - if( !empty( $this->error ))return; |
|
186 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
189 | + if( !empty( $this->error )) { |
|
190 | + return; |
|
191 | + } |
|
192 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
193 | + return; |
|
194 | + } |
|
187 | 195 | $blacklistAction = glsr( OptionManager::class )->get( 'settings.reviews-form.blacklist.action' ); |
188 | 196 | if( $blacklistAction == 'unapprove' ) { |
189 | 197 | $this->request['blacklisted'] = true; |
@@ -199,9 +207,13 @@ discard block |
||
199 | 207 | */ |
200 | 208 | protected function validateCustom() |
201 | 209 | { |
202 | - if( !empty( $this->error ))return; |
|
210 | + if( !empty( $this->error )) { |
|
211 | + return; |
|
212 | + } |
|
203 | 213 | $validated = apply_filters( 'site-reviews/validate/review/submission', true, $this->request ); |
204 | - if( $validated === true )return; |
|
214 | + if( $validated === true ) { |
|
215 | + return; |
|
216 | + } |
|
205 | 217 | $this->setSessionValues( 'errors', [] ); |
206 | 218 | $this->setSessionValues( 'values', $this->request ); |
207 | 219 | $this->error = is_string( $validated ) |
@@ -214,8 +226,12 @@ discard block |
||
214 | 226 | */ |
215 | 227 | protected function validateHoneyPot() |
216 | 228 | { |
217 | - if( !empty( $this->error ))return; |
|
218 | - if( empty( $this->request['gotcha'] ))return; |
|
229 | + if( !empty( $this->error )) { |
|
230 | + return; |
|
231 | + } |
|
232 | + if( empty( $this->request['gotcha'] )) { |
|
233 | + return; |
|
234 | + } |
|
219 | 235 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
220 | 236 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
221 | 237 | } |
@@ -225,7 +241,9 @@ discard block |
||
225 | 241 | */ |
226 | 242 | protected function validateRecaptcha() |
227 | 243 | { |
228 | - if( !empty( $this->error ))return; |
|
244 | + if( !empty( $this->error )) { |
|
245 | + return; |
|
246 | + } |
|
229 | 247 | $isValid = $this->isRecaptchaResponseValid(); |
230 | 248 | if( is_null( $isValid )) { |
231 | 249 | $this->setSessionValues( 'recaptcha', true ); |
@@ -14,7 +14,9 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function renderFilters( $postType ) |
16 | 16 | { |
17 | - if( $postType !== Application::POST_TYPE )return; |
|
17 | + if( $postType !== Application::POST_TYPE ) { |
|
18 | + return; |
|
19 | + } |
|
18 | 20 | if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
19 | 21 | $status = 'publish'; |
20 | 22 | } |
@@ -31,7 +33,9 @@ discard block |
||
31 | 33 | */ |
32 | 34 | public function renderValues( $column, $postId ) |
33 | 35 | { |
34 | - if( glsr_current_screen()->id != Application::POST_TYPE )return; |
|
36 | + if( glsr_current_screen()->id != Application::POST_TYPE ) { |
|
37 | + return; |
|
38 | + } |
|
35 | 39 | $method = glsr( Helper::class )->buildMethodName( $column, 'buildColumn' ); |
36 | 40 | echo method_exists( $this, $method ) |
37 | 41 | ? call_user_func( [$this, $method], $postId ) |
@@ -108,7 +112,9 @@ discard block |
||
108 | 112 | { |
109 | 113 | if( empty( $ratings ) |
110 | 114 | || apply_filters( 'site-reviews/disable/filter/ratings', false ) |
111 | - )return; |
|
115 | + ) { |
|
116 | + return; |
|
117 | + } |
|
112 | 118 | $ratings = array_flip( array_reverse( $ratings )); |
113 | 119 | array_walk( $ratings, function( &$value, $key ) { |
114 | 120 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
@@ -128,7 +134,9 @@ discard block |
||
128 | 134 | */ |
129 | 135 | protected function renderFilterTypes( $types ) |
130 | 136 | { |
131 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
137 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
138 | + return; |
|
139 | + } |
|
132 | 140 | $reviewTypes = ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes; |
133 | 141 | printf( '<label class="screen-reader-text" for="type">%s</label>', __( 'Filter by type', 'site-reviews' )); |
134 | 142 | glsr( Html::class )->renderPartial( 'filterby', [ |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | natsort( $routines ); |
17 | 17 | array_walk( $routines, function( $routine ) { |
18 | 18 | $version = str_replace( strtolower( __CLASS__ ).'_', '', $routine ); |
19 | - if( version_compare( glsr()->version, $version, '>=' ))return; |
|
19 | + if( version_compare( glsr()->version, $version, '>=' )) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | call_user_func( [$this, $routine] ); |
21 | 23 | }); |
22 | 24 | $this->updateVersion(); |
@@ -37,5 +39,6 @@ discard block |
||
37 | 39 | } |
38 | 40 | |
39 | 41 | protected function upgrade_3_0_0() |
40 | - {} |
|
42 | + { |
|
43 | +} |
|
41 | 44 | } |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | { |
55 | 55 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
56 | 56 | foreach( $postTypeColumns as $key => &$value ) { |
57 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
57 | + if( !array_key_exists( $key, $columns ) || !empty( $value )) { |
|
58 | + continue; |
|
59 | + } |
|
58 | 60 | $value = $columns[$key]; |
59 | 61 | } |
60 | 62 | if( count( glsr( Database::class )->getReviewsMeta( 'type' )) < 2 ) { |
@@ -111,7 +113,9 @@ discard block |
||
111 | 113 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
112 | 114 | unset( $postTypeColumns['cb'] ); |
113 | 115 | foreach( $postTypeColumns as $key => $value ) { |
114 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
116 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
117 | + continue; |
|
118 | + } |
|
115 | 119 | $columns[$key] = $key; |
116 | 120 | } |
117 | 121 | return $columns; |
@@ -135,7 +139,9 @@ discard block |
||
135 | 139 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
136 | 140 | ]; |
137 | 141 | foreach( $strings as $search => $replace ) { |
138 | - if( strpos( $single, $search ) === false )continue; |
|
142 | + if( strpos( $single, $search ) === false ) { |
|
143 | + continue; |
|
144 | + } |
|
139 | 145 | $translation = $this->getTranslation([ |
140 | 146 | 'number' => $number, |
141 | 147 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -186,7 +192,9 @@ discard block |
||
186 | 192 | */ |
187 | 193 | public function saveBulkEditFields( $postId ) |
188 | 194 | { |
189 | - if( !current_user_can( 'edit_posts' ))return; |
|
195 | + if( !current_user_can( 'edit_posts' )) { |
|
196 | + return; |
|
197 | + } |
|
190 | 198 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
191 | 199 | if( $assignedTo && get_post( $assignedTo )) { |
192 | 200 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -199,7 +207,9 @@ discard block |
||
199 | 207 | */ |
200 | 208 | public function setQueryForColumn( WP_Query $query ) |
201 | 209 | { |
202 | - if( !$this->hasPermission( $query ))return; |
|
210 | + if( !$this->hasPermission( $query )) { |
|
211 | + return; |
|
212 | + } |
|
203 | 213 | $this->setMetaQuery( $query, [ |
204 | 214 | 'rating', 'review_type', |
205 | 215 | ]); |
@@ -270,7 +280,9 @@ discard block |
||
270 | 280 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
271 | 281 | { |
272 | 282 | foreach( $metaKeys as $key ) { |
273 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
283 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
284 | + continue; |
|
285 | + } |
|
274 | 286 | $metaQuery = (array)$query->get( 'meta_query' ); |
275 | 287 | $metaQuery[] = [ |
276 | 288 | 'key' => $key, |