@@ -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 | |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | $views = $this->generatePossibleViews( $view ); |
| 57 | 57 | foreach( $views as $possibleView ) { |
| 58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
| 58 | + if( !file_exists( glsr()->file( $possibleView ))) { |
|
| 59 | + continue; |
|
| 60 | + } |
|
| 59 | 61 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
| 60 | 62 | } |
| 61 | 63 | return $view; |
@@ -88,7 +90,9 @@ discard block |
||
| 88 | 90 | */ |
| 89 | 91 | public function modifyField( Builder $instance ) |
| 90 | 92 | { |
| 91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
| 93 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 92 | 96 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
| 93 | 97 | } |
| 94 | 98 | |
@@ -105,7 +109,9 @@ discard block |
||
| 105 | 109 | */ |
| 106 | 110 | protected function customize( Builder $instance ) |
| 107 | 111 | { |
| 108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
| 112 | + if( !array_key_exists( $instance->tag, $this->fields )) { |
|
| 113 | + return; |
|
| 114 | + } |
|
| 109 | 115 | $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
| 110 | 116 | $key = $instance->tag.'_'.$args['type']; |
| 111 | 117 | $classes = !isset( $this->fields[$key] ) |
@@ -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(); |
@@ -69,7 +69,9 @@ discard block |
||
| 69 | 69 | $field = method_exists( $this, $method ) |
| 70 | 70 | ? $this->$method( $key, $value ) |
| 71 | 71 | : apply_filters( 'site-reviews/review/build/'.$key, false, $value, $this, $review ); |
| 72 | - if( $field === false )continue; |
|
| 72 | + if( $field === false ) { |
|
| 73 | + continue; |
|
| 74 | + } |
|
| 73 | 75 | $renderedFields[$key] = $field; |
| 74 | 76 | } |
| 75 | 77 | $this->wrap( $renderedFields, $review ); |
@@ -97,7 +99,9 @@ discard block |
||
| 97 | 99 | */ |
| 98 | 100 | public function generateSchema() |
| 99 | 101 | { |
| 100 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 102 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 103 | + return; |
|
| 104 | + } |
|
| 101 | 105 | glsr( Schema::class )->store( |
| 102 | 106 | glsr( Schema::class )->build( $this->args ) |
| 103 | 107 | ); |
@@ -123,9 +127,13 @@ discard block |
||
| 123 | 127 | */ |
| 124 | 128 | protected function buildOptionAssignedTo( $key, $value ) |
| 125 | 129 | { |
| 126 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
| 130 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 127 | 133 | $post = glsr( Polylang::class )->getPost( $value ); |
| 128 | - if( !( $post instanceof WP_Post ))return; |
|
| 134 | + if( !( $post instanceof WP_Post )) { |
|
| 135 | + return; |
|
| 136 | + } |
|
| 129 | 137 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 130 | 138 | 'href' => get_the_permalink( $post->ID ), |
| 131 | 139 | ]); |
@@ -140,7 +148,9 @@ discard block |
||
| 140 | 148 | */ |
| 141 | 149 | protected function buildOptionAuthor( $key, $value ) |
| 142 | 150 | { |
| 143 | - if( $this->isHidden( $key ))return; |
|
| 151 | + if( $this->isHidden( $key )) { |
|
| 152 | + return; |
|
| 153 | + } |
|
| 144 | 154 | return '<span>'.$value.'</span>'; |
| 145 | 155 | } |
| 146 | 156 | |
@@ -151,7 +161,9 @@ discard block |
||
| 151 | 161 | */ |
| 152 | 162 | protected function buildOptionAvatar( $key, $value ) |
| 153 | 163 | { |
| 154 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
| 164 | + if( $this->isHidden( $key, 'settings.reviews.avatars' )) { |
|
| 165 | + return; |
|
| 166 | + } |
|
| 155 | 167 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
| 156 | 168 | return glsr( Builder::class )->img([ |
| 157 | 169 | 'height' => $size, |
@@ -169,7 +181,9 @@ discard block |
||
| 169 | 181 | protected function buildOptionContent( $key, $value ) |
| 170 | 182 | { |
| 171 | 183 | $text = $this->normalizeText( $value ); |
| 172 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 184 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
| 185 | + return; |
|
| 186 | + } |
|
| 173 | 187 | return '<p>'.$text.'</p>'; |
| 174 | 188 | } |
| 175 | 189 | |
@@ -180,7 +194,9 @@ discard block |
||
| 180 | 194 | */ |
| 181 | 195 | protected function buildOptionDate( $key, $value ) |
| 182 | 196 | { |
| 183 | - if( $this->isHidden( $key ))return; |
|
| 197 | + if( $this->isHidden( $key )) { |
|
| 198 | + return; |
|
| 199 | + } |
|
| 184 | 200 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 185 | 201 | if( $dateFormat == 'relative' ) { |
| 186 | 202 | $date = glsr( Date::class )->relative( $value ); |
@@ -201,7 +217,9 @@ discard block |
||
| 201 | 217 | */ |
| 202 | 218 | protected function buildOptionRating( $key, $value ) |
| 203 | 219 | { |
| 204 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 220 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 221 | + return; |
|
| 222 | + } |
|
| 205 | 223 | return glsr( Partial::class )->build( 'star-rating', [ |
| 206 | 224 | 'rating' => $value, |
| 207 | 225 | ]); |
@@ -214,7 +232,9 @@ discard block |
||
| 214 | 232 | */ |
| 215 | 233 | protected function buildOptionResponse( $key, $value ) |
| 216 | 234 | { |
| 217 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 235 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 236 | + return; |
|
| 237 | + } |
|
| 218 | 238 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
| 219 | 239 | $text = $this->normalizeText( $value ); |
| 220 | 240 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -230,7 +250,9 @@ discard block |
||
| 230 | 250 | */ |
| 231 | 251 | protected function buildOptionTitle( $key, $value ) |
| 232 | 252 | { |
| 233 | - if( $this->isHidden( $key ))return; |
|
| 253 | + if( $this->isHidden( $key )) { |
|
| 254 | + return; |
|
| 255 | + } |
|
| 234 | 256 | if( empty( $value )) { |
| 235 | 257 | $value = __( 'No Title', 'site-reviews' ); |
| 236 | 258 | } |
@@ -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 ); |
@@ -367,7 +393,9 @@ discard block |
||
| 367 | 393 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
| 368 | 394 | array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
| 369 | 395 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
| 370 | - if( empty( $value ))return; |
|
| 396 | + if( empty( $value )) { |
|
| 397 | + return; |
|
| 398 | + } |
|
| 371 | 399 | $value = glsr( Builder::class )->div( $value, [ |
| 372 | 400 | 'class' => 'glsr-review-'.$key, |
| 373 | 401 | ]); |
@@ -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 | } |
@@ -19,7 +19,9 @@ discard block |
||
| 19 | 19 | 'glsr_get_review', 'glsr_get_reviews', |
| 20 | 20 | 'glsr_log', |
| 21 | 21 | ); |
| 22 | - if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return; |
|
| 22 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook )) { |
|
| 23 | + return; |
|
| 24 | + } |
|
| 23 | 25 | add_filter( $hook, function() use( $hook, $args ) { |
| 24 | 26 | array_shift( $args ); // remove the fallback value |
| 25 | 27 | return call_user_func_array( $hook, $args ); |
@@ -29,7 +31,8 @@ discard block |
||
| 29 | 31 | /** |
| 30 | 32 | * @return mixed |
| 31 | 33 | */ |
| 32 | -function glsr( $alias = null ) { |
|
| 34 | +function glsr( $alias = null ) |
|
| 35 | +{ |
|
| 33 | 36 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 34 | 37 | return !empty( $alias ) |
| 35 | 38 | ? $app->make( $alias ) |
@@ -41,11 +44,14 @@ discard block |
||
| 41 | 44 | * @param $column string |
| 42 | 45 | * @return array |
| 43 | 46 | */ |
| 44 | -function glsr_array_column( array $array, $column ) { |
|
| 47 | +function glsr_array_column( array $array, $column ) |
|
| 48 | +{ |
|
| 45 | 49 | $result = array(); |
| 46 | 50 | foreach( $array as $subarray ) { |
| 47 | 51 | $subarray = (array)$subarray; |
| 48 | - if( !isset( $subarray[$column] ))continue; |
|
| 52 | + if( !isset( $subarray[$column] )) { |
|
| 53 | + continue; |
|
| 54 | + } |
|
| 49 | 55 | $result[] = $subarray[$column]; |
| 50 | 56 | } |
| 51 | 57 | return $result; |
@@ -54,7 +60,8 @@ discard block |
||
| 54 | 60 | /** |
| 55 | 61 | * @return void |
| 56 | 62 | */ |
| 57 | -function glsr_calculate_ratings() { |
|
| 63 | +function glsr_calculate_ratings() |
|
| 64 | +{ |
|
| 58 | 65 | glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
| 59 | 66 | glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' )); |
| 60 | 67 | } |
@@ -62,7 +69,8 @@ discard block |
||
| 62 | 69 | /** |
| 63 | 70 | * @return \GeminiLabs\SiteReviews\Review|false |
| 64 | 71 | */ |
| 65 | -function glsr_create_review( $reviewValues = array() ) { |
|
| 72 | +function glsr_create_review( $reviewValues = array() ) |
|
| 73 | +{ |
|
| 66 | 74 | if( !is_array( $reviewValues )) { |
| 67 | 75 | $reviewValues = array(); |
| 68 | 76 | } |
@@ -73,7 +81,8 @@ discard block |
||
| 73 | 81 | /** |
| 74 | 82 | * @return \WP_Screen|object |
| 75 | 83 | */ |
| 76 | -function glsr_current_screen() { |
|
| 84 | +function glsr_current_screen() |
|
| 85 | +{ |
|
| 77 | 86 | if( function_exists( 'get_current_screen' )) { |
| 78 | 87 | $screen = get_current_screen(); |
| 79 | 88 | } |
@@ -86,7 +95,8 @@ discard block |
||
| 86 | 95 | * @param mixed ...$vars |
| 87 | 96 | * @return void |
| 88 | 97 | */ |
| 89 | -function glsr_debug( ...$vars ) { |
|
| 98 | +function glsr_debug( ...$vars ) |
|
| 99 | +{ |
|
| 90 | 100 | if( count( $vars ) == 1 ) { |
| 91 | 101 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
| 92 | 102 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -105,7 +115,8 @@ discard block |
||
| 105 | 115 | * @param mixed $fallback |
| 106 | 116 | * @return string|array |
| 107 | 117 | */ |
| 108 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
| 118 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
| 119 | +{ |
|
| 109 | 120 | return is_string( $path ) |
| 110 | 121 | ? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ) |
| 111 | 122 | : $fallback; |
@@ -114,7 +125,8 @@ discard block |
||
| 114 | 125 | /** |
| 115 | 126 | * @return array |
| 116 | 127 | */ |
| 117 | -function glsr_get_options() { |
|
| 128 | +function glsr_get_options() |
|
| 129 | +{ |
|
| 118 | 130 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
| 119 | 131 | } |
| 120 | 132 | |
@@ -122,7 +134,8 @@ discard block |
||
| 122 | 134 | * @param int $post_id |
| 123 | 135 | * @return \GeminiLabs\SiteReviews\Review |
| 124 | 136 | */ |
| 125 | -function glsr_get_review( $post_id ) { |
|
| 137 | +function glsr_get_review( $post_id ) |
|
| 138 | +{ |
|
| 126 | 139 | $post = null; |
| 127 | 140 | if( is_numeric( $post_id )) { |
| 128 | 141 | $post = get_post( $post_id ); |
@@ -136,7 +149,8 @@ discard block |
||
| 136 | 149 | /** |
| 137 | 150 | * @return array |
| 138 | 151 | */ |
| 139 | -function glsr_get_reviews( $args = array() ) { |
|
| 152 | +function glsr_get_reviews( $args = array() ) |
|
| 153 | +{ |
|
| 140 | 154 | if( !is_array( $args )) { |
| 141 | 155 | $args = []; |
| 142 | 156 | } |
@@ -146,7 +160,8 @@ discard block |
||
| 146 | 160 | /** |
| 147 | 161 | * @return \GeminiLabs\SiteReviews\Modules\Console |
| 148 | 162 | */ |
| 149 | -function glsr_log() { |
|
| 163 | +function glsr_log() |
|
| 164 | +{ |
|
| 150 | 165 | $args = func_get_args(); |
| 151 | 166 | $context = isset( $args[1] ) |
| 152 | 167 | ? $args[1] |
@@ -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, |