Passed
Push — master ( ceec33...d1be46 )
by Paul
05:18
created
activate.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public static function isPhpValid( $version = '' )
34 34
 	{
35
-		if( !empty( $version )) {
36
-			static::normalize( array( 'php' => $version ));
35
+		if( !empty($version) ) {
36
+			static::normalize( array( 'php' => $version ) );
37 37
 		}
38 38
 		return !version_compare( PHP_VERSION, static::$versions->php, '<' );
39 39
 	}
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public static function isValid( array $args = array() )
45 45
 	{
46
-		if( !empty( $args )) {
46
+		if( !empty($args) ) {
47 47
 			static::normalize( $args );
48 48
 		}
49 49
 		return static::isPhpValid() && static::isWpValid();
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	public static function isWpValid( $version = '' )
57 57
 	{
58 58
 		global $wp_version;
59
-		if( !empty( $version )) {
60
-			static::normalize( array( 'wordpress' => $version ));
59
+		if( !empty($version) ) {
60
+			static::normalize( array( 'wordpress' => $version ) );
61 61
 		}
62 62
 		return !version_compare( $wp_version, static::$versions->wordpress, '<' );
63 63
 	}
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public static function shouldDeactivate( $file, array $args = array() )
70 70
 	{
71
-		if( empty( static::$instance )) {
71
+		if( empty(static::$instance) ) {
72 72
 			static::$file = realpath( $file );
73 73
 			static::$instance = new static;
74 74
 			static::$versions = static::normalize( $args );
75 75
 		}
76 76
 		if( !static::isValid() ) {
77
-			add_action( 'activated_plugin', array( static::$instance, 'deactivate' ));
78
-			add_action( 'admin_notices', array( static::$instance, 'deactivate' ));
77
+			add_action( 'activated_plugin', array( static::$instance, 'deactivate' ) );
78
+			add_action( 'admin_notices', array( static::$instance, 'deactivate' ) );
79 79
 			return true;
80 80
 		}
81 81
 		return false;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		return (object)wp_parse_args( $args, array(
106 106
 			'php' => static::MIN_PHP_VERSION,
107 107
 			'wordpress' => static::MIN_WORDPRESS_VERSION,
108
-		));
108
+		) );
109 109
 	}
110 110
 
111 111
 	/**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			filter_input( INPUT_GET, 'plugin_status' ),
118 118
 			filter_input( INPUT_GET, 'paged' ),
119 119
 			filter_input( INPUT_GET, 's' )
120
-		)));
120
+		) ) );
121 121
 		exit;
122 122
 	}
123 123
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,9 @@
 block discarded – undo
87 87
 	 */
88 88
 	public function deactivate( $plugin )
89 89
 	{
90
-		if( static::isValid() )return;
90
+		if( static::isValid() ) {
91
+			return;
92
+		}
91 93
 		$pluginSlug = plugin_basename( static::$file );
92 94
 		if( $plugin == $pluginSlug ) {
93 95
 			$this->redirect(); //exit
Please login to merge, or discard this patch.
plugin/Database.php 2 patches
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -67,7 +67,9 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function getReview( $post )
69 69
 	{
70
-		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return;
70
+		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) {
71
+			return;
72
+		}
71 73
 		$review = $this->getReviewMeta( $post->ID );
72 74
 		$modified = $this->isReviewModified( $post, $review );
73 75
 		$review->content = $post->post_content;
@@ -241,7 +243,9 @@  discard block
 block discarded – undo
241 243
 		$termIds = array_map( 'trim', explode( ',', $termIds ));
242 244
 		foreach( $termIds as $termId ) {
243 245
 			$term = term_exists( $termId, Application::TAXONOMY );
244
-			if( !isset( $term['term_id'] ))continue;
246
+			if( !isset( $term['term_id'] )) {
247
+				continue;
248
+			}
245 249
 			$terms[] = intval( $term['term_id'] );
246 250
 		}
247 251
 		return $terms;
@@ -254,7 +258,9 @@  discard block
 block discarded – undo
254 258
 	public function revertReview( $postId )
255 259
 	{
256 260
 		$post = get_post( $postId );
257
-		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return;
261
+		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) {
262
+			return;
263
+		}
258 264
 		delete_post_meta( $post->ID, '_edit_last' );
259 265
 		$result = wp_update_post([
260 266
 			'ID' => $post->ID,
@@ -289,7 +295,9 @@  discard block
 block discarded – undo
289 295
 		add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 );
290 296
 		$search = new WP_Query( $args );
291 297
 		remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 );
292
-		if( !$search->have_posts() )return;
298
+		if( !$search->have_posts() ) {
299
+			return;
300
+		}
293 301
 		$results = '';
294 302
 		while( $search->have_posts() ) {
295 303
 			$search->the_post();
@@ -313,7 +321,9 @@  discard block
 block discarded – undo
313 321
 	public function setReviewMeta( $postId, $termIds )
314 322
 	{
315 323
 		$terms = $this->normalizeTerms( $termIds );
316
-		if( empty( $terms ))return;
324
+		if( empty( $terms )) {
325
+			return;
326
+		}
317 327
 		$result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY );
318 328
 		if( is_wp_error( $result )) {
319 329
 			glsr_log()->error( $result->get_error_message() );
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 			'post_type' => Application::POST_TYPE,
36 36
 		];
37 37
 		if( $review['review_type'] == 'local' && (
38
-			glsr( OptionManager::class )->get( 'settings.general.require.approval' ) == 'yes' || $command->blacklisted )) {
38
+			glsr( OptionManager::class )->get( 'settings.general.require.approval' ) == 'yes' || $command->blacklisted ) ) {
39 39
 			$post['post_status'] = 'pending';
40 40
 		}
41 41
 		$postId = wp_insert_post( $post, true );
42
-		if( is_wp_error( $postId )) {
42
+		if( is_wp_error( $postId ) ) {
43 43
 			glsr_log()->error( $postId->get_error_message() );
44 44
 			return false;
45 45
 		}
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function deleteReview( $metaReviewId )
59 59
 	{
60
-		if( $postId = $this->getReviewPostId( $metaReviewId )) {
60
+		if( $postId = $this->getReviewPostId( $metaReviewId ) ) {
61 61
 			wp_delete_post( $postId, true );
62 62
 		}
63 63
 	}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function getReview( $post )
70 70
 	{
71
-		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return;
71
+		if( !($post instanceof WP_Post) || $post->post_type != Application::POST_TYPE )return;
72 72
 		$review = $this->getReviewMeta( $post->ID );
73 73
 		$modified = $this->isReviewModified( $post, $review );
74 74
 		$review->content = $post->post_content;
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
 	{
91 91
 		$metaKey = $this->normalizeMetaKey( $metaKey );
92 92
 		if( !$metaKey ) {
93
-			return (array) wp_count_posts( Application::POST_TYPE );
93
+			return (array)wp_count_posts( Application::POST_TYPE );
94 94
 		}
95 95
 		$counts = glsr( Cache::class )->getReviewCountsFor( $metaKey );
96 96
 		if( !$metaValue ) {
97 97
 			return $counts;
98 98
 		}
99
-		return isset( $counts[$metaValue] )
99
+		return isset($counts[$metaValue])
100 100
 			? $counts[$metaValue]
101 101
 			: 0;
102 102
 	}
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	public function getReviewMeta( $postId )
118 118
 	{
119 119
 		$meta = get_post_type( $postId ) == Application::POST_TYPE
120
-			? array_map( 'array_shift', (array) get_post_meta( $postId ))
120
+			? array_map( 'array_shift', (array)get_post_meta( $postId ) )
121 121
 			: [];
122
-		return (object) $this->normalizeMeta( array_filter( $meta, 'strlen' ));
122
+		return (object)$this->normalizeMeta( array_filter( $meta, 'strlen' ) );
123 123
 	}
124 124
 
125 125
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		$paged = glsr( QueryBuilder::class )->getPaged(
149 149
 			wp_validate_boolean( $args['pagination'] )
150 150
 		);
151
-		$reviews = new WP_Query([
151
+		$reviews = new WP_Query( [
152 152
 			'meta_key' => 'pinned',
153 153
 			'meta_query' => $metaQuery,
154 154
 			'offset' => $args['offset'],
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 			'post_type' => Application::POST_TYPE,
162 162
 			'posts_per_page' => $args['count'] ? $args['count'] : -1,
163 163
 			'tax_query' => $taxQuery,
164
-		]);
165
-		return (object) [
164
+		] );
165
+		return (object)[
166 166
 			'results' => array_map( [$this, 'getReview'], $reviews->posts ),
167 167
 			'max_num_pages' => $reviews->max_num_pages,
168 168
 		];
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	public function getReviewsMeta( $keys, $status = 'publish' )
177 177
 	{
178 178
 		$keys = array_map( [$this, 'normalizeMetaKey'], (array)$keys );
179
-		if( $status == 'all' || empty( $status )) {
179
+		if( $status == 'all' || empty($status) ) {
180 180
 			$status = get_post_stati( ['exclude_from_search' => false] );
181 181
 		}
182 182
 		return glsr( SqlQueries::class )->getReviewsMeta( $keys, $status );
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
 			'fields' => 'id=>name',
193 193
 			'hide_empty' => false,
194 194
 			'taxonomy' => Application::TAXONOMY,
195
-		]);
196
-		unset( $args['count'] ); //we don't want a term count
195
+		] );
196
+		unset($args['count']); //we don't want a term count
197 197
 		$terms = get_terms( $args );
198
-		if( is_wp_error( $terms )) {
198
+		if( is_wp_error( $terms ) ) {
199 199
 			glsr_log()->error( $terms->get_error_message() );
200 200
 			return [];
201 201
 		}
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	public function normalizeMeta( array $meta )
209 209
 	{
210
-		if( empty( $meta )) {
210
+		if( empty($meta) ) {
211 211
 			return [];
212 212
 		}
213 213
 		$defaults = wp_parse_args( $meta, [
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 			'date' => '',
216 216
 			'review_id' => '',
217 217
 			'review_type' => '',
218
-		]);
218
+		] );
219 219
 		return glsr( CreateReviewDefaults::class )->merge( $defaults, true );
220 220
 	}
221 221
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	public function normalizeMetaKey( $metaKey )
227 227
 	{
228 228
 		$metaKey = strtolower( $metaKey );
229
-		if( in_array( $metaKey, ['id', 'type'] )) {
229
+		if( in_array( $metaKey, ['id', 'type'] ) ) {
230 230
 			$metaKey = 'review_'.$metaKey;
231 231
 		}
232 232
 		return $metaKey;
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	public function normalizeTerms( $termIds )
240 240
 	{
241 241
 		$terms = [];
242
-		$termIds = array_map( 'trim', explode( ',', $termIds ));
242
+		$termIds = array_map( 'trim', explode( ',', $termIds ) );
243 243
 		foreach( $termIds as $termId ) {
244 244
 			$term = term_exists( $termId, Application::TAXONOMY );
245
-			if( !isset( $term['term_id'] ))continue;
245
+			if( !isset($term['term_id']) )continue;
246 246
 			$terms[] = intval( $term['term_id'] );
247 247
 		}
248 248
 		return $terms;
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
 	public function revertReview( $postId )
256 256
 	{
257 257
 		$post = get_post( $postId );
258
-		if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return;
258
+		if( !($post instanceof WP_Post) || $post->post_type != Application::POST_TYPE )return;
259 259
 		delete_post_meta( $post->ID, '_edit_last' );
260
-		$result = wp_update_post([
260
+		$result = wp_update_post( [
261 261
 			'ID' => $post->ID,
262 262
 			'post_content' => get_post_meta( $post->ID, 'content', true ),
263 263
 			'post_date' => get_post_meta( $post->ID, 'date', true ),
264 264
 			'post_title' => get_post_meta( $post->ID, 'title', true ),
265
-		]);
266
-		if( is_wp_error( $result )) {
265
+		] );
266
+		if( is_wp_error( $result ) ) {
267 267
 			glsr_log()->error( $result->get_error_message() );
268 268
 		}
269 269
 	}
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 			'post_status' => 'publish',
279 279
 			'post_type' => 'any',
280 280
 		];
281
-		if( is_numeric( $searchTerm )) {
281
+		if( is_numeric( $searchTerm ) ) {
282 282
 			$args['post__in'] = [$searchTerm];
283 283
 		}
284 284
 		else {
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 			ob_start();
298 298
 			glsr()->render( 'partials/editor/search-result', [
299 299
 				'ID' => get_the_ID(),
300
-				'permalink' => esc_url( (string) get_permalink() ),
300
+				'permalink' => esc_url( (string)get_permalink() ),
301 301
 				'title' => esc_attr( get_the_title() ),
302
-			]);
302
+			] );
303 303
 			$results .= ob_get_clean();
304 304
 		}
305 305
 		wp_reset_postdata();
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 	public function setReviewMeta( $postId, $termIds )
315 315
 	{
316 316
 		$terms = $this->normalizeTerms( $termIds );
317
-		if( empty( $terms ))return;
317
+		if( empty($terms) )return;
318 318
 		$result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY );
319
-		if( is_wp_error( $result )) {
319
+		if( is_wp_error( $result ) ) {
320 320
 			glsr_log()->error( $result->get_error_message() );
321 321
 		}
322 322
 	}
Please login to merge, or discard this patch.
plugin/Controllers/AjaxController.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	{
24 24
 		wp_send_json( glsr( Html::class )->renderPartial( 'link', [
25 25
 			'post_id' => $request['ID'],
26
-		]));
26
+		] ) );
27 27
 	}
28 28
 
29 29
 	/**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function changeReviewStatus( array $request )
33 33
 	{
34
-		wp_send_json( $this->execute( new ChangeStatus( $request )));
34
+		wp_send_json( $this->execute( new ChangeStatus( $request ) ) );
35 35
 	}
36 36
 
37 37
 	/**
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 	public function clearLog()
41 41
 	{
42 42
 		glsr( AdminController::class )->routerClearLog();
43
-		wp_send_json([
43
+		wp_send_json( [
44 44
 			'logger' => glsr( Logger::class )->get(),
45 45
 			'notices' => glsr( Notice::class )->get(),
46
-		]);
46
+		] );
47 47
 	}
48 48
 
49 49
 	/**
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	{
54 54
 		$shortcode = $request['shortcode'];
55 55
 		$response = false;
56
-		if( array_key_exists( $shortcode, glsr()->mceShortcodes )) {
56
+		if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) {
57 57
 			$data = glsr()->mceShortcodes[$shortcode];
58
-			if( !empty( $data['errors'] )) {
58
+			if( !empty($data['errors']) ) {
59 59
 				$data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )];
60 60
 			}
61 61
 			$response = [
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	public function searchPosts( array $request )
76 76
 	{
77 77
 		$results = glsr_db()->searchPosts( $request['search'] );
78
-		wp_send_json_success([
78
+		wp_send_json_success( [
79 79
 			'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
80 80
 			'items' => $results,
81
-		]);
81
+		] );
82 82
 	}
83 83
 
84 84
 	/**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function searchTranslations( array $request )
88 88
 	{
89
-		if( empty( $request['exclude'] )) {
89
+		if( empty($request['exclude']) ) {
90 90
 			$request['exclude'] = [];
91 91
 		}
92 92
 		$results = glsr( Translator::class )
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 			->exclude()
95 95
 			->exclude( $request['exclude'] )
96 96
 			->renderResults();
97
-		wp_send_json_success([
97
+		wp_send_json_success( [
98 98
 			'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
99 99
 			'items' => $results,
100
-		]);
100
+		] );
101 101
 	}
102 102
 
103 103
 	/**
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	{
108 108
 		$response = glsr( PublicController::class )->routerCreateReview( $request );
109 109
 		$session = glsr( Session::class );
110
-		wp_send_json([
110
+		wp_send_json( [
111 111
 			'errors' => $session->get( $request['form_id'].'-errors', false, true ),
112 112
 			'message' => $response,
113 113
 			'recaptcha' => $session->get( $request['form_id'].'-recaptcha', false, true ),
114
-		]);
114
+		] );
115 115
 	}
116 116
 
117 117
 	/**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function togglePinned( array $request )
121 121
 	{
122
-		wp_send_json([
122
+		wp_send_json( [
123 123
 			'notices' => glsr( Notice::class )->get(),
124
-			'pinned' => $this->execute( new TogglePinned( $request )),
125
-		]);
124
+			'pinned' => $this->execute( new TogglePinned( $request ) ),
125
+		] );
126 126
 	}
127 127
 }
Please login to merge, or discard this patch.
plugin/Controllers/PublicController.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,9 @@
 block discarded – undo
62 62
 		if( !empty( $validated->error )) {
63 63
 			return $validated->request;
64 64
 		}
65
-		if( $validated->recaptchaIsUnset )return;
65
+		if( $validated->recaptchaIsUnset ) {
66
+			return;
67
+		}
66 68
 		return $this->execute( new CreateReview( $validated->request ));
67 69
 	}
68 70
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 		$vars[] = Application::PAGED_QUERY_VAR;
45 45
 		// dirty hack to fix a form submission with a field that has "name" as name
46 46
 		if( filter_input( INPUT_POST, 'action' ) == 'submit-review'
47
-			&& !is_null( filter_input( INPUT_POST, 'gotcha' ))) {
47
+			&& !is_null( filter_input( INPUT_POST, 'gotcha' ) ) ) {
48 48
 			$index = array_search( 'name', $vars, true );
49 49
 			if( false !== $index ) {
50
-				unset( $vars[$index] );
50
+				unset($vars[$index]);
51 51
 			}
52 52
 		}
53 53
 		return $vars;
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 	public function routerCreateReview( array $request )
60 60
 	{
61 61
 		$validated = glsr( ValidateReview::class )->validate( $request );
62
-		if( !empty( $validated->error )) {
62
+		if( !empty($validated->error) ) {
63 63
 			return $validated->request;
64 64
 		}
65 65
 		if( $validated->recaptchaIsUnset )return;
66
-		return $this->execute( new CreateReview( $validated->request ));
66
+		return $this->execute( new CreateReview( $validated->request ) );
67 67
 	}
68 68
 }
Please login to merge, or discard this patch.
plugin/Commands/CreateReview.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 	public function __construct( $input )
25 25
 	{
26
-		$this->ajaxRequest = isset( $input['ajax_request'] );
26
+		$this->ajaxRequest = isset($input['ajax_request']);
27 27
 		$this->assignedTo = is_numeric( $input['assign_to'] )
28 28
 			? $input['assign_to']
29 29
 			: '';
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		$this->rating = intval( $input['rating'] );
38 38
 		$this->referrer = $input['_wp_http_referer'];
39 39
 		$this->request = $input;
40
-		$this->terms = isset( $input['terms'] );
40
+		$this->terms = isset($input['terms']);
41 41
 		$this->title = sanitize_text_field( $input['title'] );
42 42
 	}
43 43
 }
Please login to merge, or discard this patch.
plugin/Handlers/CreateReview.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -115,7 +115,9 @@  discard block
 block discarded – undo
115 115
 	protected function sendNotification( $post_id, Command $command )
116 116
 	{
117 117
 		$notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' );
118
-		if( !in_array( $notificationType, ['default','custom','webhook'] ))return;
118
+		if( !in_array( $notificationType, ['default','custom','webhook'] )) {
119
+			return;
120
+		}
119 121
 		$assignedToTitle = get_the_title( (int) $command->assignedTo );
120 122
 		$notificationSubject = _nx(
121 123
 			'New %s-star review',
@@ -162,7 +164,9 @@  discard block
 block discarded – undo
162 164
 	 */
163 165
 	protected function sendWebhookNotification( Command $command, array $args )
164 166
 	{
165
-		if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )))return;
167
+		if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' ))) {
168
+			return;
169
+		}
166 170
 		$notification = $this->createWebhookNotification( $command, $args );
167 171
 		$result = wp_remote_post( $endpoint, [
168 172
 			'method' => 'POST',
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	protected function createWebhookNotification( Command $command, array $args )
64 64
 	{
65 65
 		$fields = [];
66
-		$fields[] = ['title' => str_repeat( ':star:', (int) $command->rating )];
66
+		$fields[] = ['title' => str_repeat( ':star:', (int)$command->rating )];
67 67
 		if( $command->title ) {
68 68
 			$fields[] = ['title' => $command->title];
69 69
 		}
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 		if( $command->author ) {
77 77
 			$fields[] = ['value' => trim( $command->author.$command->email.' - '.$command->ipAddress )];
78 78
 		}
79
-		$fields[] = ['value' => sprintf( '<%s|%s>', $args['notification_link'], __( 'View Review', 'site-reviews' ))];
80
-		return json_encode([
79
+		$fields[] = ['value' => sprintf( '<%s|%s>', $args['notification_link'], __( 'View Review', 'site-reviews' ) )];
80
+		return json_encode( [
81 81
 			'icon_url' => glsr()->url.'assets/img/icon.png',
82 82
 			'username' => glsr()->name,
83 83
 			'attachments' => [[
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 				'fallback' => $this->createEmailNotification( $command, $args )->read( 'plaintext' ),
87 87
 				'fields' => $fields,
88 88
 			]],
89
-		]);
89
+		] );
90 90
 	}
91 91
 
92 92
 	/**
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
 	protected function sendNotification( $post_id, Command $command )
116 116
 	{
117 117
 		$notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' );
118
-		if( !in_array( $notificationType, ['default','custom','webhook'] ))return;
119
-		$assignedToTitle = get_the_title( (int) $command->assignedTo );
118
+		if( !in_array( $notificationType, ['default', 'custom', 'webhook'] ) )return;
119
+		$assignedToTitle = get_the_title( (int)$command->assignedTo );
120 120
 		$notificationSubject = _nx(
121 121
 			'New %s-star review',
122 122
 			'New %s-star review of: %s',
123
-			(int) empty( $assignedToTitle ),
123
+			(int)empty($assignedToTitle),
124 124
 			'The text is different depending on whether or not the review has been assigned to a post.',
125 125
 			'site-reviews'
126 126
 		);
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 			sprintf( $notificationSubject, $command->rating, $assignedToTitle )
130 130
 		);
131 131
 		$args = [
132
-			'notification_link' => esc_url( admin_url( sprintf( 'post.php?post=%s&action=edit', $post_id ))),
132
+			'notification_link' => esc_url( admin_url( sprintf( 'post.php?post=%s&action=edit', $post_id ) ) ),
133 133
 			'notification_title' => $notificationTitle,
134 134
 			'notification_type' => $notificationType,
135 135
 		];
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 		$args['recipient'] = $args['notification_type'] === 'default'
148 148
 			? get_option( 'admin_email' )
149 149
 			: glsr( OptionManager::class )->get( 'settings.general.notification_email' );
150
-		$result = !empty( $args['recipient'] )
150
+		$result = !empty($args['recipient'])
151 151
 			? $this->createEmailNotification( $command, $args )->send()
152 152
 			: false;
153
-		if( !is_bool( $result )) {
154
-			glsr_log()->error( __( 'Email notification was not sent: missing email, subject, or message.', 'site-reviews' ));
153
+		if( !is_bool( $result ) ) {
154
+			glsr_log()->error( __( 'Email notification was not sent: missing email, subject, or message.', 'site-reviews' ) );
155 155
 		}
156 156
 		if( $result === false ) {
157
-			glsr_log()->error( __( 'Email notification was not sent: wp_mail() failed.', 'site-reviews' ));
157
+			glsr_log()->error( __( 'Email notification was not sent: wp_mail() failed.', 'site-reviews' ) );
158 158
 		}
159 159
 	}
160 160
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	protected function sendWebhookNotification( Command $command, array $args )
165 165
 	{
166
-		if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )))return;
166
+		if( !($endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )) )return;
167 167
 		$notification = $this->createWebhookNotification( $command, $args );
168 168
 		$result = wp_remote_post( $endpoint, [
169 169
 			'method' => 'POST',
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 			'sslverify' => false,
175 175
 			'headers' => ['Content-Type' => 'application/json'],
176 176
 			'body' => apply_filters( 'site-reviews/webhook/notification', $notification, $command ),
177
-		]);
178
-		if( is_wp_error( $result )) {
177
+		] );
178
+		if( is_wp_error( $result ) ) {
179 179
 			glsr_log()->error( $result->get_error_message() );
180 180
 		}
181 181
 	}
Please login to merge, or discard this patch.
plugin/Handlers/ChangeStatus.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public function handle( Command $command )
14 14
 	{
15
-		$postId = wp_update_post([
15
+		$postId = wp_update_post( [
16 16
 			'ID' => $command->id,
17 17
 			'post_status' => $command->status,
18
-		]);
19
-		if( is_wp_error( $postId )) {
18
+		] );
19
+		if( is_wp_error( $postId ) ) {
20 20
 			glsr_log()->error( $postId->get_error_message() );
21 21
 			return [];
22 22
 		}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			'href' => get_edit_post_link( $postId ),
38 38
 			'class' => 'row-title',
39 39
 			'title' => __( 'Edit', 'site-reviews' ).' &#8220;'.esc_attr( $title ).'&#8221;',
40
-		]);
40
+		] );
41 41
 	}
42 42
 
43 43
 	/**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	protected function getPostState( $postId )
48 48
 	{
49 49
 		ob_start();
50
-		_post_states( get_post( $postId ));
50
+		_post_states( get_post( $postId ) );
51 51
 		return ob_get_clean();
52 52
 	}
53 53
 }
Please login to merge, or discard this patch.
plugin/Shortcodes/ButtonGenerator.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 			'label' => '['.$tag.']',
48 48
 			'required' => $this->required,
49 49
 			'title' => esc_html__( 'Shortcode', 'site-reviews' ),
50
-		]);
50
+		] );
51 51
 		return $this;
52 52
 	}
53 53
 
@@ -57,12 +57,12 @@  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) )return;
61 61
 			$field = $this->normalize( $field );
62
-			if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return;
62
+			if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ) ) )return;
63 63
 			return $this->$method( $field );
64 64
 		}, $fields );
65
-		return array_values( array_filter( $generatedFields ));
65
+		return array_values( array_filter( $generatedFields ) );
66 66
 	}
67 67
 
68 68
 	/**
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 	protected function getFields()
72 72
 	{
73 73
 		$fields = $this->generateFields( $this->fields() );
74
-		if( !empty( $this->errors )) {
74
+		if( !empty($this->errors) ) {
75 75
 			$errors = [];
76 76
 			foreach( $this->required as $name => $alert ) {
77
-				if( false !== array_search( $name, array_column( $fields, 'name' )))continue;
77
+				if( false !== array_search( $name, array_column( $fields, 'name' ) ) )continue;
78 78
 				$errors[] = $this->errors[$name];
79 79
 			}
80 80
 			$this->errors = $errors;
81 81
 		}
82
-		return empty( $this->errors )
82
+		return empty($this->errors)
83 83
 			? $fields
84 84
 			: $this->errors;
85 85
 	}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		return wp_parse_args( $field, [
93 93
 			'items' => [],
94 94
 			'type' => '',
95
-		]);
95
+		] );
96 96
 	}
97 97
 
98 98
 	/**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 			'tooltip' => '',
111 111
 			'type' => '',
112 112
 			'value' => '',
113
-		]);
113
+		] );
114 114
 	}
115 115
 
116 116
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	protected function normalizeContainer( array $field )
120 120
 	{
121
-		if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return;
121
+		if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ) )return;
122 122
 		$field['items'] = $this->generateFields( $field['items'] );
123 123
 		return $field;
124 124
 	}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	protected function normalizeField( array $field, array $defaults )
130 130
 	{
131
-		if( !$this->validate( $field ))return;
131
+		if( !$this->validate( $field ) )return;
132 132
 		return array_filter( shortcode_atts( $defaults, $field ), function( $value ) {
133 133
 			return $value !== '';
134 134
 		});
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 			'tooltip' => '',
149 149
 			'type' => '',
150 150
 			'value' => '',
151
-		]);
152
-		if( !is_array( $listbox ))return;
153
-		if( !array_key_exists( '', $listbox['options'] )) {
151
+		] );
152
+		if( !is_array( $listbox ) )return;
153
+		if( !array_key_exists( '', $listbox['options'] ) ) {
154 154
 			$listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options'];
155 155
 		}
156 156
 		foreach( $listbox['options'] as $value => $text ) {
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	protected function normalizePost( array $field )
169 169
 	{
170
-		if( !is_array( $field['query_args'] )) {
170
+		if( !is_array( $field['query_args'] ) ) {
171 171
 			$field['query_args'] = [];
172 172
 		}
173 173
 		$posts = get_posts( wp_parse_args( $field['query_args'], [
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 			'orderby' => 'title',
176 176
 			'post_type' => 'post',
177 177
 			'posts_per_page' => 30,
178
-		]));
179
-		if( !empty( $posts )) {
178
+		] ) );
179
+		if( !empty($posts) ) {
180 180
 			$options = [];
181 181
 			foreach( $posts as $post ) {
182 182
 				$options[$post->ID] = esc_html( $post->post_title );
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			'tooltip' => '',
207 207
 			'type' => '',
208 208
 			'value' => '',
209
-		]);
209
+		] );
210 210
 	}
211 211
 
212 212
 	/**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	protected function validate( array $field )
216 216
 	{
217
-		$args = shortcode_atts([
217
+		$args = shortcode_atts( [
218 218
 			'label' => '',
219 219
 			'name' => false,
220 220
 			'required' => false,
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	protected function validateErrors( array $args )
232 232
 	{
233
-		if( !isset( $args['required']['error'] )) {
233
+		if( !isset($args['required']['error']) ) {
234 234
 			return true;
235 235
 		}
236
-		$this->errors[$args['name']] = $this->normalizeContainer([
236
+		$this->errors[$args['name']] = $this->normalizeContainer( [
237 237
 			'html' => $args['required']['error'],
238 238
 			'type' => 'container',
239
-		]);
239
+		] );
240 240
 		return false;
241 241
 	}
242 242
 
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 			return true;
250 250
 		}
251 251
 		$alert = esc_html__( 'Some of the shortcode options are required.', 'site-reviews' );
252
-		if( isset( $args['required']['alert'] )) {
252
+		if( isset($args['required']['alert']) ) {
253 253
 			$alert = $args['required']['alert'];
254 254
 		}
255
-		else if( !empty( $args['label'] )) {
255
+		else if( !empty($args['label']) ) {
256 256
 			$alert = sprintf(
257 257
 				esc_html_x( 'The "%s" option is required.', 'the option label', 'site-reviews' ),
258 258
 				str_replace( ':', '', $args['label'] )
Please login to merge, or discard this 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( !is_array( $listbox ))return;
162
+		if( !is_array( $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/Modules/Date.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 		$diff = time() - strtotime( $date );
32 32
 		foreach( static::$TIME_PERIODS as $i => $timePeriod ) {
33 33
 			if( $diff > $timePeriod[0] )continue;
34
-			$unit = intval( floor( $diff / $timePeriod[1] ));
34
+			$unit = intval( floor( $diff / $timePeriod[1] ) );
35 35
 			$relativeDates = [
36 36
 				_n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ),
37 37
 				_n( '%s minute ago', '%s minutes ago', $unit, 'site-reviews' ),
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@
 block discarded – undo
30 30
 	{
31 31
 		$diff = time() - strtotime( $date );
32 32
 		foreach( static::$TIME_PERIODS as $i => $timePeriod ) {
33
-			if( $diff > $timePeriod[0] )continue;
33
+			if( $diff > $timePeriod[0] ) {
34
+				continue;
35
+			}
34 36
 			$unit = intval( floor( $diff / $timePeriod[1] ));
35 37
 			$relativeDates = [
36 38
 				_n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ),
Please login to merge, or discard this patch.