@@ -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(); |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | $this->sendNotification( $postId ); |
35 | 35 | do_action( 'site-reviews/local/review/submitted', $postId, $command ); |
36 | 36 | glsr( Session::class )->set( $command->form_id.'message', __( 'Your review has been submitted!', 'site-reviews' )); |
37 | - if( $command->ajax_request )return; |
|
37 | + if( $command->ajax_request ) { |
|
38 | + return; |
|
39 | + } |
|
38 | 40 | wp_safe_redirect( $command->referrer ); |
39 | 41 | exit; |
40 | 42 | } |
@@ -100,7 +102,9 @@ discard block |
||
100 | 102 | protected function sendNotification( $postId ) |
101 | 103 | { |
102 | 104 | $notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' ); |
103 | - if( !in_array( $notificationType, ['default','custom','webhook'] ))return; |
|
105 | + if( !in_array( $notificationType, ['default','custom','webhook'] )) { |
|
106 | + return; |
|
107 | + } |
|
104 | 108 | $assignedToTitle = get_the_title( (int)$this->command->assigned_to ); |
105 | 109 | $notificationSubject = _nx( |
106 | 110 | 'New %s-star review', |
@@ -148,7 +152,9 @@ discard block |
||
148 | 152 | */ |
149 | 153 | protected function sendWebhookNotification( array $args ) |
150 | 154 | { |
151 | - if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )))return; |
|
155 | + if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' ))) { |
|
156 | + return; |
|
157 | + } |
|
152 | 158 | $notification = $this->createWebhookNotification( $args ); |
153 | 159 | $result = wp_remote_post( $endpoint, [ |
154 | 160 | 'blocking' => false, |
@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | // get rating counts |
37 | 37 | $this->ratingCounts = [0,0,0,0,0,0]; |
38 | 38 | |
39 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
39 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' )) { |
|
40 | + return; |
|
41 | + } |
|
40 | 42 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
41 | 43 | $this->generateSchema(); |
42 | 44 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -56,7 +58,9 @@ discard block |
||
56 | 58 | */ |
57 | 59 | protected function buildPercentage() |
58 | 60 | { |
59 | - if( $this->isHidden( 'bars' ))return; |
|
61 | + if( $this->isHidden( 'bars' )) { |
|
62 | + return; |
|
63 | + } |
|
60 | 64 | $range = range( Rating::MAX_RATING, 1 ); |
61 | 65 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
62 | 66 | $bars = array_reduce( $range, function( $carry, $level ) use( $percentages ) { |
@@ -106,7 +110,9 @@ discard block |
||
106 | 110 | */ |
107 | 111 | protected function buildRating() |
108 | 112 | { |
109 | - if( $this->isHidden( 'rating' ))return; |
|
113 | + if( $this->isHidden( 'rating' )) { |
|
114 | + return; |
|
115 | + } |
|
110 | 116 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
111 | 117 | } |
112 | 118 | |
@@ -115,7 +121,9 @@ discard block |
||
115 | 121 | */ |
116 | 122 | protected function buildStars() |
117 | 123 | { |
118 | - if( $this->isHidden( 'stars' ))return; |
|
124 | + if( $this->isHidden( 'stars' )) { |
|
125 | + return; |
|
126 | + } |
|
119 | 127 | $stars = glsr( Partial::class )->build( 'star-rating', [ |
120 | 128 | 'rating' => $this->averageRating, |
121 | 129 | ]); |
@@ -127,7 +135,9 @@ discard block |
||
127 | 135 | */ |
128 | 136 | protected function buildText() |
129 | 137 | { |
130 | - if( $this->isHidden( 'summary' ))return; |
|
138 | + if( $this->isHidden( 'summary' )) { |
|
139 | + return; |
|
140 | + } |
|
131 | 141 | $count = intval( array_sum( $this->ratingCounts )); |
132 | 142 | if( empty( $this->args['text'] )) { |
133 | 143 | // @todo document this change |
@@ -152,7 +162,9 @@ discard block |
||
152 | 162 | */ |
153 | 163 | protected function generateSchema() |
154 | 164 | { |
155 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
165 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
166 | + return; |
|
167 | + } |
|
156 | 168 | glsr( Schema::class )->store( |
157 | 169 | glsr( Schema::class )->buildSummary( $this->args ) |
158 | 170 | ); |
@@ -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'], |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | } |
43 | 43 | $views = $this->generatePossibleViews( $view ); |
44 | 44 | foreach( $views as $possibleView ) { |
45 | - if( !file_exists( glsr()->path( 'views/'.$possibleView.'.php' )))continue; |
|
45 | + if( !file_exists( glsr()->path( 'views/'.$possibleView.'.php' ))) { |
|
46 | + continue; |
|
47 | + } |
|
46 | 48 | return $possibleView; |
47 | 49 | } |
48 | 50 | return $view; |
@@ -76,7 +78,9 @@ discard block |
||
76 | 78 | */ |
77 | 79 | public function modifyField( Builder $instance ) |
78 | 80 | { |
79 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->styles )))return; |
|
81 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->styles ))) { |
|
82 | + return; |
|
83 | + } |
|
80 | 84 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
81 | 85 | } |
82 | 86 |
@@ -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 | }); |
@@ -68,7 +68,9 @@ discard block |
||
68 | 68 | $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
69 | 69 | $this->modified = $this->isModified( $properties ); |
70 | 70 | array_walk( $properties, function( $value, $key ) { |
71 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
71 | + if( !property_exists( $this, $key ) || isset( $this->$key )) { |
|
72 | + return; |
|
73 | + } |
|
72 | 74 | $this->$key = $value; |
73 | 75 | }); |
74 | 76 | } |
@@ -79,7 +81,9 @@ discard block |
||
79 | 81 | protected function setTermIds( WP_Post $post ) |
80 | 82 | { |
81 | 83 | $this->term_ids = []; |
82 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
84 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ))) { |
|
85 | + return; |
|
86 | + } |
|
83 | 87 | foreach( $terms as $term ) { |
84 | 88 | $this->term_ids[] = $term->term_id; |
85 | 89 | } |
@@ -71,7 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function decreasePostCounts( Review $review ) |
73 | 73 | { |
74 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
74 | + if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
|
75 | + return; |
|
76 | + } |
|
75 | 77 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
76 | 78 | $this->setPostCounts( $review->assigned_to, $counts ); |
77 | 79 | } |
@@ -82,7 +84,9 @@ discard block |
||
82 | 84 | public function decreaseTermCounts( Review $review ) |
83 | 85 | { |
84 | 86 | foreach( $review->term_ids as $termId ) { |
85 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
87 | + if( empty( $counts = $this->getTermCounts( $termId ))) { |
|
88 | + continue; |
|
89 | + } |
|
86 | 90 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
87 | 91 | $this->setTermCounts( $termId, $counts ); |
88 | 92 | } |
@@ -158,7 +162,9 @@ discard block |
||
158 | 162 | */ |
159 | 163 | public function increasePostCounts( Review $review ) |
160 | 164 | { |
161 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
165 | + if( !( get_post( $review->assigned_to ) instanceof WP_Post )) { |
|
166 | + return; |
|
167 | + } |
|
162 | 168 | if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
163 | 169 | $counts = $this->buildPostCounts( $review->assigned_to ); |
164 | 170 | } |
@@ -172,7 +178,9 @@ discard block |
||
172 | 178 | public function increaseTermCounts( Review $review ) |
173 | 179 | { |
174 | 180 | foreach( $review->term_ids as $termId ) { |
175 | - if( !( get_term( $termId, Application::TAXONOMY ) instanceof WP_Term ))continue; |
|
181 | + if( !( get_term( $termId, Application::TAXONOMY ) instanceof WP_Term )) { |
|
182 | + continue; |
|
183 | + } |
|
176 | 184 | if( empty( $counts = $this->getTermCounts( $termId ))) { |
177 | 185 | $counts = $this->buildTermCounts( $termId ); |
178 | 186 | } |
@@ -224,7 +232,9 @@ discard block |
||
224 | 232 | while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) { |
225 | 233 | $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
226 | 234 | foreach( $types as $type ) { |
227 | - if( isset( $counts[$type] ))continue; |
|
235 | + if( isset( $counts[$type] )) { |
|
236 | + continue; |
|
237 | + } |
|
228 | 238 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
229 | 239 | } |
230 | 240 | foreach( $reviews as $review ) { |
@@ -273,7 +283,9 @@ discard block |
||
273 | 283 | { |
274 | 284 | foreach( $reviewCounts as &$counts ) { |
275 | 285 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
276 | - if( isset( $counts[$index] ))continue; |
|
286 | + if( isset( $counts[$index] )) { |
|
287 | + continue; |
|
288 | + } |
|
277 | 289 | $counts[$index] = 0; |
278 | 290 | } |
279 | 291 | ksort( $counts ); |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function onAfterChangeCategory( $postId, $terms, $termIds, $taxonomySlug, $append, $oldTermIds ) |
24 | 24 | { |
25 | - if( !$this->isReviewPostType( $postId ))return; |
|
25 | + if( !$this->isReviewPostType( $postId )) { |
|
26 | + return; |
|
27 | + } |
|
26 | 28 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
27 | 29 | $ignoredTerms = array_intersect( $oldTermIds, $termIds ); |
28 | 30 | $review->term_ids = array_diff( $oldTermIds, $ignoredTerms ); |
@@ -40,7 +42,9 @@ discard block |
||
40 | 42 | */ |
41 | 43 | public function onAfterCreate( $postData, $meta, $postId ) |
42 | 44 | { |
43 | - if( !$this->isReviewPostType( $postId ))return; |
|
45 | + if( !$this->isReviewPostType( $postId )) { |
|
46 | + return; |
|
47 | + } |
|
44 | 48 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
45 | 49 | glsr( CountsManager::class )->increase( $review ); |
46 | 50 | } |
@@ -52,7 +56,9 @@ discard block |
||
52 | 56 | */ |
53 | 57 | public function onBeforeDelete( $postId ) |
54 | 58 | { |
55 | - if( !$this->isReviewPostType( $postId ))return; |
|
59 | + if( !$this->isReviewPostType( $postId )) { |
|
60 | + return; |
|
61 | + } |
|
56 | 62 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
57 | 63 | glsr( CountsManager::class )->decrease( $review ); |
58 | 64 | } |
@@ -69,9 +75,13 @@ discard block |
||
69 | 75 | { |
70 | 76 | if( !$this->isReviewPostType( $postId ) |
71 | 77 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
72 | - )return; |
|
78 | + ) { |
|
79 | + return; |
|
80 | + } |
|
73 | 81 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
74 | - if( $review->$metaKey == $metaValue )return; |
|
82 | + if( $review->$metaKey == $metaValue ) { |
|
83 | + return; |
|
84 | + } |
|
75 | 85 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
76 | 86 | call_user_func( [$this, $method], $review, $metaValue ); |
77 | 87 | } |
@@ -96,7 +106,9 @@ discard block |
||
96 | 106 | */ |
97 | 107 | public function onChangeStatus( $newStatus, $oldStatus, WP_Post $post ) |
98 | 108 | { |
99 | - if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
109 | + if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
110 | + return; |
|
111 | + } |
|
100 | 112 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
101 | 113 | if( $status == 'publish' ) { |
102 | 114 | glsr( CountsManager::class )->increase( $review ); |