@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $this->args = $args; |
36 | 36 | $this->reviews = glsr( Database::class )->getReviews( $args )->results; |
37 | - if( empty( $this->reviews ) && $this->isHidden( 'if_empty' ))return; |
|
37 | + if( empty($this->reviews) && $this->isHidden( 'if_empty' ) )return; |
|
38 | 38 | $this->rating = glsr( Rating::class )->getAverage( $this->reviews ); |
39 | 39 | $this->generateSchema(); |
40 | 40 | glsr_debug( $args ); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'stars' => $this->buildStars(), |
48 | 48 | 'text' => $this->buildText(), |
49 | 49 | ], |
50 | - ]); |
|
50 | + ] ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | */ |
56 | 56 | protected function buildPercentage() |
57 | 57 | { |
58 | - if( $this->isHidden( 'bars' ))return; |
|
58 | + if( $this->isHidden( 'bars' ) )return; |
|
59 | 59 | $range = range( Rating::MAX_RATING, 1 ); |
60 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews )); |
|
61 | - $bars = array_reduce( $range, function( $carry, $level ) use( $percentages ) { |
|
60 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews ) ); |
|
61 | + $bars = array_reduce( $range, function( $carry, $level ) use($percentages) { |
|
62 | 62 | $label = $this->buildPercentageLabel( $level ); |
63 | 63 | $background = $this->buildPercentageBackground( $percentages[$level] ); |
64 | 64 | $percent = $this->buildPercentagePercent( $percentages[$level] ); |
65 | 65 | return $carry.glsr( Builder::class )->div( $label.$background.$percent, [ |
66 | 66 | 'class' => 'glsr-bar', |
67 | - ]); |
|
67 | + ] ); |
|
68 | 68 | }); |
69 | 69 | return $this->wrap( 'percentage', $bars ); |
70 | 70 | } |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function buildPercentageBackground( $percent ) |
77 | 77 | { |
78 | - $backgroundPercent = glsr( Builder::class )->span([ |
|
78 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
79 | 79 | 'class' => 'glsr-bar-background-percent', |
80 | 80 | 'style' => 'width:'.$percent, |
81 | - ]); |
|
81 | + ] ); |
|
82 | 82 | return glsr( Builder::class )->span( $backgroundPercent, [ |
83 | 83 | 'class' => 'glsr-bar-background', |
84 | - ]); |
|
84 | + ] ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | return glsr( Builder::class )->span( $this->args['labels'][$level], [ |
94 | 94 | 'class' => 'glsr-bar-label', |
95 | - ]); |
|
95 | + ] ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | { |
104 | 104 | return glsr( Builder::class )->span( $percent, [ |
105 | 105 | 'class' => 'glsr-bar-percent', |
106 | - ]); |
|
106 | + ] ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function buildRating() |
113 | 113 | { |
114 | - if( $this->isHidden( 'rating' ))return; |
|
114 | + if( $this->isHidden( 'rating' ) )return; |
|
115 | 115 | return $this->wrap( 'rating', '<span>'.$this->rating.'</span>' ); |
116 | 116 | } |
117 | 117 | |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function buildStars() |
122 | 122 | { |
123 | - if( $this->isHidden( 'stars' ))return; |
|
123 | + if( $this->isHidden( 'stars' ) )return; |
|
124 | 124 | $stars = glsr( Partial::class )->build( 'star-rating', [ |
125 | 125 | 'number' => count( $this->reviews ), |
126 | 126 | 'rating' => $this->rating, |
127 | - ]); |
|
127 | + ] ); |
|
128 | 128 | return $this->wrap( 'stars', $stars ); |
129 | 129 | } |
130 | 130 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function buildText() |
135 | 135 | { |
136 | - if( $this->isHidden( 'summary' ))return; |
|
136 | + if( $this->isHidden( 'summary' ) )return; |
|
137 | 137 | $count = count( $this->reviews ); |
138 | - if( empty( $this->args['text'] )) { |
|
138 | + if( empty($this->args['text']) ) { |
|
139 | 139 | $this->args['text'] = _nx( |
140 | 140 | '{rating} out of {max} stars (based on %d review)', |
141 | 141 | '{rating} out of {max} stars (based on %d reviews)', |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | 'site-reviews' |
145 | 145 | ); |
146 | 146 | } |
147 | - $summary = str_replace( ['{rating}','{max}'], [$this->rating, Rating::MAX_RATING], $this->args['text'] ); |
|
148 | - $summary = str_replace( ['%s','%d'], $count, $summary ); |
|
147 | + $summary = str_replace( ['{rating}', '{max}'], [$this->rating, Rating::MAX_RATING], $this->args['text'] ); |
|
148 | + $summary = str_replace( ['%s', '%d'], $count, $summary ); |
|
149 | 149 | return $this->wrap( 'text', '<span>'.$summary.'</span>' ); |
150 | 150 | } |
151 | 151 | |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | */ |
155 | 155 | protected function generateSchema() |
156 | 156 | { |
157 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
158 | - glsr( Schema::class )->store( glsr( Schema::class )->buildSummary( $this->args )); |
|
157 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
158 | + glsr( Schema::class )->store( glsr( Schema::class )->buildSummary( $this->args ) ); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -185,6 +185,6 @@ discard block |
||
185 | 185 | { |
186 | 186 | return glsr( Builder::class )->div( $value, [ |
187 | 187 | 'class' => 'glsr-summary-'.$key, |
188 | - ]); |
|
188 | + ] ); |
|
189 | 189 | } |
190 | 190 | } |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | { |
35 | 35 | $this->args = $args; |
36 | 36 | $this->reviews = glsr( Database::class )->getReviews( $args )->results; |
37 | - if( empty( $this->reviews ) && $this->isHidden( 'if_empty' ))return; |
|
37 | + if( empty( $this->reviews ) && $this->isHidden( 'if_empty' )) { |
|
38 | + return; |
|
39 | + } |
|
38 | 40 | $this->rating = glsr( Rating::class )->getAverage( $this->reviews ); |
39 | 41 | $this->generateSchema(); |
40 | 42 | glsr_debug( $args ); |
@@ -55,7 +57,9 @@ discard block |
||
55 | 57 | */ |
56 | 58 | protected function buildPercentage() |
57 | 59 | { |
58 | - if( $this->isHidden( 'bars' ))return; |
|
60 | + if( $this->isHidden( 'bars' )) { |
|
61 | + return; |
|
62 | + } |
|
59 | 63 | $range = range( Rating::MAX_RATING, 1 ); |
60 | 64 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews )); |
61 | 65 | $bars = array_reduce( $range, function( $carry, $level ) use( $percentages ) { |
@@ -111,7 +115,9 @@ discard block |
||
111 | 115 | */ |
112 | 116 | protected function buildRating() |
113 | 117 | { |
114 | - if( $this->isHidden( 'rating' ))return; |
|
118 | + if( $this->isHidden( 'rating' )) { |
|
119 | + return; |
|
120 | + } |
|
115 | 121 | return $this->wrap( 'rating', '<span>'.$this->rating.'</span>' ); |
116 | 122 | } |
117 | 123 | |
@@ -120,7 +126,9 @@ discard block |
||
120 | 126 | */ |
121 | 127 | protected function buildStars() |
122 | 128 | { |
123 | - if( $this->isHidden( 'stars' ))return; |
|
129 | + if( $this->isHidden( 'stars' )) { |
|
130 | + return; |
|
131 | + } |
|
124 | 132 | $stars = glsr( Partial::class )->build( 'star-rating', [ |
125 | 133 | 'number' => count( $this->reviews ), |
126 | 134 | 'rating' => $this->rating, |
@@ -133,7 +141,9 @@ discard block |
||
133 | 141 | */ |
134 | 142 | protected function buildText() |
135 | 143 | { |
136 | - if( $this->isHidden( 'summary' ))return; |
|
144 | + if( $this->isHidden( 'summary' )) { |
|
145 | + return; |
|
146 | + } |
|
137 | 147 | $count = count( $this->reviews ); |
138 | 148 | if( empty( $this->args['text'] )) { |
139 | 149 | $this->args['text'] = _nx( |
@@ -154,7 +164,9 @@ discard block |
||
154 | 164 | */ |
155 | 165 | protected function generateSchema() |
156 | 166 | { |
157 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
167 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
168 | + return; |
|
169 | + } |
|
158 | 170 | glsr( Schema::class )->store( glsr( Schema::class )->buildSummary( $this->args )); |
159 | 171 | } |
160 | 172 |
@@ -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, 'buildOption' ); |
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; |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | */ |
88 | 88 | protected function buildOptionAssignedTo( $key, $value ) |
89 | 89 | { |
90 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
91 | - $post = get_post( intval( $value )); |
|
92 | - if( !( $post instanceof WP_Post ))return; |
|
90 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ) )return; |
|
91 | + $post = get_post( intval( $value ) ); |
|
92 | + if( !($post instanceof WP_Post) )return; |
|
93 | 93 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
94 | 94 | 'href' => get_the_permalink( $post->ID ), |
95 | - ]); |
|
95 | + ] ); |
|
96 | 96 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
97 | 97 | return $this->wrap( $key, '<span>'.$assignedTo.'</span>' ); |
98 | 98 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function buildOptionAuthor( $key, $value ) |
106 | 106 | { |
107 | - if( $this->isHidden( $key ))return; |
|
107 | + if( $this->isHidden( $key ) )return; |
|
108 | 108 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
109 | 109 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
110 | 110 | : ''; |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function buildOptionAvatar( $key, $value ) |
120 | 120 | { |
121 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
121 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ) )return; |
|
122 | 122 | $size = $this->getOption( 'settings.reviews.avatars.size', 36 ); |
123 | - return $this->wrap( $key, glsr( Builder::class )->img([ |
|
123 | + return $this->wrap( $key, glsr( Builder::class )->img( [ |
|
124 | 124 | 'src' => $value, |
125 | 125 | 'height' => $size, |
126 | 126 | 'width' => $size, |
127 | - ])); |
|
127 | + ] ) ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | protected function buildOptionContent( $key, $value ) |
136 | 136 | { |
137 | 137 | $text = $this->normalizeText( $value ); |
138 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
138 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
139 | 139 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
140 | 140 | } |
141 | 141 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function buildOptionDate( $key, $value ) |
148 | 148 | { |
149 | - if( $this->isHidden( $key ))return; |
|
149 | + if( $this->isHidden( $key ) )return; |
|
150 | 150 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
151 | 151 | if( $dateFormat == 'relative' ) { |
152 | 152 | $date = glsr( Date::class )->relative( $value ); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $format = $dateFormat == 'custom' |
156 | 156 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
157 | 157 | : (string)get_option( 'date_format' ); |
158 | - $date = date_i18n( $format, strtotime( $value )); |
|
158 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
159 | 159 | } |
160 | 160 | return $this->wrap( $key, '<span>'.$date.'</span>' ); |
161 | 161 | } |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function buildOptionRating( $key, $value ) |
169 | 169 | { |
170 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
170 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
171 | 171 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
172 | 172 | 'rating' => $value, |
173 | - ]); |
|
173 | + ] ); |
|
174 | 174 | return $this->wrap( $key, $rating ); |
175 | 175 | } |
176 | 176 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | */ |
182 | 182 | protected function buildOptionResponse( $key, $value ) |
183 | 183 | { |
184 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
185 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
184 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
185 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
186 | 186 | $text = $this->normalizeText( $value ); |
187 | 187 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
188 | 188 | return $this->wrap( $key, |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function buildOptionTitle( $key, $value ) |
200 | 200 | { |
201 | - if( $this->isHidden( $key ))return; |
|
202 | - if( empty( $value )) { |
|
201 | + if( $this->isHidden( $key ) )return; |
|
202 | + if( empty($value) ) { |
|
203 | 203 | $value = __( 'No Title', 'site-reviews' ); |
204 | 204 | } |
205 | 205 | return $this->wrap( $key, '<h3>'.$value.'</h3>' ); |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | */ |
211 | 211 | protected function generateSchema() |
212 | 212 | { |
213 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
214 | - glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args )); |
|
213 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
214 | + glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args ) ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -234,14 +234,14 @@ discard block |
||
234 | 234 | { |
235 | 235 | $limit = $this->getOption( 'settings.reviews.excerpt.length', 55 ); |
236 | 236 | if( str_word_count( $text, 0 ) > $limit ) { |
237 | - $words = array_keys( str_word_count( $text, 2 )); |
|
238 | - $excerpt = ltrim( substr( $text, 0, $words[$limit] )); |
|
239 | - $hiddenText = substr( $text, strlen( $excerpt )); |
|
237 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
238 | + $excerpt = ltrim( substr( $text, 0, $words[$limit] ) ); |
|
239 | + $hiddenText = substr( $text, strlen( $excerpt ) ); |
|
240 | 240 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
241 | 241 | 'class' => 'glsr-hidden glsr-hidden-text', |
242 | 242 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
243 | 243 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
244 | - ]); |
|
244 | + ] ); |
|
245 | 245 | $text = $excerpt.$showMore; |
246 | 246 | } |
247 | 247 | return nl2br( $text ); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | protected function getOption( $path, $fallback = '' ) |
256 | 256 | { |
257 | - if( array_key_exists( $path, $this->options )) { |
|
257 | + if( array_key_exists( $path, $this->options ) ) { |
|
258 | 258 | return $this->options[$path]; |
259 | 259 | } |
260 | 260 | return $fallback; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | protected function isHidden( $key, $path = '' ) |
269 | 269 | { |
270 | - $isOptionEnabled = !empty( $path ) |
|
270 | + $isOptionEnabled = !empty($path) |
|
271 | 271 | ? $this->isOptionEnabled( $path ) |
272 | 272 | : true; |
273 | 273 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | */ |
281 | 281 | protected function isHiddenOrEmpty( $key, $value ) |
282 | 282 | { |
283 | - return $this->isHidden( $key ) || empty( $value ); |
|
283 | + return $this->isHidden( $key ) || empty($value); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | protected function normalizeText( $text ) |
300 | 300 | { |
301 | 301 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
302 | - $text = convert_smilies( wptexturize( strip_shortcodes( $text ))); |
|
302 | + $text = convert_smilies( wptexturize( strip_shortcodes( $text ) ) ); |
|
303 | 303 | $text = str_replace( ']]>', ']]>', $text ); |
304 | 304 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
305 | 305 | return $this->isOptionEnabled( 'settings.reviews.excerpt.enabled' ) |
@@ -316,6 +316,6 @@ discard block |
||
316 | 316 | { |
317 | 317 | return glsr( Builder::class )->div( $value, [ |
318 | 318 | 'class' => 'glsr-review-'.$key, |
319 | - ]); |
|
319 | + ] ); |
|
320 | 320 | } |
321 | 321 | } |
@@ -74,7 +74,9 @@ discard block |
||
74 | 74 | $generatedReview = []; |
75 | 75 | foreach( $review as $key => $value ) { |
76 | 76 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
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; |
@@ -87,9 +89,13 @@ discard block |
||
87 | 89 | */ |
88 | 90 | protected function buildOptionAssignedTo( $key, $value ) |
89 | 91 | { |
90 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
92 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' )) { |
|
93 | + return; |
|
94 | + } |
|
91 | 95 | $post = get_post( intval( $value )); |
92 | - if( !( $post instanceof WP_Post ))return; |
|
96 | + if( !( $post instanceof WP_Post )) { |
|
97 | + return; |
|
98 | + } |
|
93 | 99 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
94 | 100 | 'href' => get_the_permalink( $post->ID ), |
95 | 101 | ]); |
@@ -104,7 +110,9 @@ discard block |
||
104 | 110 | */ |
105 | 111 | protected function buildOptionAuthor( $key, $value ) |
106 | 112 | { |
107 | - if( $this->isHidden( $key ))return; |
|
113 | + if( $this->isHidden( $key )) { |
|
114 | + return; |
|
115 | + } |
|
108 | 116 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
109 | 117 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
110 | 118 | : ''; |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | */ |
119 | 127 | protected function buildOptionAvatar( $key, $value ) |
120 | 128 | { |
121 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
129 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) { |
|
130 | + return; |
|
131 | + } |
|
122 | 132 | $size = $this->getOption( 'settings.reviews.avatars.size', 36 ); |
123 | 133 | return $this->wrap( $key, glsr( Builder::class )->img([ |
124 | 134 | 'src' => $value, |
@@ -135,7 +145,9 @@ discard block |
||
135 | 145 | protected function buildOptionContent( $key, $value ) |
136 | 146 | { |
137 | 147 | $text = $this->normalizeText( $value ); |
138 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
148 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
149 | + return; |
|
150 | + } |
|
139 | 151 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
140 | 152 | } |
141 | 153 | |
@@ -146,7 +158,9 @@ discard block |
||
146 | 158 | */ |
147 | 159 | protected function buildOptionDate( $key, $value ) |
148 | 160 | { |
149 | - if( $this->isHidden( $key ))return; |
|
161 | + if( $this->isHidden( $key )) { |
|
162 | + return; |
|
163 | + } |
|
150 | 164 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
151 | 165 | if( $dateFormat == 'relative' ) { |
152 | 166 | $date = glsr( Date::class )->relative( $value ); |
@@ -167,7 +181,9 @@ discard block |
||
167 | 181 | */ |
168 | 182 | protected function buildOptionRating( $key, $value ) |
169 | 183 | { |
170 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
184 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
185 | + return; |
|
186 | + } |
|
171 | 187 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
172 | 188 | 'rating' => $value, |
173 | 189 | ]); |
@@ -181,7 +197,9 @@ discard block |
||
181 | 197 | */ |
182 | 198 | protected function buildOptionResponse( $key, $value ) |
183 | 199 | { |
184 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
200 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
201 | + return; |
|
202 | + } |
|
185 | 203 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
186 | 204 | $text = $this->normalizeText( $value ); |
187 | 205 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -198,7 +216,9 @@ discard block |
||
198 | 216 | */ |
199 | 217 | protected function buildOptionTitle( $key, $value ) |
200 | 218 | { |
201 | - if( $this->isHidden( $key ))return; |
|
219 | + if( $this->isHidden( $key )) { |
|
220 | + return; |
|
221 | + } |
|
202 | 222 | if( empty( $value )) { |
203 | 223 | $value = __( 'No Title', 'site-reviews' ); |
204 | 224 | } |
@@ -210,7 +230,9 @@ discard block |
||
210 | 230 | */ |
211 | 231 | protected function generateSchema() |
212 | 232 | { |
213 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
233 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
234 | + return; |
|
235 | + } |
|
214 | 236 | glsr( Schema::class )->store( glsr( Schema::class )->build( $this->args )); |
215 | 237 | } |
216 | 238 |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | 'after_widget' => '</div>', |
23 | 23 | 'before_title' => '<h3 class="glsr-shortcode-title">', |
24 | 24 | 'after_title' => '</h3>', |
25 | - ]); |
|
25 | + ] ); |
|
26 | 26 | $instance = $this->normalize( $instance ); |
27 | 27 | $partial = glsr( Html::class )->buildPartial( $shortcodePartial, $instance ); |
28 | - if( !empty( $instance['title'] )) { |
|
28 | + if( !empty($instance['title']) ) { |
|
29 | 29 | $instance['title'] = $args['before_title'].$instance['title'].$args['after_title']; |
30 | 30 | } |
31 | 31 | return $args['before_widget'].$instance['title'].$partial.$args['after_widget']; |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function normalize( $args ) |
70 | 70 | { |
71 | - $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args )); |
|
71 | + $args = shortcode_atts( $this->getDefaults(), wp_parse_args( $args ) ); |
|
72 | 72 | array_walk( $args, function( &$value, $key ) { |
73 | 73 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
74 | - if( !method_exists( $this, $methodName ))return; |
|
74 | + if( !method_exists( $this, $methodName ) )return; |
|
75 | 75 | $value = $this->$methodName( $value ); |
76 | 76 | }); |
77 | 77 | return $this->sanitize( $args ); |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function normalizeHide( $hide ) |
105 | 105 | { |
106 | - if( is_string( $hide )) { |
|
106 | + if( is_string( $hide ) ) { |
|
107 | 107 | $hide = explode( ',', $hide ); |
108 | 108 | } |
109 | 109 | $hiddenKeys = defined( 'static::HIDDEN_KEYS' ) |
110 | 110 | ? static::HIDDEN_KEYS |
111 | 111 | : []; |
112 | - return array_filter( array_map( 'trim', $hide ), function( $value ) use( $hiddenKeys ) { |
|
112 | + return array_filter( array_map( 'trim', $hide ), function( $value ) use($hiddenKeys) { |
|
113 | 113 | return in_array( $value, $hiddenKeys ); |
114 | 114 | }); |
115 | 115 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | __( 'Terrible', 'site-reviews' ), |
138 | 138 | ]; |
139 | 139 | $defaults = array_pad( $defaults, Rating::MAX_RATING, '' ); |
140 | - $labels = array_map( 'trim', explode( ',', $labels )); |
|
140 | + $labels = array_map( 'trim', explode( ',', $labels ) ); |
|
141 | 141 | foreach( $defaults as $i => $label ) { |
142 | - if( empty( $labels[$i] ))continue; |
|
142 | + if( empty($labels[$i]) )continue; |
|
143 | 143 | $defaults[$i] = $labels[$i]; |
144 | 144 | } |
145 | 145 | return array_combine( range( Rating::MAX_RATING, 1 ), $defaults ); |