Passed
Push — master ( 71fe18...341f99 )
by Paul
05:12
created
plugin/Router.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	public function routeAdminPostRequest()
18 18
 	{
19 19
 		$request = $this->getRequest();
20
-		if( !$this->isValidPostRequest( $request ))return;
20
+		if( !$this->isValidPostRequest( $request ) )return;
21 21
 		check_admin_referer( $request['action'] );
22 22
 		$this->routeRequest( 'admin', $request['action'], $request );
23 23
 	}
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	{
42 42
 		if( is_admin() )return;
43 43
 		$request = $this->getRequest();
44
-		if( !$this->isValidPostRequest( $request ))return;
45
-		if( !$this->isValidPublicNonce( $request ))return;
44
+		if( !$this->isValidPostRequest( $request ) )return;
45
+		if( !$this->isValidPublicNonce( $request ) )return;
46 46
 		$this->routeRequest( 'public', $request['action'], $request );
47 47
 	}
48 48
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	protected function checkAjaxNonce( array $request )
53 53
 	{
54 54
 		if( !is_user_logged_in() )return;
55
-		if( !isset( $request['nonce'] )) {
55
+		if( !isset($request['nonce']) ) {
56 56
 			$this->sendAjaxError( 'request is missing a nonce', $request );
57 57
 		}
58
-		if( !wp_verify_nonce( $request['nonce'], $request['action'] )) {
58
+		if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) {
59 59
 			$this->sendAjaxError( 'request failed the nonce check', $request, 403 );
60 60
 		}
61 61
 	}
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	protected function checkAjaxRequest( array $request )
67 67
 	{
68
-		if( !isset( $request['action'] )) {
68
+		if( !isset($request['action']) ) {
69 69
 			$this->sendAjaxError( 'request must include an action', $request );
70 70
 		}
71
-		if( empty( $request['ajax_request'] )) {
71
+		if( empty($request['ajax_request']) ) {
72 72
 			$this->sendAjaxError( 'request is invalid', $request );
73 73
 		}
74 74
 	}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	protected function isValidPostRequest( array $request = [] )
97 97
 	{
98
-		return !empty( $request['action'] ) && empty( $request['ajax_request'] );
98
+		return !empty($request['action']) && empty($request['ajax_request']);
99 99
 	}
100 100
 
101 101
 	/**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	protected function isValidPublicNonce( array $request )
105 105
 	{
106
-		if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] )) {
106
+		if( is_user_logged_in() && !wp_verify_nonce( $request['nonce'], $request['action'] ) ) {
107 107
 			glsr_log()->error( 'nonce check failed for public request' )->debug( $request );
108 108
 			return false;
109 109
 		}
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 	protected function routeRequest( $type, $action, array $request = [] )
119 119
 	{
120 120
 		$actionHook = 'site-reviews/route/'.$type.'/request';
121
-		$controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ));
121
+		$controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) );
122 122
 		$method = glsr( Helper::class )->buildMethodName( $action, 'router' );
123 123
 		$request = apply_filters( 'site-reviews/route/request', $request, $action, $type );
124 124
 		do_action( $actionHook, $action, $request );
125
-		if( is_callable( [$controller, $method] )) {
125
+		if( is_callable( [$controller, $method] ) ) {
126 126
 			call_user_func( [$controller, $method], $request );
127 127
 			return;
128 128
 		}
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 		glsr_log()->error( $error )->debug( $request );
142 142
 		glsr_log( $_POST );
143 143
 		glsr( Notice::class )->addError( __( 'There was an error (try refreshing the page).', 'site-reviews' ).' <code>'.$error.'</code>' );
144
-		wp_send_json_error([
144
+		wp_send_json_error( [
145 145
 			'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ),
146 146
 			'notices' => glsr( Notice::class )->get(),
147 147
 			'error' => $error,
148
-		]);
148
+		] );
149 149
 	}
150 150
 }
Please login to merge, or discard this patch.
plugin/Database/ReviewManager.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 			'post_type' => Application::POST_TYPE,
36 36
 		];
37 37
 		$postId = wp_insert_post( $post, true );
38
-		if( is_wp_error( $postId )) {
38
+		if( is_wp_error( $postId ) ) {
39 39
 			glsr_log()->error( $postId->get_error_message() )->debug( $post );
40 40
 			return false;
41 41
 		}
42 42
 		$this->setTerms( $postId, $command->category );
43 43
 		do_action( 'site-reviews/create/review', $post, $review, $postId );
44
-		return $this->single( get_post( $postId ));
44
+		return $this->single( get_post( $postId ) );
45 45
 	}
46 46
 
47 47
 	/**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function delete( $metaReviewId )
52 52
 	{
53
-		if( $postId = $this->getPostId( $metaReviewId )) {
53
+		if( $postId = $this->getPostId( $metaReviewId ) ) {
54 54
 			wp_delete_post( $postId, true );
55 55
 		}
56 56
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		$paged = glsr( QueryBuilder::class )->getPaged(
73 73
 			wp_validate_boolean( $args['pagination'] )
74 74
 		);
75
-		$reviews = new WP_Query([
75
+		$reviews = new WP_Query( [
76 76
 			'meta_key' => 'pinned',
77 77
 			'meta_query' => $metaQuery,
78 78
 			'offset' => $args['offset'],
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			'post_type' => Application::POST_TYPE,
86 86
 			'posts_per_page' => $args['count'],
87 87
 			'tax_query' => $taxQuery,
88
-		]);
88
+		] );
89 89
 		return (object)[
90 90
 			'results' => array_map( [$this, 'single'], $reviews->posts ),
91 91
 			'max_num_pages' => $reviews->max_num_pages,
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	public function normalizeTerms( $commaSeparatedTermIds )
109 109
 	{
110 110
 		$terms = [];
111
-		$termIds = array_filter( array_map( 'trim', explode( ',', $commaSeparatedTermIds )));
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) )continue;
115 115
 			$terms[] = $term->term_id;
116 116
 		}
117 117
 		return $terms;
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 	{
126 126
 		if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return;
127 127
 		delete_post_meta( $postId, '_edit_last' );
128
-		$result = wp_update_post([
128
+		$result = wp_update_post( [
129 129
 			'ID' => $postId,
130 130
 			'post_content' => get_post_meta( $postId, 'content', true ),
131 131
 			'post_date' => get_post_meta( $postId, 'date', true ),
132 132
 			'post_title' => get_post_meta( $postId, 'title', true ),
133
-		]);
134
-		if( is_wp_error( $result )) {
133
+		] );
134
+		if( is_wp_error( $result ) ) {
135 135
 			glsr_log()->error( $result->get_error_message() );
136 136
 		}
137 137
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	protected function getNewPostStatus( array $review, $isBlacklisted )
154 154
 	{
155 155
 		$requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' );
156
-		return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted )
156
+		return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted)
157 157
 			? 'pending'
158 158
 			: 'publish';
159 159
 	}
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 	protected function setTerms( $postId, $termIds )
167 167
 	{
168 168
 		$terms = $this->normalizeTerms( $termIds );
169
-		if( empty( $terms ))return;
169
+		if( empty($terms) )return;
170 170
 		$result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY );
171
-		if( is_wp_error( $result )) {
171
+		if( is_wp_error( $result ) ) {
172 172
 			glsr_log()->error( $result->get_error_message() );
173 173
 		}
174 174
 	}
Please login to merge, or discard this patch.