@@ -4,7 +4,8 @@ discard block |
||
| 4 | 4 | /** |
| 5 | 5 | * @return mixed |
| 6 | 6 | */ |
| 7 | -function glsr( $alias = null ) { |
|
| 7 | +function glsr( $alias = null ) |
|
| 8 | +{ |
|
| 8 | 9 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 9 | 10 | return empty( $alias ) |
| 10 | 11 | ? $app |
@@ -15,7 +16,8 @@ discard block |
||
| 15 | 16 | * get_current_screen() is unreliable because it is not defined on all admin pages |
| 16 | 17 | * @return \WP_Screen|object |
| 17 | 18 | */ |
| 18 | -function glsr_current_screen() { |
|
| 19 | +function glsr_current_screen() |
|
| 20 | +{ |
|
| 19 | 21 | if( function_exists( 'get_current_screen' )) { |
| 20 | 22 | $screen = get_current_screen(); |
| 21 | 23 | } |
@@ -27,7 +29,8 @@ discard block |
||
| 27 | 29 | /** |
| 28 | 30 | * @return \GeminiLabs\SiteReviews\Database |
| 29 | 31 | */ |
| 30 | -function glsr_db() { |
|
| 32 | +function glsr_db() |
|
| 33 | +{ |
|
| 31 | 34 | return glsr( 'Database' ); |
| 32 | 35 | } |
| 33 | 36 | |
@@ -35,7 +38,8 @@ discard block |
||
| 35 | 38 | * @param mixed ...$vars |
| 36 | 39 | * @return void |
| 37 | 40 | */ |
| 38 | -function glsr_debug( ...$vars ) { |
|
| 41 | +function glsr_debug( ...$vars ) |
|
| 42 | +{ |
|
| 39 | 43 | if( count( $vars ) == 1 ) { |
| 40 | 44 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
| 41 | 45 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -52,7 +56,8 @@ discard block |
||
| 52 | 56 | /** |
| 53 | 57 | * @return \GeminiLabs\SiteReviews\Modules\Logger |
| 54 | 58 | */ |
| 55 | -function glsr_log() { |
|
| 59 | +function glsr_log() |
|
| 60 | +{ |
|
| 56 | 61 | $args = func_get_args(); |
| 57 | 62 | $context = isset( $args[1] ) |
| 58 | 63 | ? $args[1] |
@@ -68,7 +73,8 @@ discard block |
||
| 68 | 73 | * @return void |
| 69 | 74 | * @callback register_taxonomy() "meta_box_cb" |
| 70 | 75 | */ |
| 71 | -function glsr_categories_meta_box( $post, $box ) { |
|
| 76 | +function glsr_categories_meta_box( $post, $box ) |
|
| 77 | +{ |
|
| 72 | 78 | glsr( 'Controllers\EditorController' )->renderTaxonomyMetabox( $post, $box ); |
| 73 | 79 | } |
| 74 | 80 | |
@@ -77,14 +83,16 @@ discard block |
||
| 77 | 83 | * @param mixed $fallback |
| 78 | 84 | * @return string|array |
| 79 | 85 | */ |
| 80 | -function glsr_get_option( $option_path = '', $fallback = '' ) { |
|
| 86 | +function glsr_get_option( $option_path = '', $fallback = '' ) |
|
| 87 | +{ |
|
| 81 | 88 | return glsr( 'Database\OptionManager' )->get( 'settings.'.$option_path, $fallback ); |
| 82 | 89 | } |
| 83 | 90 | |
| 84 | 91 | /** |
| 85 | 92 | * @return array |
| 86 | 93 | */ |
| 87 | -function glsr_get_options() { |
|
| 94 | +function glsr_get_options() |
|
| 95 | +{ |
|
| 88 | 96 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
| 89 | 97 | } |
| 90 | 98 | |
@@ -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 ); |
@@ -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', |