Passed
Push — master ( 796b78...de3336 )
by Paul
05:32
created
plugin/Filters.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -38,25 +38,25 @@
 block discarded – undo
38 38
 	 */
39 39
 	public function run()
40 40
 	{
41
-		add_filter( 'mce_external_plugins',                                    [$this->admin, 'filterTinymcePlugins'], 15 );
42
-		add_filter( 'plugin_action_links_'.$this->basename,                    [$this->admin, 'filterActionLinks'] );
43
-		add_filter( 'dashboard_glance_items',                                  [$this->admin, 'filterDashboardGlanceItems'] );
44
-		add_filter( 'wp_editor_settings',                                      [$this->editor, 'filterEditorSettings'] );
45
-		add_filter( 'the_editor',                                              [$this->editor, 'filterEditorTextarea'] );
46
-		add_filter( 'gettext',                                                 [$this->editor, 'filterPostStatusLabels'], 10, 3 );
47
-		add_filter( 'gettext_with_context',                                    [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 );
48
-		add_filter( 'post_updated_messages',                                   [$this->editor, 'filterUpdateMessages'] );
49
-		add_filter( 'bulk_post_updated_messages',                              [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 );
50
-		add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns',         [$this->listtable, 'filterColumnsForPostType'] );
51
-		add_filter( 'default_hidden_columns',                                  [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 );
52
-		add_filter( 'post_row_actions',                                        [$this->listtable, 'filterRowActions'], 10, 2 );
41
+		add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 );
42
+		add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] );
43
+		add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] );
44
+		add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] );
45
+		add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] );
46
+		add_filter( 'gettext', [$this->editor, 'filterPostStatusLabels'], 10, 3 );
47
+		add_filter( 'gettext_with_context', [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 );
48
+		add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] );
49
+		add_filter( 'bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 );
50
+		add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] );
51
+		add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 );
52
+		add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 );
53 53
 		add_filter( 'manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] );
54
-		add_filter( 'ngettext',                                                [$this->listtable, 'filterStatusText'], 10, 5 );
55
-		add_filter( 'script_loader_tag',                                       [$this->public, 'filterEnqueuedScripts'], 10, 2 );
56
-		add_filter( 'query_vars',                                              [$this->public, 'filterQueryVars'] );
57
-		add_filter( 'gettext',                                                 [$this->translator, 'filterGettext'], 10, 3 );
58
-		add_filter( 'gettext_with_context',                                    [$this->translator, 'filterGettextWithContext'], 10, 4 );
59
-		add_filter( 'ngettext',                                                [$this->translator, 'filterNgettext'], 10, 5 );
60
-		add_filter( 'ngettext_with_context',                                   [$this->translator, 'filterNgettextWithContext'], 10, 6 );
54
+		add_filter( 'ngettext', [$this->listtable, 'filterStatusText'], 10, 5 );
55
+		add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 );
56
+		add_filter( 'query_vars', [$this->public, 'filterQueryVars'] );
57
+		add_filter( 'gettext', [$this->translator, 'filterGettext'], 10, 3 );
58
+		add_filter( 'gettext_with_context', [$this->translator, 'filterGettextWithContext'], 10, 4 );
59
+		add_filter( 'ngettext', [$this->translator, 'filterNgettext'], 10, 5 );
60
+		add_filter( 'ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 10, 6 );
61 61
 	}
62 62
 }
Please login to merge, or discard this patch.
plugin/Controllers/PublicController.php 1 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/Actions.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -42,48 +42,48 @@
 block discarded – undo
42 42
 	 */
43 43
 	public function run()
44 44
 	{
45
-		add_action( 'admin_enqueue_scripts',                        [$this->admin, 'enqueueAssets'] );
46
-		add_action( 'admin_enqueue_scripts',                        [$this->admin, 'registerPointers'], 13 );
47
-		add_action( 'admin_init',                                   [$this->admin, 'registerShortcodeButtons'] );
48
-		add_action( 'edit_form_after_title',                        [$this->admin, 'renderReviewEditor'] );
49
-		add_action( 'edit_form_top',                                [$this->admin, 'renderReviewNotice'] );
50
-		add_action( 'media_buttons',                                [$this->admin, 'renderTinymceButton'], 11 );
51
-		add_action( 'plugins_loaded',                               [$this->app, 'getDefaults'], 11 );
52
-		add_action( 'plugins_loaded',                               [$this->app, 'registerAddons'] );
53
-		add_action( 'plugins_loaded',                               [$this->app, 'registerLanguages'] );
54
-		add_action( 'plugins_loaded',                               [$this->app, 'registerReviewTypes'] );
55
-		add_action( 'upgrader_process_complete',                    [$this->app, 'upgraded'], 10, 2 );
56
-		add_action( 'admin_enqueue_scripts',                        [$this->editor, 'customizePostStatusLabels'] );
57
-		add_action( 'site-reviews/create/review',                   [$this->editor, 'onCreateReview'], 10, 3 );
58
-		add_action( 'before_delete_post',                           [$this->editor, 'onDeleteReview'] );
59
-		add_action( 'save_post_'.Application::POST_TYPE,            [$this->editor, 'onSaveReview'], 20, 2 );
60
-		add_action( 'add_meta_boxes',                               [$this->editor, 'registerMetaBoxes'] );
61
-		add_action( 'admin_print_scripts',                          [$this->editor, 'removeAutosave'], 999 );
62
-		add_action( 'admin_menu',                                   [$this->editor, 'removeMetaBoxes'] );
63
-		add_action( 'post_submitbox_misc_actions',                  [$this->editor, 'renderPinnedInPublishMetaBox'] );
64
-		add_action( 'admin_action_revert',                          [$this->editor, 'revertReview'] );
65
-		add_action( 'save_post_'.Application::POST_TYPE,            [$this->editor, 'saveMetaboxes'] );
66
-		add_action( 'admin_action_approve',                         [$this->listtable, 'approve'] );
67
-		add_action( 'bulk_edit_custom_box',                         [$this->listtable, 'renderBulkEditFields'], 10, 2 );
68
-		add_action( 'restrict_manage_posts',                        [$this->listtable, 'renderColumnFilters'] );
69
-		add_action( 'manage_posts_custom_column',                   [$this->listtable, 'renderColumnValues'] );
70
-		add_action( 'save_post_'.Application::POST_TYPE,            [$this->listtable, 'saveBulkEditFields'] );
71
-		add_action( 'pre_get_posts',                                [$this->listtable, 'setQueryForColumn'] );
72
-		add_action( 'admin_action_unapprove',                       [$this->listtable, 'unapprove'] );
73
-		add_action( 'init',                                         [$this->main, 'registerPostType'], 8 );
74
-		add_action( 'init',                                         [$this->main, 'registerShortcodes'] );
75
-		add_action( 'init',                                         [$this->main, 'registerTaxonomy'] );
76
-		add_action( 'widgets_init',                                 [$this->main, 'registerWidgets'] );
77
-		add_action( 'wp_footer',                                    [$this->main, 'renderSchema'] );
78
-		add_action( 'admin_menu',                                   [$this->menu, 'registerMenuCount'] );
79
-		add_action( 'admin_menu',                                   [$this->menu, 'registerSubMenus'] );
80
-		add_action( 'admin_init',                                   [$this->menu, 'setCustomPermissions'], 999 );
81
-		add_action( 'wp_enqueue_scripts',                           [$this->public, 'enqueueAssets'], 999 );
82
-		add_action( 'admin_init',                                   [$this->router, 'routeAdminPostRequest'] );
83
-		add_action( 'wp_ajax_'.Application::PREFIX.'action',        [$this->router, 'routeAjaxRequest'] );
45
+		add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] );
46
+		add_action( 'admin_enqueue_scripts', [$this->admin, 'registerPointers'], 13 );
47
+		add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] );
48
+		add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] );
49
+		add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] );
50
+		add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 );
51
+		add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 );
52
+		add_action( 'plugins_loaded', [$this->app, 'registerAddons'] );
53
+		add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] );
54
+		add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] );
55
+		add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 );
56
+		add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] );
57
+		add_action( 'site-reviews/create/review', [$this->editor, 'onCreateReview'], 10, 3 );
58
+		add_action( 'before_delete_post', [$this->editor, 'onDeleteReview'] );
59
+		add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'onSaveReview'], 20, 2 );
60
+		add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'] );
61
+		add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 );
62
+		add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] );
63
+		add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] );
64
+		add_action( 'admin_action_revert', [$this->editor, 'revertReview'] );
65
+		add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] );
66
+		add_action( 'admin_action_approve', [$this->listtable, 'approve'] );
67
+		add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 );
68
+		add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] );
69
+		add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'] );
70
+		add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] );
71
+		add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] );
72
+		add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] );
73
+		add_action( 'init', [$this->main, 'registerPostType'], 8 );
74
+		add_action( 'init', [$this->main, 'registerShortcodes'] );
75
+		add_action( 'init', [$this->main, 'registerTaxonomy'] );
76
+		add_action( 'widgets_init', [$this->main, 'registerWidgets'] );
77
+		add_action( 'wp_footer', [$this->main, 'renderSchema'] );
78
+		add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] );
79
+		add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] );
80
+		add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 );
81
+		add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 );
82
+		add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] );
83
+		add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] );
84 84
 		add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] );
85
-		add_action( 'init',                                         [$this->router, 'routePublicPostRequest'] );
86
-		add_action( 'admin_init',                                   [$this->router, 'routeWebhookRequest'] );
87
-		add_action( 'admin_init',                                   [$this->settings, 'registerSettings'] );
85
+		add_action( 'init', [$this->router, 'routePublicPostRequest'] );
86
+		add_action( 'admin_init', [$this->router, 'routeWebhookRequest'] );
87
+		add_action( 'admin_init', [$this->settings, 'registerSettings'] );
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
plugin/Modules/Validator/ValidateReview.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function validateRequest( array $request )
57 57
 	{
58
-		if( !$this->isRequestValid( $request )) {
58
+		if( !$this->isRequestValid( $request ) ) {
59 59
 			$this->error = __( 'Please fix the submission errors.', 'site-reviews' );
60 60
 			return $request;
61 61
 		}
62
-		if( empty( $request['title'] )) {
62
+		if( empty($request['title']) ) {
63 63
 			$request['title'] = __( 'No Title', 'site-reviews' );
64 64
 		}
65 65
 		return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request );
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 		$rules = array_intersect_key(
74 74
 			apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES ),
75 75
 			array_flip( array_merge(
76
-				['rating','terms'],
76
+				['rating', 'terms'],
77 77
 				glsr( OptionManager::class )->get( 'settings.submissions.required', [] )
78
-			))
78
+			) )
79 79
 		);
80
-		$excluded = isset( $request['excluded'] )
80
+		$excluded = isset($request['excluded'])
81 81
 			? json_decode( $request['excluded'] )
82 82
 			: [];
83
-		return array_diff_key( $rules, array_flip( $excluded ));
83
+		return array_diff_key( $rules, array_flip( $excluded ) );
84 84
 	}
85 85
 
86 86
 	/**
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 			return true;
94 94
 		}
95 95
 		$recaptchaResponse = filter_input( INPUT_POST, 'g-recaptcha-response' );
96
-		if( empty( $recaptchaResponse )) {
96
+		if( empty($recaptchaResponse) ) {
97 97
 			return null; //if response is empty we need to return null
98 98
 		}
99 99
 		if( $integration == 'custom' ) {
100 100
 			return $this->isRecaptchaValid( $recaptchaResponse );
101 101
 		}
102 102
 		if( $integration == 'invisible-recaptcha' ) {
103
-			return boolval( apply_filters( 'google_invre_is_valid_request_filter', true ));
103
+			return boolval( apply_filters( 'google_invre_is_valid_request_filter', true ) );
104 104
 		}
105 105
 		return false;
106 106
 	}
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	protected function isRecaptchaValid( $recaptchaResponse )
112 112
 	{
113
-		$endpoint = add_query_arg([
113
+		$endpoint = add_query_arg( [
114 114
 			'remoteip' => glsr( Helper::class )->getIpAddress(),
115 115
 			'response' => $recaptchaResponse,
116 116
 			'secret' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.secret' ),
117 117
 		], 'https://www.google.com/recaptcha/api/siteverify' );
118
-		if( is_wp_error( $response = wp_remote_get( $endpoint ))) {
118
+		if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) {
119 119
 			glsr_log()->error( $response->get_error_message() );
120 120
 			return false;
121 121
 		}
122
-		$response = json_decode( wp_remote_retrieve_body( $response ));
123
-		if( !empty( $response->success )) {
122
+		$response = json_decode( wp_remote_retrieve_body( $response ) );
123
+		if( !empty($response->success) ) {
124 124
 			return boolval( $response->success );
125 125
 		}
126 126
 		$errorCodes = [
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	{
144 144
 		$rules = $this->getValidationRules( $request );
145 145
 		$errors = glsr( Validator::class )->validate( $request, $rules );
146
-		if( empty( $errors )) {
146
+		if( empty($errors) ) {
147 147
 			return true;
148 148
 		}
149 149
 		$this->setSessionValues( 'errors', $errors );
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	protected function setSessionValues( $type, $value, $loggedMessage = '' )
161 161
 	{
162 162
 		glsr( Session::class )->set( $this->form_id.$type, $value );
163
-		if( !empty( $loggedMessage )) {
163
+		if( !empty($loggedMessage) ) {
164 164
 			glsr_log()->warning( $loggedMessage );
165 165
 			glsr_log()->warning( $this->request );
166 166
 		}
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	protected function validateAkismet()
173 173
 	{
174
-		if( !empty( $this->error ))return;
175
-		if( !glsr( Akismet::class )->isSpam( $this->request ))return;
174
+		if( !empty($this->error) )return;
175
+		if( !glsr( Akismet::class )->isSpam( $this->request ) )return;
176 176
 		$this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' );
177 177
 		$this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' );
178 178
 	}
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	protected function validateBlacklist()
184 184
 	{
185
-		if( !empty( $this->error ))return;
186
-		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return;
185
+		if( !empty($this->error) )return;
186
+		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return;
187 187
 		$blacklistAction = glsr( OptionManager::class )->get( 'settings.submissions.blacklist.action' );
188 188
 		if( $blacklistAction == 'unapprove' ) {
189 189
 			$this->request['blacklisted'] = true;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	protected function validateCustom()
201 201
 	{
202
-		if( !empty( $this->error ))return;
202
+		if( !empty($this->error) )return;
203 203
 		$validated = apply_filters( 'site-reviews/validate/review/submission', true, $this->request );
204 204
 		if( $validated === true )return;
205 205
 		$this->setSessionValues( 'errors', [] );
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	protected function validateHoneyPot()
216 216
 	{
217
-		if( !empty( $this->error ))return;
218
-		if( empty( $this->request['gotcha'] ))return;
217
+		if( !empty($this->error) )return;
218
+		if( empty($this->request['gotcha']) )return;
219 219
 		$this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' );
220 220
 		$this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
221 221
 	}
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	protected function validateRecaptcha()
227 227
 	{
228
-		if( !empty( $this->error ))return;
228
+		if( !empty($this->error) )return;
229 229
 		$isValid = $this->isRecaptchaResponseValid();
230
-		if( is_null( $isValid )) {
230
+		if( is_null( $isValid ) ) {
231 231
 			$this->setSessionValues( 'recaptcha', true );
232 232
 			$this->recaptchaIsUnset = true;
233 233
 		}
Please login to merge, or discard this patch.
plugin/Modules/Blacklist.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public function isBlacklisted( CreateReview $review )
14 14
 	{
15
-		$target = implode( "\n", array_filter([
15
+		$target = implode( "\n", array_filter( [
16 16
 			$review->author,
17 17
 			$review->content,
18 18
 			$review->email,
19 19
 			$review->ipAddress,
20 20
 			$review->title,
21
-		]));
22
-		return (bool) apply_filters( 'site-reviews/blacklist/is-blacklisted',
21
+		] ) );
22
+		return (bool)apply_filters( 'site-reviews/blacklist/is-blacklisted',
23 23
 			$this->check( $target ),
24 24
 			$review
25 25
 		);
@@ -31,16 +31,16 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	protected function check( $target )
33 33
 	{
34
-		$blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' ));
35
-		if( empty( $blacklist )) {
34
+		$blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' ) );
35
+		if( empty($blacklist) ) {
36 36
 			return false;
37 37
 		}
38 38
 		$lines = explode( "\n", $blacklist );
39
-		foreach( (array) $lines as $line ) {
39
+		foreach( (array)$lines as $line ) {
40 40
 			$line = trim( $line );
41
-			if( empty( $line ) || 256 < strlen( $line ))continue;
42
-			$pattern = sprintf( '#%s#i', preg_quote( $line, '#' ));
43
-			if( preg_match( $pattern, $target )) {
41
+			if( empty($line) || 256 < strlen( $line ) )continue;
42
+			$pattern = sprintf( '#%s#i', preg_quote( $line, '#' ) );
43
+			if( preg_match( $pattern, $target ) ) {
44 44
 				return true;
45 45
 			}
46 46
 		}
Please login to merge, or discard this patch.
plugin/Handlers/CreateReview.php 1 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/EnqueuePublicAssets.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function enqueueAssets()
25 25
 	{
26
-		if( apply_filters( 'site-reviews/assets/css', true )) {
26
+		if( apply_filters( 'site-reviews/assets/css', true ) ) {
27 27
 			wp_enqueue_style(
28 28
 				Application::ID,
29 29
 				$this->getStylesheet(),
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 				glsr()->version
32 32
 			);
33 33
 		}
34
-		if( apply_filters( 'site-reviews/assets/js', true )) {
34
+		if( apply_filters( 'site-reviews/assets/js', true ) ) {
35 35
 			wp_enqueue_script(
36 36
 				Application::ID,
37 37
 				glsr()->url( 'assets/scripts/'.Application::ID.'.js' ),
38
-				[],//glsr( Html::class )->getDependencies(),
38
+				[], //glsr( Html::class )->getDependencies(),
39 39
 				glsr()->version,
40 40
 				true
41 41
 			);
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
 	public function enqueueRecaptchaScript()
49 49
 	{
50 50
 		if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' )return;
51
-		wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([
51
+		wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [
52 52
 			'hl' => apply_filters( 'site-reviews/recaptcha/language', get_locale() ),
53 53
 			'onload' => 'glsr_render_recaptcha',
54 54
 			'render' => 'explicit',
55
-		], 'https://www.google.com/recaptcha/api.js' ));
56
-		$inlineScript = file_get_contents( glsr()->path( 'assets/scripts/recaptcha.js' ));
55
+		], 'https://www.google.com/recaptcha/api.js' ) );
56
+		$inlineScript = file_get_contents( glsr()->path( 'assets/scripts/recaptcha.js' ) );
57 57
 		wp_add_inline_script( Application::ID.'/google-recaptcha', $inlineScript, 'before' );
58 58
 	}
59 59
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		$variables = [
66 66
 			'action' => Application::PREFIX.'action',
67 67
 			'ajaxnonce' => wp_create_nonce( Application::ID.'-ajax-nonce' ),
68
-			'ajaxpagination' => ['#wpadminbar','.site-navigation-fixed'],
68
+			'ajaxpagination' => ['#wpadminbar', '.site-navigation-fixed'],
69 69
 			'ajaxurl' => admin_url( 'admin-ajax.php' ),
70 70
 		];
71 71
 		$variables = apply_filters( 'site-reviews/enqueue/localize', $variables );
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	protected function getStylesheet()
79 79
 	{
80
-		$currentTheme = sanitize_title( (string)wp_get_theme()->get( 'Name' ));
80
+		$currentTheme = sanitize_title( (string)wp_get_theme()->get( 'Name' ) );
81 81
 		return file_exists( glsr()->path.'assets/styles/'.$currentTheme.'.css' )
82 82
 			? glsr()->url( 'assets/styles/'.$currentTheme.'.css' )
83 83
 			: glsr()->url( 'assets/styles/'.Application::ID.'.css' );
Please login to merge, or discard this patch.
plugin/Modules/Editor/Metaboxes.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	public function onCreateReview( $postData, $meta, $postId )
24 24
 	{
25
-		if( !$this->isReviewPostType( $review = get_post( $postId )))return;
25
+		if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return;
26 26
 		$this->updateAssignedToPost( $review );
27 27
 	}
28 28
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function onDeleteReview( $postId )
34 34
 	{
35
-		if( !$this->isReviewPostType( $review = get_post( $postId )))return;
35
+		if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return;
36 36
 		$review->post_status = 'deleted'; // important to change the post_status here first!
37 37
 		$this->updateAssignedToPost( $review );
38 38
 	}
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function saveAssignedToMetabox( $postId )
54 54
 	{
55
-		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ))return;
55
+		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ) )return;
56 56
 		$assignedTo = filter_input( INPUT_POST, 'assigned_to' );
57 57
 		$assignedTo || $assignedTo = '';
58 58
 		if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) {
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function saveResponseMetabox( $postId )
69 69
 	{
70
-		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ))return;
70
+		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ) )return;
71 71
 		$response = filter_input( INPUT_POST, 'response' );
72 72
 		$response || $response = '';
73 73
 		update_post_meta( $postId, 'response', trim( wp_kses( $response, [
74 74
 			'a' => ['href' => [], 'title' => []],
75 75
 			'em' => [],
76 76
 			'strong' => [],
77
-		])));
77
+		] ) ) );
78 78
 	}
79 79
 
80 80
 	/**
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	protected function getAssignedToPostId( $postId )
85 85
 	{
86
-		$assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ));
87
-		if(( $post = get_post( $assignedTo )) instanceof WP_Post ) {
86
+		$assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ) );
87
+		if( ($post = get_post( $assignedTo )) instanceof WP_Post ) {
88 88
 			return $post->ID;
89 89
 		}
90 90
 		return false;
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	protected function updateAssignedToPost( WP_Post $review )
122 122
 	{
123
-		if( !( $postId = $this->getAssignedToPostId( $review->ID )))return;
124
-		$reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ));
125
-		if( empty( $reviewIds ))return;
123
+		if( !($postId = $this->getAssignedToPostId( $review->ID )) )return;
124
+		$reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) );
125
+		if( empty($reviewIds) )return;
126 126
 		$this->updateReviewIdOfPost( $postId, $review, $reviewIds );
127
-		$updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ));
128
-		if( empty( $updatedReviewIds )) {
127
+		$updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) );
128
+		if( empty($updatedReviewIds) ) {
129 129
 			delete_post_meta( $postId, static::META_RANKING );
130 130
 			delete_post_meta( $postId, static::META_REVIEW_ID );
131 131
 		}
132
-		else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds )) {
133
-			$reviews = glsr( Database::class )->getReviews([
132
+		else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds ) ) {
133
+			$reviews = glsr( Database::class )->getReviews( [
134 134
 				'count' => -1,
135 135
 				'post__in' => $updatedReviewIds,
136
-			]);
137
-			update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ));
138
-			update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ));
136
+			] );
137
+			update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ) );
138
+			update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ) );
139 139
 		}
140 140
 	}
141 141
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		if( $review->post_status != 'publish' ) {
149 149
 			delete_post_meta( $postId, static::META_REVIEW_ID, $review->ID );
150 150
 		}
151
-		else if( !in_array( $review->ID, $reviewIds )) {
151
+		else if( !in_array( $review->ID, $reviewIds ) ) {
152 152
 			add_post_meta( $postId, static::META_REVIEW_ID, $review->ID );
153 153
 		}
154 154
 	}
Please login to merge, or discard this patch.
plugin/Modules/Schema.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 		foreach( glsr( Database::class )->getReviews( $this->args )->reviews as $review ) {
33 33
 			$reviews[] = $this->buildReview( $review );
34 34
 		}
35
-		if( !empty( $reviews )) {
35
+		if( !empty($reviews) ) {
36 36
 			array_walk( $reviews, function( &$review ) {
37
-				unset( $review['@context'] );
38
-				unset( $review['itemReviewed'] );
37
+				unset($review['@context']);
38
+				unset($review['itemReviewed']);
39 39
 			});
40 40
 			$schema['review'] = $reviews;
41 41
 		}
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 	public function buildReview( $review )
50 50
 	{
51 51
 		$schema = SchemaOrg::Review()
52
-			->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) {
52
+			->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) {
53 53
 				$schema->name( $review->title );
54 54
 			})
55
-			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) {
55
+			->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) {
56 56
 				$schema->reviewBody( $review->content );
57 57
 			})
58
-			->datePublished(( new DateTime( $review->date ))->format( DateTime::ISO8601 ))
58
+			->datePublished( (new DateTime( $review->date ))->format( DateTime::ISO8601 ) )
59 59
 			->author( SchemaOrg::Person()
60 60
 				->name( $review->author )
61 61
 			)
62 62
 			->itemReviewed( $this->getSchemaType()
63 63
 				->name( $this->getThingName() )
64 64
 			);
65
-		if( !empty( $review->rating )) {
65
+		if( !empty($review->rating) ) {
66 66
 			$schema->reviewRating( SchemaOrg::Rating()
67 67
 				->ratingValue( $review->rating )
68 68
 				->bestRating( Rating::MAX_RATING )
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function buildSummary( $args = null )
80 80
 	{
81
-		if( is_array( $args )) {
81
+		if( is_array( $args ) ) {
82 82
 			$this->args = $args;
83 83
 		}
84 84
 		$schema = $this->getSchemaType()
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			->image( $this->getThingImage() )
91 91
 			->url( $this->getThingUrl() );
92 92
 		$count = $this->getReviewCount();
93
-		if( !empty( $count )) {
93
+		if( !empty($count) ) {
94 94
 			$schema->aggregateRating( SchemaOrg::AggregateRating()
95 95
 				->ratingValue( $this->getRatingValue() )
96 96
 				->reviewCount( $count )
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function render()
110 110
 	{
111
-		if( is_null( glsr()->schemas ))return;
111
+		if( is_null( glsr()->schemas ) )return;
112 112
 		printf( '<script type="application/ld+json">%s</script>', json_encode(
113 113
 			apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
114 114
 			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
115
-		));
115
+		) );
116 116
 	}
117 117
 
118 118
 	/**
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function store( array $schema )
122 122
 	{
123
-		$schemas = (array) glsr()->schemas;
123
+		$schemas = (array)glsr()->schemas;
124 124
 		$schemas[] = $schema;
125
-		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas )));
125
+		glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) );
126 126
 	}
127 127
 
128 128
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	protected function getReviews( $force = false )
149 149
 	{
150
-		if( !isset( $this->reviews ) || $force ) {
150
+		if( !isset($this->reviews) || $force ) {
151 151
 			$args = wp_parse_args( ['count' => -1], $this->args );
152 152
 			$this->reviews = glsr( Database::class )->getReviews( $args )->reviews;
153 153
 		}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	protected function getSchemaOption( $option, $fallback )
163 163
 	{
164
-		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) {
164
+		if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) {
165 165
 			return $schemaOption;
166 166
 		}
167 167
 		$default = glsr( OptionManager::class )->get( 'settings.reviews.schema.'.$option.'.default', $fallback );
Please login to merge, or discard this patch.