@@ -15,7 +15,9 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function download( $filename, $content ) |
| 17 | 17 | { |
| 18 | - if( !current_user_can( Application::CAPABILITY ))return; |
|
| 18 | + if( !current_user_can( Application::CAPABILITY )) { |
|
| 19 | + return; |
|
| 20 | + } |
|
| 19 | 21 | nocache_headers(); |
| 20 | 22 | header( 'Content-Type: text/plain' ); |
| 21 | 23 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function send() |
| 66 | 66 | { |
| 67 | - if( !$this->message || !$this->subject || !$this->to )return; |
|
| 67 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 68 | 70 | $sent = wp_mail( |
| 69 | 71 | $this->to, |
| 70 | 72 | $this->subject, |
@@ -83,7 +85,9 @@ discard block |
||
| 83 | 85 | */ |
| 84 | 86 | public function buildPlainTextMessage( $phpmailer ) |
| 85 | 87 | { |
| 86 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 88 | + if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody )) { |
|
| 89 | + return; |
|
| 90 | + } |
|
| 87 | 91 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 88 | 92 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 89 | 93 | } |
@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | foreach( $this->rules as $attribute => $rules ) { |
| 75 | 75 | foreach( $rules as $rule ) { |
| 76 | 76 | $this->validateAttribute( $attribute, $rule ); |
| 77 | - if( $this->shouldStopValidating( $attribute ))break; |
|
| 77 | + if( $this->shouldStopValidating( $attribute )) { |
|
| 78 | + break; |
|
| 79 | + } |
|
| 78 | 80 | } |
| 79 | 81 | } |
| 80 | 82 | return $this->errors; |
@@ -90,7 +92,9 @@ discard block |
||
| 90 | 92 | public function validateAttribute( $attribute, $rule ) |
| 91 | 93 | { |
| 92 | 94 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
| 93 | - if( $rule == '' )return; |
|
| 95 | + if( $rule == '' ) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 94 | 98 | $value = $this->getValue( $attribute ); |
| 95 | 99 | $this->validateRequired( $attribute, $value ) || in_array( $rule, $this->implicitRules ); |
| 96 | 100 | if( !method_exists( $this, $method = 'validate'.$rule )) { |
@@ -163,7 +167,9 @@ discard block |
||
| 163 | 167 | */ |
| 164 | 168 | protected function getRule( $attribute, $rules ) |
| 165 | 169 | { |
| 166 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
| 170 | + if( !array_key_exists( $attribute, $this->rules )) { |
|
| 171 | + return; |
|
| 172 | + } |
|
| 167 | 173 | $rules = (array) $rules; |
| 168 | 174 | foreach( $this->rules[$attribute] as $rule ) { |
| 169 | 175 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
@@ -314,7 +320,9 @@ discard block |
||
| 314 | 320 | $message = isset( $strings[$key] ) |
| 315 | 321 | ? $strings[$key] |
| 316 | 322 | : false; |
| 317 | - if( !$message )return; |
|
| 323 | + if( !$message ) { |
|
| 324 | + return; |
|
| 325 | + } |
|
| 318 | 326 | $message = str_replace( ':attribute', $attribute, $message ); |
| 319 | 327 | if( method_exists( $this, $replacer = 'replace'.$rule )) { |
| 320 | 328 | $message = $this->$replacer( $message, $parameters ); |
@@ -91,7 +91,9 @@ discard block |
||
| 91 | 91 | ]; |
| 92 | 92 | if( !isset( $properties[$property] ) |
| 93 | 93 | || empty( array_filter( [$value], $properties[$property] )) |
| 94 | - )return; |
|
| 94 | + ) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 95 | 97 | $this->$property = $value; |
| 96 | 98 | } |
| 97 | 99 | |
@@ -188,7 +190,9 @@ discard block |
||
| 188 | 190 | */ |
| 189 | 191 | protected function buildFormLabel() |
| 190 | 192 | { |
| 191 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
| 193 | + if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' ) { |
|
| 194 | + return; |
|
| 195 | + } |
|
| 192 | 196 | return $this->label([ |
| 193 | 197 | 'for' => $this->args['id'], |
| 194 | 198 | 'text' => $this->args['label'], |
@@ -190,7 +190,9 @@ |
||
| 190 | 190 | if( $index === false |
| 191 | 191 | || !isset( $caller[$index+2]['class'] ) |
| 192 | 192 | || !isset( $caller[$index+2]['function'] ) |
| 193 | - )return; |
|
| 193 | + ) { |
|
| 194 | + return; |
|
| 195 | + } |
|
| 194 | 196 | return sprintf( '[%s()->%s:%s] ', |
| 195 | 197 | $caller[$index+2]['class'], |
| 196 | 198 | $caller[$index+2]['function'], |
@@ -87,7 +87,9 @@ |
||
| 87 | 87 | */ |
| 88 | 88 | public function deactivate( $plugin ) |
| 89 | 89 | { |
| 90 | - if( static::isValid() )return; |
|
| 90 | + if( static::isValid() ) { |
|
| 91 | + return; |
|
| 92 | + } |
|
| 91 | 93 | $pluginSlug = plugin_basename( static::$file ); |
| 92 | 94 | if( $plugin == $pluginSlug ) { |
| 93 | 95 | $this->redirect(); //exit |
@@ -67,7 +67,9 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function getReview( $post ) |
| 69 | 69 | { |
| 70 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 70 | + if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) { |
|
| 71 | + return; |
|
| 72 | + } |
|
| 71 | 73 | $review = $this->getReviewMeta( $post->ID ); |
| 72 | 74 | $modified = $this->isReviewModified( $post, $review ); |
| 73 | 75 | $review->content = $post->post_content; |
@@ -241,7 +243,9 @@ discard block |
||
| 241 | 243 | $termIds = array_map( 'trim', explode( ',', $termIds )); |
| 242 | 244 | foreach( $termIds as $termId ) { |
| 243 | 245 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 244 | - if( !isset( $term['term_id'] ))continue; |
|
| 246 | + if( !isset( $term['term_id'] )) { |
|
| 247 | + continue; |
|
| 248 | + } |
|
| 245 | 249 | $terms[] = intval( $term['term_id'] ); |
| 246 | 250 | } |
| 247 | 251 | return $terms; |
@@ -254,7 +258,9 @@ discard block |
||
| 254 | 258 | public function revertReview( $postId ) |
| 255 | 259 | { |
| 256 | 260 | $post = get_post( $postId ); |
| 257 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 261 | + if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) { |
|
| 262 | + return; |
|
| 263 | + } |
|
| 258 | 264 | delete_post_meta( $post->ID, '_edit_last' ); |
| 259 | 265 | $result = wp_update_post([ |
| 260 | 266 | 'ID' => $post->ID, |
@@ -289,7 +295,9 @@ discard block |
||
| 289 | 295 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
| 290 | 296 | $search = new WP_Query( $args ); |
| 291 | 297 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
| 292 | - if( !$search->have_posts() )return; |
|
| 298 | + if( !$search->have_posts() ) { |
|
| 299 | + return; |
|
| 300 | + } |
|
| 293 | 301 | $results = ''; |
| 294 | 302 | while( $search->have_posts() ) { |
| 295 | 303 | $search->the_post(); |
@@ -313,7 +321,9 @@ discard block |
||
| 313 | 321 | public function setReviewMeta( $postId, $termIds ) |
| 314 | 322 | { |
| 315 | 323 | $terms = $this->normalizeTerms( $termIds ); |
| 316 | - if( empty( $terms ))return; |
|
| 324 | + if( empty( $terms )) { |
|
| 325 | + return; |
|
| 326 | + } |
|
| 317 | 327 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 318 | 328 | if( is_wp_error( $result )) { |
| 319 | 329 | glsr_log()->error( $result->get_error_message() ); |
@@ -62,7 +62,9 @@ |
||
| 62 | 62 | if( !empty( $validated->error )) { |
| 63 | 63 | return $validated->request; |
| 64 | 64 | } |
| 65 | - if( $validated->recaptchaIsUnset )return; |
|
| 65 | + if( $validated->recaptchaIsUnset ) { |
|
| 66 | + return; |
|
| 67 | + } |
|
| 66 | 68 | return $this->execute( new CreateReview( $validated->request )); |
| 67 | 69 | } |
| 68 | 70 | } |
@@ -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', |