@@ -85,7 +85,9 @@ discard block |
||
| 85 | 85 | 'Save as Pending' => __( 'Save as Unapproved', 'site-reviews' ), |
| 86 | 86 | ]; |
| 87 | 87 | foreach( $replacements as $search => $replacement ) { |
| 88 | - if( $translation != $search )continue; |
|
| 88 | + if( $translation != $search ) { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 89 | 91 | $translation = $replacement; |
| 90 | 92 | } |
| 91 | 93 | } |
@@ -111,7 +113,9 @@ discard block |
||
| 111 | 113 | public function filterUpdateMessages( array $messages ) |
| 112 | 114 | { |
| 113 | 115 | $post = get_post(); |
| 114 | - if( !( $post instanceof WP_Post ))return; |
|
| 116 | + if( !( $post instanceof WP_Post )) { |
|
| 117 | + return; |
|
| 118 | + } |
|
| 115 | 119 | $strings = glsr( Strings::class )->post_updated_messages(); |
| 116 | 120 | $restored = filter_input( INPUT_GET, 'revision' ); |
| 117 | 121 | if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) { |
@@ -142,7 +146,9 @@ discard block |
||
| 142 | 146 | */ |
| 143 | 147 | public function onCreateReview( $postData, $meta, $postId ) |
| 144 | 148 | { |
| 145 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
| 149 | + if( !$this->isReviewPostType( $review = get_post( $postId ))) { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 146 | 152 | $this->updateAssignedToPost( $review ); |
| 147 | 153 | } |
| 148 | 154 | |
@@ -153,7 +159,9 @@ discard block |
||
| 153 | 159 | */ |
| 154 | 160 | public function onDeleteReview( $postId ) |
| 155 | 161 | { |
| 156 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
| 162 | + if( !$this->isReviewPostType( $review = get_post( $postId ))) { |
|
| 163 | + return; |
|
| 164 | + } |
|
| 157 | 165 | $review->post_status = 'deleted'; // important to change the post_status here first! |
| 158 | 166 | $this->updateAssignedToPost( $review ); |
| 159 | 167 | } |
@@ -175,7 +183,9 @@ discard block |
||
| 175 | 183 | */ |
| 176 | 184 | public function registerMetaBoxes( $postType ) |
| 177 | 185 | { |
| 178 | - if( $postType != Application::POST_TYPE )return; |
|
| 186 | + if( $postType != Application::POST_TYPE ) { |
|
| 187 | + return; |
|
| 188 | + } |
|
| 179 | 189 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 180 | 190 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 181 | 191 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
@@ -207,7 +217,9 @@ discard block |
||
| 207 | 217 | */ |
| 208 | 218 | public function renderAssignedToMetabox( WP_Post $post ) |
| 209 | 219 | { |
| 210 | - if( !$this->isReviewPostType( $post ))return; |
|
| 220 | + if( !$this->isReviewPostType( $post )) { |
|
| 221 | + return; |
|
| 222 | + } |
|
| 211 | 223 | $assignedTo = get_post_meta( $post->ID, 'assigned_to', true ); |
| 212 | 224 | $template = ''; |
| 213 | 225 | if( $assignedPost = get_post( $assignedTo )) { |
@@ -233,7 +245,9 @@ discard block |
||
| 233 | 245 | */ |
| 234 | 246 | public function renderDetailsMetaBox( WP_Post $post ) |
| 235 | 247 | { |
| 236 | - if( !$this->isReviewPostType( $post ))return; |
|
| 248 | + if( !$this->isReviewPostType( $post )) { |
|
| 249 | + return; |
|
| 250 | + } |
|
| 237 | 251 | $review = glsr_db()->getReview( $post ); |
| 238 | 252 | glsr()->render( 'edit/metabox-details', [ |
| 239 | 253 | 'button' => $this->getMetaboxButton( $review, $post ), |
@@ -247,7 +261,9 @@ discard block |
||
| 247 | 261 | */ |
| 248 | 262 | public function renderMetaBoxPinned() |
| 249 | 263 | { |
| 250 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 264 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 251 | 267 | $pinned = get_post_meta( get_the_ID(), 'pinned', true ); |
| 252 | 268 | glsr()->render( 'edit/pinned', [ |
| 253 | 269 | 'pinned' => $pinned, |
@@ -260,7 +276,9 @@ discard block |
||
| 260 | 276 | */ |
| 261 | 277 | public function renderResponseMetaBox( WP_Post $post ) |
| 262 | 278 | { |
| 263 | - if( !$this->isReviewPostType( $post ))return; |
|
| 279 | + if( !$this->isReviewPostType( $post )) { |
|
| 280 | + return; |
|
| 281 | + } |
|
| 264 | 282 | $review = glsr_db()->getReview( $post ); |
| 265 | 283 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 266 | 284 | glsr()->render( 'edit/metabox-response', [ |
@@ -275,7 +293,9 @@ discard block |
||
| 275 | 293 | */ |
| 276 | 294 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 277 | 295 | { |
| 278 | - if( !$this->isReviewPostType( $post ))return; |
|
| 296 | + if( !$this->isReviewPostType( $post )) { |
|
| 297 | + return; |
|
| 298 | + } |
|
| 279 | 299 | glsr()->render( 'edit/metabox-categories', [ |
| 280 | 300 | 'post' => $post, |
| 281 | 301 | 'tax_name' => esc_attr( Application::TAXONOMY ), |
@@ -471,7 +491,9 @@ discard block |
||
| 471 | 491 | */ |
| 472 | 492 | protected function saveAssignedToMetabox( $postId ) |
| 473 | 493 | { |
| 474 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 494 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' )) { |
|
| 495 | + return; |
|
| 496 | + } |
|
| 475 | 497 | $assignedTo = filter_input( INPUT_POST, 'assigned_to' ); |
| 476 | 498 | $assignedTo || $assignedTo = ''; |
| 477 | 499 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -486,7 +508,9 @@ discard block |
||
| 486 | 508 | */ |
| 487 | 509 | protected function saveResponseMetabox( $postId ) |
| 488 | 510 | { |
| 489 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ))return; |
|
| 511 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' )) { |
|
| 512 | + return; |
|
| 513 | + } |
|
| 490 | 514 | $response = filter_input( INPUT_POST, 'response' ); |
| 491 | 515 | $response || $response = ''; |
| 492 | 516 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
@@ -501,7 +525,9 @@ discard block |
||
| 501 | 525 | */ |
| 502 | 526 | protected function updateAssignedToPost( WP_Post $review ) |
| 503 | 527 | { |
| 504 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
| 528 | + if( !( $postId = $this->getAssignedToPostId( $review->ID ))) { |
|
| 529 | + return; |
|
| 530 | + } |
|
| 505 | 531 | $reviewIds = get_post_meta( $postId, static::META_REVIEW_ID ); |
| 506 | 532 | $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 507 | 533 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
@@ -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.'"' ); |
@@ -25,7 +25,8 @@ |
||
| 25 | 25 | protected $router; |
| 26 | 26 | // protected $settings; |
| 27 | 27 | |
| 28 | - public function __construct( Application $app ) { |
|
| 28 | + public function __construct( Application $app ) |
|
| 29 | + { |
|
| 29 | 30 | $this->app = $app; |
| 30 | 31 | $this->admin = $app->make( AdminController::class ); |
| 31 | 32 | // $this->editor = $app->make( EditorController::class ); |
@@ -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() ); |