Passed
Push — master ( 6f6d9e...e32a3c )
by Paul
04:05
created
plugin/Modules/Rating.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,9 @@
 block discarded – undo
92 92
 		$counts = $this->flattenCounts( $reviewCounts );
93 93
 		$total = array_sum( $counts );
94 94
 		foreach( $counts as $index => $count ) {
95
-			if( empty( $count ))continue;
95
+			if( empty( $count )) {
96
+				continue;
97
+			}
96 98
 			$counts[$index] = $count / $total * 100;
97 99
 		}
98 100
 		return $this->getRoundedPercentages( $counts );
Please login to merge, or discard this patch.
plugin/Modules/Upgrader.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@
 block discarded – undo
17 17
 		natsort( $routines );
18 18
 		array_walk( $routines, function( $routine ) {
19 19
 			$parts = explode( '__', $routine );
20
-			if( version_compare( glsr()->version, end( $parts ), '>=' ))return;
20
+			if( version_compare( glsr()->version, end( $parts ), '>=' )) {
21
+				return;
22
+			}
21 23
 			call_user_func( [$this, $routine] );
22 24
 		});
23 25
 		$this->updateVersion();
Please login to merge, or discard this patch.
plugin/Review.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,9 @@
 block discarded – undo
65 65
 		$properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ));
66 66
 		$this->modified = $this->isModified( $properties );
67 67
 		array_walk( $properties, function( $value, $key ) {
68
-			if( !property_exists( $this, $key ) || isset( $this->$key ))return;
68
+			if( !property_exists( $this, $key ) || isset( $this->$key )) {
69
+				return;
70
+			}
69 71
 			$this->$key = $value;
70 72
 		});
71 73
 	}
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 1 patch
Braces   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -94,7 +94,9 @@  discard block
 block discarded – undo
94 94
 		if( !in_array( $metaKey, ['rating', 'review_type'] )
95 95
 			|| get_post_field( 'post_type', $postId ) != Application::POST_TYPE
96 96
 			|| get_post_field( 'post_status', $postId ) != 'publish' // only fire on an existing published post
97
- 		)return;
97
+ 		) {
98
+			return;
99
+		}
98 100
 		glsr( Metaboxes::class )->onBeforeUpdateReview( get_post( $postId ), $metaKey, $metaValue );
99 101
 	}
100 102
 
@@ -129,7 +131,9 @@  discard block
 block discarded – undo
129 131
 	{
130 132
 		if( in_array( $oldStatus, ['new', $newStatus] )
131 133
 			|| $post->post_type != Application::POST_TYPE
132
-		)return;
134
+		) {
135
+			return;
136
+		}
133 137
 		glsr( Metaboxes::class )->onReviewStatusChange( $newStatus, $post );
134 138
 	}
135 139
 
@@ -150,7 +154,9 @@  discard block
 block discarded – undo
150 154
 	 */
151 155
 	public function registerMetaBoxes( $postType )
152 156
 	{
153
-		if( $postType != Application::POST_TYPE )return;
157
+		if( $postType != Application::POST_TYPE ) {
158
+			return;
159
+		}
154 160
 		add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' );
155 161
 		add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' );
156 162
 		add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' );
@@ -180,7 +186,9 @@  discard block
 block discarded – undo
180 186
 	 */
181 187
 	public function renderAssignedToMetabox( WP_Post $post )
182 188
 	{
183
-		if( !$this->isReviewPostType( $post ))return;
189
+		if( !$this->isReviewPostType( $post )) {
190
+			return;
191
+		}
184 192
 		$assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true );
185 193
 		wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false );
186 194
 		glsr()->render( 'partials/editor/metabox-assigned-to', [
@@ -195,7 +203,9 @@  discard block
 block discarded – undo
195 203
 	 */
196 204
 	public function renderDetailsMetaBox( WP_Post $post )
197 205
 	{
198
-		if( !$this->isReviewPostType( $post ))return;
206
+		if( !$this->isReviewPostType( $post )) {
207
+			return;
208
+		}
199 209
 		$review = glsr( ReviewManager::class )->single( $post );
200 210
 		glsr()->render( 'partials/editor/metabox-details', [
201 211
 			'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ),
@@ -209,7 +219,9 @@  discard block
 block discarded – undo
209 219
 	 */
210 220
 	public function renderPinnedInPublishMetaBox()
211 221
 	{
212
-		if( !$this->isReviewPostType( get_post() ))return;
222
+		if( !$this->isReviewPostType( get_post() )) {
223
+			return;
224
+		}
213 225
 		glsr( Html::class )->renderTemplate( 'partials/editor/pinned', [
214 226
 			'context' => [
215 227
 				'no' => __( 'No', 'site-reviews' ),
@@ -225,7 +237,9 @@  discard block
 block discarded – undo
225 237
 	 */
226 238
 	public function renderResponseMetaBox( WP_Post $post )
227 239
 	{
228
-		if( !$this->isReviewPostType( $post ))return;
240
+		if( !$this->isReviewPostType( $post )) {
241
+			return;
242
+		}
229 243
 		wp_nonce_field( 'response', '_nonce-response', false );
230 244
 		glsr()->render( 'partials/editor/metabox-response', [
231 245
 			'response' => get_post_meta( $post->ID, 'response', true ),
@@ -239,7 +253,9 @@  discard block
 block discarded – undo
239 253
 	 */
240 254
 	public function renderTaxonomyMetabox( WP_Post $post )
241 255
 	{
242
-		if( !$this->isReviewPostType( $post ))return;
256
+		if( !$this->isReviewPostType( $post )) {
257
+			return;
258
+		}
243 259
 		glsr()->render( 'partials/editor/metabox-categories', [
244 260
 			'post' => $post,
245 261
 			'tax_name' => Application::TAXONOMY,
@@ -277,7 +293,9 @@  discard block
 block discarded – undo
277 293
 	protected function buildAssignedToTemplate( $assignedTo, WP_Post $post )
278 294
 	{
279 295
 		$assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo );
280
-		if( !( $assignedPost instanceof WP_Post ))return;
296
+		if( !( $assignedPost instanceof WP_Post )) {
297
+			return;
298
+		}
281 299
 		return glsr( Html::class )->buildTemplate( 'partials/editor/assigned-post', [
282 300
 			'context' => [
283 301
 				'data.url' => (string)get_permalink( $assignedPost ),
@@ -318,7 +336,9 @@  discard block
 block discarded – undo
318 336
 	 */
319 337
 	protected function getReviewType( $review )
320 338
 	{
321
-		if( count( glsr()->reviewTypes ) < 2 )return;
339
+		if( count( glsr()->reviewTypes ) < 2 ) {
340
+			return;
341
+		}
322 342
 		$reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes )
323 343
 			? glsr()->reviewTypes[$review->review_type]
324 344
 			: __( 'Unknown', 'site-reviews' );
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController.php 1 patch
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 	{
55 55
 		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
56 56
 		foreach( $postTypeColumns as $key => &$value ) {
57
-			if( !array_key_exists( $key, $columns ) || !empty( $value ))continue;
57
+			if( !array_key_exists( $key, $columns ) || !empty( $value )) {
58
+				continue;
59
+			}
58 60
 			$value = $columns[$key];
59 61
 		}
60 62
 		if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) {
@@ -92,7 +94,8 @@  discard block
 block discarded – undo
92 94
 	 * @return array
93 95
 	 * @filter display_post_states
94 96
 	 */
95
-	public function filterPostStates( array $postStates, WP_Post $post ) {
97
+	public function filterPostStates( array $postStates, WP_Post $post )
98
+	{
96 99
 		if( $post->post_type == Application::POST_TYPE
97 100
 			&& array_key_exists( 'pending', $postStates )) {
98 101
 			$postStates['pending'] = __( 'Unapproved', 'site-reviews' );
@@ -137,7 +140,9 @@  discard block
 block discarded – undo
137 140
 		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
138 141
 		unset( $postTypeColumns['cb'] );
139 142
 		foreach( $postTypeColumns as $key => $value ) {
140
-			if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue;
143
+			if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) {
144
+				continue;
145
+			}
141 146
 			$columns[$key] = $key;
142 147
 		}
143 148
 		return $columns;
@@ -161,7 +166,9 @@  discard block
 block discarded – undo
161 166
 				'Pending' => __( 'Unapproved', 'site-reviews' ),
162 167
 			];
163 168
 			foreach( $strings as $search => $replace ) {
164
-				if( strpos( $single, $search ) === false )continue;
169
+				if( strpos( $single, $search ) === false ) {
170
+					continue;
171
+				}
165 172
 				$translation = $this->getTranslation([
166 173
 					'number' => $number,
167 174
 					'plural' => str_replace( $search, $replace, $plural ),
@@ -213,7 +220,9 @@  discard block
 block discarded – undo
213 220
 	 */
214 221
 	public function saveBulkEditFields( $postId )
215 222
 	{
216
-		if( !current_user_can( 'edit_posts' ))return;
223
+		if( !current_user_can( 'edit_posts' )) {
224
+			return;
225
+		}
217 226
 		$assignedTo = filter_input( INPUT_GET, 'assigned_to' );
218 227
 		if( $assignedTo && get_post( $assignedTo )) {
219 228
 			update_post_meta( $postId, 'assigned_to', $assignedTo );
@@ -226,7 +235,9 @@  discard block
 block discarded – undo
226 235
 	 */
227 236
 	public function setQueryForColumn( WP_Query $query )
228 237
 	{
229
-		if( !$this->hasPermission( $query ))return;
238
+		if( !$this->hasPermission( $query )) {
239
+			return;
240
+		}
230 241
 		$this->setMetaQuery( $query, [
231 242
 			'rating', 'review_type',
232 243
 		]);
@@ -298,7 +309,9 @@  discard block
 block discarded – undo
298 309
 	protected function setMetaQuery( WP_Query $query, array $metaKeys )
299 310
 	{
300 311
 		foreach( $metaKeys as $key ) {
301
-			if( !( $value = filter_input( INPUT_GET, $key )))continue;
312
+			if( !( $value = filter_input( INPUT_GET, $key ))) {
313
+				continue;
314
+			}
302 315
 			$metaQuery = (array)$query->get( 'meta_query' );
303 316
 			$metaQuery[] = [
304 317
 				'key' => $key,
Please login to merge, or discard this patch.
plugin/Controllers/EditorController/Metaboxes.php 1 patch
Braces   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 	public function onBeforeUpdateReview( WP_Post $review, $metaKey, $metaValue )
24 24
 	{
25 25
 		$previousValue = get_post_meta( $review->ID, $metaKey, true );
26
-		if( $previousValue == $metaValue )return;
26
+		if( $previousValue == $metaValue ) {
27
+			return;
28
+		}
27 29
 		$this->decreaseReviewCount( $review );
28 30
 		$this->increaseReviewCount( $review, [$metaKey => $metaValue] );
29 31
 	}
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
 	 */
37 39
 	public function onCreateReview( $postData, $meta, $postId )
38 40
 	{
39
-		if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return;
41
+		if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) {
42
+			return;
43
+		}
40 44
 		$review = get_post( $postId );
41 45
 		$this->updateAssignedToPost( $review );
42 46
 		$this->increaseReviewCount( $review );
@@ -48,7 +52,9 @@  discard block
 block discarded – undo
48 52
 	 */
49 53
 	public function onDeleteReview( $postId )
50 54
 	{
51
-		if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return;
55
+		if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) {
56
+			return;
57
+		}
52 58
 		$review = get_post( $postId );
53 59
 		$review->post_status = 'deleted'; // important to change the post_status here first!
54 60
 		$this->updateAssignedToPost( $review );
@@ -85,7 +91,9 @@  discard block
 block discarded – undo
85 91
 	 */
86 92
 	public function saveAssignedToMetabox( $postId )
87 93
 	{
88
-		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return;
94
+		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) {
95
+			return;
96
+		}
89 97
 		$assignedTo = glsr( Helper::class )->filterInput( 'assigned_to' );
90 98
 		$assignedTo || $assignedTo = '';
91 99
 		if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) {
@@ -100,7 +108,9 @@  discard block
 block discarded – undo
100 108
 	 */
101 109
 	public function saveResponseMetabox( $postId )
102 110
 	{
103
-		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return;
111
+		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) {
112
+			return;
113
+		}
104 114
 		$response = glsr( Helper::class )->filterInput( 'response' );
105 115
 		$response || $response = '';
106 116
 		update_post_meta( $postId, 'response', trim( wp_kses( $response, [
@@ -134,10 +144,14 @@  discard block
 block discarded – undo
134 144
 		]);
135 145
 		if( !in_array( $meta['review_type'], glsr()->reviewTypes )
136 146
 			|| intval( $meta['rating'] ) > Rating::MAX_RATING
137
-		)return;
147
+		) {
148
+			return;
149
+		}
138 150
 		$counts = glsr( OptionManager::class )->get( 'counts.'.$meta['review_type'], [] );
139 151
 		foreach( range( 0, Rating::MAX_RATING ) as $rating ) {
140
-			if( isset( $counts[$rating] ))continue;
152
+			if( isset( $counts[$rating] )) {
153
+				continue;
154
+			}
141 155
 			$counts[$rating] = 0;
142 156
 		}
143 157
 		ksort( $counts );
@@ -150,7 +164,9 @@  discard block
 block discarded – undo
150 164
 	protected function setReviewCounts( WP_Post $review, array $counts )
151 165
 	{
152 166
 		$type = get_post_meta( $review->ID, 'review_type', true );
153
-		if( !in_array( $type, glsr()->reviewTypes ))return;
167
+		if( !in_array( $type, glsr()->reviewTypes )) {
168
+			return;
169
+		}
154 170
 		glsr( OptionManager::class )->set( 'counts.'.$type, $counts );
155 171
 	}
156 172
 
@@ -197,9 +213,13 @@  discard block
 block discarded – undo
197 213
 	 */
198 214
 	protected function updateAssignedToPost( WP_Post $review )
199 215
 	{
200
-		if( !( $postId = $this->getAssignedToPostId( $review->ID )))return;
216
+		if( !( $postId = $this->getAssignedToPostId( $review->ID ))) {
217
+			return;
218
+		}
201 219
 		$reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ));
202
-		if( empty( $reviewIds ))return;
220
+		if( empty( $reviewIds )) {
221
+			return;
222
+		}
203 223
 		$this->updateReviewIdOfPost( $postId, $review, $reviewIds );
204 224
 		$updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ));
205 225
 		if( empty( $updatedReviewIds )) {
Please login to merge, or discard this patch.
helpers.php 1 patch
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,7 +4,8 @@  discard block
 block discarded – undo
4 4
 /**
5 5
  * @return mixed
6 6
  */
7
-function glsr( $alias = null ) {
7
+function glsr( $alias = null )
8
+{
8 9
 	$app = \GeminiLabs\SiteReviews\Application::load();
9 10
 	return !empty( $alias )
10 11
 		? $app->make( $alias )
@@ -14,7 +15,8 @@  discard block
 block discarded – undo
14 15
 /**
15 16
  * @return \WP_Screen|object
16 17
  */
17
-function glsr_current_screen() {
18
+function glsr_current_screen()
19
+{
18 20
 	if( function_exists( 'get_current_screen' )) {
19 21
 		$screen = get_current_screen();
20 22
 	}
@@ -26,7 +28,8 @@  discard block
 block discarded – undo
26 28
 /**
27 29
  * @return \GeminiLabs\SiteReviews\Database
28 30
  */
29
-function glsr_db() {
31
+function glsr_db()
32
+{
30 33
 	return glsr( 'Database' );
31 34
 }
32 35
 
@@ -34,7 +37,8 @@  discard block
 block discarded – undo
34 37
  * @param mixed ...$vars
35 38
  * @return void
36 39
  */
37
-function glsr_debug( ...$vars ) {
40
+function glsr_debug( ...$vars )
41
+{
38 42
 	if( count( $vars ) == 1 ) {
39 43
 		$value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' );
40 44
 		printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value );
@@ -51,7 +55,8 @@  discard block
 block discarded – undo
51 55
 /**
52 56
  * @return \GeminiLabs\SiteReviews\Modules\Console
53 57
  */
54
-function glsr_log() {
58
+function glsr_log()
59
+{
55 60
 	$args = func_get_args();
56 61
 	$context = isset( $args[1] )
57 62
 		? $args[1]
@@ -67,14 +72,16 @@  discard block
 block discarded – undo
67 72
  * @param mixed $fallback
68 73
  * @return string|array
69 74
  */
70
-function glsr_get_option( $path = '', $fallback = '' ) {
75
+function glsr_get_option( $path = '', $fallback = '' )
76
+{
71 77
 	return glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback );
72 78
 }
73 79
 
74 80
 /**
75 81
  * @return array
76 82
  */
77
-function glsr_get_options() {
83
+function glsr_get_options()
84
+{
78 85
 	return glsr( 'Database\OptionManager' )->get( 'settings' );
79 86
 }
80 87
 
@@ -82,7 +89,8 @@  discard block
 block discarded – undo
82 89
  * @param int $post_id
83 90
  * @return void|\GeminiLabs\SiteReviews\Review
84 91
  */
85
-function glsr_get_review( $post_id ) {
92
+function glsr_get_review( $post_id )
93
+{
86 94
 	$post = get_post( $post_id );
87 95
 	if( $post instanceof WP_Post ) {
88 96
 		return glsr( 'Database\ReviewManager' )->single( $post );
@@ -93,6 +101,7 @@  discard block
 block discarded – undo
93 101
  * @return array
94 102
  * @todo document change of $reviews->reviews to $reviews->results
95 103
  */
96
-function glsr_get_reviews( array $args = array() ) {
104
+function glsr_get_reviews( array $args = array() )
105
+{
97 106
 	return glsr( 'Database\ReviewManager' )->get( $args );
98 107
 }
Please login to merge, or discard this patch.