@@ -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; |
@@ -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(); |
@@ -33,7 +33,9 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | public function __toString() |
| 35 | 35 | { |
| 36 | - if( empty( $this->values ))return; |
|
| 36 | + if( empty( $this->values )) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 37 | 39 | return glsr( Template::class )->build( 'templates/review', [ |
| 38 | 40 | 'context' => $this->values, |
| 39 | 41 | ]); |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function __construct( WP_Post $post ) |
| 38 | 38 | { |
| 39 | - if( $post->post_type != Application::POST_TYPE )return; |
|
| 39 | + if( $post->post_type != Application::POST_TYPE ) { |
|
| 40 | + return; |
|
| 41 | + } |
|
| 40 | 42 | $this->content = $post->post_content; |
| 41 | 43 | $this->date = $post->post_date; |
| 42 | 44 | $this->ID = intval( $post->ID ); |
@@ -163,7 +165,9 @@ discard block |
||
| 163 | 165 | $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
| 164 | 166 | $this->modified = $this->isModified( $properties ); |
| 165 | 167 | array_walk( $properties, function( $value, $key ) { |
| 166 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
| 168 | + if( !property_exists( $this, $key ) || isset( $this->$key )) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 167 | 171 | $this->$key = maybe_unserialize( $value ); |
| 168 | 172 | }); |
| 169 | 173 | } |
@@ -174,7 +178,9 @@ discard block |
||
| 174 | 178 | protected function setTermIds( WP_Post $post ) |
| 175 | 179 | { |
| 176 | 180 | $this->term_ids = []; |
| 177 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
| 181 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ))) { |
|
| 182 | + return; |
|
| 183 | + } |
|
| 178 | 184 | foreach( $terms as $term ) { |
| 179 | 185 | $this->term_ids[] = $term->term_id; |
| 180 | 186 | } |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function approve() |
| 23 | 23 | { |
| 24 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 24 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 25 | + return; |
|
| 26 | + } |
|
| 25 | 27 | check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
| 26 | 28 | wp_update_post([ |
| 27 | 29 | 'ID' => $postId, |
@@ -59,7 +61,9 @@ discard block |
||
| 59 | 61 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
| 60 | 62 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 61 | 63 | foreach( $postTypeColumns as $key => &$value ) { |
| 62 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 64 | + if( !array_key_exists( $key, $columns ) || !empty( $value )) { |
|
| 65 | + continue; |
|
| 66 | + } |
|
| 63 | 67 | $value = $columns[$key]; |
| 64 | 68 | } |
| 65 | 69 | if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
@@ -100,7 +104,8 @@ discard block |
||
| 100 | 104 | * @return array |
| 101 | 105 | * @filter display_post_states |
| 102 | 106 | */ |
| 103 | - public function filterPostStates( $postStates, WP_Post $post ) { |
|
| 107 | + public function filterPostStates( $postStates, WP_Post $post ) |
|
| 108 | + { |
|
| 104 | 109 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
| 105 | 110 | if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
| 106 | 111 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -148,7 +153,9 @@ discard block |
||
| 148 | 153 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 149 | 154 | unset( $postTypeColumns['cb'] ); |
| 150 | 155 | foreach( $postTypeColumns as $key => $value ) { |
| 151 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 156 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
| 157 | + continue; |
|
| 158 | + } |
|
| 152 | 159 | $columns[$key] = $key; |
| 153 | 160 | } |
| 154 | 161 | return $columns; |
@@ -172,7 +179,9 @@ discard block |
||
| 172 | 179 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 173 | 180 | ]; |
| 174 | 181 | foreach( $strings as $search => $replace ) { |
| 175 | - if( strpos( $single, $search ) === false )continue; |
|
| 182 | + if( strpos( $single, $search ) === false ) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 176 | 185 | $translation = $this->getTranslation([ |
| 177 | 186 | 'number' => $number, |
| 178 | 187 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -224,7 +233,9 @@ discard block |
||
| 224 | 233 | */ |
| 225 | 234 | public function saveBulkEditFields( $postId ) |
| 226 | 235 | { |
| 227 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 236 | + if( !current_user_can( 'edit_posts' )) { |
|
| 237 | + return; |
|
| 238 | + } |
|
| 228 | 239 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 229 | 240 | if( $assignedTo && get_post( $assignedTo )) { |
| 230 | 241 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -237,7 +248,9 @@ discard block |
||
| 237 | 248 | */ |
| 238 | 249 | public function setQueryForColumn( WP_Query $query ) |
| 239 | 250 | { |
| 240 | - if( !$this->hasPermission( $query ))return; |
|
| 251 | + if( !$this->hasPermission( $query )) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 241 | 254 | $this->setMetaQuery( $query, [ |
| 242 | 255 | 'rating', 'review_type', |
| 243 | 256 | ]); |
@@ -250,7 +263,9 @@ discard block |
||
| 250 | 263 | */ |
| 251 | 264 | public function unapprove() |
| 252 | 265 | { |
| 253 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 266 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 267 | + return; |
|
| 268 | + } |
|
| 254 | 269 | check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
| 255 | 270 | wp_update_post([ |
| 256 | 271 | 'ID' => $postId, |
@@ -310,7 +325,9 @@ discard block |
||
| 310 | 325 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 311 | 326 | { |
| 312 | 327 | foreach( $metaKeys as $key ) { |
| 313 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 328 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
| 329 | + continue; |
|
| 330 | + } |
|
| 314 | 331 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 315 | 332 | $metaQuery[] = [ |
| 316 | 333 | 'key' => $key, |