Passed
Push — master ( 7d2cd0...16abb1 )
by Paul
04:36
created
compatibility.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
  */
10 10
 add_filter( 'sbp_exclude_defer_scripts', function( $scriptHandles ) {
11 11
 	$scriptHandles[] = 'site-reviews/google-recaptcha';
12
-	return array_keys( array_flip( $scriptHandles ));
12
+	return array_keys( array_flip( $scriptHandles ) );
13 13
 });
14 14
 
15 15
 /**
Please login to merge, or discard this patch.
plugin/Review.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 			'review_type' => '',
63 63
 		];
64 64
 		$meta = array_filter(
65
-			array_map( 'array_shift', (array)get_post_meta( $post->ID )),
65
+			array_map( 'array_shift', (array)get_post_meta( $post->ID ) ),
66 66
 			'strlen'
67 67
 		);
68
-		$properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ));
68
+		$properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) );
69 69
 		$this->modified = $this->isModified( $properties );
70 70
 		array_walk( $properties, function( $value, $key ) {
71
-			if( !property_exists( $this, $key ) || isset( $this->$key ))return;
71
+			if( !property_exists( $this, $key ) || isset($this->$key) )return;
72 72
 			$this->$key = $value;
73 73
 		});
74 74
 	}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	protected function setTermIds( WP_Post $post )
80 80
 	{
81 81
 		$this->term_ids = [];
82
-		if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return;
82
+		if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return;
83 83
 		foreach( $terms as $term ) {
84 84
 			$this->term_ids[] = $term->term_id;
85 85
 		}
Please login to merge, or discard this patch.
plugin/Actions.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -51,55 +51,55 @@
 block discarded – undo
51 51
 	 */
52 52
 	public function run()
53 53
 	{
54
-		add_action( 'admin_enqueue_scripts',                        [$this->admin, 'enqueueAssets'] );
55
-		add_action( 'admin_init',                                   [$this->admin, 'registerShortcodeButtons'] );
56
-		add_action( 'edit_form_after_title',                        [$this->admin, 'renderReviewEditor'] );
57
-		add_action( 'edit_form_top',                                [$this->admin, 'renderReviewNotice'] );
58
-		add_action( 'media_buttons',                                [$this->admin, 'renderTinymceButton'], 11 );
59
-		add_action( 'plugins_loaded',                               [$this->app, 'getDefaults'], 11 );
60
-		add_action( 'plugins_loaded',                               [$this->app, 'registerAddons'] );
61
-		add_action( 'plugins_loaded',                               [$this->app, 'registerLanguages'] );
62
-		add_action( 'plugins_loaded',                               [$this->app, 'registerReviewTypes'] );
63
-		add_action( 'upgrader_process_complete',                    [$this->app, 'upgraded'], 10, 2 );
64
-		add_action( 'admin_enqueue_scripts',                        [$this->editor, 'customizePostStatusLabels'] );
65
-		add_action( 'add_meta_boxes',                               [$this->editor, 'registerMetaBoxes'] );
66
-		add_action( 'admin_print_scripts',                          [$this->editor, 'removeAutosave'], 999 );
67
-		add_action( 'admin_menu',                                   [$this->editor, 'removeMetaBoxes'] );
68
-		add_action( 'post_submitbox_misc_actions',                  [$this->editor, 'renderPinnedInPublishMetaBox'] );
69
-		add_action( 'admin_action_revert',                          [$this->editor, 'revertReview'] );
70
-		add_action( 'save_post_'.Application::POST_TYPE,            [$this->editor, 'saveMetaboxes'] );
71
-		add_action( 'admin_action_approve',                         [$this->listtable, 'approve'] );
72
-		add_action( 'bulk_edit_custom_box',                         [$this->listtable, 'renderBulkEditFields'], 10, 2 );
73
-		add_action( 'restrict_manage_posts',                        [$this->listtable, 'renderColumnFilters'] );
74
-		add_action( 'manage_posts_custom_column',                   [$this->listtable, 'renderColumnValues'], 10, 2 );
75
-		add_action( 'save_post_'.Application::POST_TYPE,            [$this->listtable, 'saveBulkEditFields'] );
76
-		add_action( 'pre_get_posts',                                [$this->listtable, 'setQueryForColumn'] );
77
-		add_action( 'admin_action_unapprove',                       [$this->listtable, 'unapprove'] );
78
-		add_action( 'init',                                         [$this->main, 'registerPostType'], 8 );
79
-		add_action( 'init',                                         [$this->main, 'registerShortcodes'] );
80
-		add_action( 'init',                                         [$this->main, 'registerTaxonomy'] );
81
-		add_action( 'widgets_init',                                 [$this->main, 'registerWidgets'] );
82
-		add_action( 'admin_menu',                                   [$this->menu, 'registerMenuCount'] );
83
-		add_action( 'admin_menu',                                   [$this->menu, 'registerSubMenus'] );
84
-		add_action( 'admin_init',                                   [$this->menu, 'setCustomPermissions'], 999 );
85
-		add_action( 'wp_enqueue_scripts',                           [$this->public, 'enqueueAssets'], 999 );
86
-		add_filter( 'site-reviews/builder',                         [$this->public, 'modifyBuilder'] );
87
-		add_action( 'wp_footer',                                    [$this->public, 'renderSchema'] );
88
-		add_action( 'set_object_terms',                             [$this->review, 'onAfterChangeCategory'], 10, 6 );
89
-		add_action( 'site-reviews/create/review',                   [$this->review, 'onAfterCreate'], 10, 3 );
90
-		add_action( 'before_delete_post',                           [$this->review, 'onBeforeDelete'] );
91
-		add_action( 'update_postmeta',                              [$this->review, 'onBeforeUpdate'], 10, 4 );
92
-		add_action( 'transition_post_status',                       [$this->review, 'onChangeStatus'], 10, 3 );
93
-		add_action( 'admin_init',                                   [$this->router, 'routeAdminPostRequest'] );
94
-		add_action( 'wp_ajax_'.Application::PREFIX.'action',        [$this->router, 'routeAjaxRequest'] );
54
+		add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] );
55
+		add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] );
56
+		add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] );
57
+		add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] );
58
+		add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 );
59
+		add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 );
60
+		add_action( 'plugins_loaded', [$this->app, 'registerAddons'] );
61
+		add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] );
62
+		add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] );
63
+		add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 );
64
+		add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] );
65
+		add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'] );
66
+		add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 );
67
+		add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] );
68
+		add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] );
69
+		add_action( 'admin_action_revert', [$this->editor, 'revertReview'] );
70
+		add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] );
71
+		add_action( 'admin_action_approve', [$this->listtable, 'approve'] );
72
+		add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 );
73
+		add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] );
74
+		add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 );
75
+		add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] );
76
+		add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] );
77
+		add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] );
78
+		add_action( 'init', [$this->main, 'registerPostType'], 8 );
79
+		add_action( 'init', [$this->main, 'registerShortcodes'] );
80
+		add_action( 'init', [$this->main, 'registerTaxonomy'] );
81
+		add_action( 'widgets_init', [$this->main, 'registerWidgets'] );
82
+		add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] );
83
+		add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] );
84
+		add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 );
85
+		add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 );
86
+		add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] );
87
+		add_action( 'wp_footer', [$this->public, 'renderSchema'] );
88
+		add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 );
89
+		add_action( 'site-reviews/create/review', [$this->review, 'onAfterCreate'], 10, 3 );
90
+		add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] );
91
+		add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 );
92
+		add_action( 'transition_post_status', [$this->review, 'onChangeStatus'], 10, 3 );
93
+		add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] );
94
+		add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] );
95 95
 		add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] );
96
-		add_action( 'init',                                         [$this->router, 'routePublicPostRequest'] );
97
-		add_action( 'site-reviews/schedule/session/purge',          [$this->session, 'deleteExpiredSessions'] );
98
-		add_action( 'admin_init',                                   [$this->settings, 'registerSettings'] );
99
-		add_action( Application::TAXONOMY.'_term_edit_form_top',    [$this->taxonomy, 'disableParents'] );
100
-		add_action( Application::TAXONOMY.'_term_new_form_tag',     [$this->taxonomy, 'disableParents'] );
101
-		add_action( Application::TAXONOMY.'_add_form_fields',       [$this->taxonomy, 'enableParents'] );
102
-		add_action( Application::TAXONOMY.'_edit_form',             [$this->taxonomy, 'enableParents'] );
103
-		add_action( 'restrict_manage_posts',                        [$this->taxonomy, 'renderTaxonomyFilter'], 9 );
96
+		add_action( 'init', [$this->router, 'routePublicPostRequest'] );
97
+		add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] );
98
+		add_action( 'admin_init', [$this->settings, 'registerSettings'] );
99
+		add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] );
100
+		add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] );
101
+		add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] );
102
+		add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] );
103
+		add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 );
104 104
 	}
105 105
 }
Please login to merge, or discard this patch.
plugin/Modules/Upgrader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 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 ), '<' ) )return;
21 21
 			call_user_func( [$this, $routine] );
22 22
 		});
23 23
 		$this->updateVersion();
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function updateVersion()
30 30
 	{
31 31
 		$currentVersion = glsr( OptionManager::class )->get( 'version' );
32
-		if( version_compare( $currentVersion, glsr()->version, '<' )) {
32
+		if( version_compare( $currentVersion, glsr()->version, '<' ) ) {
33 33
 			glsr( OptionManager::class )->set( 'version', glsr()->version );
34 34
 		}
35 35
 		if( $currentVersion != glsr()->version ) {
Please login to merge, or discard this patch.
plugin/Database/SqlQueries.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function deleteAllSessions( $sessionCookiePrefix )
25 25
 	{
26
-		return $this->db->query("
26
+		return $this->db->query( "
27 27
 			DELETE
28 28
 			FROM {$this->db->options}
29 29
 			WHERE option_name LIKE '{$sessionCookiePrefix}_%'
30
-		");
30
+		" );
31 31
 	}
32 32
 
33 33
 	/**
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function deleteExpiredSessions( $expiredSessions )
38 38
 	{
39
-		return $this->db->query("
39
+		return $this->db->query( "
40 40
 			DELETE
41 41
 			FROM {$this->db->options}
42 42
 			WHERE option_name IN ('{$expiredSessions}')
43
-		");
43
+		" );
44 44
 	}
45 45
 
46 46
 	/**
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function getReviewCountsFor( $metaKey )
51 51
 	{
52
-		return (array) $this->db->get_results("
52
+		return (array)$this->db->get_results( "
53 53
 			SELECT m.meta_value AS name, COUNT(*) num_posts
54 54
 			FROM {$this->db->posts} AS p
55 55
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
56 56
 			WHERE p.post_type = '{$this->postType}'
57 57
 			AND m.meta_key = '{$metaKey}'
58 58
 			GROUP BY name
59
-		");
59
+		" );
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function getExpiredSessions( $sessionCookiePrefix, $limit )
68 68
 	{
69
-		return $this->db->get_results("
69
+		return $this->db->get_results( "
70 70
 			SELECT option_name AS name, option_value AS expiration
71 71
 			FROM {$this->db->options}
72 72
 			WHERE option_name LIKE '{$sessionCookiePrefix}_expires_%'
73 73
 			ORDER BY option_value ASC
74 74
 			LIMIT 0, {$limit}
75
-		");
75
+		" );
76 76
 	}
77 77
 
78 78
 	/**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function getReviewCounts( $lastPostId = 0, $limit = 500 )
84 84
 	{
85
-		return $this->db->get_results("
85
+		return $this->db->get_results( "
86 86
 			SELECT p.ID, m1.meta_value AS rating, m2.meta_value AS type
87 87
 			FROM {$this->db->posts} AS p
88 88
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public function getReviewPostId( $metaReviewId )
105 105
 	{
106
-		$postId = $this->db->get_var("
106
+		$postId = $this->db->get_var( "
107 107
 			SELECT p.ID
108 108
 			FROM {$this->db->posts} AS p
109 109
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
110 110
 			WHERE p.post_type = '{$this->postType}'
111 111
 			AND m.meta_key = 'review_id'
112 112
 			AND m.meta_value = '{$metaReviewId}'
113
-		");
113
+		" );
114 114
 		return intval( $postId );
115 115
 	}
116 116
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function getReviewIdsByType( $reviewType )
122 122
 	{
123
-		$query = $this->db->get_col("
123
+		$query = $this->db->get_col( "
124 124
 			SELECT m1.meta_value AS review_id
125 125
 			FROM {$this->db->posts} AS p
126 126
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 			AND m1.meta_key = 'review_id'
130 130
 			AND m2.meta_key = 'review_type'
131 131
 			AND m2.meta_value = '{$reviewType}'
132
-		");
133
-		return array_keys( array_flip( $query ));
132
+		" );
133
+		return array_keys( array_flip( $query ) );
134 134
 	}
135 135
 
136 136
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function getReviewPostCounts( $postId, $lastPostId = 0, $limit = 500 )
143 143
 	{
144
-		return $this->db->get_results("
144
+		return $this->db->get_results( "
145 145
 			SELECT p.ID, m1.meta_value AS rating, m2.meta_value AS type
146 146
 			FROM {$this->db->posts} AS p
147 147
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 	public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 )
168 168
 	{
169 169
 		sort( $postIds );
170
-		$postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds )), $limit );
170
+		$postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit );
171 171
 		$postIds = implode( ',', $postIds );
172
-		return $this->db->get_results("
172
+		return $this->db->get_results( "
173 173
 			SELECT p.ID, m.meta_value AS rating
174 174
 			FROM {$this->db->posts} AS p
175 175
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		$queryBuilder = glsr( QueryBuilder::class );
194 194
 		$key = $queryBuilder->buildSqlOr( $key, "m.meta_key = '%s'" );
195 195
 		$status = $queryBuilder->buildSqlOr( $status, "p.post_status = '%s'" );
196
-		return $this->db->get_col("
196
+		return $this->db->get_col( "
197 197
 			SELECT DISTINCT m.meta_value
198 198
 			FROM {$this->db->postmeta} m
199 199
 			LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			AND ({$key})
202 202
 			AND ({$status})
203 203
 			ORDER BY m.meta_value
204
-		");
204
+		" );
205 205
 	}
206 206
 
207 207
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function getReviewTermCounts( $termId, $lastPostId = 0, $limit = 500 )
214 214
 	{
215
-		return $this->db->get_results("
215
+		return $this->db->get_results( "
216 216
 			SELECT p.ID, m1.meta_value AS rating, m2.meta_value AS type
217 217
 			FROM {$this->db->posts} AS p
218 218
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
Please login to merge, or discard this patch.
plugin/Controllers/EditorController/Metaboxes.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  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;
17
-		$assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' ));
16
+		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ) )return;
17
+		$assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' ) );
18 18
 		if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) {
19
-			$review = glsr( ReviewManager::class )->single( get_post( $postId ));
19
+			$review = glsr( ReviewManager::class )->single( get_post( $postId ) );
20 20
 			glsr( CountsManager::class )->decreasePostCounts( $review );
21 21
 		}
22 22
 		update_post_meta( $postId, 'assigned_to', $assignedTo );
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function saveResponseMetabox( $postId )
30 30
 	{
31
-		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return;
32
-		$response = strval( glsr( Helper::class )->filterInput( 'response' ));
31
+		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ) )return;
32
+		$response = strval( glsr( Helper::class )->filterInput( 'response' ) );
33 33
 		update_post_meta( $postId, 'response', trim( wp_kses( $response, [
34 34
 			'a' => ['href' => [], 'title' => []],
35 35
 			'em' => [],
36 36
 			'strong' => [],
37
-		])));
37
+		] ) ) );
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	public function enqueueAssets()
27 27
 	{
28
-		$command = new EnqueueAdminAssets([
28
+		$command = new EnqueueAdminAssets( [
29 29
 			'pointers' => [[
30 30
 				'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
31 31
 				'id' => 'glsr-pointer-pinned',
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 				'target' => '#misc-pub-pinned',
38 38
 				'title' => __( 'Pin Your Reviews', 'site-reviews' ),
39 39
 			]],
40
-		]);
40
+		] );
41 41
 		$this->execute( $command );
42 42
 	}
43 43
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	{
50 50
 		$links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
51 51
 			'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
52
-		]);
52
+		] );
53 53
 		return $links;
54 54
 	}
55 55
 
@@ -60,19 +60,19 @@  discard block
 block discarded – undo
60 60
 	public function filterDashboardGlanceItems( array $items )
61 61
 	{
62 62
 		$postCount = wp_count_posts( Application::POST_TYPE );
63
-		if( empty( $postCount->publish )) {
63
+		if( empty($postCount->publish) ) {
64 64
 			return $items;
65 65
 		}
66 66
 		$text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
67
-		$text = sprintf( $text, number_format_i18n( $postCount->publish ));
67
+		$text = sprintf( $text, number_format_i18n( $postCount->publish ) );
68 68
 		$items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts )
69 69
 			? glsr( Builder::class )->a( $text, [
70 70
 				'class' => 'glsr-review-count',
71 71
 				'href' => 'edit.php?post_type='.Application::POST_TYPE,
72
-			])
72
+			] )
73 73
 			: glsr( Builder::class )->span( $text, [
74 74
 				'class' => 'glsr-review-count',
75
-			]);
75
+			] );
76 76
 		return $items;
77 77
 	}
78 78
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	public function filterTinymcePlugins( array $plugins )
84 84
 	{
85 85
 		if( user_can_richedit()
86
-			&& ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ))) {
86
+			&& (current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) ) {
87 87
 			$plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
88 88
 		}
89 89
 		return $plugins;
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function registerShortcodeButtons()
97 97
 	{
98
-		$command = new RegisterShortcodeButtons([
98
+		$command = new RegisterShortcodeButtons( [
99 99
 			'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
100 100
 			'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
101 101
 			'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
102
-		]);
102
+		] );
103 103
 		$this->execute( $command );
104 104
 	}
105 105
 
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function renderReviewEditor( WP_Post $post )
111 111
 	{
112
-		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return;
112
+		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return;
113 113
 		glsr()->render( 'partials/editor/review', [
114 114
 			'post' => $post,
115
-		]);
115
+		] );
116 116
 	}
117 117
 
118 118
 	/**
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function renderReviewNotice( WP_Post $post )
123 123
 	{
124
-		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return;
125
-		glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ));
124
+		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return;
125
+		glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ) );
126 126
 		glsr( Html::class )->renderTemplate( 'partials/editor/notice', [
127 127
 			'context' => [
128 128
 				'notices' => glsr( Notice::class )->get(),
129 129
 			],
130
-		]);
130
+		] );
131 131
 	}
132 132
 
133 133
 	/**
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
 		if( glsr_current_screen()->base != 'post' )return;
140 140
 		$shortcodes = [];
141 141
 		foreach( glsr()->mceShortcodes as $shortcode => $values ) {
142
-			if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ))continue;
142
+			if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ) )continue;
143 143
 			$shortcodes[$shortcode] = $values;
144 144
 		}
145
-		if( empty( $shortcodes ))return;
145
+		if( empty($shortcodes) )return;
146 146
 		glsr()->render( 'partials/editor/tinymce', [
147 147
 			'shortcodes' => $shortcodes,
148
-		]);
148
+		] );
149 149
 	}
150 150
 
151 151
 	/**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	public function routerClearConsole()
155 155
 	{
156 156
 		glsr( Console::class )->clear();
157
-		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ));
157
+		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
158 158
 	}
159 159
 
160 160
 	/**
@@ -163,19 +163,19 @@  discard block
 block discarded – undo
163 163
 	public function routerCountReviews()
164 164
 	{
165 165
 		$countManager = glsr( CountsManager::class );
166
-		$terms = get_terms([
166
+		$terms = get_terms( [
167 167
 			'hide_empty' => true,
168 168
 			'taxonomy' => Application::TAXONOMY,
169
-		]);
169
+		] );
170 170
 		foreach( $terms as $term ) {
171
-			$countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ));
171
+			$countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ) );
172 172
 		}
173 173
 		$postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' );
174 174
 		foreach( $postIds as $postId ) {
175
-			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ));
175
+			$countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) );
176 176
 		}
177 177
 		$countManager->setCounts( $countManager->buildCounts() );
178
-		glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' ));
178
+		glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' ) );
179 179
 	}
180 180
 
181 181
 	/**
@@ -209,17 +209,17 @@  discard block
 block discarded – undo
209 209
 	{
210 210
 		$file = $_FILES['import-file'];
211 211
 		if( $file['error'] !== UPLOAD_ERR_OK ) {
212
-			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ));
212
+			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
213 213
 		}
214
-		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) {
215
-			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ));
214
+		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) {
215
+			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
216 216
 		}
217 217
 		$settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
218
-		if( empty( $settings )) {
219
-			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ));
218
+		if( empty($settings) ) {
219
+			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
220 220
 		}
221
-		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ));
222
-		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ));
221
+		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
222
+		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
223 223
 	}
224 224
 
225 225
 	/**
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 			UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
238 238
 			UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
239 239
 		];
240
-		return !isset( $errors[$errorCode] )
240
+		return !isset($errors[$errorCode])
241 241
 			? __( 'Unknown upload error.', 'site-reviews' )
242 242
 			: $errors[$errorCode];
243 243
 	}
Please login to merge, or discard this patch.
plugin/Controllers/Controller.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 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 ) )return;
19 19
 		nocache_headers();
20 20
 		header( 'Content-Type: text/plain' );
21 21
 		header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function execute( $command )
32 32
 	{
33
-		$handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ));
34
-		if( !class_exists( $handlerClass )) {
33
+		$handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) );
34
+		if( !class_exists( $handlerClass ) ) {
35 35
 			throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' );
36 36
 		}
37 37
 		try {
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		catch( Exception $e ) {
41 41
 			status_header( 400 );
42
-			glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ));
42
+			glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) );
43 43
 			glsr_log()->error( $e->getMessage() );
44 44
 		}
45 45
 	}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	protected function getPostId()
51 51
 	{
52
-		return intval( filter_input( INPUT_GET, 'post' ));
52
+		return intval( filter_input( INPUT_GET, 'post' ) );
53 53
 	}
54 54
 
55 55
 	/**
Please login to merge, or discard this patch.
plugin/Modules/Rating.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 	{
50 50
 		$average = array_sum( $ratingCounts );
51 51
 		if( $average > 0 ) {
52
-			$average = round( $this->getTotalSum( $ratingCounts ) / $average, intval( $roundBy ));
52
+			$average = round( $this->getTotalSum( $ratingCounts ) / $average, intval( $roundBy ) );
53 53
 		}
54
-		return floatval( apply_filters( 'site-reviews/rating/average', $average, $ratingCounts ));
54
+		return floatval( apply_filters( 'site-reviews/rating/average', $average, $ratingCounts ) );
55 55
 	}
56 56
 
57 57
 	/**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 		$z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
74 74
 		$phat = 1 * $upDownCounts[1] / $numRatings;
75
-		return ( $phat + $z * $z / ( 2 * $numRatings ) - $z * sqrt(( $phat * ( 1 - $phat ) + $z * $z / ( 4 * $numRatings )) / $numRatings )) / ( 1 + $z * $z / $numRatings );
75
+		return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings);
76 76
 	}
77 77
 
78 78
 	/**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	{
91 91
 		$total = array_sum( $ratingCounts );
92 92
 		foreach( $ratingCounts as $index => $count ) {
93
-			if( empty( $count ))continue;
93
+			if( empty($count) )continue;
94 94
 			$ratingCounts[$index] = $count / $total * 100;
95 95
 		}
96 96
 		return $this->getRoundedPercentages( $ratingCounts );
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			$this->getRankingUsingImdb( $ratingCounts ),
106 106
 			$ratingCounts,
107 107
 			$this
108
-		));
108
+		) );
109 109
 	}
110 110
 
111 111
 	/**
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 		$avgRating = $this->getAverage( $ratingCounts );
124 124
 		// Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error.
125 125
 		// This could also be the average score of all items instead of a fixed value.
126
-		$bayesMean = ( $confidencePercentage / 100 ) * static::MAX_RATING; // prior, 70% = 3.5
126
+		$bayesMean = ($confidencePercentage / 100) * static::MAX_RATING; // prior, 70% = 3.5
127 127
 		// Represents the number of ratings expected to begin observing a pattern that would put confidence in the prior.
128 128
 		$bayesMinimal = 10; // confidence
129 129
 		$numOfReviews = array_sum( $ratingCounts );
130 130
 		return $avgRating > 0
131
-			? (( $bayesMinimal * $bayesMean ) + ( $avgRating * $numOfReviews )) / ( $bayesMinimal + $numOfReviews )
131
+			? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews)
132 132
 			: 0;
133 133
 	}
134 134
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		$weight = $this->getWeight( $ratingCounts, $ratingCountsSum );
149 149
 		$weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true );
150 150
 		$zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
151
-		return $weight - $zScore * sqrt(( $weightPow2 - pow( $weight, 2 )) / ( $ratingCountsSum + 1 ));
151
+		return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) );
152 152
 	}
153 153
 
154 154
 	/**
@@ -168,14 +168,14 @@  discard block
 block discarded – undo
168 168
 		$remainders = array_column( $percentages, 'remainder' );
169 169
 		array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages );
170 170
 		$i = 0;
171
-		if( array_sum( array_column( $percentages, 'percent' )) > 0 ) {
172
-			while( array_sum( array_column( $percentages, 'percent' )) < $totalPercent ) {
171
+		if( array_sum( array_column( $percentages, 'percent' ) ) > 0 ) {
172
+			while( array_sum( array_column( $percentages, 'percent' ) ) < $totalPercent ) {
173 173
 				$percentages[$i]['percent']++;
174 174
 				$i++;
175 175
 			}
176 176
 		}
177 177
 		array_multisort( $indexes, SORT_DESC, $percentages );
178
-		return array_combine( $indexes, array_column( $percentages, 'percent' ));
178
+		return array_combine( $indexes, array_column( $percentages, 'percent' ) );
179 179
 	}
180 180
 
181 181
 	/**
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	protected function getTotalSum( array $ratingCounts )
185 185
 	{
186
-		return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use( $ratingCounts ) {
187
-			return $carry + ( $index * $ratingCounts[$index] );
186
+		return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use($ratingCounts) {
187
+			return $carry + ($index * $ratingCounts[$index]);
188 188
 		});
189 189
 	}
190 190
 
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 	protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false )
197 197
 	{
198 198
 		return array_reduce( array_keys( $ratingCounts ),
199
-			function( $count, $rating ) use( $ratingCounts, $ratingCountsSum, $powerOf2 ) {
199
+			function( $count, $rating ) use($ratingCounts, $ratingCountsSum, $powerOf2) {
200 200
 				$ratingLevel = $powerOf2
201 201
 					? pow( $rating, 2 )
202 202
 					: $rating;
203
-				return $count + ( $ratingLevel * ( $ratingCounts[$rating] + 1 )) / $ratingCountsSum;
203
+				return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum;
204 204
 			}
205 205
 		);
206 206
 	}
Please login to merge, or discard this patch.