@@ -56,9 +56,13 @@ discard block |
||
| 56 | 56 | protected function generateFields( array $fields ) |
| 57 | 57 | { |
| 58 | 58 | $generatedFields = array_map( function( $field ) { |
| 59 | - if( empty( $field ))return; |
|
| 59 | + if( empty( $field )) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 60 | 62 | $field = $this->normalize( $field ); |
| 61 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
| 63 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ))) { |
|
| 64 | + return; |
|
| 65 | + } |
|
| 62 | 66 | return $this->$method( $field ); |
| 63 | 67 | }, $fields ); |
| 64 | 68 | return array_values( array_filter( $generatedFields )); |
@@ -73,7 +77,9 @@ discard block |
||
| 73 | 77 | if( !empty( $this->errors )) { |
| 74 | 78 | $errors = []; |
| 75 | 79 | foreach( $this->required as $name => $alert ) { |
| 76 | - if( false !== array_search( $name, glsr_array_column( $fields, 'name' )))continue; |
|
| 80 | + if( false !== array_search( $name, glsr_array_column( $fields, 'name' ))) { |
|
| 81 | + continue; |
|
| 82 | + } |
|
| 77 | 83 | $errors[] = $this->errors[$name]; |
| 78 | 84 | } |
| 79 | 85 | $this->errors = $errors; |
@@ -117,7 +123,9 @@ discard block |
||
| 117 | 123 | */ |
| 118 | 124 | protected function normalizeContainer( array $field ) |
| 119 | 125 | { |
| 120 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
| 126 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field )) { |
|
| 127 | + return; |
|
| 128 | + } |
|
| 121 | 129 | $field['items'] = $this->generateFields( $field['items'] ); |
| 122 | 130 | return $field; |
| 123 | 131 | } |
@@ -127,7 +135,9 @@ discard block |
||
| 127 | 135 | */ |
| 128 | 136 | protected function normalizeField( array $field, array $defaults ) |
| 129 | 137 | { |
| 130 | - if( !$this->validate( $field ))return; |
|
| 138 | + if( !$this->validate( $field )) { |
|
| 139 | + return; |
|
| 140 | + } |
|
| 131 | 141 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
| 132 | 142 | return $value !== ''; |
| 133 | 143 | }); |
@@ -148,7 +158,9 @@ discard block |
||
| 148 | 158 | 'type' => '', |
| 149 | 159 | 'value' => '', |
| 150 | 160 | ]); |
| 151 | - if( !is_array( $listbox ))return; |
|
| 161 | + if( !is_array( $listbox )) { |
|
| 162 | + return; |
|
| 163 | + } |
|
| 152 | 164 | if( !array_key_exists( '', $listbox['options'] )) { |
| 153 | 165 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
| 154 | 166 | } |
@@ -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 ); |
@@ -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; |
@@ -60,7 +60,9 @@ discard block |
||
| 60 | 60 | public function catchFatalError() |
| 61 | 61 | { |
| 62 | 62 | $error = error_get_last(); |
| 63 | - if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false )return; |
|
| 63 | + if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false ) { |
|
| 64 | + return; |
|
| 65 | + } |
|
| 64 | 66 | glsr_log()->error( $error['message'] ); |
| 65 | 67 | } |
| 66 | 68 | |
@@ -111,7 +113,9 @@ discard block |
||
| 111 | 113 | $filePaths[] = $this->path( $view ); |
| 112 | 114 | $filePaths[] = $this->path( 'views/'.$view ); |
| 113 | 115 | foreach( $filePaths as $file ) { |
| 114 | - if( !file_exists( $file ))continue; |
|
| 116 | + if( !file_exists( $file )) { |
|
| 117 | + continue; |
|
| 118 | + } |
|
| 115 | 119 | return $file; |
| 116 | 120 | } |
| 117 | 121 | } |
@@ -215,7 +219,9 @@ discard block |
||
| 215 | 219 | */ |
| 216 | 220 | public function scheduleCronJob() |
| 217 | 221 | { |
| 218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 222 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
| 223 | + return; |
|
| 224 | + } |
|
| 219 | 225 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 220 | 226 | } |
| 221 | 227 | |
@@ -255,7 +261,9 @@ discard block |
||
| 255 | 261 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
| 256 | 262 | || $data['action'] != 'update' |
| 257 | 263 | || $data['type'] != 'plugin' |
| 258 | - )return; |
|
| 264 | + ) { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 259 | 267 | $this->upgrade(); |
| 260 | 268 | } |
| 261 | 269 | |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | foreach( glsr( ReviewManager::class )->get( $this->args ) as $review ) { |
| 36 | 36 | // Only include critic reviews that have been directly produced by your site, not reviews from third- party sites or syndicated reviews. |
| 37 | 37 | // @see https://developers.google.com/search/docs/data-types/review |
| 38 | - if( $review->review_type != 'local' )continue; |
|
| 38 | + if( $review->review_type != 'local' ) { |
|
| 39 | + continue; |
|
| 40 | + } |
|
| 39 | 41 | $reviews[] = $this->buildReview( $review ); |
| 40 | 42 | } |
| 41 | 43 | if( !empty( $reviews )) { |
@@ -80,7 +82,9 @@ discard block |
||
| 80 | 82 | */ |
| 81 | 83 | public function render() |
| 82 | 84 | { |
| 83 | - if( empty( glsr()->schemas ))return; |
|
| 85 | + if( empty( glsr()->schemas )) { |
|
| 86 | + return; |
|
| 87 | + } |
|
| 84 | 88 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 85 | 89 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 86 | 90 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -132,7 +136,9 @@ discard block |
||
| 132 | 136 | { |
| 133 | 137 | foreach( $values as $value ) { |
| 134 | 138 | $option = $this->getSchemaOptionValue( $value ); |
| 135 | - if( empty( $option ))continue; |
|
| 139 | + if( empty( $option )) { |
|
| 140 | + continue; |
|
| 141 | + } |
|
| 136 | 142 | $schema->$value( $option ); |
| 137 | 143 | } |
| 138 | 144 | return $schema; |
@@ -242,7 +248,9 @@ discard block |
||
| 242 | 248 | if( $value != $fallback ) { |
| 243 | 249 | return $value; |
| 244 | 250 | } |
| 245 | - if( !is_single() && !is_page() )return; |
|
| 251 | + if( !is_single() && !is_page() ) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 246 | 254 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
| 247 | 255 | if( method_exists( $this, $method )) { |
| 248 | 256 | return $this->$method(); |