@@ -3,64 +3,64 @@ |
||
| 3 | 3 | defined( 'WPINC' ) || die; |
| 4 | 4 | |
| 5 | 5 | add_action( 'site-reviews/review/submitted', function() { |
| 6 | - if( has_action( 'site-reviews/local/review/submitted' )) { |
|
| 6 | + if( has_action( 'site-reviews/local/review/submitted' ) ) { |
|
| 7 | 7 | glsr_log()->notice( 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.' ); |
| 8 | 8 | } |
| 9 | - if( has_filter( 'site-reviews/local/review/submitted/message' )) { |
|
| 9 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
| 10 | 10 | glsr_log()->notice( 'The "site-reviews/local/review/submitted/message" hook has been deprecated.' ); |
| 11 | 11 | } |
| 12 | 12 | }); |
| 13 | 13 | |
| 14 | 14 | add_filter( 'site-reviews/create/review-values', function( $values ) { |
| 15 | - if( has_filter( 'site-reviews/local/review' )) { |
|
| 15 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
| 16 | 16 | glsr_log()->notice( 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.' ); |
| 17 | 17 | } |
| 18 | 18 | return $values; |
| 19 | 19 | }); |
| 20 | 20 | |
| 21 | 21 | add_filter( 'site-reviews/get/defaults', function( $defaults ) { |
| 22 | - if( has_filter( 'site-reviews/addon/defaults' )) { |
|
| 22 | + if( has_filter( 'site-reviews/addon/defaults' ) ) { |
|
| 23 | 23 | glsr_log()->notice( 'The "site-reviews/addon/defaults" hook has been deprecated. Please use the "site-reviews/get/defaults" hook instead.' ); |
| 24 | 24 | } |
| 25 | 25 | return $defaults; |
| 26 | 26 | }); |
| 27 | 27 | |
| 28 | 28 | add_filter( 'site-reviews/rating/average', function( $average ) { |
| 29 | - if( has_filter( 'site-reviews/average/rating' )) { |
|
| 29 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
| 30 | 30 | glsr_log()->notice( 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.' ); |
| 31 | 31 | } |
| 32 | 32 | return $average; |
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | 35 | add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
| 36 | - if( has_filter( 'site-reviews/bayesian/ranking' )) { |
|
| 36 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
| 37 | 37 | glsr_log()->notice( 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.' ); |
| 38 | 38 | } |
| 39 | 39 | return $ranking; |
| 40 | 40 | }); |
| 41 | 41 | |
| 42 | 42 | add_filter( 'site-reviews/review/build/before', function( $review ) { |
| 43 | - if( has_filter( 'site-reviews/rendered/review/meta/order' )) { |
|
| 43 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
| 44 | 44 | glsr_log()->notice( 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom template instead (refer to the documentation).' ); |
| 45 | 45 | } |
| 46 | - if( has_filter( 'site-reviews/rendered/review/order' )) { |
|
| 46 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
| 47 | 47 | glsr_log()->notice( 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom template instead (refer to the documentation).' ); |
| 48 | 48 | } |
| 49 | 49 | return $review; |
| 50 | 50 | }); |
| 51 | 51 | |
| 52 | 52 | add_filter( 'site-reviews/review/build/after', function( $review ) { |
| 53 | - if( has_filter( 'site-reviews/reviews/review/text' )) { |
|
| 53 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
| 54 | 54 | glsr_log()->notice( 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.' ); |
| 55 | 55 | } |
| 56 | - if( has_filter( 'site-reviews/reviews/review/title' )) { |
|
| 56 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
| 57 | 57 | glsr_log()->notice( 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.' ); |
| 58 | 58 | } |
| 59 | 59 | return $review; |
| 60 | 60 | }); |
| 61 | 61 | |
| 62 | 62 | add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
| 63 | - if( has_filter( 'site-reviews/enqueue/localize' )) { |
|
| 63 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
| 64 | 64 | glsr_log()->notice( 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.' ); |
| 65 | 65 | } |
| 66 | 66 | return $variables; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'response' => $this->buildResponse(), |
| 66 | 66 | 'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(), |
| 67 | 67 | ], |
| 68 | - ]); |
|
| 68 | + ] ); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'context' => [ |
| 78 | 78 | 'text' => trim( $this->getLoginText().' '.$this->getRegisterText() ), |
| 79 | 79 | ], |
| 80 | - ]); |
|
| 80 | + ] ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | protected function buildRecaptcha() |
| 87 | 87 | { |
| 88 | 88 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
| 89 | - return glsr( Builder::class )->div([ |
|
| 89 | + return glsr( Builder::class )->div( [ |
|
| 90 | 90 | 'class' => 'glsr-recaptcha-holder', |
| 91 | 91 | 'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ), |
| 92 | - 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' )), |
|
| 92 | + 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' ) ), |
|
| 93 | 93 | 'data-size' => 'invisible', |
| 94 | - ]); |
|
| 94 | + ] ); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function buildResponse() |
| 101 | 101 | { |
| 102 | - $classes = !empty( $this->errors ) |
|
| 102 | + $classes = !empty($this->errors) |
|
| 103 | 103 | ? glsr( StyleValidationDefaults::class )->defaults()['message_error_class'] |
| 104 | 104 | : ''; |
| 105 | 105 | return glsr( Template::class )->build( 'templates/form/response', [ |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | 'class' => $classes, |
| 108 | 108 | 'message' => wpautop( $this->message ), |
| 109 | 109 | ], |
| 110 | - 'has_errors' => !empty( $this->errors ), |
|
| 111 | - ]); |
|
| 110 | + 'has_errors' => !empty($this->errors), |
|
| 111 | + ] ); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | 'context' => [ |
| 121 | 121 | 'text' => __( 'Submit your review', 'site-reviews' ), |
| 122 | 122 | ], |
| 123 | - ]); |
|
| 123 | + ] ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $fields = array_merge( |
| 140 | 140 | $this->getHiddenFields(), |
| 141 | 141 | [$this->getHoneypotField()], |
| 142 | - $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' )) |
|
| 142 | + $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' ) ) |
|
| 143 | 143 | ); |
| 144 | 144 | return $fields; |
| 145 | 145 | } |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | protected function getLoginText() |
| 151 | 151 | { |
| 152 | - $loginLink = glsr( Builder::class )->a([ |
|
| 153 | - 'href' => wp_login_url( strval( get_permalink() )), |
|
| 152 | + $loginLink = glsr( Builder::class )->a( [ |
|
| 153 | + 'href' => wp_login_url( strval( get_permalink() ) ), |
|
| 154 | 154 | 'text' => __( 'logged in', 'site-reviews' ), |
| 155 | - ]); |
|
| 155 | + ] ); |
|
| 156 | 156 | return sprintf( __( 'You must be %s to submit a review.', 'site-reviews' ), $loginLink ); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | protected function getRegisterText() |
| 163 | 163 | { |
| 164 | 164 | if( !get_option( 'users_can_register' ) || glsr( OptionManager::class )->get( 'settings.general.require.login' ) != 'yes' )return; |
| 165 | - $registerLink = glsr( Builder::class )->a([ |
|
| 165 | + $registerLink = glsr( Builder::class )->a( [ |
|
| 166 | 166 | 'href' => wp_registration_url(), |
| 167 | 167 | 'text' => __( 'register', 'site-reviews' ), |
| 168 | - ]); |
|
| 168 | + ] ); |
|
| 169 | 169 | return sprintf( __( 'You may also %s for an account.', 'site-reviews' ), $registerLink ); |
| 170 | 170 | } |
| 171 | 171 | |
@@ -177,30 +177,30 @@ discard block |
||
| 177 | 177 | $fields = [[ |
| 178 | 178 | 'name' => 'action', |
| 179 | 179 | 'value' => 'submit-review', |
| 180 | - ],[ |
|
| 180 | + ], [ |
|
| 181 | 181 | 'name' => 'assign_to', |
| 182 | 182 | 'value' => $this->args['assign_to'], |
| 183 | - ],[ |
|
| 183 | + ], [ |
|
| 184 | 184 | 'name' => 'category', |
| 185 | 185 | 'value' => $this->args['category'], |
| 186 | - ],[ |
|
| 186 | + ], [ |
|
| 187 | 187 | 'name' => 'excluded', |
| 188 | 188 | 'value' => $this->args['excluded'], // @todo should default to "[]" |
| 189 | - ],[ |
|
| 189 | + ], [ |
|
| 190 | 190 | 'name' => 'form_id', |
| 191 | 191 | 'value' => $this->args['id'], |
| 192 | - ],[ |
|
| 192 | + ], [ |
|
| 193 | 193 | 'name' => 'nonce', |
| 194 | 194 | 'value' => wp_create_nonce( 'submit-review' ), |
| 195 | - ],[ |
|
| 195 | + ], [ |
|
| 196 | 196 | 'name' => 'post_id', |
| 197 | 197 | 'value' => get_the_ID(), |
| 198 | - ],[ |
|
| 198 | + ], [ |
|
| 199 | 199 | 'name' => 'referer', |
| 200 | - 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' )), |
|
| 200 | + 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' ) ), |
|
| 201 | 201 | ]]; |
| 202 | 202 | return array_map( function( $field ) { |
| 203 | - return new Field( wp_parse_args( $field, ['type' => 'hidden'] )); |
|
| 203 | + return new Field( wp_parse_args( $field, ['type' => 'hidden'] ) ); |
|
| 204 | 204 | }, $fields ); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | protected function getHoneypotField() |
| 211 | 211 | { |
| 212 | - return new Field([ |
|
| 212 | + return new Field( [ |
|
| 213 | 213 | 'name' => 'gotcha', |
| 214 | 214 | 'type' => 'honeypot', |
| 215 | - ]); |
|
| 215 | + ] ); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | protected function normalizeFieldClass( Field &$field ) |
| 222 | 222 | { |
| 223 | - if( !isset( $field->field['class'] )) { |
|
| 223 | + if( !isset($field->field['class']) ) { |
|
| 224 | 224 | $field->field['class'] = ''; |
| 225 | 225 | } |
| 226 | 226 | $field->field['class'] = trim( $field->field['class'].' glsr-field-control' ); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | protected function normalizeFieldErrors( Field &$field ) |
| 233 | 233 | { |
| 234 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
| 234 | + if( !array_key_exists( $field->field['path'], $this->errors ) )return; |
|
| 235 | 235 | $field->field['errors'] = $this->errors[$field->field['path']]; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | protected function normalizeFieldRequired( Field &$field ) |
| 242 | 242 | { |
| 243 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
| 243 | + if( !in_array( $field->field['path'], $this->required ) )return; |
|
| 244 | 244 | $field->field['required'] = true; |
| 245 | 245 | } |
| 246 | 246 | |
@@ -264,8 +264,8 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | protected function normalizeFieldValue( Field &$field ) |
| 266 | 266 | { |
| 267 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
| 268 | - if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
|
| 267 | + if( !array_key_exists( $field->field['path'], $this->values ) )return; |
|
| 268 | + if( in_array( $field->field['type'], ['radio', 'checkbox'] ) ) { |
|
| 269 | 269 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
| 270 | 270 | } |
| 271 | 271 | else { |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | 'navigation' => $navigation, |
| 57 | 57 | 'reviews' => $this->buildReviews(), |
| 58 | 58 | ], |
| 59 | - ]); |
|
| 59 | + ] ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | $reviews = ''; |
| 68 | 68 | foreach( $this->reviews->results as $index => $result ) { |
| 69 | 69 | $this->current = $index; |
| 70 | - $reviews.= glsr( Template::class )->build( 'templates/review', [ |
|
| 70 | + $reviews .= glsr( Template::class )->build( 'templates/review', [ |
|
| 71 | 71 | 'context' => $this->buildReview( $result )->values, |
| 72 | - ]); |
|
| 72 | + ] ); |
|
| 73 | 73 | } |
| 74 | 74 | return $reviews; |
| 75 | 75 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $reviewValues = []; |
| 85 | 85 | foreach( $review as $key => $value ) { |
| 86 | 86 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
| 87 | - if( !method_exists( $this, $method ))continue; |
|
| 87 | + if( !method_exists( $this, $method ) )continue; |
|
| 88 | 88 | $reviewValues[$key] = $this->$method( $key, $value ); |
| 89 | 89 | } |
| 90 | 90 | $reviewValues = apply_filters( 'site-reviews/review/build/after', (array)$reviewValues ); |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | protected function buildOptionAssignedTo( $key, $value ) |
| 100 | 100 | { |
| 101 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
| 102 | - $post = get_post( intval( $value )); |
|
| 103 | - if( !( $post instanceof WP_Post ))return; |
|
| 101 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return; |
|
| 102 | + $post = get_post( intval( $value ) ); |
|
| 103 | + if( !($post instanceof WP_Post) )return; |
|
| 104 | 104 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 105 | 105 | 'href' => get_the_permalink( $post->ID ), |
| 106 | - ]); |
|
| 106 | + ] ); |
|
| 107 | 107 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
| 108 | 108 | return $this->wrap( $key, '<span>'.$assignedTo.'</span>' ); |
| 109 | 109 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | protected function buildOptionAuthor( $key, $value ) |
| 117 | 117 | { |
| 118 | - if( $this->isHidden( $key ))return; |
|
| 118 | + if( $this->isHidden( $key ) )return; |
|
| 119 | 119 | return $this->wrap( $key, '<span>'.$value.'</span>' ); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | protected function buildOptionAvatar( $key, $value ) |
| 128 | 128 | { |
| 129 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
| 129 | + if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return; |
|
| 130 | 130 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
| 131 | - return $this->wrap( $key, glsr( Builder::class )->img([ |
|
| 131 | + return $this->wrap( $key, glsr( Builder::class )->img( [ |
|
| 132 | 132 | 'src' => $this->generateAvatar( $value ), |
| 133 | 133 | 'height' => $size, |
| 134 | 134 | 'width' => $size, |
| 135 | - ])); |
|
| 135 | + ] ) ); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | protected function buildOptionContent( $key, $value ) |
| 144 | 144 | { |
| 145 | 145 | $text = $this->normalizeText( $value ); |
| 146 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 146 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
| 147 | 147 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function buildOptionDate( $key, $value ) |
| 156 | 156 | { |
| 157 | - if( $this->isHidden( $key ))return; |
|
| 157 | + if( $this->isHidden( $key ) )return; |
|
| 158 | 158 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 159 | 159 | if( $dateFormat == 'relative' ) { |
| 160 | 160 | $date = glsr( Date::class )->relative( $value ); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $format = $dateFormat == 'custom' |
| 164 | 164 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
| 165 | 165 | : (string)get_option( 'date_format' ); |
| 166 | - $date = date_i18n( $format, strtotime( $value )); |
|
| 166 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
| 167 | 167 | } |
| 168 | 168 | return $this->wrap( $key, '<span>'.$date.'</span>' ); |
| 169 | 169 | } |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function buildOptionRating( $key, $value ) |
| 177 | 177 | { |
| 178 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 178 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 179 | 179 | $rating = glsr( Partial::class )->build( 'star-rating', [ |
| 180 | 180 | 'rating' => $value, |
| 181 | - ]); |
|
| 181 | + ] ); |
|
| 182 | 182 | return $this->wrap( $key, $rating ); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | protected function buildOptionResponse( $key, $value ) |
| 191 | 191 | { |
| 192 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 193 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
| 192 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 193 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
| 194 | 194 | $text = $this->normalizeText( $value ); |
| 195 | 195 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
| 196 | 196 | return $this->wrap( $key, |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | protected function buildOptionTitle( $key, $value ) |
| 208 | 208 | { |
| 209 | - if( $this->isHidden( $key ))return; |
|
| 210 | - if( empty( $value )) { |
|
| 209 | + if( $this->isHidden( $key ) )return; |
|
| 210 | + if( empty($value) ) { |
|
| 211 | 211 | $value = __( 'No Title', 'site-reviews' ); |
| 212 | 212 | } |
| 213 | 213 | return $this->wrap( $key, '<h3>'.$value.'</h3>' ); |
@@ -224,10 +224,10 @@ discard block |
||
| 224 | 224 | return $avatarUrl; |
| 225 | 225 | } |
| 226 | 226 | $authorIdOrEmail = get_the_author_meta( 'ID', $review->user_id ); |
| 227 | - if( empty( $authorIdOrEmail )) { |
|
| 227 | + if( empty($authorIdOrEmail) ) { |
|
| 228 | 228 | $authorIdOrEmail = $review->email; |
| 229 | 229 | } |
| 230 | - if( $newAvatar = get_avatar_url( $authorIdOrEmail )) { |
|
| 230 | + if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) { |
|
| 231 | 231 | return $newAvatar; |
| 232 | 232 | } |
| 233 | 233 | return $avatarUrl; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | protected function generateSchema() |
| 240 | 240 | { |
| 241 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 241 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
| 242 | 242 | glsr( Schema::class )->store( |
| 243 | 243 | glsr( Schema::class )->build( $this->args ) |
| 244 | 244 | ); |
@@ -261,18 +261,18 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | protected function getExcerpt( $text ) |
| 263 | 263 | { |
| 264 | - $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 )); |
|
| 264 | + $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) ); |
|
| 265 | 265 | $split = extension_loaded( 'intl' ) |
| 266 | 266 | ? $this->getExcerptIntlSplit( $text, $limit ) |
| 267 | 267 | : $this->getExcerptSplit( $text, $limit ); |
| 268 | 268 | $hiddenText = substr( $text, $split ); |
| 269 | - if( !empty( $hiddenText )) { |
|
| 269 | + if( !empty($hiddenText) ) { |
|
| 270 | 270 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
| 271 | 271 | 'class' => 'glsr-hidden glsr-hidden-text', |
| 272 | 272 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
| 273 | 273 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
| 274 | - ]); |
|
| 275 | - $text = ltrim( substr( $text, 0, $split )).$showMore; |
|
| 274 | + ] ); |
|
| 275 | + $text = ltrim( substr( $text, 0, $split ) ).$showMore; |
|
| 276 | 276 | } |
| 277 | 277 | return nl2br( $text ); |
| 278 | 278 | } |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $words = IntlRuleBasedBreakIterator::createWordInstance( '' ); |
| 288 | 288 | $words->setText( $text ); |
| 289 | 289 | $count = 0; |
| 290 | - foreach( $words as $offset ){ |
|
| 290 | + foreach( $words as $offset ) { |
|
| 291 | 291 | if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
| 292 | 292 | $count++; |
| 293 | 293 | if( $count != $limit )continue; |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | protected function getExcerptSplit( $text, $limit ) |
| 305 | 305 | { |
| 306 | 306 | if( str_word_count( $text, 0 ) > $limit ) { |
| 307 | - $words = array_keys( str_word_count( $text, 2 )); |
|
| 307 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
| 308 | 308 | return $words[$limit]; |
| 309 | 309 | } |
| 310 | 310 | return strlen( $text ); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | protected function getOption( $path, $fallback = '' ) |
| 319 | 319 | { |
| 320 | - if( array_key_exists( $path, $this->options )) { |
|
| 320 | + if( array_key_exists( $path, $this->options ) ) { |
|
| 321 | 321 | return $this->options[$path]; |
| 322 | 322 | } |
| 323 | 323 | return $fallback; |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | protected function isHidden( $key, $path = '' ) |
| 332 | 332 | { |
| 333 | - $isOptionEnabled = !empty( $path ) |
|
| 333 | + $isOptionEnabled = !empty($path) |
|
| 334 | 334 | ? $this->isOptionEnabled( $path ) |
| 335 | 335 | : true; |
| 336 | 336 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | protected function isHiddenOrEmpty( $key, $value ) |
| 345 | 345 | { |
| 346 | - return $this->isHidden( $key ) || empty( $value ); |
|
| 346 | + return $this->isHidden( $key ) || empty($value); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -362,10 +362,10 @@ discard block |
||
| 362 | 362 | protected function normalizeText( $text ) |
| 363 | 363 | { |
| 364 | 364 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
| 365 | - $text = convert_smilies( strip_shortcodes( $text )); |
|
| 365 | + $text = convert_smilies( strip_shortcodes( $text ) ); |
|
| 366 | 366 | $text = str_replace( ']]>', ']]>', $text ); |
| 367 | 367 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
| 368 | - if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) { |
|
| 368 | + if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) { |
|
| 369 | 369 | $text = $this->getExcerpt( $text ); |
| 370 | 370 | } |
| 371 | 371 | return wptexturize( $text ); |
@@ -380,6 +380,6 @@ discard block |
||
| 380 | 380 | { |
| 381 | 381 | return glsr( Builder::class )->div( $value, [ |
| 382 | 382 | 'class' => 'glsr-review-'.$key, |
| 383 | - ]); |
|
| 383 | + ] ); |
|
| 384 | 384 | } |
| 385 | 385 | } |
@@ -84,7 +84,9 @@ discard block |
||
| 84 | 84 | $reviewValues = []; |
| 85 | 85 | foreach( $review as $key => $value ) { |
| 86 | 86 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
| 87 | - if( !method_exists( $this, $method ))continue; |
|
| 87 | + if( !method_exists( $this, $method )) { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 88 | 90 | $reviewValues[$key] = $this->$method( $key, $value ); |
| 89 | 91 | } |
| 90 | 92 | $reviewValues = apply_filters( 'site-reviews/review/build/after', (array)$reviewValues ); |
@@ -98,9 +100,13 @@ discard block |
||
| 98 | 100 | */ |
| 99 | 101 | protected function buildOptionAssignedTo( $key, $value ) |
| 100 | 102 | { |
| 101 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
| 103 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' )) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 102 | 106 | $post = get_post( intval( $value )); |
| 103 | - if( !( $post instanceof WP_Post ))return; |
|
| 107 | + if( !( $post instanceof WP_Post )) { |
|
| 108 | + return; |
|
| 109 | + } |
|
| 104 | 110 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 105 | 111 | 'href' => get_the_permalink( $post->ID ), |
| 106 | 112 | ]); |
@@ -115,7 +121,9 @@ discard block |
||
| 115 | 121 | */ |
| 116 | 122 | protected function buildOptionAuthor( $key, $value ) |
| 117 | 123 | { |
| 118 | - if( $this->isHidden( $key ))return; |
|
| 124 | + if( $this->isHidden( $key )) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 119 | 127 | return $this->wrap( $key, '<span>'.$value.'</span>' ); |
| 120 | 128 | } |
| 121 | 129 | |
@@ -126,7 +134,9 @@ discard block |
||
| 126 | 134 | */ |
| 127 | 135 | protected function buildOptionAvatar( $key, $value ) |
| 128 | 136 | { |
| 129 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
| 137 | + if( $this->isHidden( $key, 'settings.reviews.avatars' )) { |
|
| 138 | + return; |
|
| 139 | + } |
|
| 130 | 140 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
| 131 | 141 | return $this->wrap( $key, glsr( Builder::class )->img([ |
| 132 | 142 | 'src' => $this->generateAvatar( $value ), |
@@ -143,7 +153,9 @@ discard block |
||
| 143 | 153 | protected function buildOptionContent( $key, $value ) |
| 144 | 154 | { |
| 145 | 155 | $text = $this->normalizeText( $value ); |
| 146 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 156 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
| 157 | + return; |
|
| 158 | + } |
|
| 147 | 159 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
| 148 | 160 | } |
| 149 | 161 | |
@@ -154,7 +166,9 @@ discard block |
||
| 154 | 166 | */ |
| 155 | 167 | protected function buildOptionDate( $key, $value ) |
| 156 | 168 | { |
| 157 | - if( $this->isHidden( $key ))return; |
|
| 169 | + if( $this->isHidden( $key )) { |
|
| 170 | + return; |
|
| 171 | + } |
|
| 158 | 172 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 159 | 173 | if( $dateFormat == 'relative' ) { |
| 160 | 174 | $date = glsr( Date::class )->relative( $value ); |
@@ -175,7 +189,9 @@ discard block |
||
| 175 | 189 | */ |
| 176 | 190 | protected function buildOptionRating( $key, $value ) |
| 177 | 191 | { |
| 178 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 192 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 193 | + return; |
|
| 194 | + } |
|
| 179 | 195 | $rating = glsr( Partial::class )->build( 'star-rating', [ |
| 180 | 196 | 'rating' => $value, |
| 181 | 197 | ]); |
@@ -189,7 +205,9 @@ discard block |
||
| 189 | 205 | */ |
| 190 | 206 | protected function buildOptionResponse( $key, $value ) |
| 191 | 207 | { |
| 192 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 208 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 209 | + return; |
|
| 210 | + } |
|
| 193 | 211 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
| 194 | 212 | $text = $this->normalizeText( $value ); |
| 195 | 213 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -206,7 +224,9 @@ discard block |
||
| 206 | 224 | */ |
| 207 | 225 | protected function buildOptionTitle( $key, $value ) |
| 208 | 226 | { |
| 209 | - if( $this->isHidden( $key ))return; |
|
| 227 | + if( $this->isHidden( $key )) { |
|
| 228 | + return; |
|
| 229 | + } |
|
| 210 | 230 | if( empty( $value )) { |
| 211 | 231 | $value = __( 'No Title', 'site-reviews' ); |
| 212 | 232 | } |
@@ -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 | ); |
@@ -288,9 +310,13 @@ discard block |
||
| 288 | 310 | $words->setText( $text ); |
| 289 | 311 | $count = 0; |
| 290 | 312 | foreach( $words as $offset ){ |
| 291 | - if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
|
| 313 | + if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) { |
|
| 314 | + continue; |
|
| 315 | + } |
|
| 292 | 316 | $count++; |
| 293 | - if( $count != $limit )continue; |
|
| 317 | + if( $count != $limit ) { |
|
| 318 | + continue; |
|
| 319 | + } |
|
| 294 | 320 | return $offset; |
| 295 | 321 | } |
| 296 | 322 | return strlen( $text ); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function callbackRegisterSettings( $input ) |
| 18 | 18 | { |
| 19 | - if( !is_array( $input )) { |
|
| 19 | + if( !is_array( $input ) ) { |
|
| 20 | 20 | $input = ['settings' => []]; |
| 21 | 21 | } |
| 22 | 22 | if( key( $input ) == 'settings' ) { |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $options = $this->sanitizeGeneral( $input, $options ); |
| 25 | 25 | $options = $this->sanitizeSubmissions( $input, $options ); |
| 26 | 26 | $options = $this->sanitizeTranslations( $input, $options ); |
| 27 | - glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' )); |
|
| 27 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
| 28 | 28 | return $options; |
| 29 | 29 | } |
| 30 | 30 | return $input; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
| 40 | 40 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | protected function sanitizeGeneral( array $input, array $options ) |
| 48 | 48 | { |
| 49 | 49 | $inputForm = $input['settings']['general']; |
| 50 | - if( !isset( $inputForm['notifications'] )) { |
|
| 50 | + if( !isset($inputForm['notifications']) ) { |
|
| 51 | 51 | $options['settings']['general']['notifications'] = []; |
| 52 | 52 | } |
| 53 | 53 | if( trim( $inputForm['notification_message'] ) == '' ) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | protected function sanitizeSubmissions( array $input, array $options ) |
| 63 | 63 | { |
| 64 | 64 | $inputForm = $input['settings']['submissions']; |
| 65 | - if( !isset( $inputForm['required'] )) { |
|
| 65 | + if( !isset($inputForm['required']) ) { |
|
| 66 | 66 | $options['settings']['submissions']['required'] = []; |
| 67 | 67 | } |
| 68 | 68 | return $options; |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | protected function sanitizeTranslations( array $input, array $options ) |
| 75 | 75 | { |
| 76 | - if( isset( $input['settings']['strings'] )) { |
|
| 77 | - $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] )); |
|
| 76 | + if( isset($input['settings']['strings']) ) { |
|
| 77 | + $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) ); |
|
| 78 | 78 | $allowedTags = ['a' => ['class' => [], 'href' => [], 'target' => []]]; |
| 79 | - array_walk( $options['settings']['strings'], function( &$string ) use( $allowedTags ) { |
|
| 80 | - if( isset( $string['s2'] )) { |
|
| 79 | + array_walk( $options['settings']['strings'], function( &$string ) use($allowedTags) { |
|
| 80 | + if( isset($string['s2']) ) { |
|
| 81 | 81 | $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
| 82 | 82 | } |
| 83 | - if( isset( $string['p2'] )) { |
|
| 83 | + if( isset($string['p2']) ) { |
|
| 84 | 84 | $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
| 85 | 85 | } |
| 86 | 86 | }); |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | public function filterEnqueuedScripts( $tag, $handle ) |
| 33 | 33 | { |
| 34 | 34 | $scripts = [Application::ID.'/google-recaptcha']; |
| 35 | - if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ))) { |
|
| 35 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
| 36 | 36 | $tag = str_replace( ' src=', ' async src=', $tag ); |
| 37 | 37 | } |
| 38 | - if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ))) { |
|
| 38 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
| 39 | 39 | $tag = str_replace( ' src=', ' defer src=', $tag ); |
| 40 | 40 | } |
| 41 | 41 | return $tag; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | public function routerSubmitReview( array $request ) |
| 86 | 86 | { |
| 87 | 87 | $validated = glsr( ValidateReview::class )->validate( $request ); |
| 88 | - if( !empty( $validated->error ) || $validated->recaptchaIsUnset )return; |
|
| 89 | - $this->execute( new CreateReview( $validated->request )); |
|
| 88 | + if( !empty($validated->error) || $validated->recaptchaIsUnset )return; |
|
| 89 | + $this->execute( new CreateReview( $validated->request ) ); |
|
| 90 | 90 | } |
| 91 | 91 | } |