@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | public function routeAdminPostRequest() |
17 | 17 | { |
18 | 18 | $request = $this->getRequest(); |
19 | - if( !$this->isValidPostRequest( $request ))return; |
|
19 | + if( !$this->isValidPostRequest( $request )) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | check_admin_referer( $request['action'] ); |
21 | 23 | $this->routeRequest( 'admin', $request['action'], $request ); |
22 | 24 | } |
@@ -38,10 +40,16 @@ discard block |
||
38 | 40 | */ |
39 | 41 | public function routePublicPostRequest() |
40 | 42 | { |
41 | - if( is_admin() )return; |
|
43 | + if( is_admin() ) { |
|
44 | + return; |
|
45 | + } |
|
42 | 46 | $request = $this->getRequest(); |
43 | - if( !$this->isValidPostRequest( $request ))return; |
|
44 | - if( !$this->isValidPublicNonce( $request ))return; |
|
47 | + if( !$this->isValidPostRequest( $request )) { |
|
48 | + return; |
|
49 | + } |
|
50 | + if( !$this->isValidPublicNonce( $request )) { |
|
51 | + return; |
|
52 | + } |
|
45 | 53 | $this->routeRequest( 'public', $request['action'], $request ); |
46 | 54 | } |
47 | 55 | |
@@ -50,7 +58,9 @@ discard block |
||
50 | 58 | */ |
51 | 59 | protected function checkAjaxNonce( array $request ) |
52 | 60 | { |
53 | - if( !is_user_logged_in() )return; |
|
61 | + if( !is_user_logged_in() ) { |
|
62 | + return; |
|
63 | + } |
|
54 | 64 | if( !isset( $request['nonce'] )) { |
55 | 65 | $this->sendAjaxError( 'The request is missing a nonce', $request ); |
56 | 66 | } |
@@ -83,7 +83,9 @@ discard block |
||
83 | 83 | $reviewValues = []; |
84 | 84 | foreach( $review as $key => $value ) { |
85 | 85 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
86 | - if( !method_exists( $this, $method ))continue; |
|
86 | + if( !method_exists( $this, $method )) { |
|
87 | + continue; |
|
88 | + } |
|
87 | 89 | $reviewValues[$key] = $this->$method( $key, $value ); |
88 | 90 | } |
89 | 91 | $reviewValues = apply_filters( 'site-reviews/review/build/after', $reviewValues ); |
@@ -97,9 +99,13 @@ discard block |
||
97 | 99 | */ |
98 | 100 | protected function buildOptionAssignedTo( $key, $value ) |
99 | 101 | { |
100 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
102 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' )) { |
|
103 | + return; |
|
104 | + } |
|
101 | 105 | $post = get_post( intval( $value )); |
102 | - if( !( $post instanceof WP_Post ))return; |
|
106 | + if( !( $post instanceof WP_Post )) { |
|
107 | + return; |
|
108 | + } |
|
103 | 109 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
104 | 110 | 'href' => get_the_permalink( $post->ID ), |
105 | 111 | ]); |
@@ -114,7 +120,9 @@ discard block |
||
114 | 120 | */ |
115 | 121 | protected function buildOptionAuthor( $key, $value ) |
116 | 122 | { |
117 | - if( $this->isHidden( $key ))return; |
|
123 | + if( $this->isHidden( $key )) { |
|
124 | + return; |
|
125 | + } |
|
118 | 126 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
119 | 127 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
120 | 128 | : ''; |
@@ -128,7 +136,9 @@ discard block |
||
128 | 136 | */ |
129 | 137 | protected function buildOptionAvatar( $key, $value ) |
130 | 138 | { |
131 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
139 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) { |
|
140 | + return; |
|
141 | + } |
|
132 | 142 | $size = $this->getOption( 'settings.reviews.avatars.size', 40 ); |
133 | 143 | return $this->wrap( $key, glsr( Builder::class )->img([ |
134 | 144 | 'src' => $this->generateAvatar( $value ), |
@@ -145,7 +155,9 @@ discard block |
||
145 | 155 | protected function buildOptionContent( $key, $value ) |
146 | 156 | { |
147 | 157 | $text = $this->normalizeText( $value ); |
148 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
158 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
159 | + return; |
|
160 | + } |
|
149 | 161 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
150 | 162 | } |
151 | 163 | |
@@ -156,7 +168,9 @@ discard block |
||
156 | 168 | */ |
157 | 169 | protected function buildOptionDate( $key, $value ) |
158 | 170 | { |
159 | - if( $this->isHidden( $key ))return; |
|
171 | + if( $this->isHidden( $key )) { |
|
172 | + return; |
|
173 | + } |
|
160 | 174 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
161 | 175 | if( $dateFormat == 'relative' ) { |
162 | 176 | $date = glsr( Date::class )->relative( $value ); |
@@ -177,7 +191,9 @@ discard block |
||
177 | 191 | */ |
178 | 192 | protected function buildOptionRating( $key, $value ) |
179 | 193 | { |
180 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
194 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
195 | + return; |
|
196 | + } |
|
181 | 197 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
182 | 198 | 'rating' => $value, |
183 | 199 | ]); |
@@ -191,7 +207,9 @@ discard block |
||
191 | 207 | */ |
192 | 208 | protected function buildOptionResponse( $key, $value ) |
193 | 209 | { |
194 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
210 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
211 | + return; |
|
212 | + } |
|
195 | 213 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
196 | 214 | $text = $this->normalizeText( $value ); |
197 | 215 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -208,7 +226,9 @@ discard block |
||
208 | 226 | */ |
209 | 227 | protected function buildOptionTitle( $key, $value ) |
210 | 228 | { |
211 | - if( $this->isHidden( $key ))return; |
|
229 | + if( $this->isHidden( $key )) { |
|
230 | + return; |
|
231 | + } |
|
212 | 232 | if( empty( $value )) { |
213 | 233 | $value = __( 'No Title', 'site-reviews' ); |
214 | 234 | } |
@@ -238,7 +258,9 @@ discard block |
||
238 | 258 | */ |
239 | 259 | protected function generateSchema() |
240 | 260 | { |
241 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
261 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
262 | + return; |
|
263 | + } |
|
242 | 264 | glsr( Schema::class )->store( |
243 | 265 | glsr( Schema::class )->build( $this->args ) |
244 | 266 | ); |
@@ -289,9 +311,13 @@ discard block |
||
289 | 311 | $words->setText( $text ); |
290 | 312 | $count = 0; |
291 | 313 | foreach( $words as $offset ){ |
292 | - if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
|
314 | + if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) { |
|
315 | + continue; |
|
316 | + } |
|
293 | 317 | $count++; |
294 | - if( $count != $limit )continue; |
|
318 | + if( $count != $limit ) { |
|
319 | + continue; |
|
320 | + } |
|
295 | 321 | return $offset; |
296 | 322 | } |
297 | 323 | return strlen( $text ); |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | public function onBeforeUpdateReview( WP_Post $review, $metaKey, $metaValue ) |
24 | 24 | { |
25 | 25 | $previousValue = get_post_meta( $review->ID, $metaKey, true ); |
26 | - if( $previousValue == $metaValue )return; |
|
26 | + if( $previousValue == $metaValue ) { |
|
27 | + return; |
|
28 | + } |
|
27 | 29 | $this->decreaseReviewCount( $review ); |
28 | 30 | $this->increaseReviewCount( $review, [$metaKey => $metaValue] ); |
29 | 31 | } |
@@ -36,7 +38,9 @@ discard block |
||
36 | 38 | */ |
37 | 39 | public function onCreateReview( $postData, $meta, $postId ) |
38 | 40 | { |
39 | - if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return; |
|
41 | + if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) { |
|
42 | + return; |
|
43 | + } |
|
40 | 44 | $review = get_post( $postId ) |
41 | 45 | $this->updateAssignedToPost( $review ); |
42 | 46 | $this->increaseReviewCount( $review ); |
@@ -48,7 +52,9 @@ discard block |
||
48 | 52 | */ |
49 | 53 | public function onDeleteReview( $postId ) |
50 | 54 | { |
51 | - if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return; |
|
55 | + if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) { |
|
56 | + return; |
|
57 | + } |
|
52 | 58 | $review = get_post( $postId ) |
53 | 59 | $review->post_status = 'deleted'; // important to change the post_status here first! |
54 | 60 | $this->updateAssignedToPost( $review ); |
@@ -85,7 +91,9 @@ discard block |
||
85 | 91 | */ |
86 | 92 | public function saveAssignedToMetabox( $postId ) |
87 | 93 | { |
88 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
94 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) { |
|
95 | + return; |
|
96 | + } |
|
89 | 97 | $assignedTo = glsr( Helper::class )->filterInput( 'assigned_to' ); |
90 | 98 | $assignedTo || $assignedTo = ''; |
91 | 99 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -100,7 +108,9 @@ discard block |
||
100 | 108 | */ |
101 | 109 | public function saveResponseMetabox( $postId ) |
102 | 110 | { |
103 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
111 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) { |
|
112 | + return; |
|
113 | + } |
|
104 | 114 | $response = glsr( Helper::class )->filterInput( 'response' ); |
105 | 115 | $response || $response = ''; |
106 | 116 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
@@ -134,10 +144,14 @@ discard block |
||
134 | 144 | ]); |
135 | 145 | if( !in_array( $meta['review_type'], glsr()->reviewTypes ) |
136 | 146 | || intval( $meta['rating'] ) > Rating::MAX_RATING |
137 | - )return; |
|
147 | + ) { |
|
148 | + return; |
|
149 | + } |
|
138 | 150 | $counts = glsr( OptionManager::class )->get( 'counts.'.$meta['review_type'], [] ); |
139 | 151 | foreach( range( 0, Rating::MAX_RATING ) as $rating ) { |
140 | - if( isset( $counts[$rating] ))continue; |
|
152 | + if( isset( $counts[$rating] )) { |
|
153 | + continue; |
|
154 | + } |
|
141 | 155 | $counts[$rating] = 0; |
142 | 156 | } |
143 | 157 | ksort( $counts ); |
@@ -150,7 +164,9 @@ discard block |
||
150 | 164 | protected function setReviewCounts( WP_Post $review, array $counts ) |
151 | 165 | { |
152 | 166 | $type = get_post_meta( $review->ID, 'review_type', true ); |
153 | - if( !in_array( $type, glsr()->reviewTypes ))return; |
|
167 | + if( !in_array( $type, glsr()->reviewTypes )) { |
|
168 | + return; |
|
169 | + } |
|
154 | 170 | glsr( OptionManager::class )->set( 'counts.'.$type, $counts ); |
155 | 171 | } |
156 | 172 | |
@@ -197,9 +213,13 @@ discard block |
||
197 | 213 | */ |
198 | 214 | protected function updateAssignedToPost( WP_Post $review ) |
199 | 215 | { |
200 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
216 | + if( !( $postId = $this->getAssignedToPostId( $review->ID ))) { |
|
217 | + return; |
|
218 | + } |
|
201 | 219 | $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
202 | - if( empty( $reviewIds ))return; |
|
220 | + if( empty( $reviewIds )) { |
|
221 | + return; |
|
222 | + } |
|
203 | 223 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
204 | 224 | $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
205 | 225 | if( empty( $updatedReviewIds )) { |
@@ -92,7 +92,9 @@ discard block |
||
92 | 92 | if( !in_array( $metaKey, ['rating', 'review_type'] ) |
93 | 93 | || get_post_field( 'post_type', $postId ) != Application::POST_TYPE |
94 | 94 | || get_post_field( 'post_status', $postId ) != 'publish' // only fire on an existing published post |
95 | - )return; |
|
95 | + ) { |
|
96 | + return; |
|
97 | + } |
|
96 | 98 | glsr( Metaboxes::class )->onBeforeUpdateReview( get_post( $postId ), $metaKey, $metaValue ); |
97 | 99 | } |
98 | 100 | |
@@ -127,7 +129,9 @@ discard block |
||
127 | 129 | { |
128 | 130 | if( in_array( $oldStatus, ['new', $newStatus] ) |
129 | 131 | || $post->post_type != Application::POST_TYPE |
130 | - )return; |
|
132 | + ) { |
|
133 | + return; |
|
134 | + } |
|
131 | 135 | glsr( Metaboxes::class )->onReviewStatusChange( $newStatus, $post ); |
132 | 136 | } |
133 | 137 | |
@@ -148,7 +152,9 @@ discard block |
||
148 | 152 | */ |
149 | 153 | public function registerMetaBoxes( $postType ) |
150 | 154 | { |
151 | - if( $postType != Application::POST_TYPE )return; |
|
155 | + if( $postType != Application::POST_TYPE ) { |
|
156 | + return; |
|
157 | + } |
|
152 | 158 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
153 | 159 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
154 | 160 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
@@ -178,7 +184,9 @@ discard block |
||
178 | 184 | */ |
179 | 185 | public function renderAssignedToMetabox( WP_Post $post ) |
180 | 186 | { |
181 | - if( !$this->isReviewPostType( $post ))return; |
|
187 | + if( !$this->isReviewPostType( $post )) { |
|
188 | + return; |
|
189 | + } |
|
182 | 190 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
183 | 191 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
184 | 192 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -193,7 +201,9 @@ discard block |
||
193 | 201 | */ |
194 | 202 | public function renderDetailsMetaBox( WP_Post $post ) |
195 | 203 | { |
196 | - if( !$this->isReviewPostType( $post ))return; |
|
204 | + if( !$this->isReviewPostType( $post )) { |
|
205 | + return; |
|
206 | + } |
|
197 | 207 | $review = glsr( Database::class )->getReview( $post ); |
198 | 208 | glsr()->render( 'partials/editor/metabox-details', [ |
199 | 209 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -207,7 +217,9 @@ discard block |
||
207 | 217 | */ |
208 | 218 | public function renderPinnedInPublishMetaBox() |
209 | 219 | { |
210 | - if( !$this->isReviewPostType( get_post() ))return; |
|
220 | + if( !$this->isReviewPostType( get_post() )) { |
|
221 | + return; |
|
222 | + } |
|
211 | 223 | glsr( Html::class )->renderTemplate( 'partials/editor/pinned', [ |
212 | 224 | 'context' => [ |
213 | 225 | 'no' => __( 'No', 'site-reviews' ), |
@@ -223,7 +235,9 @@ discard block |
||
223 | 235 | */ |
224 | 236 | public function renderResponseMetaBox( WP_Post $post ) |
225 | 237 | { |
226 | - if( !$this->isReviewPostType( $post ))return; |
|
238 | + if( !$this->isReviewPostType( $post )) { |
|
239 | + return; |
|
240 | + } |
|
227 | 241 | wp_nonce_field( 'response', '_nonce-response', false ); |
228 | 242 | glsr()->render( 'partials/editor/metabox-response', [ |
229 | 243 | 'response' => glsr( Database::class )->getReview( $post )->response, |
@@ -237,7 +251,9 @@ discard block |
||
237 | 251 | */ |
238 | 252 | public function renderTaxonomyMetabox( WP_Post $post ) |
239 | 253 | { |
240 | - if( !$this->isReviewPostType( $post ))return; |
|
254 | + if( !$this->isReviewPostType( $post )) { |
|
255 | + return; |
|
256 | + } |
|
241 | 257 | glsr()->render( 'partials/editor/metabox-categories', [ |
242 | 258 | 'post' => $post, |
243 | 259 | 'tax_name' => Application::TAXONOMY, |
@@ -275,7 +291,9 @@ discard block |
||
275 | 291 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
276 | 292 | { |
277 | 293 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post, $assignedTo ); |
278 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
294 | + if( !( $assignedPost instanceof WP_Post )) { |
|
295 | + return; |
|
296 | + } |
|
279 | 297 | return glsr( Html::class )->buildTemplate( 'partials/editor/assigned-post', [ |
280 | 298 | 'context' => [ |
281 | 299 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -317,7 +335,9 @@ discard block |
||
317 | 335 | */ |
318 | 336 | protected function getReviewType( $review ) |
319 | 337 | { |
320 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
338 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
339 | + return; |
|
340 | + } |
|
321 | 341 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
322 | 342 | ? glsr()->reviewTypes[$review->review_type] |
323 | 343 | : __( 'Unknown', 'site-reviews' ); |
@@ -64,7 +64,9 @@ discard block |
||
64 | 64 | public function getAssignedToPost( $post, $assignedTo = '' ) |
65 | 65 | { |
66 | 66 | $post = get_post( $post ); |
67 | - if( !( $post instanceof WP_Post ))return; |
|
67 | + if( !( $post instanceof WP_Post )) { |
|
68 | + return; |
|
69 | + } |
|
68 | 70 | if( empty( $assignedTo )) { |
69 | 71 | $assignedTo = get_post_meta( $post->ID, 'assigned_to', true ); |
70 | 72 | } |
@@ -82,7 +84,9 @@ discard block |
||
82 | 84 | */ |
83 | 85 | public function getReview( $post ) |
84 | 86 | { |
85 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
87 | + if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) { |
|
88 | + return; |
|
89 | + } |
|
86 | 90 | $review = $this->getReviewMeta( $post->ID ); |
87 | 91 | $modified = $this->isReviewModified( $post, $review ); |
88 | 92 | $review->content = $post->post_content; |
@@ -256,7 +260,9 @@ discard block |
||
256 | 260 | $termIds = array_map( 'trim', explode( ',', $termIds )); |
257 | 261 | foreach( $termIds as $termId ) { |
258 | 262 | $term = term_exists( $termId, Application::TAXONOMY ); |
259 | - if( !isset( $term['term_id'] ))continue; |
|
263 | + if( !isset( $term['term_id'] )) { |
|
264 | + continue; |
|
265 | + } |
|
260 | 266 | $terms[] = intval( $term['term_id'] ); |
261 | 267 | } |
262 | 268 | return $terms; |
@@ -268,7 +274,9 @@ discard block |
||
268 | 274 | */ |
269 | 275 | public function revertReview( $postId ) |
270 | 276 | { |
271 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
277 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
278 | + return; |
|
279 | + } |
|
272 | 280 | delete_post_meta( $postId, '_edit_last' ); |
273 | 281 | $result = wp_update_post([ |
274 | 282 | 'ID' => $postId, |
@@ -303,7 +311,9 @@ discard block |
||
303 | 311 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
304 | 312 | $search = new WP_Query( $args ); |
305 | 313 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
306 | - if( !$search->have_posts() )return; |
|
314 | + if( !$search->have_posts() ) { |
|
315 | + return; |
|
316 | + } |
|
307 | 317 | $results = ''; |
308 | 318 | while( $search->have_posts() ) { |
309 | 319 | $search->the_post(); |
@@ -327,7 +337,9 @@ discard block |
||
327 | 337 | public function setReviewTerms( $postId, $termIds ) |
328 | 338 | { |
329 | 339 | $terms = $this->normalizeTerms( $termIds ); |
330 | - if( empty( $terms ))return; |
|
340 | + if( empty( $terms )) { |
|
341 | + return; |
|
342 | + } |
|
331 | 343 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
332 | 344 | if( is_wp_error( $result )) { |
333 | 345 | glsr_log()->error( $result->get_error_message() ); |