@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | 'navigation' => $navigation, |
| 56 | 56 | ], |
| 57 | 57 | 'reviews' => $this->buildReviews(), |
| 58 | - ]); |
|
| 58 | + ] ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $generatedReview = []; |
| 84 | 84 | foreach( $review as $key => $value ) { |
| 85 | 85 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
| 86 | - if( !method_exists( $this, $method ))continue; |
|
| 86 | + if( !method_exists( $this, $method ) )continue; |
|
| 87 | 87 | $generatedReview[$key] = $this->$method( $key, $value ); |
| 88 | 88 | } |
| 89 | 89 | return (object)$generatedReview; |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | protected function buildOptionAssignedTo( $key, $value ) |
| 98 | 98 | { |
| 99 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
| 100 | - $post = get_post( intval( $value )); |
|
| 101 | - if( !( $post instanceof WP_Post ))return; |
|
| 99 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ) )return; |
|
| 100 | + $post = get_post( intval( $value ) ); |
|
| 101 | + if( !($post instanceof WP_Post) )return; |
|
| 102 | 102 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 103 | 103 | 'href' => get_the_permalink( $post->ID ), |
| 104 | - ]); |
|
| 104 | + ] ); |
|
| 105 | 105 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
| 106 | 106 | return $this->wrap( $key, '<span>'.$assignedTo.'</span>' ); |
| 107 | 107 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | protected function buildOptionAuthor( $key, $value ) |
| 115 | 115 | { |
| 116 | - if( $this->isHidden( $key ))return; |
|
| 116 | + if( $this->isHidden( $key ) )return; |
|
| 117 | 117 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
| 118 | 118 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
| 119 | 119 | : ''; |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | protected function buildOptionAvatar( $key, $value ) |
| 129 | 129 | { |
| 130 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
| 130 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ) )return; |
|
| 131 | 131 | $size = $this->getOption( 'settings.reviews.avatars.size', 40 ); |
| 132 | - return $this->wrap( $key, glsr( Builder::class )->img([ |
|
| 132 | + return $this->wrap( $key, glsr( Builder::class )->img( [ |
|
| 133 | 133 | 'src' => $this->generateAvatar( $value ), |
| 134 | 134 | 'height' => $size, |
| 135 | 135 | 'width' => $size, |
| 136 | - ])); |
|
| 136 | + ] ) ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | protected function buildOptionContent( $key, $value ) |
| 145 | 145 | { |
| 146 | 146 | $text = $this->normalizeText( $value ); |
| 147 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 147 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
| 148 | 148 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | protected function buildOptionDate( $key, $value ) |
| 157 | 157 | { |
| 158 | - if( $this->isHidden( $key ))return; |
|
| 158 | + if( $this->isHidden( $key ) )return; |
|
| 159 | 159 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 160 | 160 | if( $dateFormat == 'relative' ) { |
| 161 | 161 | $date = glsr( Date::class )->relative( $value ); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $format = $dateFormat == 'custom' |
| 165 | 165 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
| 166 | 166 | : (string)get_option( 'date_format' ); |
| 167 | - $date = date_i18n( $format, strtotime( $value )); |
|
| 167 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
| 168 | 168 | } |
| 169 | 169 | return $this->wrap( $key, '<span>'.$date.'</span>' ); |
| 170 | 170 | } |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | protected function buildOptionRating( $key, $value ) |
| 178 | 178 | { |
| 179 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 179 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 180 | 180 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 181 | 181 | 'rating' => $value, |
| 182 | - ]); |
|
| 182 | + ] ); |
|
| 183 | 183 | return $this->wrap( $key, $rating ); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | protected function buildOptionResponse( $key, $value ) |
| 192 | 192 | { |
| 193 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 194 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
| 193 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 194 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
| 195 | 195 | $text = $this->normalizeText( $value ); |
| 196 | 196 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
| 197 | 197 | return $this->wrap( $key, |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | protected function buildOptionTitle( $key, $value ) |
| 209 | 209 | { |
| 210 | - if( $this->isHidden( $key ))return; |
|
| 211 | - if( empty( $value )) { |
|
| 210 | + if( $this->isHidden( $key ) )return; |
|
| 211 | + if( empty($value) ) { |
|
| 212 | 212 | $value = __( 'No Title', 'site-reviews' ); |
| 213 | 213 | } |
| 214 | 214 | return $this->wrap( $key, '<h3>'.$value.'</h3>' ); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | return $avatarUrl; |
| 227 | 227 | } |
| 228 | 228 | $authorIdOrEmail = get_the_author_meta( 'ID', $review->user_id ); |
| 229 | - if( empty( $authorIdOrEmail )) { |
|
| 229 | + if( empty($authorIdOrEmail) ) { |
|
| 230 | 230 | $authorIdOrEmail = $review->email; |
| 231 | 231 | } |
| 232 | 232 | return get_avatar_url( $authorIdOrEmail ); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | protected function generateSchema() |
| 239 | 239 | { |
| 240 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 240 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
| 241 | 241 | glsr( Schema::class )->store( |
| 242 | 242 | glsr( Schema::class )->build( $this->args ) |
| 243 | 243 | ); |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | { |
| 264 | 264 | $limit = $this->getOption( 'settings.reviews.excerpt.length', 55 ); |
| 265 | 265 | if( str_word_count( $text, 0 ) > $limit ) { |
| 266 | - $words = array_keys( str_word_count( $text, 2 )); |
|
| 267 | - $excerpt = ltrim( substr( $text, 0, $words[$limit] )); |
|
| 268 | - $hiddenText = substr( $text, strlen( $excerpt )); |
|
| 266 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
| 267 | + $excerpt = ltrim( substr( $text, 0, $words[$limit] ) ); |
|
| 268 | + $hiddenText = substr( $text, strlen( $excerpt ) ); |
|
| 269 | 269 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
| 270 | 270 | 'class' => 'glsr-hidden glsr-hidden-text', |
| 271 | 271 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
| 272 | 272 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
| 273 | - ]); |
|
| 273 | + ] ); |
|
| 274 | 274 | $text = $excerpt.$showMore; |
| 275 | 275 | } |
| 276 | 276 | return nl2br( $text ); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | protected function getOption( $path, $fallback = '' ) |
| 285 | 285 | { |
| 286 | - if( array_key_exists( $path, $this->options )) { |
|
| 286 | + if( array_key_exists( $path, $this->options ) ) { |
|
| 287 | 287 | return $this->options[$path]; |
| 288 | 288 | } |
| 289 | 289 | return $fallback; |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | protected function isHidden( $key, $path = '' ) |
| 298 | 298 | { |
| 299 | - $isOptionEnabled = !empty( $path ) |
|
| 299 | + $isOptionEnabled = !empty($path) |
|
| 300 | 300 | ? $this->isOptionEnabled( $path ) |
| 301 | 301 | : true; |
| 302 | 302 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | protected function isHiddenOrEmpty( $key, $value ) |
| 311 | 311 | { |
| 312 | - return $this->isHidden( $key ) || empty( $value ); |
|
| 312 | + return $this->isHidden( $key ) || empty($value); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | protected function normalizeText( $text ) |
| 329 | 329 | { |
| 330 | 330 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
| 331 | - $text = convert_smilies( wptexturize( strip_shortcodes( $text ))); |
|
| 331 | + $text = convert_smilies( wptexturize( strip_shortcodes( $text ) ) ); |
|
| 332 | 332 | $text = str_replace( ']]>', ']]>', $text ); |
| 333 | 333 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
| 334 | 334 | return $this->isOptionEnabled( 'settings.reviews.excerpt.enabled' ) |
@@ -345,6 +345,6 @@ discard block |
||
| 345 | 345 | { |
| 346 | 346 | return glsr( Builder::class )->div( $value, [ |
| 347 | 347 | 'class' => 'glsr-review-'.$key, |
| 348 | - ]); |
|
| 348 | + ] ); |
|
| 349 | 349 | } |
| 350 | 350 | } |
@@ -83,7 +83,9 @@ discard block |
||
| 83 | 83 | $generatedReview = []; |
| 84 | 84 | foreach( $review as $key => $value ) { |
| 85 | 85 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
| 86 | - if( !method_exists( $this, $method ))continue; |
|
| 86 | + if( !method_exists( $this, $method )) { |
|
| 87 | + continue; |
|
| 88 | + } |
|
| 87 | 89 | $generatedReview[$key] = $this->$method( $key, $value ); |
| 88 | 90 | } |
| 89 | 91 | return (object)$generatedReview; |
@@ -96,9 +98,13 @@ discard block |
||
| 96 | 98 | */ |
| 97 | 99 | protected function buildOptionAssignedTo( $key, $value ) |
| 98 | 100 | { |
| 99 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
| 101 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' )) { |
|
| 102 | + return; |
|
| 103 | + } |
|
| 100 | 104 | $post = get_post( intval( $value )); |
| 101 | - if( !( $post instanceof WP_Post ))return; |
|
| 105 | + if( !( $post instanceof WP_Post )) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 102 | 108 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 103 | 109 | 'href' => get_the_permalink( $post->ID ), |
| 104 | 110 | ]); |
@@ -113,7 +119,9 @@ discard block |
||
| 113 | 119 | */ |
| 114 | 120 | protected function buildOptionAuthor( $key, $value ) |
| 115 | 121 | { |
| 116 | - if( $this->isHidden( $key ))return; |
|
| 122 | + if( $this->isHidden( $key )) { |
|
| 123 | + return; |
|
| 124 | + } |
|
| 117 | 125 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
| 118 | 126 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
| 119 | 127 | : ''; |
@@ -127,7 +135,9 @@ discard block |
||
| 127 | 135 | */ |
| 128 | 136 | protected function buildOptionAvatar( $key, $value ) |
| 129 | 137 | { |
| 130 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
| 138 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) { |
|
| 139 | + return; |
|
| 140 | + } |
|
| 131 | 141 | $size = $this->getOption( 'settings.reviews.avatars.size', 40 ); |
| 132 | 142 | return $this->wrap( $key, glsr( Builder::class )->img([ |
| 133 | 143 | 'src' => $this->generateAvatar( $value ), |
@@ -144,7 +154,9 @@ discard block |
||
| 144 | 154 | protected function buildOptionContent( $key, $value ) |
| 145 | 155 | { |
| 146 | 156 | $text = $this->normalizeText( $value ); |
| 147 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 157 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
| 158 | + return; |
|
| 159 | + } |
|
| 148 | 160 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
| 149 | 161 | } |
| 150 | 162 | |
@@ -155,7 +167,9 @@ discard block |
||
| 155 | 167 | */ |
| 156 | 168 | protected function buildOptionDate( $key, $value ) |
| 157 | 169 | { |
| 158 | - if( $this->isHidden( $key ))return; |
|
| 170 | + if( $this->isHidden( $key )) { |
|
| 171 | + return; |
|
| 172 | + } |
|
| 159 | 173 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 160 | 174 | if( $dateFormat == 'relative' ) { |
| 161 | 175 | $date = glsr( Date::class )->relative( $value ); |
@@ -176,7 +190,9 @@ discard block |
||
| 176 | 190 | */ |
| 177 | 191 | protected function buildOptionRating( $key, $value ) |
| 178 | 192 | { |
| 179 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 193 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 194 | + return; |
|
| 195 | + } |
|
| 180 | 196 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 181 | 197 | 'rating' => $value, |
| 182 | 198 | ]); |
@@ -190,7 +206,9 @@ discard block |
||
| 190 | 206 | */ |
| 191 | 207 | protected function buildOptionResponse( $key, $value ) |
| 192 | 208 | { |
| 193 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 209 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 210 | + return; |
|
| 211 | + } |
|
| 194 | 212 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
| 195 | 213 | $text = $this->normalizeText( $value ); |
| 196 | 214 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -207,7 +225,9 @@ discard block |
||
| 207 | 225 | */ |
| 208 | 226 | protected function buildOptionTitle( $key, $value ) |
| 209 | 227 | { |
| 210 | - if( $this->isHidden( $key ))return; |
|
| 228 | + if( $this->isHidden( $key )) { |
|
| 229 | + return; |
|
| 230 | + } |
|
| 211 | 231 | if( empty( $value )) { |
| 212 | 232 | $value = __( 'No Title', 'site-reviews' ); |
| 213 | 233 | } |
@@ -237,7 +257,9 @@ discard block |
||
| 237 | 257 | */ |
| 238 | 258 | protected function generateSchema() |
| 239 | 259 | { |
| 240 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 260 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 241 | 263 | glsr( Schema::class )->store( |
| 242 | 264 | glsr( Schema::class )->build( $this->args ) |
| 243 | 265 | ); |