Passed
Push — master ( cf4dec...8426b9 )
by Paul
04:22 queued 31s
created
plugin/Handlers/ChangeStatus.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	public function handle( Command $command )
15 15
 	{
16
-		$postId = wp_update_post([
16
+		$postId = wp_update_post( [
17 17
 			'ID' => $command->id,
18 18
 			'post_status' => $command->status,
19
-		]);
20
-		if( is_wp_error( $postId )) {
19
+		] );
20
+		if( is_wp_error( $postId ) ) {
21 21
 			glsr_log()->error( $postId->get_error_message() );
22 22
 			return [];
23 23
 		}
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 			'aria-label' => '“'.esc_attr( $title ).'” ('.__( 'Edit', 'site-reviews' ).')',
40 40
 			'class' => 'row-title',
41 41
 			'href' => get_edit_post_link( $postId ),
42
-		]);
42
+		] );
43 43
 	}
44 44
 
45 45
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	protected function getPostState( $postId )
50 50
 	{
51 51
 		ob_start();
52
-		_post_states( get_post( $postId ));
52
+		_post_states( get_post( $postId ) );
53 53
 		return ob_get_clean();
54 54
 	}
55 55
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	protected function getStatusLinks()
60 60
 	{
61 61
 		global $avail_post_stati;
62
-		require_once( ABSPATH.'wp-admin/includes/class-wp-posts-list-table.php' );
62
+		require_once(ABSPATH.'wp-admin/includes/class-wp-posts-list-table.php');
63 63
 		$hookName = 'edit-'.Application::POST_TYPE;
64 64
 		set_current_screen( $hookName );
65 65
 		$avail_post_stati = get_available_post_statuses( Application::POST_TYPE );
66 66
 		$table = new \WP_Posts_List_Table( ['screen' => $hookName] );
67 67
 		$views = apply_filters( 'views_'.$hookName, $table->get_views() ); // uses compat get_views()
68
-		if( empty( $views ))return;
68
+		if( empty($views) )return;
69 69
 		foreach( $views as $class => $view ) {
70 70
 			$views[$class] = "\t<li class='$class'>$view";
71 71
 		}
Please login to merge, or discard this patch.
plugin/Actions.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -54,57 +54,57 @@
 block discarded – undo
54 54
 	 */
55 55
 	public function run()
56 56
 	{
57
-		add_action( 'admin_enqueue_scripts',                        [$this->admin, 'enqueueAssets'] );
58
-		add_action( 'admin_init',                                   [$this->admin, 'registerTinymcePopups'] );
59
-		add_action( 'media_buttons',                                [$this->admin, 'renderTinymceButton'], 11 );
60
-		add_action( 'plugins_loaded',                               [$this->app, 'getDefaults'], 11 );
61
-		add_action( 'plugins_loaded',                               [$this->app, 'registerAddons'] );
62
-		add_action( 'plugins_loaded',                               [$this->app, 'registerLanguages'] );
63
-		add_action( 'plugins_loaded',                               [$this->app, 'registerReviewTypes'] );
64
-		add_action( 'upgrader_process_complete',                    [$this->app, 'upgraded'], 10, 2 );
65
-		add_action( 'init',                                         [$this->blocks, 'registerAssets'], 9 );
66
-		add_action( 'init',                                         [$this->blocks, 'registerBlocks'] );
67
-		add_action( 'admin_enqueue_scripts',                        [$this->editor, 'customizePostStatusLabels'] );
68
-		add_action( 'add_meta_boxes',                               [$this->editor, 'registerMetaBoxes'], 10, 2 );
69
-		add_action( 'admin_print_scripts',                          [$this->editor, 'removeAutosave'], 999 );
70
-		add_action( 'admin_menu',                                   [$this->editor, 'removeMetaBoxes'] );
71
-		add_action( 'current_screen',                               [$this->editor, 'removePostTypeSupport'] );
72
-		add_action( 'post_submitbox_misc_actions',                  [$this->editor, 'renderPinnedInPublishMetaBox'] );
73
-		add_action( 'admin_head',                                   [$this->editor, 'renderReviewFields'] );
74
-		add_action( 'admin_action_revert',                          [$this->editor, 'revertReview'] );
75
-		add_action( 'save_post_'.Application::POST_TYPE,            [$this->editor, 'saveMetaboxes'] );
76
-		add_action( 'admin_action_approve',                         [$this->listtable, 'approve'] );
77
-		add_action( 'bulk_edit_custom_box',                         [$this->listtable, 'renderBulkEditFields'], 10, 2 );
78
-		add_action( 'restrict_manage_posts',                        [$this->listtable, 'renderColumnFilters'] );
79
-		add_action( 'manage_posts_custom_column',                   [$this->listtable, 'renderColumnValues'], 10, 2 );
80
-		add_action( 'save_post_'.Application::POST_TYPE,            [$this->listtable, 'saveBulkEditFields'] );
81
-		add_action( 'pre_get_posts',                                [$this->listtable, 'setQueryForColumn'] );
82
-		add_action( 'admin_action_unapprove',                       [$this->listtable, 'unapprove'] );
83
-		add_action( 'init',                                         [$this->main, 'registerPostType'], 8 );
84
-		add_action( 'init',                                         [$this->main, 'registerShortcodes'] );
85
-		add_action( 'init',                                         [$this->main, 'registerTaxonomy'] );
86
-		add_action( 'widgets_init',                                 [$this->main, 'registerWidgets'] );
87
-		add_action( 'admin_menu',                                   [$this->menu, 'registerMenuCount'] );
88
-		add_action( 'admin_menu',                                   [$this->menu, 'registerSubMenus'] );
89
-		add_action( 'admin_init',                                   [$this->menu, 'setCustomPermissions'], 999 );
90
-		add_action( 'wp_enqueue_scripts',                           [$this->public, 'enqueueAssets'], 999 );
91
-		add_filter( 'site-reviews/builder',                         [$this->public, 'modifyBuilder'] );
92
-		add_action( 'wp_footer',                                    [$this->public, 'renderSchema'] );
93
-		add_action( 'set_object_terms',                             [$this->review, 'onAfterChangeCategory'], 10, 6 );
94
-		add_action( 'transition_post_status',                       [$this->review, 'onAfterChangeStatus'], 10, 3 );
95
-		add_action( 'site-reviews/review/created',                  [$this->review, 'onAfterCreate'] );
96
-		add_action( 'before_delete_post',                           [$this->review, 'onBeforeDelete'] );
97
-		add_action( 'update_postmeta',                              [$this->review, 'onBeforeUpdate'], 10, 4 );
98
-		add_action( 'admin_init',                                   [$this->router, 'routeAdminPostRequest'] );
99
-		add_action( 'wp_ajax_'.Application::PREFIX.'action',        [$this->router, 'routeAjaxRequest'] );
57
+		add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] );
58
+		add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] );
59
+		add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 );
60
+		add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 );
61
+		add_action( 'plugins_loaded', [$this->app, 'registerAddons'] );
62
+		add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] );
63
+		add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] );
64
+		add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 );
65
+		add_action( 'init', [$this->blocks, 'registerAssets'], 9 );
66
+		add_action( 'init', [$this->blocks, 'registerBlocks'] );
67
+		add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] );
68
+		add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'], 10, 2 );
69
+		add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 );
70
+		add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] );
71
+		add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] );
72
+		add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] );
73
+		add_action( 'admin_head', [$this->editor, 'renderReviewFields'] );
74
+		add_action( 'admin_action_revert', [$this->editor, 'revertReview'] );
75
+		add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] );
76
+		add_action( 'admin_action_approve', [$this->listtable, 'approve'] );
77
+		add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 );
78
+		add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] );
79
+		add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 );
80
+		add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] );
81
+		add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] );
82
+		add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] );
83
+		add_action( 'init', [$this->main, 'registerPostType'], 8 );
84
+		add_action( 'init', [$this->main, 'registerShortcodes'] );
85
+		add_action( 'init', [$this->main, 'registerTaxonomy'] );
86
+		add_action( 'widgets_init', [$this->main, 'registerWidgets'] );
87
+		add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] );
88
+		add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] );
89
+		add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 );
90
+		add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 );
91
+		add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] );
92
+		add_action( 'wp_footer', [$this->public, 'renderSchema'] );
93
+		add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 );
94
+		add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 );
95
+		add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] );
96
+		add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] );
97
+		add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 );
98
+		add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] );
99
+		add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] );
100 100
 		add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] );
101
-		add_action( 'init',                                         [$this->router, 'routePublicPostRequest'] );
102
-		add_action( 'site-reviews/schedule/session/purge',          [$this->session, 'deleteExpiredSessions'] );
103
-		add_action( 'admin_init',                                   [$this->settings, 'registerSettings'] );
104
-		add_action( Application::TAXONOMY.'_term_edit_form_top',    [$this->taxonomy, 'disableParents'] );
105
-		add_action( Application::TAXONOMY.'_term_new_form_tag',     [$this->taxonomy, 'disableParents'] );
106
-		add_action( Application::TAXONOMY.'_add_form_fields',       [$this->taxonomy, 'enableParents'] );
107
-		add_action( Application::TAXONOMY.'_edit_form',             [$this->taxonomy, 'enableParents'] );
108
-		add_action( 'restrict_manage_posts',                        [$this->taxonomy, 'renderTaxonomyFilter'], 9 );
101
+		add_action( 'init', [$this->router, 'routePublicPostRequest'] );
102
+		add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] );
103
+		add_action( 'admin_init', [$this->settings, 'registerSettings'] );
104
+		add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] );
105
+		add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] );
106
+		add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] );
107
+		add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] );
108
+		add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 );
109 109
 	}
110 110
 }
Please login to merge, or discard this patch.
plugin/Modules/System.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 			'setting' => 'Plugin Settings',
41 41
 			'reviews' => 'Review Counts',
42 42
 		];
43
-		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) {
43
+		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) {
44 44
 			$methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
45 45
 			if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
46 46
 				return $carry.$this->implode(
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	{
61 61
 		$plugins = get_plugins();
62 62
 		$activePlugins = (array)get_option( 'active_plugins', [] );
63
-		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ));
64
-		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
63
+		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
64
+		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
65 65
 	}
66 66
 
67 67
 	/**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	public function getInactivePluginDetails()
96 96
 	{
97 97
 		$activePlugins = (array)get_option( 'active_plugins', [] );
98
-		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins )));
98
+		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
99 99
 	}
100 100
 
101 101
 	/**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	{
106 106
 		$plugins = array_merge(
107 107
 			get_mu_plugins(),
108
-			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ))
108
+			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) )
109 109
 		);
110
-		if( empty( $plugins ))return;
110
+		if( empty($plugins) )return;
111 111
 		return $this->normalizePluginList( $plugins );
112 112
 	}
113 113
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function getMultisitePluginDetails()
118 118
 	{
119
-		if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return;
119
+		if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return;
120 120
 		return $this->normalizePluginList( wp_get_active_network_plugins() );
121 121
 	}
122 122
 
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 			'Max Input Vars' => ini_get( 'max_input_vars' ),
144 144
 			'Memory Limit' => ini_get( 'memory_limit' ),
145 145
 			'Post Max Size' => ini_get( 'post_max_size' ),
146
-			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )),
147
-			'Session Name' => esc_html( ini_get( 'session.name' )),
148
-			'Session Save Path' => esc_html( ini_get( 'session.save_path' )),
149
-			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ),
150
-			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ),
146
+			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
147
+			'Session Name' => esc_html( ini_get( 'session.name' ) ),
148
+			'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
149
+			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
150
+			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
151 151
 			'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
152 152
 		];
153 153
 	}
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	{
160 160
 		$counts = glsr( CountsManager::class )->getCounts();
161 161
 		$counts = glsr( Helper::class )->flattenArray( $counts );
162
- 		array_walk( $counts, function( &$ratings ) use( $counts ) {
163
-			if( !is_array( $ratings )) {
162
+ 		array_walk( $counts, function( &$ratings ) use($counts) {
163
+			if( !is_array( $ratings ) ) {
164 164
 				glsr_log()
165 165
 					->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
166 166
 					->debug( $ratings )
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 		ksort( $settings );
200 200
 		$details = [];
201 201
 		foreach( $settings as $key => $value ) {
202
-			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue;
203
-			$value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' );
202
+			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue;
203
+			$value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
204 204
 			$details[$key] = $value;
205 205
 		}
206 206
 		return $details;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	{
214 214
 		return [
215 215
 			'Console size' => glsr( Console::class )->humanSize( '0' ),
216
-			'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' )),
216
+			'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ),
217 217
 			'Version (current)' => glsr()->version,
218 218
 			'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ),
219 219
 		];
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 			'WPE_APIKEY' => 'WP Engine',
274 274
 		];
275 275
 		foreach( $checks as $key => $value ) {
276
-			if( !$this->isWebhostCheckValid( $key ))continue;
276
+			if( !$this->isWebhostCheckValid( $key ) )continue;
277 277
 			return $value;
278 278
 		}
279
-		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ));
279
+		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
280 280
 	}
281 281
 
282 282
 	/**
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	{
298 298
 		$plugins = get_plugins();
299 299
 		$activePlugins = (array)get_option( 'active_plugins', [] );
300
-		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins )));
301
-		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
300
+		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
301
+		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
302 302
 		return $active + $inactive;
303 303
 	}
304 304
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	protected function implode( $title, array $details )
310 310
 	{
311 311
 		$strings = ['['.$title.']'];
312
-		$padding = max( array_map( 'strlen', array_keys( $details )) );
312
+		$padding = max( array_map( 'strlen', array_keys( $details ) ) );
313 313
 		$padding = max( [$padding, static::PAD] );
314 314
 		foreach( $details as $key => $value ) {
315 315
 			$strings[] = is_string( $key )
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
 		$keys = [
353 353
 			'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
354 354
 		];
355
-		array_walk( $settings, function( &$value, $setting ) use( $keys ) {
355
+		array_walk( $settings, function( &$value, $setting ) use($keys) {
356 356
 			foreach( $keys as $key ) {
357
-				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue;
357
+				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue;
358 358
 				$value = str_repeat( '•', 13 );
359 359
 				return;
360 360
 			}
Please login to merge, or discard this patch.
compatibility.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
  * @see https://wordpress.org/plugins/wp-super-cache/
21 21
  */
22 22
 add_action( 'site-reviews/review/created', function( $review, $request ) {
23
-	if( !function_exists( 'wp_cache_post_change' ))return;
23
+	if( !function_exists( 'wp_cache_post_change' ) )return;
24 24
 	wp_cache_post_change( $request->post_id );
25
-	if( empty( $review->assigned_to ) || $review->assigned_to == $request->post_id )return;
25
+	if( empty($review->assigned_to) || $review->assigned_to == $request->post_id )return;
26 26
 	wp_cache_post_change( $review->assigned_to );
27 27
 }, 10, 2 );
28 28
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
  */
34 34
 add_filter( 'sbp_exclude_defer_scripts', function( $scriptHandles ) {
35 35
 	$scriptHandles[] = 'site-reviews/google-recaptcha';
36
-	return array_keys( array_flip( $scriptHandles ));
36
+	return array_keys( array_flip( $scriptHandles ) );
37 37
 });
38 38
 
39 39
 /**
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
  * @see https://searchandfilter.com/
44 44
  */
45 45
 add_filter( 'sf_edit_query_args', function( $query ) {
46
-	if( !empty( $query['meta_key'] ) && $query['meta_key'] == '_glsr_ranking' ) {
47
-		unset( $query['meta_key'] );
46
+	if( !empty($query['meta_key']) && $query['meta_key'] == '_glsr_ranking' ) {
47
+		unset($query['meta_key']);
48 48
 		$query['meta_query'] = [
49 49
 			'relation' => 'OR',
50 50
 			['key' => '_glsr_ranking', 'compare' => 'EXISTS'],
Please login to merge, or discard this patch.
helpers.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 		'glsr_get_review', 'glsr_get_reviews',
20 20
 		'glsr_log',
21 21
 	);
22
-	if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return;
23
-	add_filter( $hook, function() use( $hook, $args ) {
22
+	if( !in_array( $hook, $hooks ) || !function_exists( $hook ) )return;
23
+	add_filter( $hook, function() use($hook, $args) {
24 24
 		array_shift( $args ); // remove the fallback value
25 25
 		return call_user_func_array( $hook, $args );
26 26
 	});
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function glsr( $alias = null ) {
33 33
 	$app = \GeminiLabs\SiteReviews\Application::load();
34
-	return !empty( $alias )
34
+	return !empty($alias)
35 35
 		? $app->make( $alias )
36 36
 		: $app;
37 37
 }
@@ -41,19 +41,19 @@  discard block
 block discarded – undo
41 41
  */
42 42
 function glsr_calculate_ratings() {
43 43
 	glsr( 'Controllers\AdminController' )->routerCountReviews( false );
44
-	glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ));
44
+	glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' ) );
45 45
 }
46 46
 
47 47
 /**
48 48
  * @return null|\GeminiLabs\SiteReviews\Review
49 49
  */
50 50
 function glsr_create_review( $reviewValues = array() ) {
51
-	if( !is_array( $reviewValues )) {
51
+	if( !is_array( $reviewValues ) ) {
52 52
 		$reviewValues = array();
53 53
 	}
54 54
 	$review = new \GeminiLabs\SiteReviews\Commands\CreateReview( $reviewValues );
55 55
 	$result = glsr( 'Database\ReviewManager' )->create( $review );
56
-	return !empty( $result )
56
+	return !empty($result)
57 57
 		? $result
58 58
 		: null;
59 59
 }
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
  * @return \WP_Screen|object
63 63
  */
64 64
 function glsr_current_screen() {
65
-	if( function_exists( 'get_current_screen' )) {
65
+	if( function_exists( 'get_current_screen' ) ) {
66 66
 		$screen = get_current_screen();
67 67
 	}
68
-	return empty( $screen )
68
+	return empty($screen)
69 69
 		? (object)array_fill_keys( ['base', 'id', 'post_type'], null )
70 70
 		: $screen;
71 71
 }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
  * @return \GeminiLabs\SiteReviews\Review|void
112 112
  */
113 113
 function glsr_get_review( $post_id ) {
114
-	if( !is_numeric( $post_id ))return;
114
+	if( !is_numeric( $post_id ) )return;
115 115
 	$post = get_post( $post_id );
116 116
 	if( $post instanceof WP_Post ) {
117 117
 		return glsr( 'Database\ReviewManager' )->single( $post );
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
  * @todo document change of $reviews->reviews to $reviews->results
124 124
  */
125 125
 function glsr_get_reviews( $args = array() ) {
126
-	if( !is_array( $args )) {
126
+	if( !is_array( $args ) ) {
127 127
 		$args = [];
128 128
 	}
129 129
 	return glsr( 'Database\ReviewManager' )->get( $args );
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
  */
135 135
 function glsr_log() {
136 136
 	$args = func_get_args();
137
-	$context = isset( $args[1] )
137
+	$context = isset($args[1])
138 138
 		? $args[1]
139 139
 		: [];
140 140
 	$console = glsr( 'Modules\Console' );
141
-	return !empty( $args )
141
+	return !empty($args)
142 142
 		? $console->log( 'debug', $args[0], $context )
143 143
 		: $console;
144 144
 }
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
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 			$className = str_replace( '.php', '', $file );
25 25
 			$version = str_replace( ['Upgrade_', '_'], ['', '.'], $className );
26 26
 			$versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions
27
-			if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return;
27
+			if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ) )return;
28 28
 			glsr( 'Modules\\Upgrader\\'.$className );
29 29
 			glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix );
30 30
 		});
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			$this->setReviewCounts();
42 42
 			$this->updateVersionFrom( $version );
43 43
 		}
44
-		else if( !glsr( OptionManager::class )->get( 'last_review_count', false )) {
44
+		else if( !glsr( OptionManager::class )->get( 'last_review_count', false ) ) {
45 45
 			$this->setReviewCounts();
46 46
 		}
47 47
 	}
Please login to merge, or discard this patch.
plugin/Modules/Validator.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		foreach( $this->rules as $attribute => $rules ) {
75 75
 			foreach( $rules as $rule ) {
76 76
 				$this->validateAttribute( $attribute, $rule );
77
-				if( $this->shouldStopValidating( $attribute ))break;
77
+				if( $this->shouldStopValidating( $attribute ) )break;
78 78
 			}
79 79
 		}
80 80
 		return $this->errors;
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function validateAttribute( $attribute, $rule )
91 91
 	{
92
-		list( $rule, $parameters ) = $this->parseRule( $rule );
92
+		list($rule, $parameters) = $this->parseRule( $rule );
93 93
 		if( $rule == '' )return;
94 94
 		$value = $this->getValue( $attribute );
95
-		if( !method_exists( $this, $method = 'validate'.$rule )) {
95
+		if( !method_exists( $this, $method = 'validate'.$rule ) ) {
96 96
 			throw new BadMethodCallException( "Method [$method] does not exist." );
97 97
 		}
98
-		if( !$this->$method( $value, $attribute, $parameters )) {
98
+		if( !$this->$method( $value, $attribute, $parameters ) ) {
99 99
 			$this->addFailure( $attribute, $rule, $parameters );
100 100
 		}
101 101
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	protected function getMessage( $attribute, $rule, array $parameters )
146 146
 	{
147
-		if( in_array( $rule, $this->sizeRules )) {
147
+		if( in_array( $rule, $this->sizeRules ) ) {
148 148
 			return $this->getSizeMessage( $attribute, $rule, $parameters );
149 149
 		}
150 150
 		$lowerRule = glsr( Helper::class )->snakeCase( $rule );
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	protected function getRule( $attribute, $rules )
161 161
 	{
162
-		if( !array_key_exists( $attribute, $this->rules ))return;
162
+		if( !array_key_exists( $attribute, $this->rules ) )return;
163 163
 		$rules = (array)$rules;
164 164
 		foreach( $this->rules[$attribute] as $rule ) {
165
-			list( $rule, $parameters ) = $this->parseRule( $rule );
166
-			if( in_array( $rule, $rules )) {
165
+			list($rule, $parameters) = $this->parseRule( $rule );
166
+			if( in_array( $rule, $rules ) ) {
167 167
 				return [$rule, $parameters];
168 168
 			}
169 169
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		if( is_numeric( $value ) && $hasNumeric ) {
182 182
 			return $value;
183 183
 		}
184
-		else if( is_array( $value )) {
184
+		else if( is_array( $value ) ) {
185 185
 			return count( $value );
186 186
 		}
187 187
 		return function_exists( 'mb_strlen' )
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	protected function getValue( $attribute )
211 211
 	{
212
-		if( isset( $this->data[$attribute] )) {
212
+		if( isset($this->data[$attribute]) ) {
213 213
 			return $this->data[$attribute];
214 214
 		}
215 215
 	}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	protected function hasRule( $attribute, $rules )
224 224
 	{
225
-		return !is_null( $this->getRule( $attribute, $rules ));
225
+		return !is_null( $this->getRule( $attribute, $rules ) );
226 226
 	}
227 227
 
228 228
 	/**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	{
261 261
 		$parameters = [];
262 262
 		if( strpos( $rule, ':' ) !== false ) {
263
-			list( $rule, $parameter ) = explode( ':', $rule, 2 );
263
+			list($rule, $parameter) = explode( ':', $rule, 2 );
264 264
 			$parameters = $this->parseParameters( $rule, $parameter );
265 265
 		}
266 266
 		$rule = glsr( Helper::class )->camelCase( $rule );
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	protected function shouldStopValidating( $attribute )
290 290
 	{
291 291
 		return $this->hasRule( $attribute, $this->implicitRules )
292
-			&& isset( $this->failedRules[$attribute] )
292
+			&& isset($this->failedRules[$attribute])
293 293
 			&& array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules );
294 294
 	}
295 295
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	protected function translator( $key, array $parameters )
303 303
 	{
304 304
 		$strings = glsr( ValidationStringsDefaults::class )->defaults();
305
-		if( isset( $strings[$key] )) {
305
+		if( isset($strings[$key]) ) {
306 306
 			return $this->replace( $strings[$key], $parameters );
307 307
 		}
308 308
 		return "error";
Please login to merge, or discard this patch.
plugin/Application.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	public function __construct()
34 34
 	{
35 35
 		static::$instance = $this;
36
-		$this->file = realpath( trailingslashit( dirname( __DIR__ )).static::ID.'.php' );
36
+		$this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' );
37 37
 		$plugin = get_file_data( $this->file, [
38 38
 			'languages' => 'Domain Path',
39 39
 			'name' => 'Plugin Name',
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	{
86 86
 		$constant = 'static::'.$property;
87 87
 		return defined( $constant )
88
-			? apply_filters( 'site-reviews/const/'.$property, constant( $constant ))
88
+			? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) )
89 89
 			: '';
90 90
 	}
91 91
 
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 	public function file( $view )
105 105
 	{
106 106
 		$file = '';
107
-		$view.= '.php';
108
-		if( glsr( Helper::class )->startsWith( 'templates/', $view )) {
109
-			$file = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ));
110
-			if( !file_exists( $file )) {
107
+		$view .= '.php';
108
+		if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) {
109
+			$file = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) );
110
+			if( !file_exists( $file ) ) {
111 111
 				$file = $this->path( $view );
112 112
 			}
113 113
 		}
114
-		if( !file_exists( $file )) {
114
+		if( !file_exists( $file ) ) {
115 115
 			$file = $this->path( 'views/'.$view );
116 116
 		}
117 117
 		return $file;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function getDefaults()
124 124
 	{
125
-		if( empty( $this->defaults )) {
125
+		if( empty($this->defaults) ) {
126 126
 			$this->defaults = $this->make( DefaultsManager::class )->get();
127 127
 			$this->upgrade();
128 128
 		}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	public function hasPermission()
136 136
 	{
137 137
 		$isAdmin = $this->isAdmin();
138
-		return !$isAdmin || ( $isAdmin && current_user_can( $this->constant( 'CAPABILITY' )));
138
+		return !$isAdmin || ($isAdmin && current_user_can( $this->constant( 'CAPABILITY' ) ));
139 139
 	}
140 140
 
141 141
 	/**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		$types = apply_filters( 'site-reviews/addon/types', [] );
192 192
 		$this->reviewTypes = wp_parse_args( $types, [
193 193
 			'local' => __( 'Local', 'site-reviews' ),
194
-		]);
194
+		] );
195 195
 	}
196 196
 
197 197
 	/**
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	{
203 203
 		$view = apply_filters( 'site-reviews/render/view', $view, $data );
204 204
 		$file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data );
205
-		if( !file_exists( $file )) {
205
+		if( !file_exists( $file ) ) {
206 206
 			glsr_log()->error( 'File not found: '.$file );
207 207
 			return;
208 208
 		}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	public function scheduleCronJob()
218 218
 	{
219
-		if( wp_next_scheduled( static::CRON_EVENT ))return;
219
+		if( wp_next_scheduled( static::CRON_EVENT ) )return;
220 220
 		wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT );
221 221
 	}
222 222
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 */
235 235
 	public function unscheduleCronJob()
236 236
 	{
237
-		wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT );
237
+		wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT );
238 238
 	}
239 239
 
240 240
 	/**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	public function url( $path = '' )
268 268
 	{
269
-		$url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ));
269
+		$url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) );
270 270
 		return apply_filters( 'site-reviews/url', $url, $path );
271 271
 	}
272 272
 }
Please login to merge, or discard this patch.
plugin/Database/Cache.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 			$ipAddresses = array_fill_keys( ['v4', 'v6'], [] );
20 20
 			foreach( array_keys( $ipAddresses ) as $version ) {
21 21
 				$response = wp_remote_get( 'https://www.cloudflare.com/ips-'.$version );
22
-				if( is_wp_error( $response )) {
22
+				if( is_wp_error( $response ) ) {
23 23
 					glsr_log()->error( $response->get_error_message() );
24 24
 					continue;
25 25
 				}
26
-				$ipAddresses[$version] = array_filter( preg_split( '/\R/', wp_remote_retrieve_body( $response )));
26
+				$ipAddresses[$version] = array_filter( preg_split( '/\R/', wp_remote_retrieve_body( $response ) ) );
27 27
 			}
28 28
 			set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, static::EXPIRY_TIME );
29 29
 		}
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		if( $test === false ) {
58 58
 			$response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' );
59 59
 			$test = !is_wp_error( $response )
60
-				&& in_array( $response['response']['code'], range( 200, 299 ))
60
+				&& in_array( $response['response']['code'], range( 200, 299 ) )
61 61
 				? 'Works'
62 62
 				: 'Does not work';
63 63
 			set_transient( Application::ID.'_remote_post_test', $test, static::EXPIRY_TIME );
Please login to merge, or discard this patch.