@@ -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; |
@@ -80,7 +82,9 @@ discard block |
||
80 | 82 | $termIds = []; |
81 | 83 | foreach( $values as $value ) { |
82 | 84 | $term = get_term_by( $field, $value, Application::TAXONOMY ); |
83 | - if( !isset( $term->term_id ))continue; |
|
85 | + if( !isset( $term->term_id )) { |
|
86 | + continue; |
|
87 | + } |
|
84 | 88 | $termIds[] = $term->term_id; |
85 | 89 | } |
86 | 90 | return $termIds; |
@@ -127,7 +131,9 @@ discard block |
||
127 | 131 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
128 | 132 | $search = new WP_Query( $args ); |
129 | 133 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
130 | - if( !$search->have_posts() )return; |
|
134 | + if( !$search->have_posts() ) { |
|
135 | + return; |
|
136 | + } |
|
131 | 137 | $results = ''; |
132 | 138 | while( $search->have_posts() ) { |
133 | 139 | $search->the_post(); |
@@ -6,7 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsSummaryShortcode extends Shortcode |
8 | 8 | { |
9 | - protected function hideOptions() { |
|
9 | + protected function hideOptions() |
|
10 | + { |
|
10 | 11 | return [ |
11 | 12 | 'rating' => __( 'Hide the rating', 'site-reviews' ), |
12 | 13 | 'stars' => __( 'Hide the stars', 'site-reviews' ), |
@@ -6,7 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsShortcode extends Shortcode |
8 | 8 | { |
9 | - protected function hideOptions() { |
|
9 | + protected function hideOptions() |
|
10 | + { |
|
10 | 11 | return [ |
11 | 12 | 'title' => __( 'Hide the title', 'site-reviews' ), |
12 | 13 | 'rating' => __( 'Hide the rating', 'site-reviews' ), |
@@ -6,7 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class SiteReviewsFormShortcode extends Shortcode |
8 | 8 | { |
9 | - protected function hideOptions() { |
|
9 | + protected function hideOptions() |
|
10 | + { |
|
10 | 11 | return [ |
11 | 12 | 'rating' => __( 'Hide the rating field', 'site-reviews' ), |
12 | 13 | 'title' => __( 'Hide the title field', 'site-reviews' ), |
@@ -150,7 +150,9 @@ discard block |
||
150 | 150 | if( !empty( $sessions )) { |
151 | 151 | $now = time(); |
152 | 152 | foreach( $sessions as $session ) { |
153 | - if( $now <= $session->expiration )continue; |
|
153 | + if( $now <= $session->expiration ) { |
|
154 | + continue; |
|
155 | + } |
|
154 | 156 | $expiredSessions[] = $session->name; |
155 | 157 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
156 | 158 | } |
@@ -193,7 +195,9 @@ discard block |
||
193 | 195 | */ |
194 | 196 | protected function setCookie() |
195 | 197 | { |
196 | - if( headers_sent() )return; |
|
198 | + if( headers_sent() ) { |
|
199 | + return; |
|
200 | + } |
|
197 | 201 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
198 | 202 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
199 | 203 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -43,7 +43,9 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function send( Review $review ) |
45 | 45 | { |
46 | - if( empty( $this->types ))return; |
|
46 | + if( empty( $this->types )) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | $this->review = $review; |
48 | 50 | $args = [ |
49 | 51 | 'link' => $this->getLink(), |
@@ -146,7 +148,9 @@ discard block |
||
146 | 148 | protected function sendToEmail( array $args ) |
147 | 149 | { |
148 | 150 | $email = $this->buildEmail( $args ); |
149 | - if( !$this->email )return; |
|
151 | + if( !$this->email ) { |
|
152 | + return; |
|
153 | + } |
|
150 | 154 | if( empty( $email->to )) { |
151 | 155 | glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
152 | 156 | return; |
@@ -161,7 +165,9 @@ discard block |
||
161 | 165 | */ |
162 | 166 | protected function sendToSlack( array $args ) |
163 | 167 | { |
164 | - if( !$this->slack )return; |
|
168 | + if( !$this->slack ) { |
|
169 | + return; |
|
170 | + } |
|
165 | 171 | $notification = $this->buildSlackNotification( $args ); |
166 | 172 | $result = $notification->send(); |
167 | 173 | if( is_wp_error( $result )) { |
@@ -175,8 +175,12 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function validateAkismet() |
177 | 177 | { |
178 | - if( !empty( $this->error ))return; |
|
179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
178 | + if( !empty( $this->error )) { |
|
179 | + return; |
|
180 | + } |
|
181 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
182 | + return; |
|
183 | + } |
|
180 | 184 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
181 | 185 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
182 | 186 | } |
@@ -186,8 +190,12 @@ discard block |
||
186 | 190 | */ |
187 | 191 | protected function validateBlacklist() |
188 | 192 | { |
189 | - if( !empty( $this->error ))return; |
|
190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
193 | + if( !empty( $this->error )) { |
|
194 | + return; |
|
195 | + } |
|
196 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
197 | + return; |
|
198 | + } |
|
191 | 199 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
192 | 200 | if( $blacklistAction == 'reject' ) { |
193 | 201 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,9 +210,13 @@ discard block |
||
202 | 210 | */ |
203 | 211 | protected function validateCustom() |
204 | 212 | { |
205 | - if( !empty( $this->error ))return; |
|
213 | + if( !empty( $this->error )) { |
|
214 | + return; |
|
215 | + } |
|
206 | 216 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
207 | - if( $validated === true )return; |
|
217 | + if( $validated === true ) { |
|
218 | + return; |
|
219 | + } |
|
208 | 220 | $this->setSessionValues( 'errors', [] ); |
209 | 221 | $this->setSessionValues( 'values', $this->request ); |
210 | 222 | $this->error = is_string( $validated ) |
@@ -217,8 +229,12 @@ discard block |
||
217 | 229 | */ |
218 | 230 | protected function validateHoneyPot() |
219 | 231 | { |
220 | - if( !empty( $this->error ))return; |
|
221 | - if( empty( $this->request['gotcha'] ))return; |
|
232 | + if( !empty( $this->error )) { |
|
233 | + return; |
|
234 | + } |
|
235 | + if( empty( $this->request['gotcha'] )) { |
|
236 | + return; |
|
237 | + } |
|
222 | 238 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
223 | 239 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
224 | 240 | } |
@@ -228,9 +244,13 @@ discard block |
||
228 | 244 | */ |
229 | 245 | protected function validateRecaptcha() |
230 | 246 | { |
231 | - if( !empty( $this->error ))return; |
|
247 | + if( !empty( $this->error )) { |
|
248 | + return; |
|
249 | + } |
|
232 | 250 | $status = $this->getRecaptchaStatus(); |
233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
251 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] )) { |
|
252 | + return; |
|
253 | + } |
|
234 | 254 | if( $status == static::RECAPTCHA_EMPTY ) { |
235 | 255 | $this->setSessionValues( 'recaptcha', 'unset' ); |
236 | 256 | $this->recaptchaIsUnset = true; |
@@ -91,7 +91,9 @@ discard block |
||
91 | 91 | { |
92 | 92 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
93 | 93 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
94 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
94 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
95 | + return; |
|
96 | + } |
|
95 | 97 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
96 | 98 | } |
97 | 99 | |
@@ -127,7 +129,9 @@ discard block |
||
127 | 129 | */ |
128 | 130 | public function renderAssignedToMetabox( WP_Post $post ) |
129 | 131 | { |
130 | - if( !$this->isReviewPostType( $post ))return; |
|
132 | + if( !$this->isReviewPostType( $post )) { |
|
133 | + return; |
|
134 | + } |
|
131 | 135 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
132 | 136 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
133 | 137 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -142,7 +146,9 @@ discard block |
||
142 | 146 | */ |
143 | 147 | public function renderDetailsMetaBox( WP_Post $post ) |
144 | 148 | { |
145 | - if( !$this->isReviewPostType( $post ))return; |
|
149 | + if( !$this->isReviewPostType( $post )) { |
|
150 | + return; |
|
151 | + } |
|
146 | 152 | $review = glsr( ReviewManager::class )->single( $post ); |
147 | 153 | glsr()->render( 'partials/editor/metabox-details', [ |
148 | 154 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -156,7 +162,9 @@ discard block |
||
156 | 162 | */ |
157 | 163 | public function renderPinnedInPublishMetaBox() |
158 | 164 | { |
159 | - if( !$this->isReviewPostType( get_post() ))return; |
|
165 | + if( !$this->isReviewPostType( get_post() )) { |
|
166 | + return; |
|
167 | + } |
|
160 | 168 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
161 | 169 | 'context' => [ |
162 | 170 | 'no' => __( 'No', 'site-reviews' ), |
@@ -172,7 +180,9 @@ discard block |
||
172 | 180 | */ |
173 | 181 | public function renderResponseMetaBox( WP_Post $post ) |
174 | 182 | { |
175 | - if( !$this->isReviewPostType( $post ))return; |
|
183 | + if( !$this->isReviewPostType( $post )) { |
|
184 | + return; |
|
185 | + } |
|
176 | 186 | wp_nonce_field( 'response', '_nonce-response', false ); |
177 | 187 | glsr()->render( 'partials/editor/metabox-response', [ |
178 | 188 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -185,7 +195,9 @@ discard block |
||
185 | 195 | */ |
186 | 196 | public function renderReviewEditor( WP_Post $post ) |
187 | 197 | { |
188 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
198 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
199 | + return; |
|
200 | + } |
|
189 | 201 | glsr()->render( 'partials/editor/review', [ |
190 | 202 | 'post' => $post, |
191 | 203 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -199,7 +211,9 @@ discard block |
||
199 | 211 | public function renderReviewFields() |
200 | 212 | { |
201 | 213 | $screen = glsr_current_screen(); |
202 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
214 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
215 | + return; |
|
216 | + } |
|
203 | 217 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
204 | 218 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
205 | 219 | } |
@@ -210,7 +224,9 @@ discard block |
||
210 | 224 | */ |
211 | 225 | public function renderReviewNotice( WP_Post $post ) |
212 | 226 | { |
213 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
227 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
228 | + return; |
|
229 | + } |
|
214 | 230 | glsr( Notice::class )->addWarning( sprintf( |
215 | 231 | __( '%s reviews are read-only.', 'site-reviews' ), |
216 | 232 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -229,7 +245,9 @@ discard block |
||
229 | 245 | */ |
230 | 246 | public function renderTaxonomyMetabox( WP_Post $post ) |
231 | 247 | { |
232 | - if( !$this->isReviewPostType( $post ))return; |
|
248 | + if( !$this->isReviewPostType( $post )) { |
|
249 | + return; |
|
250 | + } |
|
233 | 251 | glsr()->render( 'partials/editor/metabox-categories', [ |
234 | 252 | 'post' => $post, |
235 | 253 | 'tax_name' => Application::TAXONOMY, |
@@ -267,7 +285,9 @@ discard block |
||
267 | 285 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
268 | 286 | { |
269 | 287 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
270 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
288 | + if( !( $assignedPost instanceof WP_Post )) { |
|
289 | + return; |
|
290 | + } |
|
271 | 291 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
272 | 292 | 'context' => [ |
273 | 293 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -312,7 +332,9 @@ discard block |
||
312 | 332 | */ |
313 | 333 | protected function getReviewType( $review ) |
314 | 334 | { |
315 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
335 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
336 | + return; |
|
337 | + } |
|
316 | 338 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
317 | 339 | ? glsr()->reviewTypes[$review->review_type] |
318 | 340 | : __( 'Unknown', 'site-reviews' ); |
@@ -102,7 +102,9 @@ discard block |
||
102 | 102 | $field = method_exists( $this, $method ) |
103 | 103 | ? $this->$method( $key, $value ) |
104 | 104 | : apply_filters( 'site-reviews/review/build/'.$key, false, $value, $this, $review ); |
105 | - if( $field === false )continue; |
|
105 | + if( $field === false ) { |
|
106 | + continue; |
|
107 | + } |
|
106 | 108 | $renderedFields[$key] = $field; |
107 | 109 | } |
108 | 110 | $this->wrap( $renderedFields, $review ); |
@@ -117,9 +119,13 @@ discard block |
||
117 | 119 | */ |
118 | 120 | protected function buildOptionAssignedTo( $key, $value ) |
119 | 121 | { |
120 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
122 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) { |
|
123 | + return; |
|
124 | + } |
|
121 | 125 | $post = glsr( Polylang::class )->getPost( $value ); |
122 | - if( !( $post instanceof WP_Post ))return; |
|
126 | + if( !( $post instanceof WP_Post )) { |
|
127 | + return; |
|
128 | + } |
|
123 | 129 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
124 | 130 | 'href' => get_the_permalink( $post->ID ), |
125 | 131 | ]); |
@@ -134,7 +140,9 @@ discard block |
||
134 | 140 | */ |
135 | 141 | protected function buildOptionAuthor( $key, $value ) |
136 | 142 | { |
137 | - if( $this->isHidden( $key ))return; |
|
143 | + if( $this->isHidden( $key )) { |
|
144 | + return; |
|
145 | + } |
|
138 | 146 | return '<span>'.$value.'</span>'; |
139 | 147 | } |
140 | 148 | |
@@ -145,7 +153,9 @@ discard block |
||
145 | 153 | */ |
146 | 154 | protected function buildOptionAvatar( $key, $value ) |
147 | 155 | { |
148 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
156 | + if( $this->isHidden( $key, 'settings.reviews.avatars' )) { |
|
157 | + return; |
|
158 | + } |
|
149 | 159 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
150 | 160 | return glsr( Builder::class )->img([ |
151 | 161 | 'height' => $size, |
@@ -163,7 +173,9 @@ discard block |
||
163 | 173 | protected function buildOptionContent( $key, $value ) |
164 | 174 | { |
165 | 175 | $text = $this->normalizeText( $value ); |
166 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
176 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
177 | + return; |
|
178 | + } |
|
167 | 179 | return '<p>'.$text.'</p>'; |
168 | 180 | } |
169 | 181 | |
@@ -174,7 +186,9 @@ discard block |
||
174 | 186 | */ |
175 | 187 | protected function buildOptionDate( $key, $value ) |
176 | 188 | { |
177 | - if( $this->isHidden( $key ))return; |
|
189 | + if( $this->isHidden( $key )) { |
|
190 | + return; |
|
191 | + } |
|
178 | 192 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
179 | 193 | if( $dateFormat == 'relative' ) { |
180 | 194 | $date = glsr( Date::class )->relative( $value ); |
@@ -195,7 +209,9 @@ discard block |
||
195 | 209 | */ |
196 | 210 | protected function buildOptionRating( $key, $value ) |
197 | 211 | { |
198 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
212 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
213 | + return; |
|
214 | + } |
|
199 | 215 | return glsr( Partial::class )->build( 'star-rating', [ |
200 | 216 | 'rating' => $value, |
201 | 217 | ]); |
@@ -208,7 +224,9 @@ discard block |
||
208 | 224 | */ |
209 | 225 | protected function buildOptionResponse( $key, $value ) |
210 | 226 | { |
211 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
227 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
228 | + return; |
|
229 | + } |
|
212 | 230 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
213 | 231 | $text = $this->normalizeText( $value ); |
214 | 232 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -224,7 +242,9 @@ discard block |
||
224 | 242 | */ |
225 | 243 | protected function buildOptionTitle( $key, $value ) |
226 | 244 | { |
227 | - if( $this->isHidden( $key ))return; |
|
245 | + if( $this->isHidden( $key )) { |
|
246 | + return; |
|
247 | + } |
|
228 | 248 | if( empty( $value )) { |
229 | 249 | $value = __( 'No Title', 'site-reviews' ); |
230 | 250 | } |
@@ -256,7 +276,9 @@ discard block |
||
256 | 276 | */ |
257 | 277 | protected function generateSchema() |
258 | 278 | { |
259 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
279 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
280 | + return; |
|
281 | + } |
|
260 | 282 | glsr( Schema::class )->store( |
261 | 283 | glsr( Schema::class )->build( $this->args ) |
262 | 284 | ); |
@@ -306,9 +328,13 @@ discard block |
||
306 | 328 | $words->setText( $text ); |
307 | 329 | $count = 0; |
308 | 330 | foreach( $words as $offset ){ |
309 | - if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
|
331 | + if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) { |
|
332 | + continue; |
|
333 | + } |
|
310 | 334 | $count++; |
311 | - if( $count != $limit )continue; |
|
335 | + if( $count != $limit ) { |
|
336 | + continue; |
|
337 | + } |
|
312 | 338 | return $offset; |
313 | 339 | } |
314 | 340 | return strlen( $text ); |
@@ -384,7 +410,9 @@ discard block |
||
384 | 410 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
385 | 411 | array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
386 | 412 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
387 | - if( empty( $value ))return; |
|
413 | + if( empty( $value )) { |
|
414 | + return; |
|
415 | + } |
|
388 | 416 | $value = glsr( Builder::class )->div( $value, [ |
389 | 417 | 'class' => 'glsr-review-'.$key, |
390 | 418 | ]); |