Passed
Push — master ( d73cc0...4e97bc )
by Paul
04:42
created
plugin/Modules/Schema.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(
65 65
 				$this->getSchemaType( 'AggregateRating' )
66 66
 					->ratingValue( $this->getRatingValue() )
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function render()
81 81
 	{
82
-		if( is_null( glsr()->schemas ))return;
82
+		if( is_null( glsr()->schemas ) )return;
83 83
 		printf( '<script type="application/ld+json">%s</script>', json_encode(
84 84
 			apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
85 85
 			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
86
-		));
86
+		) );
87 87
 	}
88 88
 
89 89
 	/**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	{
94 94
 		$schemas = glsr()->schemas;
95 95
 		$schemas[] = $schema;
96
-		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas )));
96
+		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) );
97 97
 	}
98 98
 
99 99
 	/**
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
 	protected function buildReview( $review )
104 104
 	{
105 105
 		$schema = $this->getSchemaType( 'Review' )
106
-			->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) {
106
+			->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) {
107 107
 				$schema->name( $review->title );
108 108
 			})
109
-			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) {
109
+			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) {
110 110
 				$schema->reviewBody( $review->content );
111 111
 			})
112
-			->datePublished(( new DateTime( $review->date )))
113
-			->author( $this->getSchemaType( 'Person' )->name( $review->author ))
114
-			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' )));
115
-		if( !empty( $review->rating )) {
112
+			->datePublished( (new DateTime( $review->date )) )
113
+			->author( $this->getSchemaType( 'Person' )->name( $review->author ) )
114
+			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) );
115
+		if( !empty($review->rating) ) {
116 116
 			$schema->reviewRating(
117 117
 				$this->getSchemaType( 'Rating' )
118 118
 					->ratingValue( $review->rating )
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	{
132 132
 		foreach( $values as $value ) {
133 133
 			$option = $this->getSchemaOptionValue( $value );
134
-			if( empty( $option ))continue;
134
+			if( empty($option) )continue;
135 135
 			$schema->$value( $option );
136 136
 		}
137 137
 		return $schema;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	{
145 145
 		return $this->buildSchemaValues( $this->getSchemaType(), [
146 146
 			'description', 'image', 'name', 'url',
147
-		]);
147
+		] );
148 148
 	}
149 149
 
150 150
 	/**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	{
155 155
 		return $this->buildSchemaValues( $this->buildSummaryForCustom(), [
156 156
 			'address', 'priceRange', 'telephone',
157
-		]);
157
+		] );
158 158
 	}
159 159
 
160 160
 	/**
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 	{
165 165
 		$offers = $this->buildSchemaValues( $this->getSchemaType( 'AggregateOffer' ), [
166 166
 			'highPrice', 'lowPrice', 'priceCurrency',
167
-		]);
167
+		] );
168 168
 		return $this->buildSummaryForCustom()
169 169
 			->offers( $offers )
170
-			->setProperty( '@id', $this->getSchemaOptionValue( 'url' ));
170
+			->setProperty( '@id', $this->getSchemaOptionValue( 'url' ) );
171 171
 	}
172 172
 
173 173
 	/**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	protected function getReviews( $force = false )
193 193
 	{
194
-		if( !isset( $this->reviews ) || $force ) {
194
+		if( !isset($this->reviews) || $force ) {
195 195
 			$args = wp_parse_args( ['count' => -1], $this->args );
196 196
 			$this->reviews = glsr( Database::class )->getReviews( $args )->results;
197 197
 		}
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 	protected function getSchemaOption( $option, $fallback )
207 207
 	{
208 208
 		$option = strtolower( $option );
209
-		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) {
209
+		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) {
210 210
 			return $schemaOption;
211 211
 		}
212 212
 		$setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option );
213
-		if( is_array( $setting )) {
213
+		if( is_array( $setting ) ) {
214 214
 			return $this->getSchemaOptionDefault( $setting, $fallback );
215 215
 		}
216
-		return !empty( $setting )
216
+		return !empty($setting)
217 217
 			? $setting
218 218
 			: $fallback;
219 219
 	}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		$setting = wp_parse_args( $setting, [
228 228
 			'custom' => '',
229 229
 			'default' => $fallback,
230
-		]);
230
+		] );
231 231
 		return $setting['default'] != 'custom'
232 232
 			? $setting['default']
233 233
 			: $setting['custom'];
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		}
247 247
 		if( !is_single() && !is_page() )return;
248 248
 		$method = glsr( Helper::class )->buildMethodName( $option, 'getThing' );
249
-		if( method_exists( $this, $method )) {
249
+		if( method_exists( $this, $method ) ) {
250 250
 			return $this->$method();
251 251
 		}
252 252
 	}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 */
258 258
 	protected function getSchemaType( $type = null )
259 259
 	{
260
-		if( !is_string( $type )) {
260
+		if( !is_string( $type ) ) {
261 261
 			$type = $this->getSchemaOption( 'type', 'LocalBusiness' );
262 262
 		}
263 263
 		$className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' );
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 	protected function getThingDescription()
273 273
 	{
274 274
 		$post = get_post();
275
-		if( !( $post instanceof WP_Post )) {
275
+		if( !($post instanceof WP_Post) ) {
276 276
 			return '';
277 277
 		}
278
-		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ));
279
-		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ));
278
+		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) );
279
+		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) );
280 280
 	}
281 281
 
282 282
 	/**
Please login to merge, or discard this patch.