Passed
Push — master ( 9e5df1...156e0e )
by Paul
05:18
created
plugin/Database.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 		if( empty( $assignedTo )) {
24 24
 			$assignedTo = get_post_meta( $postId, 'assigned_to', true );
25 25
 		}
26
-		if( empty( $assignedTo ))return;
26
+		if( empty( $assignedTo )) {
27
+			return;
28
+		}
27 29
 		$assignedPost = get_post( $assignedTo );
28 30
 		if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) {
29 31
 			return $assignedPost;
@@ -112,7 +114,9 @@  discard block
 block discarded – undo
112 114
 		add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 );
113 115
 		$search = new WP_Query( $args );
114 116
 		remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 );
115
-		if( !$search->have_posts() )return;
117
+		if( !$search->have_posts() ) {
118
+			return;
119
+		}
116 120
 		$results = '';
117 121
 		while( $search->have_posts() ) {
118 122
 			$search->the_post();
Please login to merge, or discard this patch.
plugin/Modules/Html/Builder.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -81,7 +81,9 @@  discard block
 block discarded – undo
81 81
 		];
82 82
 		if( !isset( $properties[$property] )
83 83
 			|| empty( array_filter( [$value], $properties[$property] ))
84
-		)return;
84
+		) {
85
+			return;
86
+		}
85 87
 		$this->$property = $value;
86 88
 	}
87 89
 
@@ -90,7 +92,9 @@  discard block
 block discarded – undo
90 92
 	 */
91 93
 	public function getClosingTag()
92 94
 	{
93
-		if( empty( $this->tag ))return;
95
+		if( empty( $this->tag )) {
96
+			return;
97
+		}
94 98
 		return '</'.$this->tag.'>';
95 99
 	}
96 100
 
@@ -99,7 +103,9 @@  discard block
 block discarded – undo
99 103
 	 */
100 104
 	public function getOpeningTag()
101 105
 	{
102
-		if( empty( $this->tag ))return;
106
+		if( empty( $this->tag )) {
107
+			return;
108
+		}
103 109
 		$attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString();
104 110
 		return '<'.trim( $this->tag.' '.$attributes ).'>';
105 111
 	}
@@ -141,7 +147,9 @@  discard block
 block discarded – undo
141 147
 	 */
142 148
 	protected function buildFieldDescription()
143 149
 	{
144
-		if( empty( $this->args['description'] ))return;
150
+		if( empty( $this->args['description'] )) {
151
+			return;
152
+		}
145 153
 		if( $this->args['is_widget'] ) {
146 154
 			return $this->small( $this->args['description'] );
147 155
 		}
@@ -207,7 +215,9 @@  discard block
 block discarded – undo
207 215
 	 */
208 216
 	protected function buildFormLabel( array $customArgs = [] )
209 217
 	{
210
-		if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return;
218
+		if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' ) {
219
+			return;
220
+		}
211 221
 		return $this->label( wp_parse_args( $customArgs, [
212 222
 			'for' => $this->args['id'],
213 223
 			'is_public' => $this->args['is_public'],
Please login to merge, or discard this patch.
compatibility.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,6 +17,8 @@
 block discarded – undo
17 17
  * @return void
18 18
  */
19 19
 add_action( 'site-reviews/customize/divi', function( $instance ) {
20
-	if( $instance->tag != 'label' || $instance->args['type'] != 'checkbox' )return;
20
+	if( $instance->tag != 'label' || $instance->args['type'] != 'checkbox' ) {
21
+		return;
22
+	}
21 23
 	$instance->args['text'] = '<i></i>'.$instance->args['text'];
22 24
 });
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -88,7 +88,9 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function registerMetaBoxes( $postType )
90 90
 	{
91
-		if( $postType != Application::POST_TYPE )return;
91
+		if( $postType != Application::POST_TYPE ) {
92
+			return;
93
+		}
92 94
 		add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' );
93 95
 		add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' );
94 96
 		add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' );
@@ -118,7 +120,9 @@  discard block
 block discarded – undo
118 120
 	 */
119 121
 	public function renderAssignedToMetabox( WP_Post $post )
120 122
 	{
121
-		if( !$this->isReviewPostType( $post ))return;
123
+		if( !$this->isReviewPostType( $post )) {
124
+			return;
125
+		}
122 126
 		$assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true );
123 127
 		wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false );
124 128
 		glsr()->render( 'partials/editor/metabox-assigned-to', [
@@ -133,7 +137,9 @@  discard block
 block discarded – undo
133 137
 	 */
134 138
 	public function renderDetailsMetaBox( WP_Post $post )
135 139
 	{
136
-		if( !$this->isReviewPostType( $post ))return;
140
+		if( !$this->isReviewPostType( $post )) {
141
+			return;
142
+		}
137 143
 		$review = glsr( ReviewManager::class )->single( $post );
138 144
 		glsr()->render( 'partials/editor/metabox-details', [
139 145
 			'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ),
@@ -147,7 +153,9 @@  discard block
 block discarded – undo
147 153
 	 */
148 154
 	public function renderPinnedInPublishMetaBox()
149 155
 	{
150
-		if( !$this->isReviewPostType( get_post() ))return;
156
+		if( !$this->isReviewPostType( get_post() )) {
157
+			return;
158
+		}
151 159
 		glsr( Html::class )->renderTemplate( 'partials/editor/pinned', [
152 160
 			'context' => [
153 161
 				'no' => __( 'No', 'site-reviews' ),
@@ -163,7 +171,9 @@  discard block
 block discarded – undo
163 171
 	 */
164 172
 	public function renderResponseMetaBox( WP_Post $post )
165 173
 	{
166
-		if( !$this->isReviewPostType( $post ))return;
174
+		if( !$this->isReviewPostType( $post )) {
175
+			return;
176
+		}
167 177
 		wp_nonce_field( 'response', '_nonce-response', false );
168 178
 		glsr()->render( 'partials/editor/metabox-response', [
169 179
 			'response' => get_post_meta( $post->ID, 'response', true ),
@@ -177,7 +187,9 @@  discard block
 block discarded – undo
177 187
 	 */
178 188
 	public function renderTaxonomyMetabox( WP_Post $post )
179 189
 	{
180
-		if( !$this->isReviewPostType( $post ))return;
190
+		if( !$this->isReviewPostType( $post )) {
191
+			return;
192
+		}
181 193
 		glsr()->render( 'partials/editor/metabox-categories', [
182 194
 			'post' => $post,
183 195
 			'tax_name' => Application::TAXONOMY,
@@ -215,7 +227,9 @@  discard block
 block discarded – undo
215 227
 	protected function buildAssignedToTemplate( $assignedTo, WP_Post $post )
216 228
 	{
217 229
 		$assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo );
218
-		if( !( $assignedPost instanceof WP_Post ))return;
230
+		if( !( $assignedPost instanceof WP_Post )) {
231
+			return;
232
+		}
219 233
 		return glsr( Html::class )->buildTemplate( 'partials/editor/assigned-post', [
220 234
 			'context' => [
221 235
 				'data.url' => (string)get_permalink( $assignedPost ),
@@ -256,7 +270,9 @@  discard block
 block discarded – undo
256 270
 	 */
257 271
 	protected function getReviewType( $review )
258 272
 	{
259
-		if( count( glsr()->reviewTypes ) < 2 )return;
273
+		if( count( glsr()->reviewTypes ) < 2 ) {
274
+			return;
275
+		}
260 276
 		$reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes )
261 277
 			? glsr()->reviewTypes[$review->review_type]
262 278
 			: __( 'Unknown', 'site-reviews' );
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/Controllers/EditorController/Metaboxes.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	public function saveAssignedToMetabox( $postId )
15 15
 	{
16
-		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return;
16
+		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) {
17
+			return;
18
+		}
17 19
 		$assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' ));
18 20
 		if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) {
19 21
 			$review = glsr( ReviewManager::class )->single( get_post( $postId ));
@@ -28,7 +30,9 @@  discard block
 block discarded – undo
28 30
 	 */
29 31
 	public function saveResponseMetabox( $postId )
30 32
 	{
31
-		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return;
33
+		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) {
34
+			return;
35
+		}
32 36
 		$response = strval( glsr( Helper::class )->filterInput( 'response' ));
33 37
 		update_post_meta( $postId, 'response', trim( wp_kses( $response, [
34 38
 			'a' => ['href' => [], 'title' => []],
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 1 patch
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -73,7 +73,9 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function decreasePostCounts( Review $review )
75 75
 	{
76
-		if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return;
76
+		if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) {
77
+			return;
78
+		}
77 79
 		$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
78 80
 		$this->setPostCounts( $review->assigned_to, $counts );
79 81
 	}
@@ -84,7 +86,9 @@  discard block
 block discarded – undo
84 86
 	public function decreaseTermCounts( Review $review )
85 87
 	{
86 88
 		foreach( $review->term_ids as $termId ) {
87
-			if( empty( $counts = $this->getTermCounts( $termId )))continue;
89
+			if( empty( $counts = $this->getTermCounts( $termId ))) {
90
+				continue;
91
+			}
88 92
 			$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
89 93
 			$this->setTermCounts( $termId, $counts );
90 94
 		}
@@ -106,7 +110,9 @@  discard block
 block discarded – undo
106 110
 			'min' => Rating::MIN_RATING,
107 111
 		]);
108 112
 		foreach( $counts as $index => &$num ) {
109
-			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue;
113
+			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) {
114
+				continue;
115
+			}
110 116
 			$num = 0;
111 117
 		}
112 118
 		return $counts;
@@ -191,7 +197,9 @@  discard block
 block discarded – undo
191 197
 	 */
192 198
 	public function increasePostCounts( Review $review )
193 199
 	{
194
-		if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return;
200
+		if( !( get_post( $review->assigned_to ) instanceof WP_Post )) {
201
+			return;
202
+		}
195 203
 		$counts = $this->getPostCounts( $review->assigned_to );
196 204
 		$counts = empty( $counts )
197 205
 			? $this->buildPostCounts( $review->assigned_to )
@@ -240,7 +248,9 @@  discard block
 block discarded – undo
240 248
 	 */
241 249
 	public function setTermCounts( $termId, array $reviewCounts )
242 250
 	{
243
-		if( !term_exists( $termId ))return;
251
+		if( !term_exists( $termId )) {
252
+			return;
253
+		}
244 254
 		$ratingCounts = glsr( CountsManager::class )->flatten( $reviewCounts );
245 255
 		update_term_meta( $termId, static::META_COUNT, $reviewCounts );
246 256
 		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
@@ -258,7 +268,9 @@  discard block
 block discarded – undo
258 268
 		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) {
259 269
 			$types = array_keys( array_flip( array_column( $reviews, 'type' )));
260 270
 			foreach( $types as $type ) {
261
-				if( isset( $counts[$type] ))continue;
271
+				if( isset( $counts[$type] )) {
272
+					continue;
273
+				}
262 274
 				$counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 );
263 275
 			}
264 276
 			foreach( $reviews as $review ) {
@@ -307,7 +319,9 @@  discard block
 block discarded – undo
307 319
 	{
308 320
 		foreach( $reviewCounts as &$counts ) {
309 321
 			foreach( range( 0, Rating::MAX_RATING ) as $index ) {
310
-				if( isset( $counts[$index] ))continue;
322
+				if( isset( $counts[$index] )) {
323
+					continue;
324
+				}
311 325
 				$counts[$index] = 0;
312 326
 			}
313 327
 			ksort( $counts );
Please login to merge, or discard this patch.
plugin/Database/ReviewManager.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -111,7 +111,9 @@  discard block
 block discarded – undo
111 111
 		$termIds = array_filter( array_map( 'trim', explode( ',', $commaSeparatedTermIds )));
112 112
 		foreach( $termIds as $termId ) {
113 113
 			$term = get_term( $termId, Application::TAXONOMY );
114
-			if( !isset( $term->term_id ))continue;
114
+			if( !isset( $term->term_id )) {
115
+				continue;
116
+			}
115 117
 			$terms[] = $term->term_id;
116 118
 		}
117 119
 		return $terms;
@@ -123,7 +125,9 @@  discard block
 block discarded – undo
123 125
 	 */
124 126
 	public function revert( $postId )
125 127
 	{
126
-		if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return;
128
+		if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) {
129
+			return;
130
+		}
127 131
 		delete_post_meta( $postId, '_edit_last' );
128 132
 		$result = wp_update_post([
129 133
 			'ID' => $postId,
@@ -141,7 +145,9 @@  discard block
 block discarded – undo
141 145
 	 */
142 146
 	public function single( WP_Post $post )
143 147
 	{
144
-		if( $post->post_type != Application::POST_TYPE )return;
148
+		if( $post->post_type != Application::POST_TYPE ) {
149
+			return;
150
+		}
145 151
 		$review = new Review( $post );
146 152
 		return apply_filters( 'site-reviews/get/review', $review, $post );
147 153
 	}
@@ -166,7 +172,9 @@  discard block
 block discarded – undo
166 172
 	protected function setTerms( $postId, $termIds )
167 173
 	{
168 174
 		$terms = $this->normalizeTerms( $termIds );
169
-		if( empty( $terms ))return;
175
+		if( empty( $terms )) {
176
+			return;
177
+		}
170 178
 		$result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY );
171 179
 		if( is_wp_error( $result )) {
172 180
 			glsr_log()->error( $result->get_error_message() );
Please login to merge, or discard this patch.
plugin/Controllers/ReviewController.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 	{
26 26
 		sort( $termIds );
27 27
 		sort( $oldTermIds );
28
-		if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ))return;
28
+		if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId )) {
29
+			return;
30
+		}
29 31
 		$review = glsr( ReviewManager::class )->single( get_post( $postId ));
30 32
 		$ignoredTerms = array_intersect( $oldTermIds, $termIds );
31 33
 		if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms )) {
@@ -45,7 +47,9 @@  discard block
 block discarded – undo
45 47
 	 */
46 48
 	public function onAfterCreate( $postData, $meta, $postId )
47 49
 	{
48
-		if( !$this->isReviewPostId( $postId ))return;
50
+		if( !$this->isReviewPostId( $postId )) {
51
+			return;
52
+		}
49 53
 		$review = glsr( ReviewManager::class )->single( get_post( $postId ));
50 54
 		glsr( CountsManager::class )->increase( $review );
51 55
 	}
@@ -57,7 +61,9 @@  discard block
 block discarded – undo
57 61
 	 */
58 62
 	public function onBeforeDelete( $postId )
59 63
 	{
60
-		if( !$this->isReviewPostId( $postId ))return;
64
+		if( !$this->isReviewPostId( $postId )) {
65
+			return;
66
+		}
61 67
 		$review = glsr( ReviewManager::class )->single( get_post( $postId ));
62 68
 		glsr( CountsManager::class )->decrease( $review );
63 69
 	}
@@ -74,9 +80,13 @@  discard block
 block discarded – undo
74 80
 	{
75 81
 		if( !$this->isReviewPostId( $postId )
76 82
 			|| !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] )
77
-		)return;
83
+		) {
84
+			return;
85
+		}
78 86
 		$review = glsr( ReviewManager::class )->single( get_post( $postId ));
79
-		if( $review->$metaKey == $metaValue )return;
87
+		if( $review->$metaKey == $metaValue ) {
88
+			return;
89
+		}
80 90
 		$method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' );
81 91
 		call_user_func( [$this, $method], $review, $metaValue );
82 92
 	}
@@ -122,7 +132,9 @@  discard block
 block discarded – undo
122 132
 	 */
123 133
 	public function onChangeStatus( $newStatus, $oldStatus, WP_Post $post )
124 134
 	{
125
-		if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return;
135
+		if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) {
136
+			return;
137
+		}
126 138
 		$review = glsr( ReviewManager::class )->single( get_post( $post->ID ));
127 139
 		if( $post->post_status == 'publish' ) {
128 140
 			glsr( CountsManager::class )->increase( $review );
Please login to merge, or discard this patch.