@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'navigation' => $navigation, |
| 51 | 51 | ], |
| 52 | 52 | 'reviews' => $this->buildReviews(), |
| 53 | - ]); |
|
| 53 | + ] ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $generatedReview = []; |
| 75 | 75 | foreach( $review as $key => $value ) { |
| 76 | 76 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildReview' ); |
| 77 | - if( !method_exists( $this, $method ))continue; |
|
| 77 | + if( !method_exists( $this, $method ) )continue; |
|
| 78 | 78 | $generatedReview[$key] = $this->$method( $key, $value ); |
| 79 | 79 | } |
| 80 | 80 | return (object)$generatedReview; |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | protected function buildReviewAssignedTo( $key, $value ) |
| 89 | 89 | { |
| 90 | 90 | if( !$this->isOptionEnabled( 'settings.reviews.assigned_links.enabled' ) |
| 91 | - || empty( $value ) |
|
| 91 | + || empty($value) |
|
| 92 | 92 | )return; |
| 93 | - $post = get_post( intval( $value )); |
|
| 94 | - if( !( $post instanceof WP_Post ))return; |
|
| 93 | + $post = get_post( intval( $value ) ); |
|
| 94 | + if( !($post instanceof WP_Post) )return; |
|
| 95 | 95 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 96 | 96 | 'href' => get_the_permalink( $post->ID ), |
| 97 | - ]); |
|
| 97 | + ] ); |
|
| 98 | 98 | $permalink = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
| 99 | 99 | return $this->wrap( $key, $permalink ); |
| 100 | 100 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | protected function buildReviewAuthor( $key, $value ) |
| 108 | 108 | { |
| 109 | - if( $this->isHidden( $key ))return; |
|
| 109 | + if( $this->isHidden( $key ) )return; |
|
| 110 | 110 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
| 111 | 111 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
| 112 | 112 | : ''; |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected function buildReviewAvatar( $key, $value ) |
| 122 | 122 | { |
| 123 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
| 124 | - return $this->wrap( $key, '<img src="'.$value.'" width="36">'); |
|
| 123 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ) )return; |
|
| 124 | + return $this->wrap( $key, '<img src="'.$value.'" width="36">' ); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | protected function buildReviewContent( $key, $value ) |
| 133 | 133 | { |
| 134 | 134 | $text = $this->normalizeText( $value ); |
| 135 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 135 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
| 136 | 136 | return $this->wrap( $key, $text ); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | protected function buildReviewDate( $key, $value ) |
| 145 | 145 | { |
| 146 | - if( $this->isHidden( $key ))return; |
|
| 146 | + if( $this->isHidden( $key ) )return; |
|
| 147 | 147 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 148 | 148 | if( $dateFormat == 'relative' ) { |
| 149 | 149 | $date = glsr( Date::class )->relative( $value ); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $format = $dateFormat == 'custom' |
| 153 | 153 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
| 154 | 154 | : (string)get_option( 'date_format' ); |
| 155 | - $date = date_i18n( $format, strtotime( $value )); |
|
| 155 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
| 156 | 156 | } |
| 157 | 157 | return $this->wrap( $key, $date ); |
| 158 | 158 | } |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | protected function buildReviewRating( $key, $value ) |
| 166 | 166 | { |
| 167 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 167 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 168 | 168 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 169 | 169 | 'rating' => $value, |
| 170 | - ]); |
|
| 170 | + ] ); |
|
| 171 | 171 | return $this->wrap( $key, $rating ); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | protected function buildReviewResponse( $key, $value ) |
| 180 | 180 | { |
| 181 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 182 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
| 181 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 182 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
| 183 | 183 | $text = $this->normalizeText( $value ); |
| 184 | 184 | return $this->wrap( $key, '<p><strong>'.$title.'</strong></p>'.$text ); |
| 185 | 185 | } |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | protected function buildReviewTitle( $key, $value ) |
| 193 | 193 | { |
| 194 | - if( $this->isHidden( $key ))return; |
|
| 195 | - if( empty( $value )) { |
|
| 194 | + if( $this->isHidden( $key ) )return; |
|
| 195 | + if( empty($value) ) { |
|
| 196 | 196 | $value = __( 'No Title', 'site-reviews' ); |
| 197 | 197 | } |
| 198 | 198 | return $this->wrap( $key, '<h3>'.$value.'</h3>' ); |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | protected function generateSchema() |
| 205 | 205 | { |
| 206 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 207 | - glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args )); |
|
| 206 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
| 207 | + glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args ) ); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -225,14 +225,14 @@ discard block |
||
| 225 | 225 | { |
| 226 | 226 | $limit = $this->getOption( 'settings.reviews.excerpt.length', 55 ); |
| 227 | 227 | if( str_word_count( $text, 0 ) > $limit ) { |
| 228 | - $words = array_keys( str_word_count( $text, 2 )); |
|
| 229 | - $excerpt = ltrim( substr( $text, 0, $words[$limit] )); |
|
| 230 | - $hiddenText = substr( $text, strlen( $excerpt )); |
|
| 228 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
| 229 | + $excerpt = ltrim( substr( $text, 0, $words[$limit] ) ); |
|
| 230 | + $hiddenText = substr( $text, strlen( $excerpt ) ); |
|
| 231 | 231 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
| 232 | 232 | 'class' => 'glsr-hidden glsr-hidden-text', |
| 233 | 233 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
| 234 | 234 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
| 235 | - ]); |
|
| 235 | + ] ); |
|
| 236 | 236 | $text = $excerpt.$showMore; |
| 237 | 237 | } |
| 238 | 238 | return nl2br( $text ); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | protected function getOption( $path, $fallback = '' ) |
| 247 | 247 | { |
| 248 | - if( array_key_exists( $path, $this->options )) { |
|
| 248 | + if( array_key_exists( $path, $this->options ) ) { |
|
| 249 | 249 | return $this->options[$path]; |
| 250 | 250 | } |
| 251 | 251 | return $fallback; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | protected function isHidden( $key, $path = '' ) |
| 260 | 260 | { |
| 261 | - $isOptionEnabled = !empty( $path ) |
|
| 261 | + $isOptionEnabled = !empty($path) |
|
| 262 | 262 | ? $this->isOptionEnabled( $path ) |
| 263 | 263 | : true; |
| 264 | 264 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | protected function isHiddenOrEmpty( $key, $value ) |
| 273 | 273 | { |
| 274 | - return $this->isHidden( $key ) || empty( $value ); |
|
| 274 | + return $this->isHidden( $key ) || empty($value); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | protected function normalizeText( $text ) |
| 291 | 291 | { |
| 292 | 292 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
| 293 | - $text = convert_smilies( wptexturize( strip_shortcodes( $text ))); |
|
| 293 | + $text = convert_smilies( wptexturize( strip_shortcodes( $text ) ) ); |
|
| 294 | 294 | $text = str_replace( ']]>', ']]>', $text ); |
| 295 | 295 | $text = $this->isOptionEnabled( 'settings.reviews.excerpt.enabled' ) |
| 296 | 296 | ? $this->getExcerpt( $text ) |
@@ -307,6 +307,6 @@ discard block |
||
| 307 | 307 | { |
| 308 | 308 | return glsr( Builder::class )->div( $value, [ |
| 309 | 309 | 'class' => 'glsr-review-'.$key, |
| 310 | - ]); |
|
| 310 | + ] ); |
|
| 311 | 311 | } |
| 312 | 312 | } |
@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | $generatedReview = []; |
| 75 | 75 | foreach( $review as $key => $value ) { |
| 76 | 76 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildReview' ); |
| 77 | - if( !method_exists( $this, $method ))continue; |
|
| 77 | + if( !method_exists( $this, $method )) { |
|
| 78 | + continue; |
|
| 79 | + } |
|
| 78 | 80 | $generatedReview[$key] = $this->$method( $key, $value ); |
| 79 | 81 | } |
| 80 | 82 | return (object)$generatedReview; |
@@ -89,9 +91,13 @@ discard block |
||
| 89 | 91 | { |
| 90 | 92 | if( !$this->isOptionEnabled( 'settings.reviews.assigned_links.enabled' ) |
| 91 | 93 | || empty( $value ) |
| 92 | - )return; |
|
| 94 | + ) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 93 | 97 | $post = get_post( intval( $value )); |
| 94 | - if( !( $post instanceof WP_Post ))return; |
|
| 98 | + if( !( $post instanceof WP_Post )) { |
|
| 99 | + return; |
|
| 100 | + } |
|
| 95 | 101 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 96 | 102 | 'href' => get_the_permalink( $post->ID ), |
| 97 | 103 | ]); |
@@ -106,7 +112,9 @@ discard block |
||
| 106 | 112 | */ |
| 107 | 113 | protected function buildReviewAuthor( $key, $value ) |
| 108 | 114 | { |
| 109 | - if( $this->isHidden( $key ))return; |
|
| 115 | + if( $this->isHidden( $key )) { |
|
| 116 | + return; |
|
| 117 | + } |
|
| 110 | 118 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
| 111 | 119 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
| 112 | 120 | : ''; |
@@ -120,7 +128,9 @@ discard block |
||
| 120 | 128 | */ |
| 121 | 129 | protected function buildReviewAvatar( $key, $value ) |
| 122 | 130 | { |
| 123 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
| 131 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) { |
|
| 132 | + return; |
|
| 133 | + } |
|
| 124 | 134 | return $this->wrap( $key, '<img src="'.$value.'" width="36">'); |
| 125 | 135 | } |
| 126 | 136 | |
@@ -132,7 +142,9 @@ discard block |
||
| 132 | 142 | protected function buildReviewContent( $key, $value ) |
| 133 | 143 | { |
| 134 | 144 | $text = $this->normalizeText( $value ); |
| 135 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 145 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
| 146 | + return; |
|
| 147 | + } |
|
| 136 | 148 | return $this->wrap( $key, $text ); |
| 137 | 149 | } |
| 138 | 150 | |
@@ -143,7 +155,9 @@ discard block |
||
| 143 | 155 | */ |
| 144 | 156 | protected function buildReviewDate( $key, $value ) |
| 145 | 157 | { |
| 146 | - if( $this->isHidden( $key ))return; |
|
| 158 | + if( $this->isHidden( $key )) { |
|
| 159 | + return; |
|
| 160 | + } |
|
| 147 | 161 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 148 | 162 | if( $dateFormat == 'relative' ) { |
| 149 | 163 | $date = glsr( Date::class )->relative( $value ); |
@@ -164,7 +178,9 @@ discard block |
||
| 164 | 178 | */ |
| 165 | 179 | protected function buildReviewRating( $key, $value ) |
| 166 | 180 | { |
| 167 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 181 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 182 | + return; |
|
| 183 | + } |
|
| 168 | 184 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 169 | 185 | 'rating' => $value, |
| 170 | 186 | ]); |
@@ -178,7 +194,9 @@ discard block |
||
| 178 | 194 | */ |
| 179 | 195 | protected function buildReviewResponse( $key, $value ) |
| 180 | 196 | { |
| 181 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 197 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 198 | + return; |
|
| 199 | + } |
|
| 182 | 200 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
| 183 | 201 | $text = $this->normalizeText( $value ); |
| 184 | 202 | return $this->wrap( $key, '<p><strong>'.$title.'</strong></p>'.$text ); |
@@ -191,7 +209,9 @@ discard block |
||
| 191 | 209 | */ |
| 192 | 210 | protected function buildReviewTitle( $key, $value ) |
| 193 | 211 | { |
| 194 | - if( $this->isHidden( $key ))return; |
|
| 212 | + if( $this->isHidden( $key )) { |
|
| 213 | + return; |
|
| 214 | + } |
|
| 195 | 215 | if( empty( $value )) { |
| 196 | 216 | $value = __( 'No Title', 'site-reviews' ); |
| 197 | 217 | } |
@@ -203,7 +223,9 @@ discard block |
||
| 203 | 223 | */ |
| 204 | 224 | protected function generateSchema() |
| 205 | 225 | { |
| 206 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 226 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 227 | + return; |
|
| 228 | + } |
|
| 207 | 229 | glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args )); |
| 208 | 230 | } |
| 209 | 231 | |