Passed
Push — master ( 6b8ca8...3384db )
by Paul
04:57
created
helpers.php 1 patch
Braces   +16 added lines, -8 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
@@ -15,7 +16,8 @@  discard block
 block discarded – undo
15 16
  * get_current_screen() is unreliable because it is not defined on all admin pages
16 17
  * @return \WP_Screen|object
17 18
  */
18
-function glsr_current_screen() {
19
+function glsr_current_screen()
20
+{
19 21
 	if( function_exists( 'get_current_screen' )) {
20 22
 		$screen = get_current_screen();
21 23
 	}
@@ -27,7 +29,8 @@  discard block
 block discarded – undo
27 29
 /**
28 30
  * @return \GeminiLabs\SiteReviews\Database
29 31
  */
30
-function glsr_db() {
32
+function glsr_db()
33
+{
31 34
 	return glsr( 'Database' );
32 35
 }
33 36
 
@@ -35,7 +38,8 @@  discard block
 block discarded – undo
35 38
  * @param mixed ...$vars
36 39
  * @return void
37 40
  */
38
-function glsr_debug( ...$vars ) {
41
+function glsr_debug( ...$vars )
42
+{
39 43
 	if( count( $vars ) == 1 ) {
40 44
 		$value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' );
41 45
 		printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value );
@@ -52,7 +56,8 @@  discard block
 block discarded – undo
52 56
 /**
53 57
  * @return \GeminiLabs\SiteReviews\Modules\Logger
54 58
  */
55
-function glsr_log() {
59
+function glsr_log()
60
+{
56 61
 	$args = func_get_args();
57 62
 	$context = isset( $args[1] )
58 63
 		? $args[1]
@@ -68,7 +73,8 @@  discard block
 block discarded – undo
68 73
  * @return void
69 74
  * @callback register_taxonomy() "meta_box_cb"
70 75
  */
71
-function glsr_categories_meta_box( $post, $box ) {
76
+function glsr_categories_meta_box( $post, $box )
77
+{
72 78
 	glsr( 'Controllers\EditorController' )->renderTaxonomyMetabox( $post, $box );
73 79
 }
74 80
 
@@ -77,14 +83,16 @@  discard block
 block discarded – undo
77 83
  * @param mixed $fallback
78 84
  * @return string|array
79 85
  */
80
-function glsr_get_option( $option_path = '', $fallback = '' ) {
86
+function glsr_get_option( $option_path = '', $fallback = '' )
87
+{
81 88
 	return glsr( 'Database\OptionManager' )->get( 'settings.'.$option_path, $fallback );
82 89
 }
83 90
 
84 91
 /**
85 92
  * @return array
86 93
  */
87
-function glsr_get_options() {
94
+function glsr_get_options()
95
+{
88 96
 	return glsr( 'Database\OptionManager' )->get( 'settings' );
89 97
 }
90 98
 
Please login to merge, or discard this patch.
plugin/Database.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,7 +65,9 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function getReview( $post )
67 67
 	{
68
-		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return;
68
+		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) {
69
+			return;
70
+		}
69 71
 		$review = $this->getReviewMeta( $post->ID );
70 72
 		$modified = $this->isReviewModified( $review );
71 73
 		$review->content = $post->post_content;
@@ -239,7 +241,9 @@  discard block
 block discarded – undo
239 241
 		$termIds = array_map( 'trim', explode( ',', $termIds ));
240 242
 		foreach( $termIds as $termId ) {
241 243
 			$term = term_exists( $termId, Application::TAXONOMY );
242
-			if( !isset( $term['term_id'] ))continue;
244
+			if( !isset( $term['term_id'] )) {
245
+				continue;
246
+			}
243 247
 			$terms[] = intval( $term['term_id'] );
244 248
 		}
245 249
 		return $terms;
@@ -252,7 +256,9 @@  discard block
 block discarded – undo
252 256
 	public function revertReview( $postId )
253 257
 	{
254 258
 		$post = get_post( $postId );
255
-		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return;
259
+		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) {
260
+			return;
261
+		}
256 262
 		delete_post_meta( $post->ID, '_edit_last' );
257 263
 		return wp_update_post([
258 264
 			'ID' => $post->ID,
@@ -284,7 +290,9 @@  discard block
 block discarded – undo
284 290
 		add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 );
285 291
 		$search = new WP_Query( $args );
286 292
 		remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 );
287
-		if( !$search->have_posts() )return;
293
+		if( !$search->have_posts() ) {
294
+			return;
295
+		}
288 296
 		$results = '';
289 297
 		while( $search->have_posts() ) {
290 298
 			$search->the_post();
@@ -308,7 +316,9 @@  discard block
 block discarded – undo
308 316
 	public function setReviewMeta( $postId, $termIds )
309 317
 	{
310 318
 		$terms = $this->normalizeTerms( $termIds );
311
-		if( empty( $terms ))return;
319
+		if( empty( $terms )) {
320
+			return;
321
+		}
312 322
 		$result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY );
313 323
 		if( is_wp_error( $result )) {
314 324
 			glsr_log()->error( '['.__METHOD__.'] '.$result->get_error_message() );
Please login to merge, or discard this patch.
plugin/Router.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 	public function routeAdminPostRequest()
17 17
 	{
18 18
 		$request = filter_input( INPUT_POST, Application::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
19
-		if( !isset( $request['action'] ))return;
19
+		if( !isset( $request['action'] )) {
20
+			return;
21
+		}
20 22
 		$this->checkNonce( $request['action'] );
21 23
 		switch( $request['action'] ) {
22 24
 			case 'clear-log':
@@ -75,7 +77,9 @@  discard block
 block discarded – undo
75 77
 	public function routeWebhookRequest()
76 78
 	{
77 79
 		$request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID ));
78
-		if( !$request )return;
80
+		if( !$request ) {
81
+			return;
82
+		}
79 83
 		// @todo manage webhook here
80 84
 	}
81 85
 
Please login to merge, or discard this patch.
plugin/Shortcodes/ButtonGenerator.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,9 +57,13 @@  discard block
 block discarded – undo
57 57
 	protected function generateFields( array $fields )
58 58
 	{
59 59
 		$generatedFields = array_map( function( $field ) {
60
-			if( empty( $field ))return;
60
+			if( empty( $field )) {
61
+				return;
62
+			}
61 63
 			$field = $this->normalize( $field );
62
-			if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return;
64
+			if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ))) {
65
+				return;
66
+			}
63 67
 			return $this->$method( $field );
64 68
 		}, $fields );
65 69
 		return array_values( array_filter( $generatedFields ));
@@ -74,7 +78,9 @@  discard block
 block discarded – undo
74 78
 		if( !empty( $this->errors )) {
75 79
 			$errors = [];
76 80
 			foreach( $this->required as $name => $alert ) {
77
-				if( false !== array_search( $name, array_column( $fields, 'name' )))continue;
81
+				if( false !== array_search( $name, array_column( $fields, 'name' ))) {
82
+					continue;
83
+				}
78 84
 				$errors[] = $this->errors[$name];
79 85
 			}
80 86
 			$this->errors = $errors;
@@ -118,7 +124,9 @@  discard block
 block discarded – undo
118 124
 	 */
119 125
 	protected function normalizeContainer( array $field )
120 126
 	{
121
-		if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return;
127
+		if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field )) {
128
+			return;
129
+		}
122 130
 		$field['items'] = $this->generateFields( $field['items'] );
123 131
 		return $field;
124 132
 	}
@@ -128,7 +136,9 @@  discard block
 block discarded – undo
128 136
 	 */
129 137
 	protected function normalizeField( array $field, array $defaults )
130 138
 	{
131
-		if( !$this->validate( $field ))return;
139
+		if( !$this->validate( $field )) {
140
+			return;
141
+		}
132 142
 		return array_filter( shortcode_atts( $defaults, $field ), function( $value ) {
133 143
 			return $value !== '';
134 144
 		});
@@ -149,7 +159,9 @@  discard block
 block discarded – undo
149 159
 			'type' => '',
150 160
 			'value' => '',
151 161
 		]);
152
-		if( !$listbox )return;
162
+		if( !$listbox ) {
163
+			return;
164
+		}
153 165
 		if( !array_key_exists( '', $listbox['options'] )) {
154 166
 			$listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options'];
155 167
 		}
Please login to merge, or discard this patch.
plugin/Handlers/SubmitReview.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,9 @@
 block discarded – undo
113 113
 	protected function sendNotification( $post_id, Command $command )
114 114
 	{
115 115
 		$notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' );
116
-		if( !in_array( $notificationType, ['default','custom','webhook'] ))return;
116
+		if( !in_array( $notificationType, ['default','custom','webhook'] )) {
117
+			return;
118
+		}
117 119
 		$assignedToTitle = get_the_title( (int) $command->assignedTo );
118 120
 		$notificationSubject = _nx(
119 121
 			'New %s-star review',
Please login to merge, or discard this patch.
plugin/Filters.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,8 @@
 block discarded – undo
22 22
 	// protected $public;
23 23
 	// protected $translator;
24 24
 
25
-	public function __construct( Application $app ) {
25
+	public function __construct( Application $app )
26
+	{
26 27
 		$this->app = $app;
27 28
 		$this->admin = $app->make( AdminController::class );
28 29
 		$this->basename = plugin_basename( $app->file );
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 1 patch
Braces   +39 added lines, -13 removed lines patch added patch discarded remove patch
@@ -85,7 +85,9 @@  discard block
 block discarded – undo
85 85
 				'Save as Pending' => __( 'Save as Unapproved', 'site-reviews' ),
86 86
 			];
87 87
 			foreach( $replacements as $search => $replacement ) {
88
-				if( $translation != $search )continue;
88
+				if( $translation != $search ) {
89
+					continue;
90
+				}
89 91
 				$translation = $replacement;
90 92
 			}
91 93
 		}
@@ -111,7 +113,9 @@  discard block
 block discarded – undo
111 113
 	public function filterUpdateMessages( array $messages )
112 114
 	{
113 115
 		$post = get_post();
114
-		if( !( $post instanceof WP_Post ))return;
116
+		if( !( $post instanceof WP_Post )) {
117
+			return;
118
+		}
115 119
 		$strings = glsr( Strings::class )->post_updated_messages();
116 120
 		$restored = filter_input( INPUT_GET, 'revision' );
117 121
 		if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) {
@@ -142,7 +146,9 @@  discard block
 block discarded – undo
142 146
 	 */
143 147
 	public function onCreateReview( $postData, $meta, $postId )
144 148
 	{
145
-		if( !$this->isReviewPostType( $review = get_post( $postId )))return;
149
+		if( !$this->isReviewPostType( $review = get_post( $postId ))) {
150
+			return;
151
+		}
146 152
 		$this->updateAssignedToPost( $review );
147 153
 	}
148 154
 
@@ -153,7 +159,9 @@  discard block
 block discarded – undo
153 159
 	 */
154 160
 	public function onDeleteReview( $postId )
155 161
 	{
156
-		if( !$this->isReviewPostType( $review = get_post( $postId )))return;
162
+		if( !$this->isReviewPostType( $review = get_post( $postId ))) {
163
+			return;
164
+		}
157 165
 		$review->post_status = 'deleted'; // important to change the post_status here first!
158 166
 		$this->updateAssignedToPost( $review );
159 167
 	}
@@ -175,7 +183,9 @@  discard block
 block discarded – undo
175 183
 	 */
176 184
 	public function registerMetaBoxes( $postType )
177 185
 	{
178
-		if( $postType != Application::POST_TYPE )return;
186
+		if( $postType != Application::POST_TYPE ) {
187
+			return;
188
+		}
179 189
 		add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' );
180 190
 		add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' );
181 191
 		add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' );
@@ -207,7 +217,9 @@  discard block
 block discarded – undo
207 217
 	 */
208 218
 	public function renderAssignedToMetabox( WP_Post $post )
209 219
 	{
210
-		if( !$this->isReviewPostType( $post ))return;
220
+		if( !$this->isReviewPostType( $post )) {
221
+			return;
222
+		}
211 223
 		$assignedTo = get_post_meta( $post->ID, 'assigned_to', true );
212 224
 		$template = '';
213 225
 		if( $assignedPost = get_post( $assignedTo )) {
@@ -233,7 +245,9 @@  discard block
 block discarded – undo
233 245
 	 */
234 246
 	public function renderDetailsMetaBox( WP_Post $post )
235 247
 	{
236
-		if( !$this->isReviewPostType( $post ))return;
248
+		if( !$this->isReviewPostType( $post )) {
249
+			return;
250
+		}
237 251
 		$review = glsr_db()->getReview( $post );
238 252
 		glsr()->render( 'edit/metabox-details', [
239 253
 			'button' => $this->getMetaboxButton( $review, $post ),
@@ -247,7 +261,9 @@  discard block
 block discarded – undo
247 261
 	 */
248 262
 	public function renderMetaBoxPinned()
249 263
 	{
250
-		if( !$this->isReviewPostType( get_post() ))return;
264
+		if( !$this->isReviewPostType( get_post() )) {
265
+			return;
266
+		}
251 267
 		$pinned = get_post_meta( get_the_ID(), 'pinned', true );
252 268
 		glsr()->render( 'edit/pinned', [
253 269
 			'pinned' => $pinned,
@@ -260,7 +276,9 @@  discard block
 block discarded – undo
260 276
 	 */
261 277
 	public function renderResponseMetaBox( WP_Post $post )
262 278
 	{
263
-		if( !$this->isReviewPostType( $post ))return;
279
+		if( !$this->isReviewPostType( $post )) {
280
+			return;
281
+		}
264 282
 		$review = glsr_db()->getReview( $post );
265 283
 		wp_nonce_field( 'response', '_nonce-response', false );
266 284
 		glsr()->render( 'edit/metabox-response', [
@@ -275,7 +293,9 @@  discard block
 block discarded – undo
275 293
 	 */
276 294
 	public function renderTaxonomyMetabox( WP_Post $post )
277 295
 	{
278
-		if( !$this->isReviewPostType( $post ))return;
296
+		if( !$this->isReviewPostType( $post )) {
297
+			return;
298
+		}
279 299
 		glsr()->render( 'edit/metabox-categories', [
280 300
 			'post' => $post,
281 301
 			'tax_name' => esc_attr( Application::TAXONOMY ),
@@ -471,7 +491,9 @@  discard block
 block discarded – undo
471 491
 	 */
472 492
 	protected function saveAssignedToMetabox( $postId )
473 493
 	{
474
-		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ))return;
494
+		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' )) {
495
+			return;
496
+		}
475 497
 		$assignedTo = filter_input( INPUT_POST, 'assigned_to' );
476 498
 		$assignedTo || $assignedTo = '';
477 499
 		if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) {
@@ -486,7 +508,9 @@  discard block
 block discarded – undo
486 508
 	 */
487 509
 	protected function saveResponseMetabox( $postId )
488 510
 	{
489
-		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ))return;
511
+		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' )) {
512
+			return;
513
+		}
490 514
 		$response = filter_input( INPUT_POST, 'response' );
491 515
 		$response || $response = '';
492 516
 		update_post_meta( $postId, 'response', trim( wp_kses( $response, [
@@ -501,7 +525,9 @@  discard block
 block discarded – undo
501 525
 	 */
502 526
 	protected function updateAssignedToPost( WP_Post $review )
503 527
 	{
504
-		if( !( $postId = $this->getAssignedToPostId( $review->ID )))return;
528
+		if( !( $postId = $this->getAssignedToPostId( $review->ID ))) {
529
+			return;
530
+		}
505 531
 		$reviewIds = get_post_meta( $postId, static::META_REVIEW_ID );
506 532
 		$updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ));
507 533
 		$this->updateReviewIdOfPost( $postId, $review, $reviewIds );
Please login to merge, or discard this patch.
plugin/Controllers/Controller.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@
 block discarded – undo
15 15
 	 */
16 16
 	public function download( $filename, $content )
17 17
 	{
18
-		if( !current_user_can( Application::CAPABILITY ))return;
18
+		if( !current_user_can( Application::CAPABILITY )) {
19
+			return;
20
+		}
19 21
 		nocache_headers();
20 22
 		header( 'Content-Type: text/plain' );
21 23
 		header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
Please login to merge, or discard this patch.
plugin/Actions.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@
 block discarded – undo
25 25
 	protected $router;
26 26
 	// protected $settings;
27 27
 
28
-	public function __construct( Application $app ) {
28
+	public function __construct( Application $app )
29
+	{
29 30
 		$this->app = $app;
30 31
 		$this->admin = $app->make( AdminController::class );
31 32
 		// $this->editor = $app->make( EditorController::class );
Please login to merge, or discard this patch.