@@ -90,7 +90,9 @@ |
||
| 90 | 90 | { |
| 91 | 91 | $total = array_sum( $ratingCounts ); |
| 92 | 92 | foreach( $ratingCounts as $index => $count ) { |
| 93 | - if( empty( $count ))continue; |
|
| 93 | + if( empty( $count )) { |
|
| 94 | + continue; |
|
| 95 | + } |
|
| 94 | 96 | $ratingCounts[$index] = $count / $total * 100; |
| 95 | 97 | } |
| 96 | 98 | return $this->getRoundedPercentages( $ratingCounts ); |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | if( empty( $assignedTo )) { |
| 24 | 24 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
| 25 | 25 | } |
| 26 | - if( empty( $assignedTo ))return; |
|
| 26 | + if( empty( $assignedTo )) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 27 | 29 | $assignedPost = get_post( $assignedTo ); |
| 28 | 30 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
| 29 | 31 | return $assignedPost; |
@@ -112,7 +114,9 @@ discard block |
||
| 112 | 114 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
| 113 | 115 | $search = new WP_Query( $args ); |
| 114 | 116 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
| 115 | - if( !$search->have_posts() )return; |
|
| 117 | + if( !$search->have_posts() ) { |
|
| 118 | + return; |
|
| 119 | + } |
|
| 116 | 120 | $results = ''; |
| 117 | 121 | while( $search->have_posts() ) { |
| 118 | 122 | $search->the_post(); |
@@ -81,7 +81,9 @@ discard block |
||
| 81 | 81 | ]; |
| 82 | 82 | if( !isset( $properties[$property] ) |
| 83 | 83 | || empty( array_filter( [$value], $properties[$property] )) |
| 84 | - )return; |
|
| 84 | + ) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 85 | 87 | $this->$property = $value; |
| 86 | 88 | } |
| 87 | 89 | |
@@ -90,7 +92,9 @@ discard block |
||
| 90 | 92 | */ |
| 91 | 93 | public function getClosingTag() |
| 92 | 94 | { |
| 93 | - if( empty( $this->tag ))return; |
|
| 95 | + if( empty( $this->tag )) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 94 | 98 | return '</'.$this->tag.'>'; |
| 95 | 99 | } |
| 96 | 100 | |
@@ -99,7 +103,9 @@ discard block |
||
| 99 | 103 | */ |
| 100 | 104 | public function getOpeningTag() |
| 101 | 105 | { |
| 102 | - if( empty( $this->tag ))return; |
|
| 106 | + if( empty( $this->tag )) { |
|
| 107 | + return; |
|
| 108 | + } |
|
| 103 | 109 | $attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString(); |
| 104 | 110 | return '<'.trim( $this->tag.' '.$attributes ).'>'; |
| 105 | 111 | } |
@@ -141,7 +147,9 @@ discard block |
||
| 141 | 147 | */ |
| 142 | 148 | protected function buildFieldDescription() |
| 143 | 149 | { |
| 144 | - if( empty( $this->args['description'] ))return; |
|
| 150 | + if( empty( $this->args['description'] )) { |
|
| 151 | + return; |
|
| 152 | + } |
|
| 145 | 153 | if( $this->args['is_widget'] ) { |
| 146 | 154 | return $this->small( $this->args['description'] ); |
| 147 | 155 | } |
@@ -207,7 +215,9 @@ discard block |
||
| 207 | 215 | */ |
| 208 | 216 | protected function buildFormLabel( array $customArgs = [] ) |
| 209 | 217 | { |
| 210 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
| 218 | + if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' ) { |
|
| 219 | + return; |
|
| 220 | + } |
|
| 211 | 221 | return $this->label( wp_parse_args( $customArgs, [ |
| 212 | 222 | 'for' => $this->args['id'], |
| 213 | 223 | 'is_public' => $this->args['is_public'], |
@@ -17,6 +17,8 @@ |
||
| 17 | 17 | * @return void |
| 18 | 18 | */ |
| 19 | 19 | add_action( 'site-reviews/customize/divi', function( $instance ) { |
| 20 | - if( $instance->tag != 'label' || $instance->args['type'] != 'checkbox' )return; |
|
| 20 | + if( $instance->tag != 'label' || $instance->args['type'] != 'checkbox' ) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 21 | 23 | $instance->args['text'] = '<i></i>'.$instance->args['text']; |
| 22 | 24 | }); |
@@ -13,7 +13,9 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function saveAssignedToMetabox( $postId ) |
| 15 | 15 | { |
| 16 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 16 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) { |
|
| 17 | + return; |
|
| 18 | + } |
|
| 17 | 19 | $assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' )); |
| 18 | 20 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
| 19 | 21 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
@@ -28,7 +30,9 @@ discard block |
||
| 28 | 30 | */ |
| 29 | 31 | public function saveResponseMetabox( $postId ) |
| 30 | 32 | { |
| 31 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
| 33 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 32 | 36 | $response = strval( glsr( Helper::class )->filterInput( 'response' )); |
| 33 | 37 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
| 34 | 38 | 'a' => ['href' => [], 'title' => []], |
@@ -25,7 +25,9 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | sort( $termIds ); |
| 27 | 27 | sort( $oldTermIds ); |
| 28 | - if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ))return; |
|
| 28 | + if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId )) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 29 | 31 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 30 | 32 | $ignoredTerms = array_intersect( $oldTermIds, $termIds ); |
| 31 | 33 | if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms )) { |
@@ -45,7 +47,9 @@ discard block |
||
| 45 | 47 | */ |
| 46 | 48 | public function onAfterCreate( $postData, $meta, $postId ) |
| 47 | 49 | { |
| 48 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 50 | + if( !$this->isReviewPostId( $postId )) { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 49 | 53 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 50 | 54 | glsr( CountsManager::class )->increase( $review ); |
| 51 | 55 | } |
@@ -57,7 +61,9 @@ discard block |
||
| 57 | 61 | */ |
| 58 | 62 | public function onBeforeDelete( $postId ) |
| 59 | 63 | { |
| 60 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 64 | + if( !$this->isReviewPostId( $postId )) { |
|
| 65 | + return; |
|
| 66 | + } |
|
| 61 | 67 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 62 | 68 | glsr( CountsManager::class )->decrease( $review ); |
| 63 | 69 | } |
@@ -74,9 +80,13 @@ discard block |
||
| 74 | 80 | { |
| 75 | 81 | if( !$this->isReviewPostId( $postId ) |
| 76 | 82 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 77 | - )return; |
|
| 83 | + ) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 78 | 86 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 79 | - if( $review->$metaKey == $metaValue )return; |
|
| 87 | + if( $review->$metaKey == $metaValue ) { |
|
| 88 | + return; |
|
| 89 | + } |
|
| 80 | 90 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 81 | 91 | call_user_func( [$this, $method], $review, $metaValue ); |
| 82 | 92 | } |
@@ -122,7 +132,9 @@ discard block |
||
| 122 | 132 | */ |
| 123 | 133 | public function onChangeStatus( $newStatus, $oldStatus, WP_Post $post ) |
| 124 | 134 | { |
| 125 | - if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 135 | + if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
| 136 | + return; |
|
| 137 | + } |
|
| 126 | 138 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
| 127 | 139 | if( $post->post_status == 'publish' ) { |
| 128 | 140 | glsr( CountsManager::class )->increase( $review ); |
@@ -93,7 +93,9 @@ discard block |
||
| 93 | 93 | foreach( $this->rules as $attribute => $rules ) { |
| 94 | 94 | foreach( $rules as $rule ) { |
| 95 | 95 | $this->validateAttribute( $attribute, $rule ); |
| 96 | - if( $this->shouldStopValidating( $attribute ))break; |
|
| 96 | + if( $this->shouldStopValidating( $attribute )) { |
|
| 97 | + break; |
|
| 98 | + } |
|
| 97 | 99 | } |
| 98 | 100 | } |
| 99 | 101 | return $this->errors; |
@@ -109,7 +111,9 @@ discard block |
||
| 109 | 111 | public function validateAttribute( $attribute, $rule ) |
| 110 | 112 | { |
| 111 | 113 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
| 112 | - if( $rule == '' )return; |
|
| 114 | + if( $rule == '' ) { |
|
| 115 | + return; |
|
| 116 | + } |
|
| 113 | 117 | $value = $this->getValue( $attribute ); |
| 114 | 118 | if( !method_exists( $this, $method = 'validate'.$rule )) { |
| 115 | 119 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
@@ -178,7 +182,9 @@ discard block |
||
| 178 | 182 | */ |
| 179 | 183 | protected function getRule( $attribute, $rules ) |
| 180 | 184 | { |
| 181 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
| 185 | + if( !array_key_exists( $attribute, $this->rules )) { |
|
| 186 | + return; |
|
| 187 | + } |
|
| 182 | 188 | $rules = (array)$rules; |
| 183 | 189 | foreach( $this->rules[$attribute] as $rule ) { |
| 184 | 190 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function enqueuePolyfillService() |
| 57 | 57 | { |
| 58 | - if( !apply_filters( 'site-reviews/assets/polyfill', true ))return; |
|
| 58 | + if( !apply_filters( 'site-reviews/assets/polyfill', true )) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 59 | 61 | wp_enqueue_script( Application::ID.'/polyfill', add_query_arg([ |
| 60 | 62 | 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event', |
| 61 | 63 | 'flags' => 'gated', |
@@ -70,7 +72,9 @@ discard block |
||
| 70 | 72 | // wpforms-recaptcha |
| 71 | 73 | // google-recaptcha |
| 72 | 74 | // nf-google-recaptcha |
| 73 | - if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
|
| 75 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 74 | 78 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
| 75 | 79 | wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
| 76 | 80 | 'hl' => $language, |
@@ -84,7 +88,9 @@ discard block |
||
| 84 | 88 | public function inlineStyles() |
| 85 | 89 | { |
| 86 | 90 | $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
| 87 | - if( !apply_filters( 'site-reviews/assets/css', true ))return; |
|
| 91 | + if( !apply_filters( 'site-reviews/assets/css', true )) { |
|
| 92 | + return; |
|
| 93 | + } |
|
| 88 | 94 | if( !file_exists( $inlineStylesheetPath )) { |
| 89 | 95 | glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
| 90 | 96 | return; |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | public function routeAdminPostRequest() |
| 18 | 18 | { |
| 19 | 19 | $request = $this->getRequest(); |
| 20 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 20 | + if( !$this->isValidPostRequest( $request )) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 21 | 23 | check_admin_referer( $request['action'] ); |
| 22 | 24 | $this->routeRequest( 'admin', $request['action'], $request ); |
| 23 | 25 | } |
@@ -39,10 +41,16 @@ discard block |
||
| 39 | 41 | */ |
| 40 | 42 | public function routePublicPostRequest() |
| 41 | 43 | { |
| 42 | - if( is_admin() )return; |
|
| 44 | + if( is_admin() ) { |
|
| 45 | + return; |
|
| 46 | + } |
|
| 43 | 47 | $request = $this->getRequest(); |
| 44 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 45 | - if( !$this->isValidPublicNonce( $request ))return; |
|
| 48 | + if( !$this->isValidPostRequest( $request )) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | + if( !$this->isValidPublicNonce( $request )) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 46 | 54 | $this->routeRequest( 'public', $request['action'], $request ); |
| 47 | 55 | } |
| 48 | 56 | |
@@ -51,7 +59,9 @@ discard block |
||
| 51 | 59 | */ |
| 52 | 60 | protected function checkAjaxNonce( array $request ) |
| 53 | 61 | { |
| 54 | - if( !is_user_logged_in() )return; |
|
| 62 | + if( !is_user_logged_in() ) { |
|
| 63 | + return; |
|
| 64 | + } |
|
| 55 | 65 | if( !isset( $request['nonce'] )) { |
| 56 | 66 | $this->sendAjaxError( 'request is missing a nonce', $request ); |
| 57 | 67 | } |