@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | if( $review->review_type != 'local' )continue; |
37 | 37 | $reviews[] = $this->buildReview( $review ); |
38 | 38 | } |
39 | - if( !empty( $reviews )) { |
|
39 | + if( !empty($reviews) ) { |
|
40 | 40 | array_walk( $reviews, function( &$review ) { |
41 | - unset( $review['@context'] ); |
|
42 | - unset( $review['itemReviewed'] ); |
|
41 | + unset($review['@context']); |
|
42 | + unset($review['itemReviewed']); |
|
43 | 43 | }); |
44 | 44 | $schema['review'] = $reviews; |
45 | 45 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function buildSummary( $args = null ) |
54 | 54 | { |
55 | - if( is_array( $args )) { |
|
55 | + if( is_array( $args ) ) { |
|
56 | 56 | $this->args = $args; |
57 | 57 | } |
58 | 58 | $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' ); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $schema = method_exists( $this, $buildSummary ) |
61 | 61 | ? $this->$buildSummary() |
62 | 62 | : $this->buildSummaryForCustom(); |
63 | - if( !empty( $count )) { |
|
63 | + if( !empty($count) ) { |
|
64 | 64 | $schema->aggregateRating( $this->getSchemaType( 'AggregateRating' ) |
65 | 65 | ->ratingValue( $this->getRatingValue() ) |
66 | 66 | ->reviewCount( $count ) |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function render() |
80 | 80 | { |
81 | - if( is_null( glsr()->schemas ))return; |
|
81 | + if( is_null( glsr()->schemas ) )return; |
|
82 | 82 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
83 | 83 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
84 | 84 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
85 | - )); |
|
85 | + ) ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $schemas = glsr()->schemas; |
94 | 94 | $schemas[] = $schema; |
95 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
95 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | protected function buildReview( $review ) |
103 | 103 | { |
104 | 104 | $schema = $this->getSchemaType( 'Review' ) |
105 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
105 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) { |
|
106 | 106 | $schema->name( $review->title ); |
107 | 107 | }) |
108 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
108 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) { |
|
109 | 109 | $schema->reviewBody( $review->content ); |
110 | 110 | }) |
111 | - ->datePublished(( new DateTime( $review->date ))) |
|
112 | - ->author( $this->getSchemaType( 'Person' )->name( $review->author )) |
|
113 | - ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ))); |
|
114 | - if( !empty( $review->rating )) { |
|
111 | + ->datePublished( (new DateTime( $review->date )) ) |
|
112 | + ->author( $this->getSchemaType( 'Person' )->name( $review->author ) ) |
|
113 | + ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) ); |
|
114 | + if( !empty($review->rating) ) { |
|
115 | 115 | $schema->reviewRating( $this->getSchemaType( 'Rating' ) |
116 | 116 | ->ratingValue( $review->rating ) |
117 | 117 | ->bestRating( Rating::MAX_RATING ) |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | foreach( $values as $value ) { |
131 | 131 | $option = $this->getSchemaOptionValue( $value ); |
132 | - if( empty( $option ))continue; |
|
132 | + if( empty($option) )continue; |
|
133 | 133 | $schema->$value( $option ); |
134 | 134 | } |
135 | 135 | return $schema; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | return $this->buildSchemaValues( $this->getSchemaType(), [ |
144 | 144 | 'description', 'image', 'name', 'url', |
145 | - ]); |
|
145 | + ] ); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | { |
153 | 153 | return $this->buildSchemaValues( $this->buildSummaryForCustom(), [ |
154 | 154 | 'address', 'priceRange', 'telephone', |
155 | - ]); |
|
155 | + ] ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | { |
163 | 163 | $offers = $this->buildSchemaValues( $this->getSchemaType( 'AggregateOffer' ), [ |
164 | 164 | 'highPrice', 'lowPrice', 'priceCurrency', |
165 | - ]); |
|
165 | + ] ); |
|
166 | 166 | return $this->buildSummaryForCustom() |
167 | 167 | ->offers( $offers ) |
168 | - ->setProperty( '@id', $this->getSchemaOptionValue( 'url' )); |
|
168 | + ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ) ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | protected function getReviews( $force = false ) |
191 | 191 | { |
192 | - if( !isset( $this->reviews ) || $force ) { |
|
192 | + if( !isset($this->reviews) || $force ) { |
|
193 | 193 | $args = wp_parse_args( ['count' => -1], $this->args ); |
194 | 194 | $this->reviews = glsr( Database::class )->getReviews( $args )->results; |
195 | 195 | } |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | protected function getSchemaOption( $option, $fallback ) |
205 | 205 | { |
206 | 206 | $option = strtolower( $option ); |
207 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
207 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
208 | 208 | return $schemaOption; |
209 | 209 | } |
210 | 210 | $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option ); |
211 | - if( is_array( $setting )) { |
|
211 | + if( is_array( $setting ) ) { |
|
212 | 212 | return $this->getSchemaOptionDefault( $setting, $fallback ); |
213 | 213 | } |
214 | - return !empty( $setting ) |
|
214 | + return !empty($setting) |
|
215 | 215 | ? $setting |
216 | 216 | : $fallback; |
217 | 217 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $setting = wp_parse_args( $setting, [ |
226 | 226 | 'custom' => '', |
227 | 227 | 'default' => $fallback, |
228 | - ]); |
|
228 | + ] ); |
|
229 | 229 | return $setting['default'] != 'custom' |
230 | 230 | ? $setting['default'] |
231 | 231 | : $setting['custom']; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | } |
245 | 245 | if( !is_single() && !is_page() )return; |
246 | 246 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
247 | - if( method_exists( $this, $method )) { |
|
247 | + if( method_exists( $this, $method ) ) { |
|
248 | 248 | return $this->$method(); |
249 | 249 | } |
250 | 250 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | protected function getSchemaType( $type = null ) |
257 | 257 | { |
258 | - if( !is_string( $type )) { |
|
258 | + if( !is_string( $type ) ) { |
|
259 | 259 | $type = $this->getSchemaOption( 'type', 'LocalBusiness' ); |
260 | 260 | } |
261 | 261 | $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' ); |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | protected function getThingDescription() |
271 | 271 | { |
272 | 272 | $post = get_post(); |
273 | - if( !( $post instanceof WP_Post )) { |
|
273 | + if( !($post instanceof WP_Post) ) { |
|
274 | 274 | return ''; |
275 | 275 | } |
276 | - $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt )); |
|
277 | - return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 )); |
|
276 | + $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) ); |
|
277 | + return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) ); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | foreach( glsr( Database::class )->getReviews( $this->args )->results as $review ) { |
34 | 34 | // Only include critic reviews that have been directly produced by your site, not reviews from third- party sites or syndicated reviews. |
35 | 35 | // @see https://developers.google.com/search/docs/data-types/review |
36 | - if( $review->review_type != 'local' )continue; |
|
36 | + if( $review->review_type != 'local' ) { |
|
37 | + continue; |
|
38 | + } |
|
37 | 39 | $reviews[] = $this->buildReview( $review ); |
38 | 40 | } |
39 | 41 | if( !empty( $reviews )) { |
@@ -78,7 +80,9 @@ discard block |
||
78 | 80 | */ |
79 | 81 | public function render() |
80 | 82 | { |
81 | - if( is_null( glsr()->schemas ))return; |
|
83 | + if( is_null( glsr()->schemas )) { |
|
84 | + return; |
|
85 | + } |
|
82 | 86 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
83 | 87 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
84 | 88 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -129,7 +133,9 @@ discard block |
||
129 | 133 | { |
130 | 134 | foreach( $values as $value ) { |
131 | 135 | $option = $this->getSchemaOptionValue( $value ); |
132 | - if( empty( $option ))continue; |
|
136 | + if( empty( $option )) { |
|
137 | + continue; |
|
138 | + } |
|
133 | 139 | $schema->$value( $option ); |
134 | 140 | } |
135 | 141 | 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(); |