Passed
Push — master ( 7de9ff...9a7a6b )
by Paul
07:10 queued 03:33
created
plugin/Database/ReviewManager.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 			'post_type' => Application::POST_TYPE,
36 36
 		];
37 37
 		$postId = wp_insert_post( $postValues, true );
38
-		if( is_wp_error( $postId )) {
38
+		if( is_wp_error( $postId ) ) {
39 39
 			glsr_log()->error( $postId->get_error_message() )->debug( $postValues );
40 40
 			return false;
41 41
 		}
42 42
 		$this->setTerms( $postId, $command->category );
43
-		$review = $this->single( get_post( $postId ));
43
+		$review = $this->single( get_post( $postId ) );
44 44
 		do_action( 'site-reviews/review/created', $review, $command );
45 45
 		return $review;
46 46
 	}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function delete( $metaReviewId )
53 53
 	{
54
-		if( $postId = $this->getPostId( $metaReviewId )) {
54
+		if( $postId = $this->getPostId( $metaReviewId ) ) {
55 55
 			wp_delete_post( $postId, true );
56 56
 		}
57 57
 	}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		$paged = glsr( QueryBuilder::class )->getPaged(
74 74
 			wp_validate_boolean( $args['pagination'] )
75 75
 		);
76
-		$reviews = new WP_Query([
76
+		$reviews = new WP_Query( [
77 77
 			'meta_key' => 'pinned',
78 78
 			'meta_query' => $metaQuery,
79 79
 			'offset' => $args['offset'],
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			'post_type' => Application::POST_TYPE,
87 87
 			'posts_per_page' => $args['count'],
88 88
 			'tax_query' => $taxQuery,
89
-		]);
89
+		] );
90 90
 		return (object)[
91 91
 			'results' => array_map( [$this, 'single'], $reviews->posts ),
92 92
 			'max_num_pages' => $reviews->max_num_pages,
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 		$terms = [];
112 112
 		$termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds );
113 113
 		foreach( $termIds as $termId ) {
114
-			if( is_numeric( $termId )) {
114
+			if( is_numeric( $termId ) ) {
115 115
 				$termId = intval( $termId );
116 116
 			}
117 117
 			$term = term_exists( $termId, Application::TAXONOMY );
118
-			if( !isset( $term['term_id'] ))continue;
118
+			if( !isset($term['term_id']) )continue;
119 119
 			$terms[] = intval( $term['term_id'] );
120 120
 		}
121 121
 		return $terms;
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	{
130 130
 		if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return;
131 131
 		delete_post_meta( $postId, '_edit_last' );
132
-		$result = wp_update_post([
132
+		$result = wp_update_post( [
133 133
 			'ID' => $postId,
134 134
 			'post_content' => get_post_meta( $postId, 'content', true ),
135 135
 			'post_date' => get_post_meta( $postId, 'date', true ),
136 136
 			'post_title' => get_post_meta( $postId, 'title', true ),
137
-		]);
138
-		if( is_wp_error( $result )) {
137
+		] );
138
+		if( is_wp_error( $result ) ) {
139 139
 			glsr_log()->error( $result->get_error_message() );
140 140
 		}
141 141
 	}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	protected function getNewPostStatus( array $review, $isBlacklisted )
158 158
 	{
159 159
 		$requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' );
160
-		return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted )
160
+		return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted)
161 161
 			? 'pending'
162 162
 			: 'publish';
163 163
 	}
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	protected function setTerms( $postId, $termIds )
171 171
 	{
172 172
 		$terms = $this->normalizeTerms( $termIds );
173
-		if( empty( $terms ))return;
173
+		if( empty($terms) )return;
174 174
 		$result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY );
175
-		if( is_wp_error( $result )) {
175
+		if( is_wp_error( $result ) ) {
176 176
 			glsr_log()->error( $result->get_error_message() );
177 177
 		}
178 178
 	}
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviewsSummary.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
 	public function build( array $args = [] )
36 36
 	{
37 37
 		$this->args = $args;
38
-		$counts = glsr( CountsManager::class )->get([
38
+		$counts = glsr( CountsManager::class )->get( [
39 39
 			'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ),
40 40
 			'term_ids' => glsr( ReviewManager::class )->normalizeTerms( $args['category'] ),
41 41
 			'type' => $args['type'],
42
-		]);
42
+		] );
43 43
 		$this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [
44 44
 			'min' => $args['rating'],
45
-		]);
46
-		if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return;
45
+		] );
46
+		if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) )return;
47 47
 		$this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts );
48 48
 		$this->generateSchema();
49 49
 		return glsr( Template::class )->build( 'templates/reviews-summary', [
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 				'stars' => $this->buildStars(),
56 56
 				'text' => $this->buildText(),
57 57
 			],
58
-		]);
58
+		] );
59 59
 	}
60 60
 
61 61
 	/**
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	protected function buildPercentage()
65 65
 	{
66
-		if( $this->isHidden( 'bars' ))return;
67
-		$percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ));
68
-		$bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) {
66
+		if( $this->isHidden( 'bars' ) )return;
67
+		$percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) );
68
+		$bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use($percentages) {
69 69
 			$label = $this->buildPercentageLabel( $this->args['labels'][$level] );
70 70
 			$background = $this->buildPercentageBackground( $percentages[$level] );
71 71
 			$count = apply_filters( 'site-reviews/summary/counts',
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			$percent = $this->buildPercentageCount( $count );
76 76
 			return $carry.glsr( Builder::class )->div( $label.$background.$percent, [
77 77
 				'class' => 'glsr-bar',
78
-			]);
78
+			] );
79 79
 		});
80 80
 		return $this->wrap( 'percentage', $bars );
81 81
 	}
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	protected function buildPercentageBackground( $percent )
88 88
 	{
89
-		$backgroundPercent = glsr( Builder::class )->span([
89
+		$backgroundPercent = glsr( Builder::class )->span( [
90 90
 			'class' => 'glsr-bar-background-percent',
91 91
 			'style' => 'width:'.$percent,
92
-		]);
92
+		] );
93 93
 		return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>';
94 94
 	}
95 95
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	protected function buildRating()
118 118
 	{
119
-		if( $this->isHidden( 'rating' ))return;
119
+		if( $this->isHidden( 'rating' ) )return;
120 120
 		return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' );
121 121
 	}
122 122
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	protected function buildStars()
127 127
 	{
128
-		if( $this->isHidden( 'stars' ))return;
128
+		if( $this->isHidden( 'stars' ) )return;
129 129
 		$stars = glsr( Partial::class )->build( 'star-rating', ['rating' => $this->averageRating] );
130 130
 		return $this->wrap( 'stars', $stars );
131 131
 	}
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	protected function buildText()
137 137
 	{
138
-		if( $this->isHidden( 'summary' ))return;
139
-		$count = intval( array_sum( $this->ratingCounts ));
140
-		if( empty( $this->args['text'] )) {
138
+		if( $this->isHidden( 'summary' ) )return;
139
+		$count = intval( array_sum( $this->ratingCounts ) );
140
+		if( empty($this->args['text']) ) {
141 141
 			// @todo document this change
142 142
 			 $this->args['text'] = _nx(
143 143
 				'{rating} out of {max} stars (based on {num} review)',
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 			);
149 149
 		}
150 150
 		$summary = str_replace(
151
-			['{rating}','{max}', '{num}'],
151
+			['{rating}', '{max}', '{num}'],
152 152
 			[$this->averageRating, Rating::MAX_RATING, $count],
153 153
 			$this->args['text']
154 154
 		);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	protected function generateSchema()
162 162
 	{
163
-		if( !wp_validate_boolean( $this->args['schema'] ))return;
163
+		if( !wp_validate_boolean( $this->args['schema'] ) )return;
164 164
 		glsr( Schema::class )->store(
165 165
 			glsr( Schema::class )->buildSummary( $this->args )
166 166
 		);
@@ -192,6 +192,6 @@  discard block
 block discarded – undo
192 192
 	{
193 193
 		return glsr( Builder::class )->div( $value, [
194 194
 			'class' => 'glsr-summary-'.$key,
195
-		]);
195
+		] );
196 196
 	}
197 197
 }
Please login to merge, or discard this patch.
plugin/Review.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function __get( $key )
48 48
 	{
49
-		if( property_exists( $this, $key )) {
49
+		if( property_exists( $this, $key ) ) {
50 50
 			return $this->$key;
51 51
 		}
52
-		if( is_array( $this->custom ) && array_key_exists( $key, $this->custom )) {
52
+		if( is_array( $this->custom ) && array_key_exists( $key, $this->custom ) ) {
53 53
 			return $this->custom[$key];
54 54
 		}
55 55
 		return '';
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
 			'review_type' => 'local',
78 78
 		];
79 79
 		$meta = array_filter(
80
-			array_map( 'array_shift', (array)get_post_meta( $post->ID )),
80
+			array_map( 'array_shift', (array)get_post_meta( $post->ID ) ),
81 81
 			'strlen'
82 82
 		);
83
-		$properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ));
83
+		$properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) );
84 84
 		$this->modified = $this->isModified( $properties );
85 85
 		array_walk( $properties, function( $value, $key ) {
86
-			if( !property_exists( $this, $key ) || isset( $this->$key ))return;
86
+			if( !property_exists( $this, $key ) || isset($this->$key) )return;
87 87
 			$this->$key = maybe_unserialize( $value );
88 88
 		});
89 89
 	}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	protected function setTermIds( WP_Post $post )
95 95
 	{
96 96
 		$this->term_ids = [];
97
-		if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return;
97
+		if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return;
98 98
 		foreach( $terms as $term ) {
99 99
 			$this->term_ids[] = $term->term_id;
100 100
 		}
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 			$this->getCounts(),
67 67
 			$review->review_type,
68 68
 			$review->rating
69
-		));
69
+		) );
70 70
 	}
71 71
 
72 72
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function decreasePostCounts( Review $review )
76 76
 	{
77
-		if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return;
77
+		if( empty($counts = $this->getPostCounts( $review->assigned_to )) )return;
78 78
 		$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
79 79
 		$this->setPostCounts( $review->assigned_to, $counts );
80 80
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	public function decreaseTermCounts( Review $review )
86 86
 	{
87 87
 		foreach( $review->term_ids as $termId ) {
88
-			if( empty( $counts = $this->getTermCounts( $termId )))continue;
88
+			if( empty($counts = $this->getTermCounts( $termId )) )continue;
89 89
 			$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
90 90
 			$this->setTermCounts( $termId, $counts );
91 91
 		}
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	public function flatten( array $reviewCounts, array $args = [] )
98 98
 	{
99 99
 		$counts = [];
100
-		array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) {
101
-			$counts[$index] = isset( $counts[$index] )
100
+		array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) {
101
+			$counts[$index] = isset($counts[$index])
102 102
 				? $num + $counts[$index]
103 103
 				: $num;
104 104
 		});
105 105
 		$args = wp_parse_args( $args, [
106 106
 			'max' => Rating::MAX_RATING,
107 107
 			'min' => Rating::MIN_RATING,
108
-		]);
108
+		] );
109 109
 		foreach( $counts as $index => &$num ) {
110
-			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue;
110
+			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue;
111 111
 			$num = 0;
112 112
 		}
113 113
 		return $counts;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			'post_ids' => [],
123 123
 			'term_ids' => [],
124 124
 			'type' => 'local',
125
-		]);
125
+		] );
126 126
 		$counts = [];
127 127
 		foreach( glsr( Polylang::class )->getPostIds( $args['post_ids'] ) as $postId ) {
128 128
 			$counts[] = $this->getPostCounts( $postId );
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
 		foreach( $args['term_ids'] as $termId ) {
131 131
 			$counts[] = $this->getTermCounts( $termId );
132 132
 		}
133
-		if( empty( $counts )) {
133
+		if( empty($counts) ) {
134 134
 			$counts[] = $this->getCounts();
135 135
 		}
136 136
 		return in_array( $args['type'], ['', 'all'] )
137 137
 			? $this->normalize( [$this->flatten( $counts )] )
138
-			: $this->normalize( array_column( $counts, $args['type'] ));
138
+			: $this->normalize( array_column( $counts, $args['type'] ) );
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	public function getCounts()
145 145
 	{
146 146
 		$counts = glsr( OptionManager::class )->get( 'counts', [] );
147
-		if( !is_array( $counts )) {
147
+		if( !is_array( $counts ) ) {
148 148
 			glsr_log()->error( 'CountsManager: counts is not an array' )->debug( $counts );
149 149
 			return [];
150 150
 		}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function getPostCounts( $postId )
159 159
 	{
160
-		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ));
160
+		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) );
161 161
 	}
162 162
 
163 163
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function getTermCounts( $termId )
168 168
 	{
169
-		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ));
169
+		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) );
170 170
 	}
171 171
 
172 172
 	/**
@@ -184,14 +184,14 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function increaseCounts( Review $review )
186 186
 	{
187
-		if( empty( $counts = $this->getCounts() )) {
187
+		if( empty($counts = $this->getCounts()) ) {
188 188
 			$counts = $this->buildCounts();
189 189
 		}
190 190
 		$this->setCounts( $this->increaseRating(
191 191
 			$counts,
192 192
 			$review->review_type,
193 193
 			$review->rating
194
-		));
194
+		) );
195 195
 	}
196 196
 
197 197
 	/**
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	public function increasePostCounts( Review $review )
201 201
 	{
202
-		if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return;
202
+		if( !(get_post( $review->assigned_to ) instanceof WP_Post) )return;
203 203
 		$counts = $this->getPostCounts( $review->assigned_to );
204
-		$counts = empty( $counts )
204
+		$counts = empty($counts)
205 205
 			? $this->buildPostCounts( $review->assigned_to )
206 206
 			: $this->increaseRating( $counts, $review->review_type, $review->rating );
207 207
 		$this->setPostCounts( $review->assigned_to, $counts );
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function increaseTermCounts( Review $review )
214 214
 	{
215
-		$termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ));
215
+		$termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) );
216 216
 		foreach( $termIds as $termId ) {
217 217
 			$counts = $this->getTermCounts( $termId );
218
-			$counts = empty( $counts )
218
+			$counts = empty($counts)
219 219
 				? $this->buildTermCounts( $termId )
220 220
 				: $this->increaseRating( $counts, $review->review_type, $review->rating );
221 221
 			$this->setTermCounts( $termId, $counts );
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 	{
239 239
 		$ratingCounts = $this->flatten( $reviewCounts );
240 240
 		update_post_meta( $postId, static::META_COUNT, $reviewCounts );
241
-		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
242
-		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
241
+		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
242
+		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
243 243
 	}
244 244
 
245 245
 	/**
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
 	 */
249 249
 	public function setTermCounts( $termId, array $reviewCounts )
250 250
 	{
251
-		if( !term_exists( $termId ))return;
251
+		if( !term_exists( $termId ) )return;
252 252
 		$ratingCounts = $this->flatten( $reviewCounts );
253 253
 		update_term_meta( $termId, static::META_COUNT, $reviewCounts );
254
-		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
255
-		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
254
+		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
255
+		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
256 256
 	}
257 257
 
258 258
 	/**
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
 	{
264 264
 		$counts = [];
265 265
 		$lastPostId = 0;
266
-		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) {
267
-			$types = array_keys( array_flip( array_column( $reviews, 'type' )));
268
-			$types = array_unique( array_merge( ['local'], $types ));
266
+		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit ) ) {
267
+			$types = array_keys( array_flip( array_column( $reviews, 'type' ) ) );
268
+			$types = array_unique( array_merge( ['local'], $types ) );
269 269
 			foreach( $types as $type ) {
270 270
 				$type = $this->normalizeType( $type );
271
-				if( isset( $counts[$type] ))continue;
271
+				if( isset($counts[$type]) )continue;
272 272
 				$counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 );
273 273
 			}
274 274
 			foreach( $reviews as $review ) {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 */
288 288
 	protected function decreaseRating( array $reviewCounts, $type, $rating )
289 289
 	{
290
-		if( isset( $reviewCounts[$type][$rating] )) {
290
+		if( isset($reviewCounts[$type][$rating]) ) {
291 291
 			$reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 );
292 292
 		}
293 293
 		return $reviewCounts;
@@ -300,10 +300,10 @@  discard block
 block discarded – undo
300 300
 	 */
301 301
 	protected function increaseRating( array $reviewCounts, $type, $rating )
302 302
 	{
303
-		if( !array_key_exists( $type, glsr()->reviewTypes )) {
303
+		if( !array_key_exists( $type, glsr()->reviewTypes ) ) {
304 304
 			return $reviewCounts;
305 305
 		}
306
-		if( !array_key_exists( $type, $reviewCounts )) {
306
+		if( !array_key_exists( $type, $reviewCounts ) ) {
307 307
 			$reviewCounts[$type] = [];
308 308
 		}
309 309
 		$reviewCounts = $this->normalize( $reviewCounts );
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	protected function normalize( array $reviewCounts )
318 318
 	{
319
-		if( empty( $reviewCounts )) {
319
+		if( empty($reviewCounts) ) {
320 320
 			$reviewCounts = [[]];
321 321
 		}
322 322
 		foreach( $reviewCounts as &$counts ) {
323 323
 			foreach( range( 0, Rating::MAX_RATING ) as $index ) {
324
-				if( isset( $counts[$index] ))continue;
324
+				if( isset($counts[$index]) )continue;
325 325
 				$counts[$index] = 0;
326 326
 			}
327 327
 			ksort( $counts );
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	 */
336 336
 	protected function normalizeType( $type )
337 337
 	{
338
-		return empty( $type ) || !is_string( $type )
338
+		return empty($type) || !is_string( $type )
339 339
 			? 'local'
340 340
 			: $type;
341 341
 	}
@@ -347,14 +347,14 @@  discard block
 block discarded – undo
347 347
 	 */
348 348
 	protected function queryReviews( array $args = [], $lastPostId, $limit )
349 349
 	{
350
-		$args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ));
351
-		if( empty( array_filter( $args ))) {
350
+		$args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ) );
351
+		if( empty(array_filter( $args )) ) {
352 352
 			return glsr( SqlQueries::class )->getReviewCounts( $lastPostId, $limit );
353 353
 		}
354
-		if( !empty( $args['post_id'] )) {
354
+		if( !empty($args['post_id']) ) {
355 355
 			return glsr( SqlQueries::class )->getReviewPostCounts( $args['post_id'], $lastPostId, $limit );
356 356
 		}
357
-		if( !empty( $args['term_id'] )) {
357
+		if( !empty($args['term_id']) ) {
358 358
 			return glsr( SqlQueries::class )->getReviewTermCounts( $args['term_id'], $lastPostId, $limit );
359 359
 		}
360 360
 	}
Please login to merge, or discard this patch.
plugin/Modules/Validator.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		foreach( $this->rules as $attribute => $rules ) {
75 75
 			foreach( $rules as $rule ) {
76 76
 				$this->validateAttribute( $attribute, $rule );
77
-				if( $this->shouldStopValidating( $attribute ))break;
77
+				if( $this->shouldStopValidating( $attribute ) )break;
78 78
 			}
79 79
 		}
80 80
 		return $this->errors;
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function validateAttribute( $attribute, $rule )
91 91
 	{
92
-		list( $rule, $parameters ) = $this->parseRule( $rule );
92
+		list($rule, $parameters) = $this->parseRule( $rule );
93 93
 		if( $rule == '' )return;
94 94
 		$value = $this->getValue( $attribute );
95
-		if( !method_exists( $this, $method = 'validate'.$rule )) {
95
+		if( !method_exists( $this, $method = 'validate'.$rule ) ) {
96 96
 			throw new BadMethodCallException( "Method [$method] does not exist." );
97 97
 		}
98
-		if( !$this->$method( $value, $attribute, $parameters )) {
98
+		if( !$this->$method( $value, $attribute, $parameters ) ) {
99 99
 			$this->addFailure( $attribute, $rule, $parameters );
100 100
 		}
101 101
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	protected function getMessage( $attribute, $rule, array $parameters )
146 146
 	{
147
-		if( in_array( $rule, $this->sizeRules )) {
147
+		if( in_array( $rule, $this->sizeRules ) ) {
148 148
 			return $this->getSizeMessage( $attribute, $rule, $parameters );
149 149
 		}
150 150
 		$lowerRule = glsr( Helper::class )->snakeCase( $rule );
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	protected function getRule( $attribute, $rules )
161 161
 	{
162
-		if( !array_key_exists( $attribute, $this->rules ))return;
162
+		if( !array_key_exists( $attribute, $this->rules ) )return;
163 163
 		$rules = (array)$rules;
164 164
 		foreach( $this->rules[$attribute] as $rule ) {
165
-			list( $rule, $parameters ) = $this->parseRule( $rule );
166
-			if( in_array( $rule, $rules )) {
165
+			list($rule, $parameters) = $this->parseRule( $rule );
166
+			if( in_array( $rule, $rules ) ) {
167 167
 				return [$rule, $parameters];
168 168
 			}
169 169
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		if( is_numeric( $value ) && $hasNumeric ) {
182 182
 			return $value;
183 183
 		}
184
-		elseif( is_array( $value )) {
184
+		elseif( is_array( $value ) ) {
185 185
 			return count( $value );
186 186
 		}
187 187
 		return function_exists( 'mb_strlen' )
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	protected function getValue( $attribute )
211 211
 	{
212
-		if( isset( $this->data[$attribute] )) {
212
+		if( isset($this->data[$attribute]) ) {
213 213
 			return $this->data[$attribute];
214 214
 		}
215 215
 	}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	protected function hasRule( $attribute, $rules )
224 224
 	{
225
-		return !is_null( $this->getRule( $attribute, $rules ));
225
+		return !is_null( $this->getRule( $attribute, $rules ) );
226 226
 	}
227 227
 
228 228
 	/**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	{
261 261
 		$parameters = [];
262 262
 		if( strpos( $rule, ':' ) !== false ) {
263
-			list( $rule, $parameter ) = explode( ':', $rule, 2 );
263
+			list($rule, $parameter) = explode( ':', $rule, 2 );
264 264
 			$parameters = $this->parseParameters( $rule, $parameter );
265 265
 		}
266 266
 		$rule = glsr( Helper::class )->camelCase( $rule );
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	protected function shouldStopValidating( $attribute )
290 290
 	{
291 291
 		return $this->hasRule( $attribute, $this->implicitRules )
292
-			&& isset( $this->failedRules[$attribute] )
292
+			&& isset($this->failedRules[$attribute])
293 293
 			&& array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules );
294 294
 	}
295 295
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	protected function translator( $key, array $parameters )
303 303
 	{
304 304
 		$strings = glsr( ValidationStringsDefaults::class )->defaults();
305
-		if( isset( $strings[$key] )) {
305
+		if( isset($strings[$key]) ) {
306 306
 			return $this->replace( $strings[$key], $parameters );
307 307
 		}
308 308
 		return "error";
Please login to merge, or discard this patch.
plugin/Helper.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	{
17 17
 		$className = $this->camelCase( $name );
18 18
 		$path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' );
19
-		return !empty( $path )
19
+		return !empty($path)
20 20
 			? __NAMESPACE__.'\\'.$path.'\\'.$className
21 21
 			: $className;
22 22
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function buildMethodName( $name, $prefix = '' )
30 30
 	{
31
-		return lcfirst( $prefix.$this->buildClassName( $name ));
31
+		return lcfirst( $prefix.$this->buildClassName( $name ) );
32 32
 	}
33 33
 
34 34
 	/**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public function buildPropertyName( $name )
39 39
 	{
40
-		return lcfirst( $this->buildClassName( $name ));
40
+		return lcfirst( $this->buildClassName( $name ) );
41 41
 	}
42 42
 
43 43
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function camelCase( $string )
48 48
 	{
49
-		$string = ucwords( str_replace( ['-', '_'], ' ', trim( $string )));
49
+		$string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) );
50 50
 		return str_replace( ' ', '', $string );
51 51
 	}
52 52
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function convertPathToId( $path, $prefix = '' )
80 80
 	{
81
-		return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ));
81
+		return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) );
82 82
 	}
83 83
 
84 84
 	/**
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	{
90 90
 		$levels = explode( '.', $path );
91 91
 		return array_reduce( $levels, function( $result, $value ) {
92
-			return $result.= '['.$value.']';
92
+			return $result .= '['.$value.']';
93 93
 		}, $prefix );
94 94
 	}
95 95
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function convertStringToArray( $string, $callback = null )
102 102
 	{
103
-		$array = array_map( 'trim', explode( ',', $string ));
103
+		$array = array_map( 'trim', explode( ',', $string ) );
104 104
 		return $callback
105 105
 			? array_filter( $array, $callback )
106 106
 			: array_filter( $array );
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function dashCase( $string )
114 114
 	{
115
-		return str_replace( '_', '-', $this->snakeCase( $string ));
115
+		return str_replace( '_', '-', $this->snakeCase( $string ) );
116 116
 	}
117 117
 
118 118
 	/**
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function filterInput( $key, array $request = [] )
136 136
 	{
137
-		if( isset( $request[$key] )) {
137
+		if( isset($request[$key]) ) {
138 138
 			return $request[$key];
139 139
 		}
140 140
 		$variable = filter_input( INPUT_POST, $key );
141
-		if( is_null( $variable ) && isset( $_POST[$key] )) {
141
+		if( is_null( $variable ) && isset($_POST[$key]) ) {
142 142
 			$variable = $_POST[$key];
143 143
 		}
144 144
 		return $variable;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	public function filterInputArray( $key )
152 152
 	{
153 153
 		$variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
154
-		if( empty( $variable ) && !empty( $_POST[$key] ) && is_array( $_POST[$key] )) {
154
+		if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
155 155
 			$variable = $_POST[$key];
156 156
 		}
157 157
 		return (array)$variable;
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
 		$result = [];
168 168
 		foreach( $array as $key => $value ) {
169 169
 			$newKey = ltrim( $prefix.'.'.$key, '.' );
170
-			if( $this->isIndexedFlatArray( $value )) {
170
+			if( $this->isIndexedFlatArray( $value ) ) {
171 171
 				if( $flattenValue ) {
172 172
 					$value = '['.implode( ', ', $value ).']';
173 173
 				}
174 174
 			}
175
-			else if( is_array( $value )) {
176
-				$result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ));
175
+			else if( is_array( $value ) ) {
176
+				$result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) );
177 177
 				continue;
178 178
 			}
179 179
 			$result[$newKey] = $value;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 				Whip::IPV4 => $cloudflareIps['v4'],
196 196
 				Whip::IPV6 => $ipv6,
197 197
 			],
198
-		]))->getValidIpAddress();
198
+		] ))->getValidIpAddress();
199 199
 	}
200 200
 
201 201
 	/**
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	{
209 209
 		$keys = explode( '.', $path );
210 210
 		foreach( $keys as $key ) {
211
-			if( !isset( $values[$key] )) {
211
+			if( !isset($values[$key]) ) {
212 212
 				return $fallback;
213 213
 			}
214 214
 			$values = $values[$key];
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public function isIndexedArray( $array )
224 224
 	{
225
-		if( !is_array( $array )) {
225
+		if( !is_array( $array ) ) {
226 226
 			return false;
227 227
 		}
228 228
 		$current = 0;
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function isIndexedFlatArray( $array )
243 243
 	{
244
-		if( !is_array( $array ) || array_filter( $array, 'is_array' )) {
244
+		if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) {
245 245
 			return false;
246 246
 		}
247 247
 		return $this->isIndexedArray( $array );
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public function prefixString( $string, $prefix = '' )
256 256
 	{
257
-		return $prefix.str_replace( $prefix, '', trim( $string ));
257
+		return $prefix.str_replace( $prefix, '', trim( $string ) );
258 258
 	}
259 259
 
260 260
 	/**
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function removePrefix( $prefix, $text ) {
281 281
 		return 0 === strpos( $text, $prefix )
282
-			? substr( $text, strlen( $prefix ))
282
+			? substr( $text, strlen( $prefix ) )
283 283
 			: $text;
284 284
 	}
285 285
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 */
311 311
 	public function snakeCase( $string )
312 312
 	{
313
-		if( !ctype_lower( $string )) {
313
+		if( !ctype_lower( $string ) ) {
314 314
 			$string = preg_replace( '/\s+/u', '', $string );
315 315
 			$string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
316 316
 			$string = function_exists( 'mb_strtolower' )
@@ -327,6 +327,6 @@  discard block
 block discarded – undo
327 327
 	 */
328 328
 	public function startsWith( $needle, $haystack )
329 329
 	{
330
-		return substr( $haystack, 0, strlen( $needle )) === $needle;
330
+		return substr( $haystack, 0, strlen( $needle ) ) === $needle;
331 331
 	}
332 332
 }
Please login to merge, or discard this patch.
plugin/Modules/System.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 			'setting' => 'Plugin Settings',
41 41
 			'reviews' => 'Review Counts',
42 42
 		];
43
-		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) {
43
+		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) {
44 44
 			$methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
45 45
 			if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
46 46
 				return $carry.$this->implode(
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	{
61 61
 		$plugins = get_plugins();
62 62
 		$activePlugins = (array)get_option( 'active_plugins', [] );
63
-		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ));
64
-		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
63
+		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
64
+		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
65 65
 	}
66 66
 
67 67
 	/**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	public function getInactivePluginDetails()
96 96
 	{
97 97
 		$activePlugins = (array)get_option( 'active_plugins', [] );
98
-		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins )));
98
+		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
99 99
 	}
100 100
 
101 101
 	/**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	{
106 106
 		$plugins = array_merge(
107 107
 			get_mu_plugins(),
108
-			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ))
108
+			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) )
109 109
 		);
110
-		if( empty( $plugins ))return;
110
+		if( empty($plugins) )return;
111 111
 		return $this->normalizePluginList( $plugins );
112 112
 	}
113 113
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function getMultisitePluginDetails()
118 118
 	{
119
-		if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return;
119
+		if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return;
120 120
 		return $this->normalizePluginList( wp_get_active_network_plugins() );
121 121
 	}
122 122
 
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 			'Max Input Vars' => ini_get( 'max_input_vars' ),
144 144
 			'Memory Limit' => ini_get( 'memory_limit' ),
145 145
 			'Post Max Size' => ini_get( 'post_max_size' ),
146
-			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )),
147
-			'Session Name' => esc_html( ini_get( 'session.name' )),
148
-			'Session Save Path' => esc_html( ini_get( 'session.save_path' )),
149
-			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ),
150
-			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ),
146
+			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
147
+			'Session Name' => esc_html( ini_get( 'session.name' ) ),
148
+			'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
149
+			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
150
+			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
151 151
 			'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
152 152
 		];
153 153
 	}
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	{
160 160
 		$counts = glsr( CountsManager::class )->getCounts();
161 161
 		$counts = glsr( Helper::class )->flattenArray( $counts );
162
- 		array_walk( $counts, function( &$ratings ) use( $counts ) {
163
-			if( !is_array( $ratings )) {
162
+ 		array_walk( $counts, function( &$ratings ) use($counts) {
163
+			if( !is_array( $ratings ) ) {
164 164
 				glsr_log()
165 165
 					->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
166 166
 					->debug( $ratings )
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 		ksort( $settings );
200 200
 		$details = [];
201 201
 		foreach( $settings as $key => $value ) {
202
-			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue;
203
-			$value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' );
202
+			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue;
203
+			$value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
204 204
 			$details[$key] = $value;
205 205
 		}
206 206
 		return $details;
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 			'WPE_APIKEY' => 'WP Engine',
273 273
 		];
274 274
 		foreach( $checks as $key => $value ) {
275
-			if( !$this->isWebhostCheckValid( $key ))continue;
275
+			if( !$this->isWebhostCheckValid( $key ) )continue;
276 276
 			return $value;
277 277
 		}
278
-		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ));
278
+		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
279 279
 	}
280 280
 
281 281
 	/**
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 	{
297 297
 		$plugins = get_plugins();
298 298
 		$activePlugins = (array)get_option( 'active_plugins', [] );
299
-		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins )));
300
-		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
299
+		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
300
+		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
301 301
 		return $active + $inactive;
302 302
 	}
303 303
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	protected function implode( $title, array $details )
309 309
 	{
310 310
 		$strings = ['['.$title.']'];
311
-		$padding = max( array_map( 'strlen', array_keys( $details )) );
311
+		$padding = max( array_map( 'strlen', array_keys( $details ) ) );
312 312
 		$padding = max( [$padding, static::PAD] );
313 313
 		foreach( $details as $key => $value ) {
314 314
 			$strings[] = is_string( $key )
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 		$keys = [
352 352
 			'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
353 353
 		];
354
-		array_walk( $settings, function( &$value, $setting ) use( $keys ) {
354
+		array_walk( $settings, function( &$value, $setting ) use($keys) {
355 355
 			foreach( $keys as $key ) {
356
-				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue;
356
+				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue;
357 357
 				$value = str_repeat( '•', 13 );
358 358
 				return;
359 359
 			}
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function enqueueAssets()
25 25
 	{
26
-		$command = new EnqueueAdminAssets([
26
+		$command = new EnqueueAdminAssets( [
27 27
 			'pointers' => [[
28 28
 				'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
29 29
 				'id' => 'glsr-pointer-pinned',
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 				'target' => '#misc-pub-pinned',
36 36
 				'title' => __( 'Pin Your Reviews', 'site-reviews' ),
37 37
 			]],
38
-		]);
38
+		] );
39 39
 		$this->execute( $command );
40 40
 	}
41 41
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	{
48 48
 		$links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
49 49
 			'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
50
-		]);
50
+		] );
51 51
 		return $links;
52 52
 	}
53 53
 
@@ -58,19 +58,19 @@  discard block
 block discarded – undo
58 58
 	public function filterDashboardGlanceItems( array $items )
59 59
 	{
60 60
 		$postCount = wp_count_posts( Application::POST_TYPE );
61
-		if( empty( $postCount->publish )) {
61
+		if( empty($postCount->publish) ) {
62 62
 			return $items;
63 63
 		}
64 64
 		$text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
65
-		$text = sprintf( $text, number_format_i18n( $postCount->publish ));
65
+		$text = sprintf( $text, number_format_i18n( $postCount->publish ) );
66 66
 		$items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts )
67 67
 			? glsr( Builder::class )->a( $text, [
68 68
 				'class' => 'glsr-review-count',
69 69
 				'href' => 'edit.php?post_type='.Application::POST_TYPE,
70
-			])
70
+			] )
71 71
 			: glsr( Builder::class )->span( $text, [
72 72
 				'class' => 'glsr-review-count',
73
-			]);
73
+			] );
74 74
 		return $items;
75 75
 	}
76 76
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function filterTinymcePlugins( array $plugins )
82 82
 	{
83
-		if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) {
83
+		if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
84 84
 			$plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
85 85
 		}
86 86
 		return $plugins;
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function registerTinymcePopups()
94 94
 	{
95
-		$command = new RegisterTinymcePopups([
95
+		$command = new RegisterTinymcePopups( [
96 96
 			'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
97 97
 			'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
98 98
 			'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
99
-		]);
99
+		] );
100 100
 		$this->execute( $command );
101 101
 	}
102 102
 
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	public function renderTinymceButton( $editorId )
109 109
 	{
110 110
 		$allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'] );
111
-		if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return;
111
+		if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ) )return;
112 112
 		$shortcodes = [];
113 113
 		foreach( glsr()->mceShortcodes as $shortcode => $values ) {
114 114
 			$shortcodes[$shortcode] = $values;
115 115
 		}
116
-		if( empty( $shortcodes ))return;
116
+		if( empty($shortcodes) )return;
117 117
 		glsr()->render( 'partials/editor/tinymce', [
118 118
 			'shortcodes' => $shortcodes,
119
-		]);
119
+		] );
120 120
 	}
121 121
 
122 122
 	/**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	public function routerClearConsole()
126 126
 	{
127 127
 		glsr( Console::class )->clear();
128
-		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ));
128
+		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
129 129
 	}
130 130
 
131 131
 	/**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function routerFetchConsole()
135 135
 	{
136
-		glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ));
136
+		glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) );
137 137
 	}
138 138
 
139 139
 	/**
@@ -143,22 +143,22 @@  discard block
 block discarded – undo
143 143
 	public function routerCountReviews( $showNotice = true )
144 144
 	{
145 145
 		$countManager = glsr( CountsManager::class );
146
-		$terms = get_terms([
146
+		$terms = get_terms( [
147 147
 			'hide_empty' => true,
148 148
 			'taxonomy' => Application::TAXONOMY,
149
-		]);
149
+		] );
150 150
 		foreach( $terms as $term ) {
151
-			$countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ));
151
+			$countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ) );
152 152
 		}
153 153
 		$postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' );
154 154
 		foreach( $postIds as $postId ) {
155
-			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ));
155
+			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) );
156 156
 		}
157 157
 		$countManager->setCounts( $countManager->buildCounts() );
158 158
 		if( $showNotice ) {
159
-			glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ));
159
+			glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) );
160 160
 		}
161
-		glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ));
161
+		glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) );
162 162
 	}
163 163
 
164 164
 	/**
@@ -192,17 +192,17 @@  discard block
 block discarded – undo
192 192
 	{
193 193
 		$file = $_FILES['import-file'];
194 194
 		if( $file['error'] !== UPLOAD_ERR_OK ) {
195
-			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ));
195
+			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
196 196
 		}
197
-		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) {
198
-			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ));
197
+		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) {
198
+			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
199 199
 		}
200 200
 		$settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
201
-		if( empty( $settings )) {
202
-			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ));
201
+		if( empty($settings) ) {
202
+			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
203 203
 		}
204
-		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ));
205
-		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ));
204
+		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
205
+		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
206 206
 	}
207 207
 
208 208
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 			UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
221 221
 			UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
222 222
 		];
223
-		return !isset( $errors[$errorCode] )
223
+		return !isset($errors[$errorCode])
224 224
 			? __( 'Unknown upload error.', 'site-reviews' )
225 225
 			: $errors[$errorCode];
226 226
 	}
Please login to merge, or discard this patch.
plugin/Commands/CreateReview.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -31,25 +31,25 @@  discard block
 block discarded – undo
31 31
 	public function __construct( $input )
32 32
 	{
33 33
 		$this->request = $input;
34
-		$this->ajax_request = isset( $input['_ajax_request'] );
34
+		$this->ajax_request = isset($input['_ajax_request']);
35 35
 		$this->assigned_to = $this->getNumeric( 'assign_to' );
36
-		$this->author = sanitize_text_field( $this->getUser( 'name' ));
36
+		$this->author = sanitize_text_field( $this->getUser( 'name' ) );
37 37
 		$this->avatar = $this->getAvatar();
38
-		$this->blacklisted = isset( $input['blacklisted'] );
39
-		$this->category = sanitize_key( $this->get( 'category' ));
40
-		$this->content = sanitize_textarea_field( $this->get( 'content' ));
38
+		$this->blacklisted = isset($input['blacklisted']);
39
+		$this->category = sanitize_key( $this->get( 'category' ) );
40
+		$this->content = sanitize_textarea_field( $this->get( 'content' ) );
41 41
 		$this->custom = $this->getCustom();
42 42
 		$this->date = $this->getDate( 'date' );
43
-		$this->email = sanitize_email( $this->getUser( 'email' ));
44
-		$this->form_id = sanitize_key( $this->get( 'form_id' ));
43
+		$this->email = sanitize_email( $this->getUser( 'email' ) );
44
+		$this->form_id = sanitize_key( $this->get( 'form_id' ) );
45 45
 		$this->ip_address = $this->get( 'ip_address' );
46
-		$this->post_id = intval( $this->get( '_post_id' ));
47
-		$this->rating = intval( $this->get( 'rating' ));
46
+		$this->post_id = intval( $this->get( '_post_id' ) );
47
+		$this->rating = intval( $this->get( 'rating' ) );
48 48
 		$this->referer = $this->get( '_referer' );
49
-		$this->response = sanitize_textarea_field( $this->get( 'response' ));
50
-		$this->terms = !empty( $input['terms'] );
51
-		$this->title = sanitize_text_field( $this->get( 'title' ));
52
-		$this->url = esc_url_raw( $this->get( 'url' ));
49
+		$this->response = sanitize_textarea_field( $this->get( 'response' ) );
50
+		$this->terms = !empty($input['terms']);
51
+		$this->title = sanitize_text_field( $this->get( 'title' ) );
52
+		$this->url = esc_url_raw( $this->get( 'url' ) );
53 53
 	}
54 54
 
55 55
 	/**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	protected function get( $key )
60 60
 	{
61
-		return isset( $this->request[$key] )
61
+		return isset($this->request[$key])
62 62
 			? (string)$this->request[$key]
63 63
 			: '';
64 64
 	}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	{
71 71
 		$avatar = $this->get( 'avatar' );
72 72
 		return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_PATH_REQUIRED )
73
-			? (string)get_avatar_url( $this->get( 'email' ))
73
+			? (string)get_avatar_url( $this->get( 'email' ) )
74 74
 			: $avatar;
75 75
 	}
76 76
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		];
87 87
 		$custom = $this->request;
88 88
 		foreach( $unset as $value ) {
89
-			unset( $custom[$value] );
89
+			unset($custom[$value]);
90 90
 		}
91 91
 		return $custom;
92 92
 	}
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	protected function getDate( $key )
99 99
 	{
100
-		$date = strtotime( $this->get( $key ));
100
+		$date = strtotime( $this->get( $key ) );
101 101
 		if( $date === false ) {
102 102
 			$date = time();
103 103
 		}
104
-		return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ));
104
+		return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) );
105 105
 	}
106 106
 
107 107
 	/**
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 	protected function getUser( $key )
112 112
 	{
113 113
 		$value = $this->get( $key );
114
-		if( empty( $value )) {
114
+		if( empty($value) ) {
115 115
 			$user = wp_get_current_user();
116 116
 			$userValues = [
117 117
 				'email' => 'user_email',
118 118
 				'name' => 'display_name',
119 119
 			];
120
-			if( $user->exists() && array_key_exists( $key, $userValues )) {
120
+			if( $user->exists() && array_key_exists( $key, $userValues ) ) {
121 121
 				return $user->{$userValues[$key]};
122 122
 			}
123 123
 		}
Please login to merge, or discard this patch.