Passed
Push — hotfix/fix-counts ( 1ce239...9810ae )
by Paul
11:30 queued 06:23
created
plugin/Handlers/EnqueuePublicAssets.php 2 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function enqueuePolyfillService()
57 57
 	{
58
-		if( !apply_filters( 'site-reviews/assets/polyfill', true ))return;
58
+		if( !apply_filters( 'site-reviews/assets/polyfill', true )) {
59
+			return;
60
+		}
59 61
 		wp_enqueue_script( Application::ID.'/polyfill', add_query_arg([
60 62
 			'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
61 63
 			'flags' => 'gated',
@@ -70,7 +72,9 @@  discard block
 block discarded – undo
70 72
 		// wpforms-recaptcha
71 73
 		// google-recaptcha
72 74
 		// nf-google-recaptcha
73
-		if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return;
75
+		if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
76
+			return;
77
+		}
74 78
 		$language = apply_filters( 'site-reviews/recaptcha/language', get_locale() );
75 79
 		wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([
76 80
 			'hl' => $language,
@@ -84,7 +88,9 @@  discard block
 block discarded – undo
84 88
 	public function inlineStyles()
85 89
 	{
86 90
 		$inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' );
87
-		if( !apply_filters( 'site-reviews/assets/css', true ))return;
91
+		if( !apply_filters( 'site-reviews/assets/css', true )) {
92
+			return;
93
+		}
88 94
 		if( !file_exists( $inlineStylesheetPath )) {
89 95
 			glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath );
90 96
 			return;
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public function enqueueAssets()
29 29
 	{
30
-		if( apply_filters( 'site-reviews/assets/css', true )) {
30
+		if( apply_filters( 'site-reviews/assets/css', true ) ) {
31 31
 			wp_enqueue_style(
32 32
 				Application::ID,
33 33
 				$this->getStylesheet(),
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 				glsr()->version
36 36
 			);
37 37
 		}
38
-		if( apply_filters( 'site-reviews/assets/js', true )) {
38
+		if( apply_filters( 'site-reviews/assets/js', true ) ) {
39 39
 			$dependencies = apply_filters( 'site-reviews/assets/polyfill', true )
40 40
 				? [Application::ID.'/polyfill']
41 41
 				: [];
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function enqueuePolyfillService()
57 57
 	{
58
-		if( !apply_filters( 'site-reviews/assets/polyfill', true ))return;
59
-		wp_enqueue_script( Application::ID.'/polyfill', add_query_arg([
58
+		if( !apply_filters( 'site-reviews/assets/polyfill', true ) )return;
59
+		wp_enqueue_script( Application::ID.'/polyfill', add_query_arg( [
60 60
 			'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
61 61
 			'flags' => 'gated',
62
-		], 'https://polyfill.io/v3/polyfill.min.js' ));
62
+		], 'https://polyfill.io/v3/polyfill.min.js' ) );
63 63
 	}
64 64
 
65 65
 	/**
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 		// nf-google-recaptcha
73 73
 		if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return;
74 74
 		$language = apply_filters( 'site-reviews/recaptcha/language', get_locale() );
75
-		wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([
75
+		wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [
76 76
 			'hl' => $language,
77 77
 			'render' => 'explicit',
78
-		], 'https://www.google.com/recaptcha/api.js' ));
78
+		], 'https://www.google.com/recaptcha/api.js' ) );
79 79
 	}
80 80
 
81 81
 	/**
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	public function inlineStyles()
102 102
 	{
103 103
 		$inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' );
104
-		if( !apply_filters( 'site-reviews/assets/css', true ))return;
105
-		if( !file_exists( $inlineStylesheetPath )) {
104
+		if( !apply_filters( 'site-reviews/assets/css', true ) )return;
105
+		if( !file_exists( $inlineStylesheetPath ) ) {
106 106
 			glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath );
107 107
 			return;
108 108
 		}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	{
123 123
 		$script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
124 124
 		foreach( $variables as $key => $value ) {
125
-			$script.= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ));
125
+			$script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) );
126 126
 		}
127 127
 		$pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
128 128
 		$optimizedScript = preg_replace( $pattern, '$1$2', $script );
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	protected function getFixedSelectorsForPagination()
136 136
 	{
137
-		$selectors = ['#wpadminbar','.site-navigation-fixed'];
137
+		$selectors = ['#wpadminbar', '.site-navigation-fixed'];
138 138
 		return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors );
139 139
 	}
140 140
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	protected function getStylesheet()
145 145
 	{
146 146
 		$currentStyle = glsr( Style::class )->style;
147
-		return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ))
147
+		return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) )
148 148
 			? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' )
149 149
 			: glsr()->url( 'assets/styles/'.Application::ID.'.css' );
150 150
 	}
Please login to merge, or discard this patch.
plugin/Modules/Schema.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 			if( $review->review_type != 'local' )continue;
39 39
 			$reviews[] = $this->buildReview( $review );
40 40
 		}
41
-		if( !empty( $reviews )) {
41
+		if( !empty($reviews) ) {
42 42
 			array_walk( $reviews, function( &$review ) {
43
-				unset( $review['@context'] );
44
-				unset( $review['itemReviewed'] );
43
+				unset($review['@context']);
44
+				unset($review['itemReviewed']);
45 45
 			});
46 46
 			$schema['review'] = $reviews;
47 47
 		}
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function buildSummary( $args = null )
56 56
 	{
57
-		if( is_array( $args )) {
57
+		if( is_array( $args ) ) {
58 58
 			$this->args = $args;
59 59
 		}
60 60
 		$buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$schema = method_exists( $this, $buildSummary )
63 63
 			? $this->$buildSummary()
64 64
 			: $this->buildSummaryForCustom();
65
-		if( !empty( $count )) {
65
+		if( !empty($count) ) {
66 66
 			$schema->aggregateRating(
67 67
 				$this->getSchemaType( 'AggregateRating' )
68 68
 					->ratingValue( $this->getRatingValue() )
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function render()
82 82
 	{
83
-		if( empty( glsr()->schemas ))return;
83
+		if( empty(glsr()->schemas) )return;
84 84
 		printf( '<script type="application/ld+json">%s</script>', json_encode(
85 85
 			apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
86 86
 			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
87
-		));
87
+		) );
88 88
 	}
89 89
 
90 90
 	/**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	{
95 95
 		$schemas = glsr()->schemas;
96 96
 		$schemas[] = $schema;
97
-		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas )));
97
+		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) );
98 98
 	}
99 99
 
100 100
 	/**
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
 	protected function buildReview( $review )
105 105
 	{
106 106
 		$schema = $this->getSchemaType( 'Review' )
107
-			->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) {
107
+			->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) {
108 108
 				$schema->name( $review->title );
109 109
 			})
110
-			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) {
110
+			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) {
111 111
 				$schema->reviewBody( $review->content );
112 112
 			})
113
-			->datePublished(( new DateTime( $review->date )))
114
-			->author( $this->getSchemaType( 'Person' )->name( $review->author ))
115
-			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' )));
116
-		if( !empty( $review->rating )) {
113
+			->datePublished( (new DateTime( $review->date )) )
114
+			->author( $this->getSchemaType( 'Person' )->name( $review->author ) )
115
+			->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) );
116
+		if( !empty($review->rating) ) {
117 117
 			$schema->reviewRating(
118 118
 				$this->getSchemaType( 'Rating' )
119 119
 					->ratingValue( $review->rating )
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	{
133 133
 		foreach( $values as $value ) {
134 134
 			$option = $this->getSchemaOptionValue( $value );
135
-			if( empty( $option ))continue;
135
+			if( empty($option) )continue;
136 136
 			$schema->$value( $option );
137 137
 		}
138 138
 		return $schema;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	{
146 146
 		return $this->buildSchemaValues( $this->getSchemaType(), [
147 147
 			'description', 'image', 'name', 'url',
148
-		]);
148
+		] );
149 149
 	}
150 150
 
151 151
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	{
156 156
 		return $this->buildSchemaValues( $this->buildSummaryForCustom(), [
157 157
 			'address', 'priceRange', 'telephone',
158
-		]);
158
+		] );
159 159
 	}
160 160
 
161 161
 	/**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	{
166 166
 		$offers = $this->buildSchemaValues( $this->getSchemaType( 'AggregateOffer' ), [
167 167
 			'highPrice', 'lowPrice', 'priceCurrency',
168
-		]);
168
+		] );
169 169
 		return $this->buildSummaryForCustom()
170 170
 			->offers( $offers )
171 171
 			->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' );
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	protected function getRatingCounts()
178 178
 	{
179
-		if( !isset( $this->ratingCounts )) {
179
+		if( !isset($this->ratingCounts) ) {
180 180
 			$this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args );
181 181
 		}
182 182
 		return $this->ratingCounts;
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
 	protected function getSchemaOption( $option, $fallback )
199 199
 	{
200 200
 		$option = strtolower( $option );
201
-		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) {
201
+		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) {
202 202
 			return $schemaOption;
203 203
 		}
204 204
 		$setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option );
205
-		if( is_array( $setting )) {
205
+		if( is_array( $setting ) ) {
206 206
 			return $this->getSchemaOptionDefault( $setting, $fallback );
207 207
 		}
208
-		return !empty( $setting )
208
+		return !empty($setting)
209 209
 			? $setting
210 210
 			: $fallback;
211 211
 	}
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		$setting = wp_parse_args( $setting, [
220 220
 			'custom' => '',
221 221
 			'default' => $fallback,
222
-		]);
222
+		] );
223 223
 		return $setting['default'] != 'custom'
224 224
 			? $setting['default']
225 225
 			: $setting['custom'];
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		}
239 239
 		if( !is_single() && !is_page() )return;
240 240
 		$method = glsr( Helper::class )->buildMethodName( $option, 'getThing' );
241
-		if( method_exists( $this, $method )) {
241
+		if( method_exists( $this, $method ) ) {
242 242
 			return $this->$method();
243 243
 		}
244 244
 	}
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 */
250 250
 	protected function getSchemaType( $type = null )
251 251
 	{
252
-		if( !is_string( $type )) {
252
+		if( !is_string( $type ) ) {
253 253
 			$type = $this->getSchemaOption( 'type', 'LocalBusiness' );
254 254
 		}
255 255
 		$className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' );
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 	protected function getThingDescription()
265 265
 	{
266 266
 		$post = get_post();
267
-		if( !( $post instanceof WP_Post )) {
267
+		if( !($post instanceof WP_Post) ) {
268 268
 			return '';
269 269
 		}
270
-		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ));
271
-		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ));
270
+		$text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) );
271
+		return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) );
272 272
 	}
273 273
 
274 274
 	/**
Please login to merge, or discard this patch.