@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | if( $review->review_type != 'local' )continue; |
40 | 40 | $reviews[] = $this->buildReview( $review ); |
41 | 41 | } |
42 | - if( !empty( $reviews )) { |
|
42 | + if( !empty($reviews) ) { |
|
43 | 43 | array_walk( $reviews, function( &$review ) { |
44 | - unset( $review['@context'] ); |
|
45 | - unset( $review['itemReviewed'] ); |
|
44 | + unset($review['@context']); |
|
45 | + unset($review['itemReviewed']); |
|
46 | 46 | }); |
47 | 47 | $schema['review'] = $reviews; |
48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function buildSummary( $args = null ) |
57 | 57 | { |
58 | - if( is_array( $args )) { |
|
58 | + if( is_array( $args ) ) { |
|
59 | 59 | $this->args = $args; |
60 | 60 | } |
61 | 61 | $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' ); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $schema = method_exists( $this, $buildSummary ) |
64 | 64 | ? $this->$buildSummary() |
65 | 65 | : $this->buildSummaryForCustom(); |
66 | - if( !empty( $count )) { |
|
66 | + if( !empty($count) ) { |
|
67 | 67 | $schema->aggregateRating( |
68 | 68 | $this->getSchemaType( 'AggregateRating' ) |
69 | 69 | ->ratingValue( $this->getRatingValue() ) |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function render() |
83 | 83 | { |
84 | - if( empty( glsr()->schemas ))return; |
|
84 | + if( empty(glsr()->schemas) )return; |
|
85 | 85 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
86 | 86 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
87 | 87 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
88 | - )); |
|
88 | + ) ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | { |
96 | 96 | $schemas = glsr()->schemas; |
97 | 97 | $schemas[] = $schema; |
98 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
98 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | protected function buildReview( $review ) |
106 | 106 | { |
107 | 107 | $schema = $this->getSchemaType( 'Review' ) |
108 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
108 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) { |
|
109 | 109 | $schema->name( $review->title ); |
110 | 110 | }) |
111 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
111 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) { |
|
112 | 112 | $schema->reviewBody( $review->content ); |
113 | 113 | }) |
114 | - ->datePublished(( new DateTime( $review->date ))) |
|
115 | - ->author( $this->getSchemaType( 'Person' )->name( $review->author )) |
|
116 | - ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ))); |
|
117 | - if( !empty( $review->rating )) { |
|
114 | + ->datePublished( (new DateTime( $review->date )) ) |
|
115 | + ->author( $this->getSchemaType( 'Person' )->name( $review->author ) ) |
|
116 | + ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) ); |
|
117 | + if( !empty($review->rating) ) { |
|
118 | 118 | $schema->reviewRating( |
119 | 119 | $this->getSchemaType( 'Rating' ) |
120 | 120 | ->ratingValue( $review->rating ) |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | foreach( $values as $value ) { |
135 | 135 | $option = $this->getSchemaOptionValue( $value ); |
136 | - if( empty( $option ))continue; |
|
136 | + if( empty($option) )continue; |
|
137 | 137 | $schema->$value( $option ); |
138 | 138 | } |
139 | 139 | return $schema; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | { |
147 | 147 | return $this->buildSchemaValues( $this->getSchemaType(), [ |
148 | 148 | 'description', 'image', 'name', 'url', |
149 | - ]); |
|
149 | + ] ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | { |
157 | 157 | return $this->buildSchemaValues( $this->buildSummaryForCustom(), [ |
158 | 158 | 'address', 'priceRange', 'telephone', |
159 | - ]); |
|
159 | + ] ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | { |
167 | 167 | $offers = $this->buildSchemaValues( $this->getSchemaType( 'AggregateOffer' ), [ |
168 | 168 | 'highPrice', 'lowPrice', 'priceCurrency', |
169 | - ]); |
|
169 | + ] ); |
|
170 | 170 | return $this->buildSummaryForCustom() |
171 | 171 | ->offers( $offers ) |
172 | 172 | ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' ); |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function getRatingCounts() |
179 | 179 | { |
180 | - if( !isset( $this->ratingCounts )) { |
|
181 | - $counts = glsr( CountsManager::class )->get([ |
|
180 | + if( !isset($this->ratingCounts) ) { |
|
181 | + $counts = glsr( CountsManager::class )->get( [ |
|
182 | 182 | 'post_ids' => glsr( Helper::class )->convertStringToArray( $this->args['assigned_to'] ), |
183 | 183 | 'term_ids' => glsr( ReviewManager::class )->normalizeTermIds( $this->args['category'] ), |
184 | - ]); |
|
184 | + ] ); |
|
185 | 185 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
186 | 186 | 'min' => $this->args['rating'], |
187 | - ]); |
|
187 | + ] ); |
|
188 | 188 | } |
189 | 189 | return $this->ratingCounts; |
190 | 190 | } |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | protected function getSchemaOption( $option, $fallback ) |
206 | 206 | { |
207 | 207 | $option = strtolower( $option ); |
208 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
208 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
209 | 209 | return $schemaOption; |
210 | 210 | } |
211 | 211 | $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option ); |
212 | - if( is_array( $setting )) { |
|
212 | + if( is_array( $setting ) ) { |
|
213 | 213 | return $this->getSchemaOptionDefault( $setting, $fallback ); |
214 | 214 | } |
215 | - return !empty( $setting ) |
|
215 | + return !empty($setting) |
|
216 | 216 | ? $setting |
217 | 217 | : $fallback; |
218 | 218 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $setting = wp_parse_args( $setting, [ |
227 | 227 | 'custom' => '', |
228 | 228 | 'default' => $fallback, |
229 | - ]); |
|
229 | + ] ); |
|
230 | 230 | return $setting['default'] != 'custom' |
231 | 231 | ? $setting['default'] |
232 | 232 | : $setting['custom']; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | if( !is_single() && !is_page() )return; |
247 | 247 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
248 | - if( method_exists( $this, $method )) { |
|
248 | + if( method_exists( $this, $method ) ) { |
|
249 | 249 | return $this->$method(); |
250 | 250 | } |
251 | 251 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | */ |
257 | 257 | protected function getSchemaType( $type = null ) |
258 | 258 | { |
259 | - if( !is_string( $type )) { |
|
259 | + if( !is_string( $type ) ) { |
|
260 | 260 | $type = $this->getSchemaOption( 'type', 'LocalBusiness' ); |
261 | 261 | } |
262 | 262 | $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' ); |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | protected function getThingDescription() |
272 | 272 | { |
273 | 273 | $post = get_post(); |
274 | - if( !( $post instanceof WP_Post )) { |
|
274 | + if( !($post instanceof WP_Post) ) { |
|
275 | 275 | return ''; |
276 | 276 | } |
277 | - $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt )); |
|
278 | - return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 )); |
|
277 | + $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) ); |
|
278 | + return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) ); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |