Passed
Push — master ( 3384db...78f140 )
by Paul
04:58
created
plugin/Modules/Blacklist.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,9 @@
 block discarded – undo
37 37
 		$lines = explode( "\n", $blacklist );
38 38
 		foreach( (array) $lines as $line ) {
39 39
 			$line = trim( $line );
40
-			if( empty( $line ) || 256 < strlen( $line ))continue;
40
+			if( empty( $line ) || 256 < strlen( $line )) {
41
+				continue;
42
+			}
41 43
 			$pattern = sprintf( '#%s#i', preg_quote( $line, '#' ));
42 44
 			if( preg_match( $pattern, $target )) {
43 45
 				return true;
Please login to merge, or discard this 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.reviews-form.blacklist.entries' ));
35
-		if( empty( $blacklist )) {
34
+		$blacklist = trim( glsr( OptionManager::class )->get( 'settings.reviews-form.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/Modules/Notice.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	public function add( $type, $message, array $args = [] )
17 17
 	{
18
-		if( empty( array_filter( [$message, $type] )))return;
18
+		if( empty( array_filter( [$message, $type] ))) {
19
+			return;
20
+		}
19 21
 		$args['message'] = $message;
20 22
 		$args['type'] = $type;
21 23
 		add_settings_error( Application::ID, '', json_encode( $this->normalize( $args )));
@@ -56,7 +58,9 @@  discard block
 block discarded – undo
56 58
 		$notices = array_map( 'unserialize',
57 59
 			array_unique( array_map( 'serialize', get_settings_errors( Application::ID )))
58 60
 		);
59
-		if( empty( $notices ))return;
61
+		if( empty( $notices )) {
62
+			return;
63
+		}
60 64
 		return array_reduce( $notices, function( $carry, $notice ) {
61 65
 			return $carry.$this->buildNotice( json_decode( $notice['message'], true ));
62 66
 		});
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	public function add( $type, $message, array $args = [] )
17 17
 	{
18
-		if( empty( array_filter( [$message, $type] )))return;
18
+		if( empty(array_filter( [$message, $type] )) )return;
19 19
 		$args['message'] = $message;
20 20
 		$args['type'] = $type;
21
-		add_settings_error( Application::ID, '', json_encode( $this->normalize( $args )));
21
+		add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) );
22 22
 	}
23 23
 
24 24
 	/**
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	public function get()
55 55
 	{
56 56
 		$notices = array_map( 'unserialize',
57
-			array_unique( array_map( 'serialize', get_settings_errors( Application::ID )))
57
+			array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) )
58 58
 		);
59
-		if( empty( $notices ))return;
59
+		if( empty($notices) )return;
60 60
 		return array_reduce( $notices, function( $carry, $notice ) {
61
-			return $carry.$this->buildNotice( json_decode( $notice['message'], true ));
61
+			return $carry.$this->buildNotice( json_decode( $notice['message'], true ) );
62 62
 		});
63 63
 	}
64 64
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		}
80 80
 		return glsr( Builder::class )->div( $messages, [
81 81
 			'class' => $class,
82
-		]);
82
+		] );
83 83
 	}
84 84
 
85 85
 	/**
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 			'type' => '',
95 95
 		];
96 96
 		$args = shortcode_atts( $defaults, $args );
97
-		if( !in_array( $args['type'], ['error', 'warning', 'success'] )) {
97
+		if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) {
98 98
 			$args['type'] = 'success';
99 99
 		}
100 100
 		$args['messages'] = is_wp_error( $args['message'] )
101 101
 			? (array)$args['message']->get_error_message()
102 102
 			: (array)$args['message'];
103
-		unset( $args['message'] );
103
+		unset($args['message']);
104 104
 		return $args;
105 105
 	}
106 106
 }
Please login to merge, or discard this patch.
plugin/Modules/Date.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@
 block discarded – undo
30 30
 	{
31 31
 		$diff = time() - strtotime( $date );
32 32
 		foreach( static::$TIME_PERIODS as $i => $timePeriod ) {
33
-			if( $diff > $timePeriod[0] )continue;
33
+			if( $diff > $timePeriod[0] ) {
34
+				continue;
35
+			}
34 36
 			$unit = floor( $diff / $timePeriod[1] );
35 37
 			$relativeDates = [
36 38
 				_n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ),
Please login to merge, or discard this patch.
plugin/Modules/System.php 2 patches
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,7 +83,9 @@  discard block
 block discarded – undo
83 83
 			get_mu_plugins(),
84 84
 			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ))
85 85
 		);
86
-		if( empty( $plugins ))return;
86
+		if( empty( $plugins )) {
87
+			return;
88
+		}
87 89
 		return $this->normalizePluginList( $plugins );
88 90
 	}
89 91
 
@@ -92,7 +94,9 @@  discard block
 block discarded – undo
92 94
 	 */
93 95
 	public function getMultisitePluginDetails()
94 96
 	{
95
-		if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return;
97
+		if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] ))) {
98
+			return;
99
+		}
96 100
 		return $this->normalizePluginList( wp_get_active_network_plugins() );
97 101
 	}
98 102
 
@@ -146,12 +150,16 @@  discard block
 block discarded – undo
146 150
 		$settings = glsr( OptionManager::class )->get( 'settings' );
147 151
 		$settings = $helper->flattenArray( $settings );
148 152
 		foreach( ['submissions.recaptcha.key', 'submissions.recaptcha.secret'] as $key ) {
149
-			if( empty( $settings[$key] ))continue;
153
+			if( empty( $settings[$key] )) {
154
+				continue;
155
+			}
150 156
 			$settings[$key] = str_repeat( '*', 10 );
151 157
 		}
152 158
 		$details = [];
153 159
 		foreach( $settings as $key => $value ) {
154
-			if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key ))continue;
160
+			if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key )) {
161
+				continue;
162
+			}
155 163
 			$value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' );
156 164
 			$details[$key] = $value;
157 165
 		}
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 			'inactive-plugin' => 'Inactive Plugins',
30 30
 			'setting' => 'Plugin Settings',
31 31
 		];
32
-		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) {
32
+		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) {
33 33
 			$methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
34 34
 			if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
35 35
 				return $carry.$this->implode( $details[$key], $systemDetails );
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	{
47 47
 		$plugins = get_plugins();
48 48
 		$activePlugins = (array)get_option( 'active_plugins', [] );
49
-		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ));
50
-		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
49
+		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
50
+		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
51 51
 	}
52 52
 
53 53
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	public function getInactivePluginDetails()
72 72
 	{
73 73
 		$activePlugins = (array)get_option( 'active_plugins', [] );
74
-		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins )));
74
+		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
75 75
 	}
76 76
 
77 77
 	/**
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 	{
82 82
 		$plugins = array_merge(
83 83
 			get_mu_plugins(),
84
-			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ))
84
+			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) )
85 85
 		);
86
-		if( empty( $plugins ))return;
86
+		if( empty($plugins) )return;
87 87
 		return $this->normalizePluginList( $plugins );
88 88
 	}
89 89
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function getMultisitePluginDetails()
94 94
 	{
95
-		if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return;
95
+		if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return;
96 96
 		return $this->normalizePluginList( wp_get_active_network_plugins() );
97 97
 	}
98 98
 
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 			'Max Input Vars' => ini_get( 'max_input_vars' ),
115 115
 			'Memory Limit' => ini_get( 'memory_limit' ),
116 116
 			'Post Max Size' => ini_get( 'post_max_size' ),
117
-			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )),
118
-			'Session Name' => esc_html( ini_get( 'session.name' )),
119
-			'Session Save Path' => esc_html( ini_get( 'session.save_path' )),
120
-			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), 1 ),
121
-			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), 1 ),
117
+			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
118
+			'Session Name' => esc_html( ini_get( 'session.name' ) ),
119
+			'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
120
+			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), 1 ),
121
+			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), 1 ),
122 122
 			'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
123 123
 		];
124 124
 	}
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 		$settings = glsr( OptionManager::class )->get( 'settings' );
147 147
 		$settings = $helper->flattenArray( $settings );
148 148
 		foreach( ['submissions.recaptcha.key', 'submissions.recaptcha.secret'] as $key ) {
149
-			if( empty( $settings[$key] ))continue;
149
+			if( empty($settings[$key]) )continue;
150 150
 			$settings[$key] = str_repeat( '*', 10 );
151 151
 		}
152 152
 		$details = [];
153 153
 		foreach( $settings as $key => $value ) {
154
-			if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key ))continue;
155
-			$value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' );
154
+			if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key ) )continue;
155
+			$value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
156 156
 			$details[$key] = $value;
157 157
 		}
158 158
 		return $details;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 				return $host;
233 233
 			}
234 234
 		}
235
-		return implode( ',', array_filter( [DB_HOST, $serverName] ));
235
+		return implode( ',', array_filter( [DB_HOST, $serverName] ) );
236 236
 	}
237 237
 
238 238
 	/**
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	{
254 254
 		$plugins = get_plugins();
255 255
 		$activePlugins = (array)get_option( 'active_plugins', [] );
256
-		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins )));
257
-		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
256
+		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
257
+		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
258 258
 		return $active + $inactive;
259 259
 	}
260 260
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	protected function implode( $title, array $details )
266 266
 	{
267 267
 		$strings = ['['.$title.']'];
268
-		$padding = max( array_map( 'strlen', array_keys( $details )) );
268
+		$padding = max( array_map( 'strlen', array_keys( $details ) ) );
269 269
 		$padding = max( [$padding, static::PAD] );
270 270
 		foreach( $details as $key => $value ) {
271 271
 			$strings[] = is_string( $key )
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
 	{
295 295
 		$response = wp_remote_post( static::WP_API_URL );
296 296
 		return !is_wp_error( $response )
297
-			&& !empty( $response['response']['code'] )
298
-			&& in_array( $response['response']['code'], range( 200, 299 ))
297
+			&& !empty($response['response']['code'])
298
+			&& in_array( $response['response']['code'], range( 200, 299 ) )
299 299
 			? 'Works'
300 300
 			: 'Does not work';
301 301
 	}
Please login to merge, or discard this patch.
plugin/Modules/Session.php 4 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
 use PasswordHash;
6 6
 
7 7
  /**
8
- * This class is derived from WP Session Manager (1.2.0)
9
- */
8
+  * This class is derived from WP Session Manager (1.2.0)
9
+  */
10 10
 class Session
11 11
 {
12 12
 	const SESSION_COOKIE = '_glsr_session';
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 
34 34
 	public function __construct()
35 35
 	{
36
-		if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE )) {
37
-			$cookie = explode( '||', stripslashes( $cookieId ));
36
+		if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ) ) {
37
+			$cookie = explode( '||', stripslashes( $cookieId ) );
38 38
 			$this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] );
39 39
 			$this->expiryTimestamp = absint( $cookie[1] );
40 40
 			$this->expiryTimestampReset = absint( $cookie[2] );
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	public function deleteExpiredSessions( $limit = 1000 )
79 79
 	{
80 80
 		global $wpdb;
81
-		if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) {
81
+		if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) {
82 82
 			$wpdb->query(
83 83
 				"DELETE FROM {$wpdb->options} WHERE option_name IN ('{$expiredSessions}')"
84 84
 			);
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 	public function get( $key, $fallback = '', $unset = false )
95 95
 	{
96 96
 		$key = sanitize_key( $key );
97
-		$value = isset( $this->sessionData[$key] )
97
+		$value = isset($this->sessionData[$key])
98 98
 			? maybe_unserialize( $this->sessionData[$key] )
99 99
 			: $fallback;
100
-		if( isset( $this->sessionData[$key] ) && $unset ) {
101
-			unset( $this->sessionData[$key] );
100
+		if( isset($this->sessionData[$key]) && $unset ) {
101
+			unset($this->sessionData[$key]);
102 102
 			$this->updateSession();
103 103
 		}
104 104
 		return $value;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	protected function deleteSession()
133 133
 	{
134 134
 		delete_option( $this->getSessionId() );
135
-		delete_option( $this->getSessionId( 'expires' ));
135
+		delete_option( $this->getSessionId( 'expires' ) );
136 136
 	}
137 137
 
138 138
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	protected function generateSessionId()
142 142
 	{
143
-		return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 ));
143
+		return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) );
144 144
 	}
145 145
 
146 146
 	/**
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
 		global $wpdb;
153 153
 		$expiredSessions = [];
154 154
 		$sessions = $wpdb->get_results(
155
-			"SELECT option_name AS name, option_value AS expiration " .
156
-			"FROM {$wpdb->options} " .
157
-			"WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' " .
158
-			"ORDER BY option_value ASC " .
155
+			"SELECT option_name AS name, option_value AS expiration ".
156
+			"FROM {$wpdb->options} ".
157
+			"WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' ".
158
+			"ORDER BY option_value ASC ".
159 159
 			"LIMIT 0, ".absint( $limit )
160 160
 		);
161
-		if( !empty( $sessions )) {
161
+		if( !empty($sessions) ) {
162 162
 			$now = time();
163 163
 			foreach( $sessions as $session ) {
164 164
 				if( $now <= $session->expiration )continue;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	protected function getSessionId( $separator = '' )
177 177
 	{
178
-		return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ));
178
+		return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) );
179 179
 	}
180 180
 
181 181
 	/**
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	protected function getSessionData()
185 185
 	{
186
-		return $this->sessionData = (array) get_option( $this->getSessionId(), [] );
186
+		return $this->sessionData = (array)get_option( $this->getSessionId(), [] );
187 187
 	}
188 188
 
189 189
 	/**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	{
207 207
 		if( headers_sent() )return;
208 208
 		$cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset;
209
-		$cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( get_option( 'home' )));
209
+		$cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( get_option( 'home' ) ) );
210 210
 		setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath );
211 211
 	}
212 212
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 */
225 225
 	protected function updateSession()
226 226
 	{
227
-		if( false === get_option( $this->getSessionId() )) {
227
+		if( false === get_option( $this->getSessionId() ) ) {
228 228
 			$this->createSession();
229 229
 		}
230 230
 		else {
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -161,7 +161,9 @@  discard block
 block discarded – undo
161 161
 		if( !empty( $sessions )) {
162 162
 			$now = time();
163 163
 			foreach( $sessions as $session ) {
164
-				if( $now <= $session->expiration )continue;
164
+				if( $now <= $session->expiration ) {
165
+					continue;
166
+				}
165 167
 				$expiredSessions[] = $session->name;
166 168
 				$expiredSessions[] = str_replace( '_expires_', '_', $session->name );
167 169
 			}
@@ -204,7 +206,9 @@  discard block
 block discarded – undo
204 206
 	 */
205 207
 	protected function setCookie()
206 208
 	{
207
-		if( headers_sent() )return;
209
+		if( headers_sent() ) {
210
+			return;
211
+		}
208 212
 		$cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset;
209 213
 		$cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( get_option( 'home' )));
210 214
 		setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath );
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@
 block discarded – undo
153 153
 		$expiredSessions = [];
154 154
 		$sessions = $wpdb->get_results(
155 155
 			"SELECT option_name AS name, option_value AS expiration " .
156
-			"FROM {$wpdb->options} " .
156
+			"from {$wpdb->options} " .
157 157
 			"WHERE option_name LIKE '".static::SESSION_COOKIE."_expires_%' " .
158 158
 			"ORDER BY option_value ASC " .
159 159
 			"LIMIT 0, ".absint( $limit )
Please login to merge, or discard this patch.
plugin/Modules/Schema.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,7 +108,9 @@  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 )) {
112
+			return;
113
+		}
112 114
 		printf( '<script type="application/ld+json">%s</script>', json_encode(
113 115
 			apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
114 116
 			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
@@ -181,7 +183,9 @@  discard block
 block discarded – undo
181 183
 		if( $value != $fallback ) {
182 184
 			return $value;
183 185
 		}
184
-		if( !is_single() && !is_page() )return;
186
+		if( !is_single() && !is_page() ) {
187
+			return;
188
+		}
185 189
 		switch( $option ) {
186 190
 			case 'description':
187 191
 				return get_the_excerpt();
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 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
 	/**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	protected function getSchemaOption( $option, $fallback )
163 163
 	{
164
-		if( $schemaOption = trim( get_post_meta( get_the_ID(), 'schema_'.$option, true ))) {
164
+		if( $schemaOption = trim( get_post_meta( 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.
plugin/Modules/Akismet.php 2 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@  discard block
 block discarded – undo
30 30
 			// 'is_test' => 1,
31 31
 		];
32 32
 		foreach( $_SERVER as $key => $value ) {
33
-			if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ))continue;
33
+			if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] )) {
34
+				continue;
35
+			}
34 36
 			$submission[$key] = $value;
35 37
 		}
36 38
 		return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review ));
@@ -56,12 +58,16 @@  discard block
 block discarded – undo
56 58
 	{
57 59
 		$query = [];
58 60
 		foreach( $data as $key => $value ) {
59
-			if( is_array( $value ) || is_object( $value ))continue;
61
+			if( is_array( $value ) || is_object( $value )) {
62
+				continue;
63
+			}
60 64
 			if( $value === false ) {
61 65
 				$value = '0';
62 66
 			}
63 67
 			$value = trim( $value );
64
-			if( !strlen( $value ))continue;
68
+			if( !strlen( $value )) {
69
+				continue;
70
+			}
65 71
 			$query[] = urlencode( $key ).'='.urlencode( $value );
66 72
 		}
67 73
 		return implode( '&', $query );
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 			// 'is_test' => 1,
32 32
 		];
33 33
 		foreach( $_SERVER as $key => $value ) {
34
-			if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ))continue;
34
+			if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ) )continue;
35 35
 			$submission[$key] = $value;
36 36
 		}
37
-		return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review ));
37
+		return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review ) );
38 38
 	}
39 39
 
40 40
 	/**
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	{
58 58
 		$query = [];
59 59
 		foreach( $data as $key => $value ) {
60
-			if( is_array( $value ) || is_object( $value ))continue;
60
+			if( is_array( $value ) || is_object( $value ) )continue;
61 61
 			if( $value === false ) {
62 62
 				$value = '0';
63 63
 			}
64 64
 			$value = trim( $value );
65
-			if( !strlen( $value ))continue;
65
+			if( !strlen( $value ) )continue;
66 66
 			$query[] = urlencode( $key ).'='.urlencode( $value );
67 67
 		}
68 68
 		return implode( '&', $query );
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			|| !is_callable( ['Akismet', 'get_api_key'] )
78 78
 			|| !is_callable( ['Akismet', 'http_post'] )
79 79
 			? false
80
-			: (bool) AkismetPlugin::get_api_key();
80
+			: (bool)AkismetPlugin::get_api_key();
81 81
 		return apply_filters( 'site-reviews/akismet/is-active', $check );
82 82
 	}
83 83
 }
Please login to merge, or discard this patch.
plugin/Modules/Rating.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 		$counts = array_fill_keys( [5,4,3,2,1], [] );
64 64
 		array_walk( $counts, function( &$count, $key ) use( $reviews ) {
65 65
 			$count = count( array_filter( $reviews, function( $review ) use( $key ) {
66
-				if( !isset( $review->rating ))return;
66
+				if( !isset( $review->rating )) {
67
+					return;
68
+				}
67 69
 				return $review->rating == $key;
68 70
 			}));
69 71
 		});
@@ -83,7 +85,9 @@  discard block
 block discarded – undo
83 85
 	public function getLowerBound( array $upDownRatings, $confidencePercentage = 95 )
84 86
 	{
85 87
 		$numRatings = count( $upDownRatings );
86
-		if( !$numRatings )return 0;
88
+		if( !$numRatings ) {
89
+			return 0;
90
+		}
87 91
 		$positiveRatings = count( array_filter( $upDownRatings, function( $value ) {
88 92
 			return $value > 0;
89 93
 		}));
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	{
51 51
 		$average = count( $reviews );
52 52
 		if( $average > 0 ) {
53
-			$average = round( $this->getTotal( $reviews ) / $average, intval( $roundBy ));
53
+			$average = round( $this->getTotal( $reviews ) / $average, intval( $roundBy ) );
54 54
 		}
55
-		return floatval( apply_filters( 'site-reviews/rating/average', $average, $reviews ));
55
+		return floatval( apply_filters( 'site-reviews/rating/average', $average, $reviews ) );
56 56
 	}
57 57
 
58 58
 	/**
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function getCounts( array $reviews )
62 62
 	{
63
-		$counts = array_fill_keys( [5,4,3,2,1], [] );
64
-		array_walk( $counts, function( &$count, $key ) use( $reviews ) {
65
-			$count = count( array_filter( $reviews, function( $review ) use( $key ) {
66
-				if( !isset( $review->rating ))return;
63
+		$counts = array_fill_keys( [5, 4, 3, 2, 1], [] );
64
+		array_walk( $counts, function( &$count, $key ) use($reviews) {
65
+			$count = count( array_filter( $reviews, function( $review ) use($key) {
66
+				if( !isset($review->rating) )return;
67 67
 				return $review->rating == $key;
68
-			}));
68
+			}) );
69 69
 		});
70 70
 		return $counts;
71 71
 	}
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 		if( !$numRatings )return 0;
87 87
 		$positiveRatings = count( array_filter( $upDownRatings, function( $value ) {
88 88
 			return $value > 0;
89
-		}));
89
+		}) );
90 90
 		$z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
91 91
 		$phat = 1 * $positiveRatings / $numRatings;
92
-		return ( $phat + $z * $z / ( 2 * $numRatings ) - $z * sqrt(( $phat * ( 1 - $phat ) + $z * $z / ( 4 * $numRatings )) / $numRatings )) / ( 1 + $z * $z / $numRatings );
92
+		return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings);
93 93
 	}
94 94
 
95 95
 	/**
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	public function getPercentages( array $reviews )
109 109
 	{
110 110
 		$counts = $this->getCounts( $reviews );
111
-		array_walk( $counts, function( &$count, $rating ) use( $counts ) {
111
+		array_walk( $counts, function( &$count, $rating ) use($counts) {
112 112
 			$total = array_sum( $counts );
113
-			$count = !empty( $total ) && !empty( $counts[$rating] )
113
+			$count = !empty($total) && !empty($counts[$rating])
114 114
 				? $counts[$rating] / array_sum( $counts ) * 100
115 115
 				: 0;
116 116
 		});
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			$this->getRankingUsingImdb( $reviews ),
128 128
 			$reviews,
129 129
 			$this
130
-		));
130
+		) );
131 131
 	}
132 132
 
133 133
 	/**
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 		$bayesMinimal = 10; // confidence
158 158
 		// Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error.
159 159
 		// This could also be the average score of all items instead of a fixed value.
160
-		$bayesMean = ( $confidencePercentage / 100 ) * static::MAX_RATING; // prior, 70% = 3.5
160
+		$bayesMean = ($confidencePercentage / 100) * static::MAX_RATING; // prior, 70% = 3.5
161 161
 		$numOfReviews = count( $reviews );
162 162
 		$avgRating = $this->getAverage( $reviews );
163 163
 		return $avgRating > 0
164
-			? (( $bayesMinimal * $bayesMean ) + ( $avgRating * $numOfReviews )) / ( $bayesMinimal + $numOfReviews )
164
+			? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews)
165 165
 			: 0;
166 166
 	}
167 167
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		$weight = $this->getWeight( $ratingCounts, $ratingCountsSum );
183 183
 		$weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true );
184 184
 		$zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
185
-		return $weight - $zScore * sqrt(( $weightPow2 - pow( $weight, 2 )) / ( $ratingCountsSum + 1 ));
185
+		return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) );
186 186
 	}
187 187
 
188 188
 	/**
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 		$remainders = array_column( $percentages, 'remainder' );
203 203
 		array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages );
204 204
 		$i = 0;
205
-		if( array_sum( array_column( $percentages, 'percent' )) > 0 ) {
206
-			while( array_sum( array_column( $percentages, 'percent' )) < $target ) {
205
+		if( array_sum( array_column( $percentages, 'percent' ) ) > 0 ) {
206
+			while( array_sum( array_column( $percentages, 'percent' ) ) < $target ) {
207 207
 				$percentages[$i]['percent']++;
208 208
 				$i++;
209 209
 			}
210 210
 		}
211 211
 		array_multisort( $indexes, SORT_DESC, $percentages );
212
-		return array_combine( $indexes, array_column( $percentages, 'percent' ));
212
+		return array_combine( $indexes, array_column( $percentages, 'percent' ) );
213 213
 	}
214 214
 
215 215
 	/**
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false )
221 221
 	{
222 222
 		return array_reduce( array_keys( $ratingCounts ),
223
-			function( $count, $rating ) use( $ratingCounts, $ratingCountsSum, $powerOf2 ) {
223
+			function( $count, $rating ) use($ratingCounts, $ratingCountsSum, $powerOf2) {
224 224
 				$ratingLevel = $powerOf2 ? pow( $rating, 2 ) : $rating;
225
-				return $count + ( $ratingLevel * ( $ratingCounts[$rating] + 1 )) / $ratingCountsSum;
225
+				return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum;
226 226
 			}
227 227
 		);
228 228
 	}
Please login to merge, or discard this patch.
plugin/Database/OptionManager.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@
 block discarded – undo
42 42
 		$options = $this->all();
43 43
 		$pointer = &$options;
44 44
 		foreach( $keys as $key ) {
45
-			if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue;
45
+			if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] )) {
46
+				continue;
47
+			}
46 48
 			$pointer = &$pointer[$key];
47 49
 		}
48 50
 		unset( $pointer[$last] );
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	public function all()
25 25
 	{
26 26
 		$options = get_option( static::databaseKey(), [] );
27
-		if( !is_array( $options )) {
27
+		if( !is_array( $options ) ) {
28 28
 			delete_option( static::databaseKey() );
29 29
 			$options = [];
30 30
 		}
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 		$options = $this->all();
43 43
 		$pointer = &$options;
44 44
 		foreach( $keys as $key ) {
45
-			if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue;
45
+			if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) )continue;
46 46
 			$pointer = &$pointer[$key];
47 47
 		}
48
-		unset( $pointer[$last] );
48
+		unset($pointer[$last]);
49 49
 		return $this->set( $options );
50 50
 	}
51 51
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	public function get( $path = '', $fallback = '' )
58 58
 	{
59 59
 		$options = $this->all();
60
-		if( empty( $options )) {
60
+		if( empty($options) ) {
61 61
 			$options = [
62 62
 				'settings' => glsr( DefaultsManager::class )->get(),
63 63
 			];
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function set( $pathOrOptions, $value = '' )
74 74
 	{
75
-		if( is_string( $pathOrOptions )) {
75
+		if( is_string( $pathOrOptions ) ) {
76 76
 			$pathOrOptions = glsr( Helper::class )->setPathValue( $pathOrOptions, $value, $this->all() );
77 77
 		}
78 78
 		return update_option( static::databaseKey(), (array)$pathOrOptions );
Please login to merge, or discard this patch.