Passed
Push — master ( e5c4f5...cb56ad )
by Paul
03:27
created
plugin/Modules/Html/ReviewsHtml.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 		$this->reviews = $reviews;
31 31
 		$this->navigation = glsr( Partial::class )->build( 'pagination', [
32 32
 			'total' => $maxPageCount,
33
-		]);
34
-		parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS );
33
+		] );
34
+		parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
35 35
 	}
36 36
 
37 37
 	/**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 				'navigation' => $this->getNavigation(),
58 58
 				'reviews' => implode( PHP_EOL, $this->reviews ),
59 59
 			],
60
-		]);
60
+		] );
61 61
 	}
62 62
 
63 63
 	/**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			$defaults[] = 'glsr-ajax-pagination';
73 73
 		}
74 74
 		$classes = explode( ' ', $this->args['class'] );
75
-		$classes = array_unique( array_merge( $defaults, $classes ));
75
+		$classes = array_unique( array_merge( $defaults, $classes ) );
76 76
 		return implode( ' ', $classes );
77 77
 	}
78 78
 
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviews.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		foreach( $this->reviews as $index => $review ) {
88 88
 			$renderedReviews[] = glsr( Template::class )->build( 'templates/review', [
89 89
 				'context' => $this->buildReview( $review )->values,
90
-			]);
90
+			] );
91 91
 		}
92 92
 		return new ReviewsHtml( $renderedReviews, $this->reviews->max_num_pages, $this->args );
93 93
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function generateSchema()
99 99
 	{
100
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
100
+		if( !wp_validate_boolean( $this->args['schema'] ) )return;
101 101
 		glsr( Schema::class )->store(
102 102
 			glsr( Schema::class )->build( $this->args )
103 103
 		);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function isHidden( $key, $path = '' )
112 112
 	{
113
-		$isOptionEnabled = !empty( $path )
113
+		$isOptionEnabled = !empty($path)
114 114
 			? $this->isOptionEnabled( $path )
115 115
 			: true;
116 116
 		return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled;
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	protected function buildOptionAssignedTo( $key, $value )
125 125
 	{
126
-		if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return;
126
+		if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return;
127 127
 		$post = glsr( Polylang::class )->getPost( $value );
128
-		if( !( $post instanceof WP_Post ))return;
128
+		if( !($post instanceof WP_Post) )return;
129 129
 		$permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [
130 130
 			'href' => get_the_permalink( $post->ID ),
131
-		]);
131
+		] );
132 132
 		$assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink );
133 133
 		return '<span>'.$assignedTo.'</span>';
134 134
 	}
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	protected function buildOptionAuthor( $key, $value )
142 142
 	{
143
-		if( $this->isHidden( $key ))return;
143
+		if( $this->isHidden( $key ) )return;
144 144
 		return '<span>'.$value.'</span>';
145 145
 	}
146 146
 
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	protected function buildOptionAvatar( $key, $value )
153 153
 	{
154
-		if( $this->isHidden( $key, 'settings.reviews.avatars' ))return;
154
+		if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return;
155 155
 		$size = $this->getOption( 'settings.reviews.avatars_size', 40 );
156
-		return glsr( Builder::class )->img([
156
+		return glsr( Builder::class )->img( [
157 157
 			'height' => $size,
158 158
 			'src' => $this->generateAvatar( $value ),
159 159
 			'style' => sprintf( 'width:%1$spx; height:%1$spx;', $size ),
160 160
 			'width' => $size,
161
-		]);
161
+		] );
162 162
 	}
163 163
 
164 164
 	/**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	protected function buildOptionContent( $key, $value )
170 170
 	{
171 171
 		$text = $this->normalizeText( $value );
172
-		if( $this->isHiddenOrEmpty( $key, $text ))return;
172
+		if( $this->isHiddenOrEmpty( $key, $text ) )return;
173 173
 		return '<p>'.$text.'</p>';
174 174
 	}
175 175
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	protected function buildOptionDate( $key, $value )
182 182
 	{
183
-		if( $this->isHidden( $key ))return;
183
+		if( $this->isHidden( $key ) )return;
184 184
 		$dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' );
185 185
 		if( $dateFormat == 'relative' ) {
186 186
 			$date = glsr( Date::class )->relative( $value );
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 			$format = $dateFormat == 'custom'
190 190
 				? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' )
191 191
 				: (string)get_option( 'date_format' );
192
-			$date = date_i18n( $format, strtotime( $value ));
192
+			$date = date_i18n( $format, strtotime( $value ) );
193 193
 		}
194 194
 		return '<span>'.$date.'</span>';
195 195
 	}
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
 	 */
202 202
 	protected function buildOptionRating( $key, $value )
203 203
 	{
204
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
204
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
205 205
 		return glsr( Partial::class )->build( 'star-rating', [
206 206
 			'rating' => $value,
207
-		]);
207
+		] );
208 208
 	}
209 209
 
210 210
 	/**
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	protected function buildOptionResponse( $key, $value )
216 216
 	{
217
-		if( $this->isHiddenOrEmpty( $key, $value ))return;
218
-		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ));
217
+		if( $this->isHiddenOrEmpty( $key, $value ) )return;
218
+		$title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) );
219 219
 		$text = $this->normalizeText( $value );
220 220
 		$text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
221 221
 		$response = glsr( Builder::class )->div( $text, ['class' => 'glsr-review-response-inner'] );
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	protected function buildOptionTitle( $key, $value )
232 232
 	{
233
-		if( $this->isHidden( $key ))return;
234
-		if( empty( $value )) {
233
+		if( $this->isHidden( $key ) )return;
234
+		if( empty($value) ) {
235 235
 			$value = __( 'No Title', 'site-reviews' );
236 236
 		}
237 237
 		return '<h3>'.$value.'</h3>';
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 			return $avatarUrl;
248 248
 		}
249 249
 		$authorIdOrEmail = get_the_author_meta( 'ID', $this->current->user_id );
250
-		if( empty( $authorIdOrEmail )) {
250
+		if( empty($authorIdOrEmail) ) {
251 251
 			$authorIdOrEmail = $this->current->email;
252 252
 		}
253
-		if( $newAvatar = get_avatar_url( $authorIdOrEmail )) {
253
+		if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) {
254 254
 			return $newAvatar;
255 255
 		}
256 256
 		return $avatarUrl;
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
 	 */
263 263
 	protected function getExcerpt( $text )
264 264
 	{
265
-		$limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ));
265
+		$limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) );
266 266
 		$split = extension_loaded( 'intl' )
267 267
 			? $this->getExcerptIntlSplit( $text, $limit )
268 268
 			: $this->getExcerptSplit( $text, $limit );
269 269
 		$hiddenText = substr( $text, $split );
270
-		if( !empty( $hiddenText )) {
270
+		if( !empty($hiddenText) ) {
271 271
 			$showMore = glsr( Builder::class )->span( $hiddenText, [
272 272
 				'class' => 'glsr-hidden glsr-hidden-text',
273 273
 				'data-show-less' => __( 'Show less', 'site-reviews' ),
274 274
 				'data-show-more' => __( 'Show more', 'site-reviews' ),
275
-			]);
276
-			$text = ltrim( substr( $text, 0, $split )).$showMore;
275
+			] );
276
+			$text = ltrim( substr( $text, 0, $split ) ).$showMore;
277 277
 		}
278 278
 		return nl2br( $text );
279 279
 	}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 		$words = IntlRuleBasedBreakIterator::createWordInstance( '' );
289 289
 		$words->setText( $text );
290 290
 		$count = 0;
291
-		foreach( $words as $offset ){
291
+		foreach( $words as $offset ) {
292 292
 			if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue;
293 293
 			$count++;
294 294
 			if( $count != $limit )continue;
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	protected function getExcerptSplit( $text, $limit )
306 306
 	{
307 307
 		if( str_word_count( $text, 0 ) > $limit ) {
308
-			$words = array_keys( str_word_count( $text, 2 ));
308
+			$words = array_keys( str_word_count( $text, 2 ) );
309 309
 			return $words[$limit];
310 310
 		}
311 311
 		return strlen( $text );
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	 */
319 319
 	protected function getOption( $path, $fallback = '' )
320 320
 	{
321
-		if( array_key_exists( $path, $this->options )) {
321
+		if( array_key_exists( $path, $this->options ) ) {
322 322
 			return $this->options[$path];
323 323
 		}
324 324
 		return $fallback;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	 */
332 332
 	protected function isHiddenOrEmpty( $key, $value )
333 333
 	{
334
-		return $this->isHidden( $key ) || empty( $value );
334
+		return $this->isHidden( $key ) || empty($value);
335 335
 	}
336 336
 
337 337
 	/**
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
 	protected function normalizeText( $text )
351 351
 	{
352 352
 		$text = wp_kses( $text, wp_kses_allowed_html() );
353
-		$text = convert_smilies( strip_shortcodes( $text ));
353
+		$text = convert_smilies( strip_shortcodes( $text ) );
354 354
 		$text = str_replace( ']]>', ']]&gt;', $text );
355 355
 		$text = preg_replace( '/(\R){2,}/', '$1', $text );
356
-		if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) {
356
+		if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) {
357 357
 			$text = $this->getExcerpt( $text );
358 358
 		}
359 359
 		return wptexturize( $text );
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
 	protected function wrap( array &$renderedFields, Review $review )
366 366
 	{
367 367
 		$renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review );
368
-		array_walk( $renderedFields, function( &$value, $key ) use( $review ) {
368
+		array_walk( $renderedFields, function( &$value, $key ) use($review) {
369 369
 			$value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review );
370
-			if( empty( $value ))return;
370
+			if( empty($value) )return;
371 371
 			$value = glsr( Builder::class )->div( $value, [
372 372
 				'class' => 'glsr-review-'.$key,
373
-			]);
373
+			] );
374 374
 		});
375 375
 	}
376 376
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/ReviewHtml.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	public function __construct( array $values = [] )
16 16
 	{
17 17
 		$this->values = $values;
18
-		parent::__construct( $values, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS );
18
+		parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
19 19
 	}
20 20
 
21 21
 	/**
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	public function __toString()
35 35
 	{
36
-		if( empty( $this->values ))return;
36
+		if( empty($this->values) )return;
37 37
 		return glsr( Template::class )->build( 'templates/review', [
38 38
 			'context' => $this->values,
39
-		]);
39
+		] );
40 40
 	}
41 41
 }
Please login to merge, or discard this patch.
plugin/Reviews.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 		$this->args = $args;
30 30
 		$this->max_num_pages = $maxPageCount;
31 31
 		$this->results = $reviews;
32
-		parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS );
32
+		parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
33 33
 	}
34 34
 
35 35
 	/**
Please login to merge, or discard this patch.
plugin/Review.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function build( array $args = [] )
70 70
 	{
71
-		if( empty( $this->ID )) {
71
+		if( empty($this->ID) ) {
72 72
 			return new ReviewHtml;
73 73
 		}
74 74
 		$partial = glsr( SiteReviewsPartial::class );
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function offsetGet( $key )
94 94
 	{
95
-		if( property_exists( $this, $key )) {
95
+		if( property_exists( $this, $key ) ) {
96 96
 			return $this->$key;
97 97
 		}
98
-		if( array_key_exists( $key, (array)$this->custom )) {
98
+		if( array_key_exists( $key, (array)$this->custom ) ) {
99 99
 			return $this->custom[$key];
100 100
 		}
101 101
 		return null;
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function offsetSet( $key, $value )
110 110
 	{
111
-		if( property_exists( $this, $key )) {
111
+		if( property_exists( $this, $key ) ) {
112 112
 			$this->$key = $value;
113 113
 			return;
114 114
 		}
115
-		if( !is_array( $this->custom )) {
115
+		if( !is_array( $this->custom ) ) {
116 116
 			$this->custom = array_filter( (array)$this->custom );
117 117
 		}
118 118
 		$this->custom[$key] = $value;
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 			'review_type' => 'local',
158 158
 		];
159 159
 		$meta = array_filter(
160
-			array_map( 'array_shift', array_filter((array)get_post_meta( $post->ID ))),
160
+			array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ),
161 161
 			'strlen'
162 162
 		);
163
-		$properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ));
163
+		$properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) );
164 164
 		$this->modified = $this->isModified( $properties );
165 165
 		array_walk( $properties, function( $value, $key ) {
166
-			if( !property_exists( $this, $key ) || isset( $this->$key ))return;
166
+			if( !property_exists( $this, $key ) || isset($this->$key) )return;
167 167
 			$this->$key = maybe_unserialize( $value );
168 168
 		});
169 169
 	}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	protected function setTermIds( WP_Post $post )
175 175
 	{
176 176
 		$this->term_ids = [];
177
-		if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return;
177
+		if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return;
178 178
 		foreach( $terms as $term ) {
179 179
 			$this->term_ids[] = $term->term_id;
180 180
 		}
Please login to merge, or discard this patch.
helpers.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 		'glsr_get_review', 'glsr_get_reviews',
20 20
 		'glsr_log',
21 21
 	);
22
-	if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return;
23
-	add_filter( $hook, function() use( $hook, $args ) {
22
+	if( !in_array( $hook, $hooks ) || !function_exists( $hook ) )return;
23
+	add_filter( $hook, function() use($hook, $args) {
24 24
 		array_shift( $args ); // remove the fallback value
25 25
 		return call_user_func_array( $hook, $args );
26 26
 	});
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function glsr( $alias = null ) {
33 33
 	$app = \GeminiLabs\SiteReviews\Application::load();
34
-	return !empty( $alias )
34
+	return !empty($alias)
35 35
 		? $app->make( $alias )
36 36
 		: $app;
37 37
 }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	$result = array();
46 46
 	foreach( $array as $subarray ) {
47 47
 		$subarray = (array)$subarray;
48
-		if( !isset( $subarray[$column] ))continue;
48
+		if( !isset($subarray[$column]) )continue;
49 49
 		$result[] = $subarray[$column];
50 50
 	}
51 51
 	return $result;
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
  */
57 57
 function glsr_calculate_ratings() {
58 58
 	glsr( 'Controllers\AdminController' )->routerCountReviews( false );
59
-	glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ));
59
+	glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ) );
60 60
 }
61 61
 
62 62
 /**
63 63
  * @return \GeminiLabs\SiteReviews\Review|false
64 64
  */
65 65
 function glsr_create_review( $reviewValues = array() ) {
66
-	if( !is_array( $reviewValues )) {
66
+	if( !is_array( $reviewValues ) ) {
67 67
 		$reviewValues = array();
68 68
 	}
69 69
 	$review = new \GeminiLabs\SiteReviews\Commands\CreateReview( $reviewValues );
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
  * @return \WP_Screen|object
75 75
  */
76 76
 function glsr_current_screen() {
77
-	if( function_exists( 'get_current_screen' )) {
77
+	if( function_exists( 'get_current_screen' ) ) {
78 78
 		$screen = get_current_screen();
79 79
 	}
80
-	return empty( $screen )
80
+	return empty($screen)
81 81
 		? (object)array_fill_keys( ['base', 'id', 'post_type'], null )
82 82
 		: $screen;
83 83
 }
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
  */
125 125
 function glsr_get_review( $post_id ) {
126 126
 	$post = null;
127
-	if( is_numeric( $post_id )) {
127
+	if( is_numeric( $post_id ) ) {
128 128
 		$post = get_post( $post_id );
129 129
 	}
130
-	if( !( $post instanceof WP_Post )) {
130
+	if( !($post instanceof WP_Post) ) {
131 131
 		$post = new WP_Post( (object)[] );
132 132
 	}
133 133
 	return glsr( 'Database\ReviewManager' )->single( $post );
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
  * @return array
138 138
  */
139 139
 function glsr_get_reviews( $args = array() ) {
140
-	if( !is_array( $args )) {
140
+	if( !is_array( $args ) ) {
141 141
 		$args = [];
142 142
 	}
143 143
 	return glsr( 'Database\ReviewManager' )->get( $args );
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
  */
149 149
 function glsr_log() {
150 150
 	$args = func_get_args();
151
-	$context = isset( $args[1] )
151
+	$context = isset($args[1])
152 152
 		? $args[1]
153 153
 		: [];
154 154
 	$console = glsr( 'Modules\Console' );
155
-	return !empty( $args )
155
+	return !empty($args)
156 156
 		? $console->log( 'debug', $args[0], $context )
157 157
 		: $console;
158 158
 }
Please login to merge, or discard this patch.
plugin/Database/ReviewManager.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 			'post_type' => Application::POST_TYPE,
37 37
 		];
38 38
 		$postId = wp_insert_post( $postValues, true );
39
-		if( is_wp_error( $postId )) {
39
+		if( is_wp_error( $postId ) ) {
40 40
 			glsr_log()->error( $postId->get_error_message() )->debug( $postValues );
41 41
 			return false;
42 42
 		}
43 43
 		$this->setTerms( $postId, $command->category );
44
-		$review = $this->single( get_post( $postId ));
44
+		$review = $this->single( get_post( $postId ) );
45 45
 		do_action( 'site-reviews/review/created', $review, $command );
46 46
 		return $review;
47 47
 	}
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function delete( $metaReviewId )
54 54
 	{
55
-		if( $postId = $this->getPostId( $metaReviewId )) {
55
+		if( $postId = $this->getPostId( $metaReviewId ) ) {
56 56
 			wp_delete_post( $postId, true );
57 57
 		}
58 58
 	}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		$paged = glsr( QueryBuilder::class )->getPaged(
75 75
 			wp_validate_boolean( $args['pagination'] )
76 76
 		);
77
-		$query = new WP_Query([
77
+		$query = new WP_Query( [
78 78
 			'meta_key' => 'pinned',
79 79
 			'meta_query' => $metaQuery,
80 80
 			'offset' => $args['offset'],
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			'post_type' => Application::POST_TYPE,
88 88
 			'posts_per_page' => $args['count'],
89 89
 			'tax_query' => $taxQuery,
90
-		]);
90
+		] );
91 91
 		$results = array_map( [$this, 'single'], $query->posts );
92 92
 		$reviews = new Reviews( $results, $query->max_num_pages, $args );
93 93
 		return apply_filters( 'site-reviews/get/reviews', $reviews, $query );
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 		$terms = [];
121 121
 		$termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds );
122 122
 		foreach( $termIds as $termId ) {
123
-			if( is_numeric( $termId )) {
123
+			if( is_numeric( $termId ) ) {
124 124
 				$termId = intval( $termId );
125 125
 			}
126 126
 			$term = term_exists( $termId, Application::TAXONOMY );
127
-			if( !isset( $term['term_id'] ))continue;
127
+			if( !isset($term['term_id']) )continue;
128 128
 			$terms[] = $term;
129 129
 		}
130 130
 		return $terms;
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	{
139 139
 		if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return;
140 140
 		delete_post_meta( $postId, '_edit_last' );
141
-		$result = wp_update_post([
141
+		$result = wp_update_post( [
142 142
 			'ID' => $postId,
143 143
 			'post_content' => get_post_meta( $postId, 'content', true ),
144 144
 			'post_date' => get_post_meta( $postId, 'date', true ),
145 145
 			'post_title' => get_post_meta( $postId, 'title', true ),
146
-		]);
147
-		if( is_wp_error( $result )) {
146
+		] );
147
+		if( is_wp_error( $result ) ) {
148 148
 			glsr_log()->error( $result->get_error_message() );
149 149
 		}
150 150
 	}
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	protected function getNewPostStatus( array $review, $isBlacklisted )
169 169
 	{
170 170
 		$requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' );
171
-		return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted )
171
+		return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted)
172 172
 			? 'pending'
173 173
 			: 'publish';
174 174
 	}
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	protected function setTerms( $postId, $termIds )
182 182
 	{
183 183
 		$terms = $this->normalizeTermIds( $termIds );
184
-		if( empty( $terms ))return;
184
+		if( empty($terms) )return;
185 185
 		$result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY );
186
-		if( is_wp_error( $result )) {
186
+		if( is_wp_error( $result ) ) {
187 187
 			glsr_log()->error( $result->get_error_message() );
188 188
 		}
189 189
 	}
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function approve()
23 23
 	{
24
-		check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() ));
25
-		wp_update_post([
24
+		check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) );
25
+		wp_update_post( [
26 26
 			'ID' => $postId,
27 27
 			'post_status' => 'publish',
28
-		]);
28
+		] );
29 29
 		wp_safe_redirect( wp_get_referer() );
30 30
 		exit;
31 31
 	}
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 		$columns = glsr( Helper::class )->consolidateArray( $columns );
59 59
 		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
60 60
 		foreach( $postTypeColumns as $key => &$value ) {
61
-			if( !array_key_exists( $key, $columns ) || !empty( $value ))continue;
61
+			if( !array_key_exists( $key, $columns ) || !empty($value) )continue;
62 62
 			$value = $columns[$key];
63 63
 		}
64
-		if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) {
65
-			unset( $postTypeColumns['review_type'] );
64
+		if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) {
65
+			unset($postTypeColumns['review_type']);
66 66
 		}
67 67
 		return array_filter( $postTypeColumns, 'strlen' );
68 68
 	}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function filterPostStates( $postStates, WP_Post $post ) {
103 103
 		$postStates = glsr( Helper::class )->consolidateArray( $postStates );
104
-		if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) {
104
+		if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates ) ) {
105 105
 			$postStates['pending'] = __( 'Unapproved', 'site-reviews' );
106 106
 		}
107 107
 		return $postStates;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		if( $post->post_type != Application::POST_TYPE || $post->post_status == 'trash' ) {
118 118
 			return $actions;
119 119
 		}
120
-		unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit
120
+		unset($actions['inline hide-if-no-js']); //Remove Quick-edit
121 121
 		$rowActions = [
122 122
 			'approve' => esc_attr__( 'Approve', 'site-reviews' ),
123 123
 			'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ),
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 					admin_url( 'post.php?post='.$post->ID.'&action='.$key ),
132 132
 					$key.'-review_'.$post->ID
133 133
 				),
134
-			]);
134
+			] );
135 135
 		}
136 136
 		return $newActions + glsr( Helper::class )->consolidateArray( $actions );
137 137
 	}
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	{
146 146
 		$columns = glsr( Helper::class )->consolidateArray( $columns );
147 147
 		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
148
-		unset( $postTypeColumns['cb'] );
148
+		unset($postTypeColumns['cb']);
149 149
 		foreach( $postTypeColumns as $key => $value ) {
150
-			if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue;
150
+			if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue;
151 151
 			$columns[$key] = $key;
152 152
 		}
153 153
 		return $columns;
@@ -165,18 +165,18 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function filterStatusText( $translation, $single, $plural, $number, $domain )
167 167
 	{
168
-		if( $this->canModifyTranslation( $domain )) {
168
+		if( $this->canModifyTranslation( $domain ) ) {
169 169
 			$strings = [
170 170
 				'Published' => __( 'Approved', 'site-reviews' ),
171 171
 				'Pending' => __( 'Unapproved', 'site-reviews' ),
172 172
 			];
173 173
 			foreach( $strings as $search => $replace ) {
174 174
 				if( strpos( $single, $search ) === false )continue;
175
-				$translation = $this->getTranslation([
175
+				$translation = $this->getTranslation( [
176 176
 					'number' => $number,
177 177
 					'plural' => str_replace( $search, $replace, $plural ),
178 178
 					'single' => str_replace( $search, $replace, $single ),
179
-				]);
179
+				] );
180 180
 			}
181 181
 		}
182 182
 		return $translation;
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	public function saveBulkEditFields( $postId )
225 225
 	{
226
-		if( !current_user_can( 'edit_posts' ))return;
226
+		if( !current_user_can( 'edit_posts' ) )return;
227 227
 		$assignedTo = filter_input( INPUT_GET, 'assigned_to' );
228
-		if( $assignedTo && get_post( $assignedTo )) {
228
+		if( $assignedTo && get_post( $assignedTo ) ) {
229 229
 			update_post_meta( $postId, 'assigned_to', $assignedTo );
230 230
 		}
231 231
 	}
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	public function setQueryForColumn( WP_Query $query )
238 238
 	{
239
-		if( !$this->hasPermission( $query ))return;
239
+		if( !$this->hasPermission( $query ) )return;
240 240
 		$this->setMetaQuery( $query, [
241 241
 			'rating', 'review_type',
242
-		]);
242
+		] );
243 243
 		$this->setOrderby( $query );
244 244
 	}
245 245
 
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 	 */
250 250
 	public function unapprove()
251 251
 	{
252
-		check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() ));
253
-		wp_update_post([
252
+		check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) );
253
+		wp_update_post( [
254 254
 			'ID' => $postId,
255 255
 			'post_status' => 'pending',
256
-		]);
256
+		] );
257 257
 		wp_safe_redirect( wp_get_referer() );
258 258
 		exit;
259 259
 	}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 			'single' => '',
284 284
 			'text' => '',
285 285
 		];
286
-		$args = (object) wp_parse_args( $args, $defaults );
286
+		$args = (object)wp_parse_args( $args, $defaults );
287 287
 		$translations = get_translations_for_domain( Application::ID );
288 288
 		return $args->text
289 289
 			? $translations->translate( $args->text )
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	protected function setMetaQuery( WP_Query $query, array $metaKeys )
309 309
 	{
310 310
 		foreach( $metaKeys as $key ) {
311
-			if( !( $value = filter_input( INPUT_GET, $key )))continue;
311
+			if( !($value = filter_input( INPUT_GET, $key )) )continue;
312 312
 			$metaQuery = (array)$query->get( 'meta_query' );
313 313
 			$metaQuery[] = [
314 314
 				'key' => $key,
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 	{
326 326
 		$orderby = $query->get( 'orderby' );
327 327
 		$columns = glsr()->postTypeColumns[Application::POST_TYPE];
328
-		unset( $columns['cb'], $columns['title'], $columns['date'] );
329
-		if( in_array( $orderby, array_keys( $columns ))) {
328
+		unset($columns['cb'], $columns['title'], $columns['date']);
329
+		if( in_array( $orderby, array_keys( $columns ) ) ) {
330 330
 			$query->set( 'meta_key', $orderby );
331 331
 			$query->set( 'orderby', 'meta_value' );
332 332
 		}
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function enqueueAssets()
26 26
 	{
27
-		$command = new EnqueueAdminAssets([
27
+		$command = new EnqueueAdminAssets( [
28 28
 			'pointers' => [[
29 29
 				'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
30 30
 				'id' => 'glsr-pointer-pinned',
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 				'target' => '#misc-pub-pinned',
37 37
 				'title' => __( 'Pin Your Reviews', 'site-reviews' ),
38 38
 			]],
39
-		]);
39
+		] );
40 40
 		$this->execute( $command );
41 41
 	}
42 42
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	{
49 49
 		$links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
50 50
 			'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
51
-		]);
51
+		] );
52 52
 		return $links;
53 53
 	}
54 54
 
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
 	public function filterDashboardGlanceItems( $items )
61 61
 	{
62 62
 		$postCount = wp_count_posts( Application::POST_TYPE );
63
-		if( empty( $postCount->publish )) {
63
+		if( empty($postCount->publish) ) {
64 64
 			return $items;
65 65
 		}
66 66
 		$text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
67
-		$text = sprintf( $text, number_format_i18n( $postCount->publish ));
67
+		$text = sprintf( $text, number_format_i18n( $postCount->publish ) );
68 68
 		$items = glsr( Helper::class )->consolidateArray( $items );
69 69
 		$items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts )
70 70
 			? glsr( Builder::class )->a( $text, [
71 71
 				'class' => 'glsr-review-count',
72 72
 				'href' => 'edit.php?post_type='.Application::POST_TYPE,
73
-			])
73
+			] )
74 74
 			: glsr( Builder::class )->span( $text, [
75 75
 				'class' => 'glsr-review-count',
76
-			]);
76
+			] );
77 77
 		return $items;
78 78
 	}
79 79
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function filterTinymcePlugins( $plugins )
86 86
 	{
87
-		if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) {
87
+		if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
88 88
 			$plugins = glsr( Helper::class )->consolidateArray( $plugins );
89 89
 			$plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
90 90
 		}
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function registerTinymcePopups()
99 99
 	{
100
-		$command = new RegisterTinymcePopups([
100
+		$command = new RegisterTinymcePopups( [
101 101
 			'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
102 102
 			'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
103 103
 			'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
104
-		]);
104
+		] );
105 105
 		$this->execute( $command );
106 106
 	}
107 107
 
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 	public function renderTinymceButton( $editorId )
114 114
 	{
115 115
 		$allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId );
116
-		if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return;
116
+		if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ) )return;
117 117
 		$shortcodes = [];
118 118
 		foreach( glsr()->mceShortcodes as $shortcode => $values ) {
119 119
 			$shortcodes[$shortcode] = $values;
120 120
 		}
121
-		if( empty( $shortcodes ))return;
121
+		if( empty($shortcodes) )return;
122 122
 		glsr()->render( 'partials/editor/tinymce', [
123 123
 			'shortcodes' => $shortcodes,
124
-		]);
124
+		] );
125 125
 	}
126 126
 
127 127
 	/**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	public function routerClearConsole()
131 131
 	{
132 132
 		glsr( Console::class )->clear();
133
-		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ));
133
+		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
134 134
 	}
135 135
 
136 136
 	/**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function routerFetchConsole()
140 140
 	{
141
-		glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ));
141
+		glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) );
142 142
 	}
143 143
 
144 144
 	/**
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 		}
158 158
 		$postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' );
159 159
 		foreach( $postIds as $postId ) {
160
-			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ));
160
+			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) );
161 161
 		}
162 162
 		$countManager->setCounts( $countManager->buildCounts() );
163 163
 		if( $showNotice ) {
164
-			glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ));
164
+			glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) );
165 165
 		}
166
-		glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ));
166
+		glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) );
167 167
 	}
168 168
 
169 169
 	/**
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
 	{
198 198
 		$file = $_FILES['import-file'];
199 199
 		if( $file['error'] !== UPLOAD_ERR_OK ) {
200
-			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ));
200
+			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
201 201
 		}
202
-		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) {
203
-			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ));
202
+		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) {
203
+			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
204 204
 		}
205 205
 		$settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
206
-		if( empty( $settings )) {
207
-			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ));
206
+		if( empty($settings) ) {
207
+			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
208 208
 		}
209
-		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ));
210
-		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ));
209
+		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
210
+		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
211 211
 	}
212 212
 
213 213
 	/**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
226 226
 			UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
227 227
 		];
228
-		return !isset( $errors[$errorCode] )
228
+		return !isset($errors[$errorCode])
229 229
 			? __( 'Unknown upload error.', 'site-reviews' )
230 230
 			: $errors[$errorCode];
231 231
 	}
Please login to merge, or discard this patch.