Passed
Push — feature/rebusify ( 816514...289185 )
by Paul
07:17
created
plugin/Modules/System.php 2 patches
Indentation   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -10,368 +10,368 @@
 block discarded – undo
10 10
 
11 11
 class System
12 12
 {
13
-    const PAD = 40;
13
+	const PAD = 40;
14 14
 
15
-    /**
16
-     * @return string
17
-     */
18
-    public function __toString()
19
-    {
20
-        return $this->get();
21
-    }
15
+	/**
16
+	 * @return string
17
+	 */
18
+	public function __toString()
19
+	{
20
+		return $this->get();
21
+	}
22 22
 
23
-    /**
24
-     * @return string
25
-     */
26
-    public function get()
27
-    {
28
-        $details = [
29
-            'plugin' => 'Plugin Details',
30
-            'addon' => 'Addon Details',
31
-            'browser' => 'Browser Details',
32
-            'server' => 'Server Details',
33
-            'php' => 'PHP Configuration',
34
-            'wordpress' => 'WordPress Configuration',
35
-            'mu-plugin' => 'Must-Use Plugins',
36
-            'multisite-plugin' => 'Network Active Plugins',
37
-            'active-plugin' => 'Active Plugins',
38
-            'inactive-plugin' => 'Inactive Plugins',
39
-            'setting' => 'Plugin Settings',
40
-            'reviews' => 'Review Counts',
41
-        ];
42
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
-            $methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
45
-                return $carry.$this->implode(
46
-                    strtoupper($details[$key]),
47
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
48
-                );
49
-            }
50
-            return $carry;
51
-        });
52
-        return trim($systemInfo);
53
-    }
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function get()
27
+	{
28
+		$details = [
29
+			'plugin' => 'Plugin Details',
30
+			'addon' => 'Addon Details',
31
+			'browser' => 'Browser Details',
32
+			'server' => 'Server Details',
33
+			'php' => 'PHP Configuration',
34
+			'wordpress' => 'WordPress Configuration',
35
+			'mu-plugin' => 'Must-Use Plugins',
36
+			'multisite-plugin' => 'Network Active Plugins',
37
+			'active-plugin' => 'Active Plugins',
38
+			'inactive-plugin' => 'Inactive Plugins',
39
+			'setting' => 'Plugin Settings',
40
+			'reviews' => 'Review Counts',
41
+		];
42
+		$systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
+			$methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
+			if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
45
+				return $carry.$this->implode(
46
+					strtoupper($details[$key]),
47
+					apply_filters('site-reviews/system/'.$key, $systemDetails)
48
+				);
49
+			}
50
+			return $carry;
51
+		});
52
+		return trim($systemInfo);
53
+	}
54 54
 
55
-    /**
56
-     * @return array
57
-     */
58
-    public function getActivePluginDetails()
59
-    {
60
-        $plugins = get_plugins();
61
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
63
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
64
-    }
55
+	/**
56
+	 * @return array
57
+	 */
58
+	public function getActivePluginDetails()
59
+	{
60
+		$plugins = get_plugins();
61
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
+		$inactive = array_diff_key($plugins, array_flip($activePlugins));
63
+		return $this->normalizePluginList(array_diff_key($plugins, $inactive));
64
+	}
65 65
 
66
-    /**
67
-     * @return array
68
-     */
69
-    public function getAddonDetails()
70
-    {
71
-        $details = apply_filters('site-reviews/addon/system-info', []);
72
-        ksort($details);
73
-        return $details;
74
-    }
66
+	/**
67
+	 * @return array
68
+	 */
69
+	public function getAddonDetails()
70
+	{
71
+		$details = apply_filters('site-reviews/addon/system-info', []);
72
+		ksort($details);
73
+		return $details;
74
+	}
75 75
 
76
-    /**
77
-     * @return array
78
-     */
79
-    public function getBrowserDetails()
80
-    {
81
-        $browser = new Browser();
82
-        $name = esc_attr($browser->getName());
83
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
-        $version = esc_attr($browser->getVersion());
85
-        return [
86
-            'Browser Name' => sprintf('%s %s', $name, $version),
87
-            'Browser UA' => $userAgent,
88
-        ];
89
-    }
76
+	/**
77
+	 * @return array
78
+	 */
79
+	public function getBrowserDetails()
80
+	{
81
+		$browser = new Browser();
82
+		$name = esc_attr($browser->getName());
83
+		$userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
+		$version = esc_attr($browser->getVersion());
85
+		return [
86
+			'Browser Name' => sprintf('%s %s', $name, $version),
87
+			'Browser UA' => $userAgent,
88
+		];
89
+	}
90 90
 
91
-    /**
92
-     * @return array
93
-     */
94
-    public function getInactivePluginDetails()
95
-    {
96
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
98
-        $multisitePlugins = $this->getMultisitePluginDetails();
99
-        return is_array($multisitePlugins)
100
-            ? array_diff($inactivePlugins, $multisitePlugins)
101
-            : $inactivePlugins;
102
-    }
91
+	/**
92
+	 * @return array
93
+	 */
94
+	public function getInactivePluginDetails()
95
+	{
96
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
+		$inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
98
+		$multisitePlugins = $this->getMultisitePluginDetails();
99
+		return is_array($multisitePlugins)
100
+			? array_diff($inactivePlugins, $multisitePlugins)
101
+			: $inactivePlugins;
102
+	}
103 103
 
104
-    /**
105
-     * @return void|array
106
-     */
107
-    public function getMuPluginDetails()
108
-    {
109
-        if (empty($plugins = get_mu_plugins())) {
110
-            return;
111
-        }
112
-        return $this->normalizePluginList($plugins);
113
-    }
104
+	/**
105
+	 * @return void|array
106
+	 */
107
+	public function getMuPluginDetails()
108
+	{
109
+		if (empty($plugins = get_mu_plugins())) {
110
+			return;
111
+		}
112
+		return $this->normalizePluginList($plugins);
113
+	}
114 114
 
115
-    /**
116
-     * @return void|array
117
-     */
118
-    public function getMultisitePluginDetails()
119
-    {
120
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
-        if (!is_multisite() || empty($activePlugins)) {
122
-            return;
123
-        }
124
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
125
-    }
115
+	/**
116
+	 * @return void|array
117
+	 */
118
+	public function getMultisitePluginDetails()
119
+	{
120
+		$activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
+		if (!is_multisite() || empty($activePlugins)) {
122
+			return;
123
+		}
124
+		return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
125
+	}
126 126
 
127
-    /**
128
-     * @return array
129
-     */
130
-    public function getPhpDetails()
131
-    {
132
-        $displayErrors = ini_get('display_errors')
133
-            ? 'On ('.ini_get('display_errors').')'
134
-            : 'N/A';
135
-        $intlSupport = extension_loaded('intl')
136
-            ? phpversion('intl')
137
-            : 'false';
138
-        return [
139
-            'cURL' => var_export(function_exists('curl_init'), true),
140
-            'Default Charset' => ini_get('default_charset'),
141
-            'Display Errors' => $displayErrors,
142
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
143
-            'Intl' => $intlSupport,
144
-            'IPv6' => var_export(defined('AF_INET6'), true),
145
-            'Max Execution Time' => ini_get('max_execution_time'),
146
-            'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
-            'Max Input Vars' => ini_get('max_input_vars'),
148
-            'Memory Limit' => ini_get('memory_limit'),
149
-            'Post Max Size' => ini_get('post_max_size'),
150
-            'Sendmail Path' => ini_get('sendmail_path'),
151
-            'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
-            'Session Name' => esc_html(ini_get('session.name')),
153
-            'Session Save Path' => esc_html(ini_get('session.save_path')),
154
-            'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
-            'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
-            'Upload Max Filesize' => ini_get('upload_max_filesize'),
157
-        ];
158
-    }
127
+	/**
128
+	 * @return array
129
+	 */
130
+	public function getPhpDetails()
131
+	{
132
+		$displayErrors = ini_get('display_errors')
133
+			? 'On ('.ini_get('display_errors').')'
134
+			: 'N/A';
135
+		$intlSupport = extension_loaded('intl')
136
+			? phpversion('intl')
137
+			: 'false';
138
+		return [
139
+			'cURL' => var_export(function_exists('curl_init'), true),
140
+			'Default Charset' => ini_get('default_charset'),
141
+			'Display Errors' => $displayErrors,
142
+			'fsockopen' => var_export(function_exists('fsockopen'), true),
143
+			'Intl' => $intlSupport,
144
+			'IPv6' => var_export(defined('AF_INET6'), true),
145
+			'Max Execution Time' => ini_get('max_execution_time'),
146
+			'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
+			'Max Input Vars' => ini_get('max_input_vars'),
148
+			'Memory Limit' => ini_get('memory_limit'),
149
+			'Post Max Size' => ini_get('post_max_size'),
150
+			'Sendmail Path' => ini_get('sendmail_path'),
151
+			'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
+			'Session Name' => esc_html(ini_get('session.name')),
153
+			'Session Save Path' => esc_html(ini_get('session.save_path')),
154
+			'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
+			'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
+			'Upload Max Filesize' => ini_get('upload_max_filesize'),
157
+		];
158
+	}
159 159
 
160
-    /**
161
-     * @return array
162
-     */
163
-    public function getReviewsDetails()
164
-    {
165
-        $counts = glsr(CountsManager::class)->getCounts();
166
-        $counts = glsr(Helper::class)->flattenArray($counts);
167
-        array_walk($counts, function (&$ratings) use ($counts) {
168
-            if (!is_array($ratings)) {
169
-                glsr_log()
170
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
-                    ->debug($ratings)
172
-                    ->debug($counts);
173
-                return;
174
-            }
175
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
176
-        });
177
-        ksort($counts);
178
-        return $counts;
179
-    }
160
+	/**
161
+	 * @return array
162
+	 */
163
+	public function getReviewsDetails()
164
+	{
165
+		$counts = glsr(CountsManager::class)->getCounts();
166
+		$counts = glsr(Helper::class)->flattenArray($counts);
167
+		array_walk($counts, function (&$ratings) use ($counts) {
168
+			if (!is_array($ratings)) {
169
+				glsr_log()
170
+					->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
+					->debug($ratings)
172
+					->debug($counts);
173
+				return;
174
+			}
175
+			$ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
176
+		});
177
+		ksort($counts);
178
+		return $counts;
179
+	}
180 180
 
181
-    /**
182
-     * @return array
183
-     */
184
-    public function getServerDetails()
185
-    {
186
-        global $wpdb;
187
-        return [
188
-            'Host Name' => $this->getHostName(),
189
-            'MySQL Version' => $wpdb->db_version(),
190
-            'PHP Version' => PHP_VERSION,
191
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
192
-        ];
193
-    }
181
+	/**
182
+	 * @return array
183
+	 */
184
+	public function getServerDetails()
185
+	{
186
+		global $wpdb;
187
+		return [
188
+			'Host Name' => $this->getHostName(),
189
+			'MySQL Version' => $wpdb->db_version(),
190
+			'PHP Version' => PHP_VERSION,
191
+			'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
192
+		];
193
+	}
194 194
 
195
-    /**
196
-     * @return array
197
-     */
198
-    public function getSettingDetails()
199
-    {
200
-        $helper = glsr(Helper::class);
201
-        $settings = glsr(OptionManager::class)->get('settings', []);
202
-        $settings = $helper->flattenArray($settings, true);
203
-        $settings = $this->purgeSensitiveData($settings);
204
-        ksort($settings);
205
-        $details = [];
206
-        foreach ($settings as $key => $value) {
207
-            if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
208
-                continue;
209
-            }
210
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
211
-            $details[$key] = $value;
212
-        }
213
-        return $details;
214
-    }
195
+	/**
196
+	 * @return array
197
+	 */
198
+	public function getSettingDetails()
199
+	{
200
+		$helper = glsr(Helper::class);
201
+		$settings = glsr(OptionManager::class)->get('settings', []);
202
+		$settings = $helper->flattenArray($settings, true);
203
+		$settings = $this->purgeSensitiveData($settings);
204
+		ksort($settings);
205
+		$details = [];
206
+		foreach ($settings as $key => $value) {
207
+			if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
208
+				continue;
209
+			}
210
+			$value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
211
+			$details[$key] = $value;
212
+		}
213
+		return $details;
214
+	}
215 215
 
216
-    /**
217
-     * @return array
218
-     */
219
-    public function getPluginDetails()
220
-    {
221
-        return [
222
-            'Console level' => glsr(Console::class)->humanLevel(),
223
-            'Console size' => glsr(Console::class)->humanSize('0'),
224
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
225
-            'Version (current)' => glsr()->version,
226
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
227
-        ];
228
-    }
216
+	/**
217
+	 * @return array
218
+	 */
219
+	public function getPluginDetails()
220
+	{
221
+		return [
222
+			'Console level' => glsr(Console::class)->humanLevel(),
223
+			'Console size' => glsr(Console::class)->humanSize('0'),
224
+			'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
225
+			'Version (current)' => glsr()->version,
226
+			'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
227
+		];
228
+	}
229 229
 
230
-    /**
231
-     * @return array
232
-     */
233
-    public function getWordpressDetails()
234
-    {
235
-        global $wpdb;
236
-        $theme = wp_get_theme();
237
-        return [
238
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
240
-            'Home URL' => home_url(),
241
-            'Language' => get_locale(),
242
-            'Memory Limit' => WP_MEMORY_LIMIT,
243
-            'Multisite' => var_export(is_multisite(), true),
244
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
-            'Post Stati' => implode(', ', get_post_stati()),
248
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
250
-            'Site URL' => site_url(),
251
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
-            'Version' => get_bloginfo('version'),
253
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
255
-            'WP Memory Limit' => WP_MEMORY_LIMIT,
256
-        ];
257
-    }
230
+	/**
231
+	 * @return array
232
+	 */
233
+	public function getWordpressDetails()
234
+	{
235
+		global $wpdb;
236
+		$theme = wp_get_theme();
237
+		return [
238
+			'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
+			'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
240
+			'Home URL' => home_url(),
241
+			'Language' => get_locale(),
242
+			'Memory Limit' => WP_MEMORY_LIMIT,
243
+			'Multisite' => var_export(is_multisite(), true),
244
+			'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
+			'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
+			'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
+			'Post Stati' => implode(', ', get_post_stati()),
248
+			'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
+			'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
250
+			'Site URL' => site_url(),
251
+			'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
+			'Version' => get_bloginfo('version'),
253
+			'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
+			'WP Max Upload Size' => size_format(wp_max_upload_size()),
255
+			'WP Memory Limit' => WP_MEMORY_LIMIT,
256
+		];
257
+	}
258 258
 
259
-    /**
260
-     * @return string
261
-     */
262
-    protected function detectWebhostProvider()
263
-    {
264
-        $checks = [
265
-            '.accountservergroup.com' => 'Site5',
266
-            '.gridserver.com' => 'MediaTemple Grid',
267
-            '.inmotionhosting.com' => 'InMotion Hosting',
268
-            '.ovh.net' => 'OVH',
269
-            '.pair.com' => 'pair Networks',
270
-            '.stabletransit.com' => 'Rackspace Cloud',
271
-            '.stratoserver.net' => 'STRATO',
272
-            '.sysfix.eu' => 'SysFix.eu Power Hosting',
273
-            'bluehost.com' => 'Bluehost',
274
-            'DH_USER' => 'DreamHost',
275
-            'Flywheel' => 'Flywheel',
276
-            'ipagemysql.com' => 'iPage',
277
-            'ipowermysql.com' => 'IPower',
278
-            'localhost:/tmp/mysql5.sock' => 'ICDSoft',
279
-            'mysqlv5' => 'NetworkSolutions',
280
-            'PAGELYBIN' => 'Pagely',
281
-            'secureserver.net' => 'GoDaddy',
282
-            'WPE_APIKEY' => 'WP Engine',
283
-        ];
284
-        foreach ($checks as $key => $value) {
285
-            if (!$this->isWebhostCheckValid($key)) {
286
-                continue;
287
-            }
288
-            return $value;
289
-        }
290
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
291
-    }
259
+	/**
260
+	 * @return string
261
+	 */
262
+	protected function detectWebhostProvider()
263
+	{
264
+		$checks = [
265
+			'.accountservergroup.com' => 'Site5',
266
+			'.gridserver.com' => 'MediaTemple Grid',
267
+			'.inmotionhosting.com' => 'InMotion Hosting',
268
+			'.ovh.net' => 'OVH',
269
+			'.pair.com' => 'pair Networks',
270
+			'.stabletransit.com' => 'Rackspace Cloud',
271
+			'.stratoserver.net' => 'STRATO',
272
+			'.sysfix.eu' => 'SysFix.eu Power Hosting',
273
+			'bluehost.com' => 'Bluehost',
274
+			'DH_USER' => 'DreamHost',
275
+			'Flywheel' => 'Flywheel',
276
+			'ipagemysql.com' => 'iPage',
277
+			'ipowermysql.com' => 'IPower',
278
+			'localhost:/tmp/mysql5.sock' => 'ICDSoft',
279
+			'mysqlv5' => 'NetworkSolutions',
280
+			'PAGELYBIN' => 'Pagely',
281
+			'secureserver.net' => 'GoDaddy',
282
+			'WPE_APIKEY' => 'WP Engine',
283
+		];
284
+		foreach ($checks as $key => $value) {
285
+			if (!$this->isWebhostCheckValid($key)) {
286
+				continue;
287
+			}
288
+			return $value;
289
+		}
290
+		return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
291
+	}
292 292
 
293
-    /**
294
-     * @return string
295
-     */
296
-    protected function getHostName()
297
-    {
298
-        return sprintf('%s (%s)',
299
-            $this->detectWebhostProvider(),
300
-            glsr(Helper::class)->getIpAddress()
301
-        );
302
-    }
293
+	/**
294
+	 * @return string
295
+	 */
296
+	protected function getHostName()
297
+	{
298
+		return sprintf('%s (%s)',
299
+			$this->detectWebhostProvider(),
300
+			glsr(Helper::class)->getIpAddress()
301
+		);
302
+	}
303 303
 
304
-    /**
305
-     * @return array
306
-     */
307
-    protected function getWordpressPlugins()
308
-    {
309
-        $plugins = get_plugins();
310
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
313
-        return $active + $inactive;
314
-    }
304
+	/**
305
+	 * @return array
306
+	 */
307
+	protected function getWordpressPlugins()
308
+	{
309
+		$plugins = get_plugins();
310
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
+		$inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
+		$active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
313
+		return $active + $inactive;
314
+	}
315 315
 
316
-    /**
317
-     * @param string $title
318
-     * @return string
319
-     */
320
-    protected function implode($title, array $details)
321
-    {
322
-        $strings = ['['.$title.']'];
323
-        $padding = max(array_map('strlen', array_keys($details)));
324
-        $padding = max([$padding, static::PAD]);
325
-        foreach ($details as $key => $value) {
326
-            $strings[] = is_string($key)
327
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
328
-                : ' - '.$value;
329
-        }
330
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
331
-    }
316
+	/**
317
+	 * @param string $title
318
+	 * @return string
319
+	 */
320
+	protected function implode($title, array $details)
321
+	{
322
+		$strings = ['['.$title.']'];
323
+		$padding = max(array_map('strlen', array_keys($details)));
324
+		$padding = max([$padding, static::PAD]);
325
+		foreach ($details as $key => $value) {
326
+			$strings[] = is_string($key)
327
+				? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
328
+				: ' - '.$value;
329
+		}
330
+		return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
331
+	}
332 332
 
333
-    /**
334
-     * @param string $key
335
-     * @return bool
336
-     */
337
-    protected function isWebhostCheckValid($key)
338
-    {
339
-        return defined($key)
340
-            || filter_input(INPUT_SERVER, $key)
341
-            || false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
-            || false !== strpos(DB_HOST, $key)
343
-            || false !== strpos(php_uname(), $key);
344
-    }
333
+	/**
334
+	 * @param string $key
335
+	 * @return bool
336
+	 */
337
+	protected function isWebhostCheckValid($key)
338
+	{
339
+		return defined($key)
340
+			|| filter_input(INPUT_SERVER, $key)
341
+			|| false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
+			|| false !== strpos(DB_HOST, $key)
343
+			|| false !== strpos(php_uname(), $key);
344
+	}
345 345
 
346
-    /**
347
-     * @return array
348
-     */
349
-    protected function normalizePluginList(array $plugins)
350
-    {
351
-        $plugins = array_map(function ($plugin) {
352
-            return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
-        }, $plugins);
354
-        natcasesort($plugins);
355
-        return array_flip($plugins);
356
-    }
346
+	/**
347
+	 * @return array
348
+	 */
349
+	protected function normalizePluginList(array $plugins)
350
+	{
351
+		$plugins = array_map(function ($plugin) {
352
+			return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
+		}, $plugins);
354
+		natcasesort($plugins);
355
+		return array_flip($plugins);
356
+	}
357 357
 
358
-    /**
359
-     * @return array
360
-     */
361
-    protected function purgeSensitiveData(array $settings)
362
-    {
363
-        $keys = [
364
-            'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
365
-        ];
366
-        array_walk($settings, function (&$value, $setting) use ($keys) {
367
-            foreach ($keys as $key) {
368
-                if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
369
-                    continue;
370
-                }
371
-                $value = str_repeat('•', 13);
372
-                return;
373
-            }
374
-        });
375
-        return $settings;
376
-    }
358
+	/**
359
+	 * @return array
360
+	 */
361
+	protected function purgeSensitiveData(array $settings)
362
+	{
363
+		$keys = [
364
+			'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
365
+		];
366
+		array_walk($settings, function (&$value, $setting) use ($keys) {
367
+			foreach ($keys as $key) {
368
+				if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
369
+					continue;
370
+				}
371
+				$value = str_repeat('•', 13);
372
+				return;
373
+			}
374
+		});
375
+		return $settings;
376
+	}
377 377
 }
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
             'setting' => 'Plugin Settings',
40 40
             'reviews' => 'Review Counts',
41 41
         ];
42
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
-            $methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
42
+        $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) {
43
+            $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
44
+            if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
45 45
                 return $carry.$this->implode(
46
-                    strtoupper($details[$key]),
47
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
46
+                    strtoupper( $details[$key] ),
47
+                    apply_filters( 'site-reviews/system/'.$key, $systemDetails )
48 48
                 );
49 49
             }
50 50
             return $carry;
51 51
         });
52
-        return trim($systemInfo);
52
+        return trim( $systemInfo );
53 53
     }
54 54
 
55 55
     /**
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     public function getActivePluginDetails()
59 59
     {
60 60
         $plugins = get_plugins();
61
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
63
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
61
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
62
+        $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
63
+        return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
64 64
     }
65 65
 
66 66
     /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function getAddonDetails()
70 70
     {
71
-        $details = apply_filters('site-reviews/addon/system-info', []);
72
-        ksort($details);
71
+        $details = apply_filters( 'site-reviews/addon/system-info', [] );
72
+        ksort( $details );
73 73
         return $details;
74 74
     }
75 75
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
     public function getBrowserDetails()
80 80
     {
81 81
         $browser = new Browser();
82
-        $name = esc_attr($browser->getName());
83
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
-        $version = esc_attr($browser->getVersion());
82
+        $name = esc_attr( $browser->getName() );
83
+        $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() );
84
+        $version = esc_attr( $browser->getVersion() );
85 85
         return [
86
-            'Browser Name' => sprintf('%s %s', $name, $version),
86
+            'Browser Name' => sprintf( '%s %s', $name, $version ),
87 87
             'Browser UA' => $userAgent,
88 88
         ];
89 89
     }
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getInactivePluginDetails()
95 95
     {
96
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
96
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
97
+        $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
98 98
         $multisitePlugins = $this->getMultisitePluginDetails();
99
-        return is_array($multisitePlugins)
100
-            ? array_diff($inactivePlugins, $multisitePlugins)
99
+        return is_array( $multisitePlugins )
100
+            ? array_diff( $inactivePlugins, $multisitePlugins )
101 101
             : $inactivePlugins;
102 102
     }
103 103
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function getMuPluginDetails()
108 108
     {
109
-        if (empty($plugins = get_mu_plugins())) {
109
+        if( empty($plugins = get_mu_plugins()) ) {
110 110
             return;
111 111
         }
112
-        return $this->normalizePluginList($plugins);
112
+        return $this->normalizePluginList( $plugins );
113 113
     }
114 114
 
115 115
     /**
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function getMultisitePluginDetails()
119 119
     {
120
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
-        if (!is_multisite() || empty($activePlugins)) {
120
+        $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] );
121
+        if( !is_multisite() || empty($activePlugins) ) {
122 122
             return;
123 123
         }
124
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
124
+        return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) );
125 125
     }
126 126
 
127 127
     /**
@@ -129,31 +129,31 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function getPhpDetails()
131 131
     {
132
-        $displayErrors = ini_get('display_errors')
133
-            ? 'On ('.ini_get('display_errors').')'
132
+        $displayErrors = ini_get( 'display_errors' )
133
+            ? 'On ('.ini_get( 'display_errors' ).')'
134 134
             : 'N/A';
135
-        $intlSupport = extension_loaded('intl')
136
-            ? phpversion('intl')
135
+        $intlSupport = extension_loaded( 'intl' )
136
+            ? phpversion( 'intl' )
137 137
             : 'false';
138 138
         return [
139
-            'cURL' => var_export(function_exists('curl_init'), true),
140
-            'Default Charset' => ini_get('default_charset'),
139
+            'cURL' => var_export( function_exists( 'curl_init' ), true ),
140
+            'Default Charset' => ini_get( 'default_charset' ),
141 141
             'Display Errors' => $displayErrors,
142
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
142
+            'fsockopen' => var_export( function_exists( 'fsockopen' ), true ),
143 143
             'Intl' => $intlSupport,
144
-            'IPv6' => var_export(defined('AF_INET6'), true),
145
-            'Max Execution Time' => ini_get('max_execution_time'),
146
-            'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
-            'Max Input Vars' => ini_get('max_input_vars'),
148
-            'Memory Limit' => ini_get('memory_limit'),
149
-            'Post Max Size' => ini_get('post_max_size'),
150
-            'Sendmail Path' => ini_get('sendmail_path'),
151
-            'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
-            'Session Name' => esc_html(ini_get('session.name')),
153
-            'Session Save Path' => esc_html(ini_get('session.save_path')),
154
-            'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
-            'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
-            'Upload Max Filesize' => ini_get('upload_max_filesize'),
144
+            'IPv6' => var_export( defined( 'AF_INET6' ), true ),
145
+            'Max Execution Time' => ini_get( 'max_execution_time' ),
146
+            'Max Input Nesting Level' => ini_get( 'max_input_nesting_level' ),
147
+            'Max Input Vars' => ini_get( 'max_input_vars' ),
148
+            'Memory Limit' => ini_get( 'memory_limit' ),
149
+            'Post Max Size' => ini_get( 'post_max_size' ),
150
+            'Sendmail Path' => ini_get( 'sendmail_path' ),
151
+            'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
152
+            'Session Name' => esc_html( ini_get( 'session.name' ) ),
153
+            'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
154
+            'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
155
+            'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
156
+            'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
157 157
         ];
158 158
     }
159 159
 
@@ -162,19 +162,19 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function getReviewsDetails()
164 164
     {
165
-        $counts = glsr(CountsManager::class)->getCounts();
166
-        $counts = glsr(Helper::class)->flattenArray($counts);
167
-        array_walk($counts, function (&$ratings) use ($counts) {
168
-            if (!is_array($ratings)) {
165
+        $counts = glsr( CountsManager::class )->getCounts();
166
+        $counts = glsr( Helper::class )->flattenArray( $counts );
167
+        array_walk( $counts, function( &$ratings ) use ($counts) {
168
+            if( !is_array( $ratings ) ) {
169 169
                 glsr_log()
170
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
-                    ->debug($ratings)
172
-                    ->debug($counts);
170
+                    ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
171
+                    ->debug( $ratings )
172
+                    ->debug( $counts );
173 173
                 return;
174 174
             }
175
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
175
+            $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')';
176 176
         });
177
-        ksort($counts);
177
+        ksort( $counts );
178 178
         return $counts;
179 179
     }
180 180
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             'Host Name' => $this->getHostName(),
189 189
             'MySQL Version' => $wpdb->db_version(),
190 190
             'PHP Version' => PHP_VERSION,
191
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
191
+            'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ),
192 192
         ];
193 193
     }
194 194
 
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function getSettingDetails()
199 199
     {
200
-        $helper = glsr(Helper::class);
201
-        $settings = glsr(OptionManager::class)->get('settings', []);
202
-        $settings = $helper->flattenArray($settings, true);
203
-        $settings = $this->purgeSensitiveData($settings);
204
-        ksort($settings);
200
+        $helper = glsr( Helper::class );
201
+        $settings = glsr( OptionManager::class )->get( 'settings', [] );
202
+        $settings = $helper->flattenArray( $settings, true );
203
+        $settings = $this->purgeSensitiveData( $settings );
204
+        ksort( $settings );
205 205
         $details = [];
206
-        foreach ($settings as $key => $value) {
207
-            if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
206
+        foreach( $settings as $key => $value ) {
207
+            if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) ) {
208 208
                 continue;
209 209
             }
210
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
210
+            $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
211 211
             $details[$key] = $value;
212 212
         }
213 213
         return $details;
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
     public function getPluginDetails()
220 220
     {
221 221
         return [
222
-            'Console level' => glsr(Console::class)->humanLevel(),
223
-            'Console size' => glsr(Console::class)->humanSize('0'),
224
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
222
+            'Console level' => glsr( Console::class )->humanLevel(),
223
+            'Console size' => glsr( Console::class )->humanSize( '0' ),
224
+            'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ),
225 225
             'Version (current)' => glsr()->version,
226
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
226
+            'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ),
227 227
         ];
228 228
     }
229 229
 
@@ -235,23 +235,23 @@  discard block
 block discarded – undo
235 235
         global $wpdb;
236 236
         $theme = wp_get_theme();
237 237
         return [
238
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
238
+            'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ),
239
+            'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ),
240 240
             'Home URL' => home_url(),
241 241
             'Language' => get_locale(),
242 242
             'Memory Limit' => WP_MEMORY_LIMIT,
243
-            'Multisite' => var_export(is_multisite(), true),
244
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
-            'Post Stati' => implode(', ', get_post_stati()),
248
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
243
+            'Multisite' => var_export( is_multisite(), true ),
244
+            'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ),
245
+            'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ),
246
+            'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ),
247
+            'Post Stati' => implode( ', ', get_post_stati() ),
248
+            'Remote Post' => glsr( Cache::class )->getRemotePostTest(),
249
+            'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ),
250 250
             'Site URL' => site_url(),
251
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
-            'Version' => get_bloginfo('version'),
253
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
251
+            'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', ini_get( 'date.timezone' ).' (PHP)' ),
252
+            'Version' => get_bloginfo( 'version' ),
253
+            'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ),
254
+            'WP Max Upload Size' => size_format( wp_max_upload_size() ),
255 255
             'WP Memory Limit' => WP_MEMORY_LIMIT,
256 256
         ];
257 257
     }
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
             'secureserver.net' => 'GoDaddy',
282 282
             'WPE_APIKEY' => 'WP Engine',
283 283
         ];
284
-        foreach ($checks as $key => $value) {
285
-            if (!$this->isWebhostCheckValid($key)) {
284
+        foreach( $checks as $key => $value ) {
285
+            if( !$this->isWebhostCheckValid( $key ) ) {
286 286
                 continue;
287 287
             }
288 288
             return $value;
289 289
         }
290
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
290
+        return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
291 291
     }
292 292
 
293 293
     /**
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
      */
296 296
     protected function getHostName()
297 297
     {
298
-        return sprintf('%s (%s)',
298
+        return sprintf( '%s (%s)',
299 299
             $this->detectWebhostProvider(),
300
-            glsr(Helper::class)->getIpAddress()
300
+            glsr( Helper::class )->getIpAddress()
301 301
         );
302 302
     }
303 303
 
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
     protected function getWordpressPlugins()
308 308
     {
309 309
         $plugins = get_plugins();
310
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
310
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
311
+        $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
312
+        $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
313 313
         return $active + $inactive;
314 314
     }
315 315
 
@@ -317,58 +317,58 @@  discard block
 block discarded – undo
317 317
      * @param string $title
318 318
      * @return string
319 319
      */
320
-    protected function implode($title, array $details)
320
+    protected function implode( $title, array $details )
321 321
     {
322 322
         $strings = ['['.$title.']'];
323
-        $padding = max(array_map('strlen', array_keys($details)));
324
-        $padding = max([$padding, static::PAD]);
325
-        foreach ($details as $key => $value) {
326
-            $strings[] = is_string($key)
327
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
323
+        $padding = max( array_map( 'strlen', array_keys( $details ) ) );
324
+        $padding = max( [$padding, static::PAD] );
325
+        foreach( $details as $key => $value ) {
326
+            $strings[] = is_string( $key )
327
+                ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value )
328 328
                 : ' - '.$value;
329 329
         }
330
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
330
+        return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL;
331 331
     }
332 332
 
333 333
     /**
334 334
      * @param string $key
335 335
      * @return bool
336 336
      */
337
-    protected function isWebhostCheckValid($key)
337
+    protected function isWebhostCheckValid( $key )
338 338
     {
339
-        return defined($key)
340
-            || filter_input(INPUT_SERVER, $key)
341
-            || false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
-            || false !== strpos(DB_HOST, $key)
343
-            || false !== strpos(php_uname(), $key);
339
+        return defined( $key )
340
+            || filter_input( INPUT_SERVER, $key )
341
+            || false !== strpos( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key )
342
+            || false !== strpos( DB_HOST, $key )
343
+            || false !== strpos( php_uname(), $key );
344 344
     }
345 345
 
346 346
     /**
347 347
      * @return array
348 348
      */
349
-    protected function normalizePluginList(array $plugins)
349
+    protected function normalizePluginList( array $plugins )
350 350
     {
351
-        $plugins = array_map(function ($plugin) {
352
-            return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
-        }, $plugins);
354
-        natcasesort($plugins);
355
-        return array_flip($plugins);
351
+        $plugins = array_map( function( $plugin ) {
352
+            return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' ) );
353
+        }, $plugins );
354
+        natcasesort( $plugins );
355
+        return array_flip( $plugins );
356 356
     }
357 357
 
358 358
     /**
359 359
      * @return array
360 360
      */
361
-    protected function purgeSensitiveData(array $settings)
361
+    protected function purgeSensitiveData( array $settings )
362 362
     {
363 363
         $keys = [
364 364
             'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
365 365
         ];
366
-        array_walk($settings, function (&$value, $setting) use ($keys) {
367
-            foreach ($keys as $key) {
368
-                if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
366
+        array_walk( $settings, function( &$value, $setting ) use ($keys) {
367
+            foreach( $keys as $key ) {
368
+                if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) ) {
369 369
                     continue;
370 370
                 }
371
-                $value = str_repeat('•', 13);
371
+                $value = str_repeat( '•', 13 );
372 372
                 return;
373 373
             }
374 374
         });
Please login to merge, or discard this patch.
plugin/Modules/Notification.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -8,164 +8,164 @@
 block discarded – undo
8 8
 
9 9
 class Notification
10 10
 {
11
-    /**
12
-     * @var bool
13
-     */
14
-    protected $email;
11
+	/**
12
+	 * @var bool
13
+	 */
14
+	protected $email;
15 15
 
16
-    /**
17
-     * @var Review
18
-     */
19
-    protected $review;
16
+	/**
17
+	 * @var Review
18
+	 */
19
+	protected $review;
20 20
 
21
-    /**
22
-     * @var bool
23
-     */
24
-    protected $slack;
21
+	/**
22
+	 * @var bool
23
+	 */
24
+	protected $slack;
25 25
 
26
-    /**
27
-     * @var array
28
-     */
29
-    protected $types;
26
+	/**
27
+	 * @var array
28
+	 */
29
+	protected $types;
30 30
 
31
-    public function __construct()
32
-    {
33
-        $types = glsr(OptionManager::class)->get('settings.general.notifications', []);
34
-        $this->email = count(array_intersect(['admin', 'custom'], $types)) > 0;
35
-        $this->slack = in_array('slack', $types);
36
-        $this->types = $types;
37
-    }
31
+	public function __construct()
32
+	{
33
+		$types = glsr(OptionManager::class)->get('settings.general.notifications', []);
34
+		$this->email = count(array_intersect(['admin', 'custom'], $types)) > 0;
35
+		$this->slack = in_array('slack', $types);
36
+		$this->types = $types;
37
+	}
38 38
 
39
-    /**
40
-     * @return void
41
-     */
42
-    public function send(Review $review)
43
-    {
44
-        if (empty($this->types)) {
45
-            return;
46
-        }
47
-        $this->review = $review;
48
-        $args = [
49
-            'link' => $this->getLink(),
50
-            'title' => $this->getTitle(),
51
-        ];
52
-        $this->sendToEmail($args);
53
-        $this->sendToSlack($args);
54
-    }
39
+	/**
40
+	 * @return void
41
+	 */
42
+	public function send(Review $review)
43
+	{
44
+		if (empty($this->types)) {
45
+			return;
46
+		}
47
+		$this->review = $review;
48
+		$args = [
49
+			'link' => $this->getLink(),
50
+			'title' => $this->getTitle(),
51
+		];
52
+		$this->sendToEmail($args);
53
+		$this->sendToSlack($args);
54
+	}
55 55
 
56
-    /**
57
-     * @return Email
58
-     */
59
-    protected function buildEmail(array $args)
60
-    {
61
-        return glsr(Email::class)->compose([
62
-            'to' => $this->getEmailAddresses(),
63
-            'subject' => $args['title'],
64
-            'template' => 'email-notification',
65
-            'template-tags' => [
66
-                'review_author' => $this->review->author ?: __('Anonymous', 'site-reviews'),
67
-                'review_content' => $this->review->content,
68
-                'review_email' => $this->review->email,
69
-                'review_ip' => $this->review->ip_address,
70
-                'review_link' => sprintf('<a href="%1$s">%1$s</a>', $args['link']),
71
-                'review_rating' => $this->review->rating,
72
-                'review_title' => $this->review->title,
73
-            ],
74
-        ]);
75
-    }
56
+	/**
57
+	 * @return Email
58
+	 */
59
+	protected function buildEmail(array $args)
60
+	{
61
+		return glsr(Email::class)->compose([
62
+			'to' => $this->getEmailAddresses(),
63
+			'subject' => $args['title'],
64
+			'template' => 'email-notification',
65
+			'template-tags' => [
66
+				'review_author' => $this->review->author ?: __('Anonymous', 'site-reviews'),
67
+				'review_content' => $this->review->content,
68
+				'review_email' => $this->review->email,
69
+				'review_ip' => $this->review->ip_address,
70
+				'review_link' => sprintf('<a href="%1$s">%1$s</a>', $args['link']),
71
+				'review_rating' => $this->review->rating,
72
+				'review_title' => $this->review->title,
73
+			],
74
+		]);
75
+	}
76 76
 
77
-    /**
78
-     * @return Slack
79
-     */
80
-    protected function buildSlackNotification(array $args)
81
-    {
82
-        return glsr(Slack::class)->compose($this->review, [
83
-            'button_url' => $args['link'],
84
-            'fallback' => $this->buildEmail($args)->read('plaintext'),
85
-            'pretext' => $args['title'],
86
-        ]);
87
-    }
77
+	/**
78
+	 * @return Slack
79
+	 */
80
+	protected function buildSlackNotification(array $args)
81
+	{
82
+		return glsr(Slack::class)->compose($this->review, [
83
+			'button_url' => $args['link'],
84
+			'fallback' => $this->buildEmail($args)->read('plaintext'),
85
+			'pretext' => $args['title'],
86
+		]);
87
+	}
88 88
 
89
-    /**
90
-     * @return array
91
-     */
92
-    protected function getEmailAddresses()
93
-    {
94
-        $emails = [];
95
-        if (in_array('admin', $this->types)) {
96
-            $emails[] = glsr(OptionManager::class)->getWP('admin_email');
97
-        }
98
-        if (in_array('author', $this->types)) {
99
-            $assignedPost = get_post(intval($this->review->assigned_to));
100
-            if ($assignedPost instanceof WP_Post) {
101
-                $this->email = true;
102
-                $emails[] = get_the_author_meta('user_email', intval($assignedPost->post_author));
103
-            }
104
-        }
105
-        if (in_array('custom', $this->types)) {
106
-            $customEmails = glsr(OptionManager::class)->get('settings.general.notification_email');
107
-            $customEmails = str_replace([' ', ',', ';'], ',', $customEmails);
108
-            $customEmails = explode(',', $customEmails);
109
-            $emails = array_merge($emails, $customEmails);
110
-        }
111
-        $emails = array_filter(array_keys(array_flip($emails)));
112
-        return apply_filters('site-reviews/notification/emails', $emails, $this->review);
113
-    }
89
+	/**
90
+	 * @return array
91
+	 */
92
+	protected function getEmailAddresses()
93
+	{
94
+		$emails = [];
95
+		if (in_array('admin', $this->types)) {
96
+			$emails[] = glsr(OptionManager::class)->getWP('admin_email');
97
+		}
98
+		if (in_array('author', $this->types)) {
99
+			$assignedPost = get_post(intval($this->review->assigned_to));
100
+			if ($assignedPost instanceof WP_Post) {
101
+				$this->email = true;
102
+				$emails[] = get_the_author_meta('user_email', intval($assignedPost->post_author));
103
+			}
104
+		}
105
+		if (in_array('custom', $this->types)) {
106
+			$customEmails = glsr(OptionManager::class)->get('settings.general.notification_email');
107
+			$customEmails = str_replace([' ', ',', ';'], ',', $customEmails);
108
+			$customEmails = explode(',', $customEmails);
109
+			$emails = array_merge($emails, $customEmails);
110
+		}
111
+		$emails = array_filter(array_keys(array_flip($emails)));
112
+		return apply_filters('site-reviews/notification/emails', $emails, $this->review);
113
+	}
114 114
 
115
-    /**
116
-     * @return string
117
-     */
118
-    protected function getLink()
119
-    {
120
-        return admin_url('post.php?post='.$this->review->ID.'&action=edit');
121
-    }
115
+	/**
116
+	 * @return string
117
+	 */
118
+	protected function getLink()
119
+	{
120
+		return admin_url('post.php?post='.$this->review->ID.'&action=edit');
121
+	}
122 122
 
123
-    /**
124
-     * @return string
125
-     */
126
-    protected function getTitle()
127
-    {
128
-        $assignedTitle = get_the_title(intval($this->review->assigned_to));
129
-        $title = _nx(
130
-            'New %s-star review',
131
-            'New %s-star review of: %s',
132
-            intval(empty($assignedTitle)),
133
-            'This string differs depending on whether or not the review has been assigned to a post.',
134
-            'site-reviews'
135
-        );
136
-        $title = sprintf('[%s] %s',
137
-            wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES),
138
-            sprintf($title, $this->review->rating, $assignedTitle)
139
-        );
140
-        return apply_filters('site-reviews/notification/title', $title, $this->review);
141
-    }
123
+	/**
124
+	 * @return string
125
+	 */
126
+	protected function getTitle()
127
+	{
128
+		$assignedTitle = get_the_title(intval($this->review->assigned_to));
129
+		$title = _nx(
130
+			'New %s-star review',
131
+			'New %s-star review of: %s',
132
+			intval(empty($assignedTitle)),
133
+			'This string differs depending on whether or not the review has been assigned to a post.',
134
+			'site-reviews'
135
+		);
136
+		$title = sprintf('[%s] %s',
137
+			wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES),
138
+			sprintf($title, $this->review->rating, $assignedTitle)
139
+		);
140
+		return apply_filters('site-reviews/notification/title', $title, $this->review);
141
+	}
142 142
 
143
-    /**
144
-     * @return void
145
-     */
146
-    protected function sendToEmail(array $args)
147
-    {
148
-        $email = $this->buildEmail($args);
149
-        if (empty($email->to)) {
150
-            glsr_log()->error('Email notification was not sent (missing email address)');
151
-            return;
152
-        }
153
-        $email->send();
154
-    }
143
+	/**
144
+	 * @return void
145
+	 */
146
+	protected function sendToEmail(array $args)
147
+	{
148
+		$email = $this->buildEmail($args);
149
+		if (empty($email->to)) {
150
+			glsr_log()->error('Email notification was not sent (missing email address)');
151
+			return;
152
+		}
153
+		$email->send();
154
+	}
155 155
 
156
-    /**
157
-     * @return void
158
-     */
159
-    protected function sendToSlack(array $args)
160
-    {
161
-        if (!$this->slack) {
162
-            return;
163
-        }
164
-        $notification = $this->buildSlackNotification($args);
165
-        $result = $notification->send();
166
-        if (is_wp_error($result)) {
167
-            $notification->review = null;
168
-            glsr_log()->error($result->get_error_message())->debug($notification);
169
-        }
170
-    }
156
+	/**
157
+	 * @return void
158
+	 */
159
+	protected function sendToSlack(array $args)
160
+	{
161
+		if (!$this->slack) {
162
+			return;
163
+		}
164
+		$notification = $this->buildSlackNotification($args);
165
+		$result = $notification->send();
166
+		if (is_wp_error($result)) {
167
+			$notification->review = null;
168
+			glsr_log()->error($result->get_error_message())->debug($notification);
169
+		}
170
+	}
171 171
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -30,18 +30,18 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function __construct()
32 32
     {
33
-        $types = glsr(OptionManager::class)->get('settings.general.notifications', []);
34
-        $this->email = count(array_intersect(['admin', 'custom'], $types)) > 0;
35
-        $this->slack = in_array('slack', $types);
33
+        $types = glsr( OptionManager::class )->get( 'settings.general.notifications', [] );
34
+        $this->email = count( array_intersect( ['admin', 'custom'], $types ) ) > 0;
35
+        $this->slack = in_array( 'slack', $types );
36 36
         $this->types = $types;
37 37
     }
38 38
 
39 39
     /**
40 40
      * @return void
41 41
      */
42
-    public function send(Review $review)
42
+    public function send( Review $review )
43 43
     {
44
-        if (empty($this->types)) {
44
+        if( empty($this->types) ) {
45 45
             return;
46 46
         }
47 47
         $this->review = $review;
@@ -49,41 +49,41 @@  discard block
 block discarded – undo
49 49
             'link' => $this->getLink(),
50 50
             'title' => $this->getTitle(),
51 51
         ];
52
-        $this->sendToEmail($args);
53
-        $this->sendToSlack($args);
52
+        $this->sendToEmail( $args );
53
+        $this->sendToSlack( $args );
54 54
     }
55 55
 
56 56
     /**
57 57
      * @return Email
58 58
      */
59
-    protected function buildEmail(array $args)
59
+    protected function buildEmail( array $args )
60 60
     {
61
-        return glsr(Email::class)->compose([
61
+        return glsr( Email::class )->compose( [
62 62
             'to' => $this->getEmailAddresses(),
63 63
             'subject' => $args['title'],
64 64
             'template' => 'email-notification',
65 65
             'template-tags' => [
66
-                'review_author' => $this->review->author ?: __('Anonymous', 'site-reviews'),
66
+                'review_author' => $this->review->author ?: __( 'Anonymous', 'site-reviews' ),
67 67
                 'review_content' => $this->review->content,
68 68
                 'review_email' => $this->review->email,
69 69
                 'review_ip' => $this->review->ip_address,
70
-                'review_link' => sprintf('<a href="%1$s">%1$s</a>', $args['link']),
70
+                'review_link' => sprintf( '<a href="%1$s">%1$s</a>', $args['link'] ),
71 71
                 'review_rating' => $this->review->rating,
72 72
                 'review_title' => $this->review->title,
73 73
             ],
74
-        ]);
74
+        ] );
75 75
     }
76 76
 
77 77
     /**
78 78
      * @return Slack
79 79
      */
80
-    protected function buildSlackNotification(array $args)
80
+    protected function buildSlackNotification( array $args )
81 81
     {
82
-        return glsr(Slack::class)->compose($this->review, [
82
+        return glsr( Slack::class )->compose( $this->review, [
83 83
             'button_url' => $args['link'],
84
-            'fallback' => $this->buildEmail($args)->read('plaintext'),
84
+            'fallback' => $this->buildEmail( $args )->read( 'plaintext' ),
85 85
             'pretext' => $args['title'],
86
-        ]);
86
+        ] );
87 87
     }
88 88
 
89 89
     /**
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
     protected function getEmailAddresses()
93 93
     {
94 94
         $emails = [];
95
-        if (in_array('admin', $this->types)) {
96
-            $emails[] = glsr(OptionManager::class)->getWP('admin_email');
95
+        if( in_array( 'admin', $this->types ) ) {
96
+            $emails[] = glsr( OptionManager::class )->getWP( 'admin_email' );
97 97
         }
98
-        if (in_array('author', $this->types)) {
99
-            $assignedPost = get_post(intval($this->review->assigned_to));
100
-            if ($assignedPost instanceof WP_Post) {
98
+        if( in_array( 'author', $this->types ) ) {
99
+            $assignedPost = get_post( intval( $this->review->assigned_to ) );
100
+            if( $assignedPost instanceof WP_Post ) {
101 101
                 $this->email = true;
102
-                $emails[] = get_the_author_meta('user_email', intval($assignedPost->post_author));
102
+                $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author ) );
103 103
             }
104 104
         }
105
-        if (in_array('custom', $this->types)) {
106
-            $customEmails = glsr(OptionManager::class)->get('settings.general.notification_email');
107
-            $customEmails = str_replace([' ', ',', ';'], ',', $customEmails);
108
-            $customEmails = explode(',', $customEmails);
109
-            $emails = array_merge($emails, $customEmails);
105
+        if( in_array( 'custom', $this->types ) ) {
106
+            $customEmails = glsr( OptionManager::class )->get( 'settings.general.notification_email' );
107
+            $customEmails = str_replace( [' ', ',', ';'], ',', $customEmails );
108
+            $customEmails = explode( ',', $customEmails );
109
+            $emails = array_merge( $emails, $customEmails );
110 110
         }
111
-        $emails = array_filter(array_keys(array_flip($emails)));
112
-        return apply_filters('site-reviews/notification/emails', $emails, $this->review);
111
+        $emails = array_filter( array_keys( array_flip( $emails ) ) );
112
+        return apply_filters( 'site-reviews/notification/emails', $emails, $this->review );
113 113
     }
114 114
 
115 115
     /**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      */
118 118
     protected function getLink()
119 119
     {
120
-        return admin_url('post.php?post='.$this->review->ID.'&action=edit');
120
+        return admin_url( 'post.php?post='.$this->review->ID.'&action=edit' );
121 121
     }
122 122
 
123 123
     /**
@@ -125,29 +125,29 @@  discard block
 block discarded – undo
125 125
      */
126 126
     protected function getTitle()
127 127
     {
128
-        $assignedTitle = get_the_title(intval($this->review->assigned_to));
128
+        $assignedTitle = get_the_title( intval( $this->review->assigned_to ) );
129 129
         $title = _nx(
130 130
             'New %s-star review',
131 131
             'New %s-star review of: %s',
132
-            intval(empty($assignedTitle)),
132
+            intval( empty($assignedTitle) ),
133 133
             'This string differs depending on whether or not the review has been assigned to a post.',
134 134
             'site-reviews'
135 135
         );
136
-        $title = sprintf('[%s] %s',
137
-            wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES),
138
-            sprintf($title, $this->review->rating, $assignedTitle)
136
+        $title = sprintf( '[%s] %s',
137
+            wp_specialchars_decode( glsr( OptionManager::class )->getWP( 'blogname' ), ENT_QUOTES ),
138
+            sprintf( $title, $this->review->rating, $assignedTitle )
139 139
         );
140
-        return apply_filters('site-reviews/notification/title', $title, $this->review);
140
+        return apply_filters( 'site-reviews/notification/title', $title, $this->review );
141 141
     }
142 142
 
143 143
     /**
144 144
      * @return void
145 145
      */
146
-    protected function sendToEmail(array $args)
146
+    protected function sendToEmail( array $args )
147 147
     {
148
-        $email = $this->buildEmail($args);
149
-        if (empty($email->to)) {
150
-            glsr_log()->error('Email notification was not sent (missing email address)');
148
+        $email = $this->buildEmail( $args );
149
+        if( empty($email->to) ) {
150
+            glsr_log()->error( 'Email notification was not sent (missing email address)' );
151 151
             return;
152 152
         }
153 153
         $email->send();
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
     /**
157 157
      * @return void
158 158
      */
159
-    protected function sendToSlack(array $args)
159
+    protected function sendToSlack( array $args )
160 160
     {
161
-        if (!$this->slack) {
161
+        if( !$this->slack ) {
162 162
             return;
163 163
         }
164
-        $notification = $this->buildSlackNotification($args);
164
+        $notification = $this->buildSlackNotification( $args );
165 165
         $result = $notification->send();
166
-        if (is_wp_error($result)) {
166
+        if( is_wp_error( $result ) ) {
167 167
             $notification->review = null;
168
-            glsr_log()->error($result->get_error_message())->debug($notification);
168
+            glsr_log()->error( $result->get_error_message() )->debug( $notification );
169 169
         }
170 170
     }
171 171
 }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController/Metaboxes.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@
 block discarded – undo
7 7
 
8 8
 class Metaboxes
9 9
 {
10
-    /**
11
-     * @param int $postId
12
-     * @return void
13
-     */
14
-    public function saveAssignedToMetabox($postId)
15
-    {
16
-        if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-assigned-to'), 'assigned_to')) {
17
-            return;
18
-        }
19
-        $assignedTo = strval(glsr(Helper::class)->filterInput('assigned_to'));
20
-        glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
21
-    }
10
+	/**
11
+	 * @param int $postId
12
+	 * @return void
13
+	 */
14
+	public function saveAssignedToMetabox($postId)
15
+	{
16
+		if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-assigned-to'), 'assigned_to')) {
17
+			return;
18
+		}
19
+		$assignedTo = strval(glsr(Helper::class)->filterInput('assigned_to'));
20
+		glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
21
+	}
22 22
 
23
-    /**
24
-     * @param int $postId
25
-     * @return mixed
26
-     */
27
-    public function saveResponseMetabox($postId)
28
-    {
29
-        if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-response'), 'response')) {
30
-            return;
31
-        }
32
-        $response = strval(glsr(Helper::class)->filterInput('response'));
33
-        glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [
34
-            'a' => ['href' => [], 'title' => []],
35
-            'em' => [],
36
-            'strong' => [],
37
-        ])));
38
-    }
23
+	/**
24
+	 * @param int $postId
25
+	 * @return mixed
26
+	 */
27
+	public function saveResponseMetabox($postId)
28
+	{
29
+		if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-response'), 'response')) {
30
+			return;
31
+		}
32
+		$response = strval(glsr(Helper::class)->filterInput('response'));
33
+		glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [
34
+			'a' => ['href' => [], 'title' => []],
35
+			'em' => [],
36
+			'strong' => [],
37
+		])));
38
+	}
39 39
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,29 +11,29 @@
 block discarded – undo
11 11
      * @param int $postId
12 12
      * @return void
13 13
      */
14
-    public function saveAssignedToMetabox($postId)
14
+    public function saveAssignedToMetabox( $postId )
15 15
     {
16
-        if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-assigned-to'), 'assigned_to')) {
16
+        if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ) ) {
17 17
             return;
18 18
         }
19
-        $assignedTo = strval(glsr(Helper::class)->filterInput('assigned_to'));
20
-        glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
19
+        $assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' ) );
20
+        glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo );
21 21
     }
22 22
 
23 23
     /**
24 24
      * @param int $postId
25 25
      * @return mixed
26 26
      */
27
-    public function saveResponseMetabox($postId)
27
+    public function saveResponseMetabox( $postId )
28 28
     {
29
-        if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-response'), 'response')) {
29
+        if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ) ) {
30 30
             return;
31 31
         }
32
-        $response = strval(glsr(Helper::class)->filterInput('response'));
33
-        glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [
32
+        $response = strval( glsr( Helper::class )->filterInput( 'response' ) );
33
+        glsr( Database::class )->update( $postId, 'response', trim( wp_kses( $response, [
34 34
             'a' => ['href' => [], 'title' => []],
35 35
             'em' => [],
36 36
             'strong' => [],
37
-        ])));
37
+        ] ) ) );
38 38
     }
39 39
 }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController/Customization.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -7,84 +7,84 @@
 block discarded – undo
7 7
 
8 8
 class Customization
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    public function filterEditorSettings(array $settings)
14
-    {
15
-        if ($this->isReviewEditable()) {
16
-            $settings = [
17
-                'media_buttons' => false,
18
-                'quicktags' => false,
19
-                'textarea_rows' => 12,
20
-                'tinymce' => false,
21
-            ];
22
-        }
23
-        return $settings;
24
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	public function filterEditorSettings(array $settings)
14
+	{
15
+		if ($this->isReviewEditable()) {
16
+			$settings = [
17
+				'media_buttons' => false,
18
+				'quicktags' => false,
19
+				'textarea_rows' => 12,
20
+				'tinymce' => false,
21
+			];
22
+		}
23
+		return $settings;
24
+	}
25 25
 
26
-    /**
27
-     * @param string $html
28
-     * @return string
29
-     */
30
-    public function filterEditorTextarea($html)
31
-    {
32
-        if ($this->isReviewEditable()) {
33
-            $html = str_replace('<textarea', '<div id="ed_toolbar"></div><textarea', $html);
34
-        }
35
-        return $html;
36
-    }
26
+	/**
27
+	 * @param string $html
28
+	 * @return string
29
+	 */
30
+	public function filterEditorTextarea($html)
31
+	{
32
+		if ($this->isReviewEditable()) {
33
+			$html = str_replace('<textarea', '<div id="ed_toolbar"></div><textarea', $html);
34
+		}
35
+		return $html;
36
+	}
37 37
 
38
-    /**
39
-     * @return void
40
-     */
41
-    public function removeAutosave()
42
-    {
43
-        if (!$this->isReviewEditor() || $this->isReviewEditable()) {
44
-            return;
45
-        }
46
-        wp_deregister_script('autosave');
47
-    }
38
+	/**
39
+	 * @return void
40
+	 */
41
+	public function removeAutosave()
42
+	{
43
+		if (!$this->isReviewEditor() || $this->isReviewEditable()) {
44
+			return;
45
+		}
46
+		wp_deregister_script('autosave');
47
+	}
48 48
 
49
-    /**
50
-     * @return void
51
-     */
52
-    public function removeMetaBoxes()
53
-    {
54
-        remove_meta_box('slugdiv', Application::POST_TYPE, 'advanced');
55
-    }
49
+	/**
50
+	 * @return void
51
+	 */
52
+	public function removeMetaBoxes()
53
+	{
54
+		remove_meta_box('slugdiv', Application::POST_TYPE, 'advanced');
55
+	}
56 56
 
57
-    /**
58
-     * @return void
59
-     */
60
-    public function removePostTypeSupport()
61
-    {
62
-        if (!$this->isReviewEditor() || $this->isReviewEditable()) {
63
-            return;
64
-        }
65
-        remove_post_type_support(Application::POST_TYPE, 'title');
66
-        remove_post_type_support(Application::POST_TYPE, 'editor');
67
-    }
57
+	/**
58
+	 * @return void
59
+	 */
60
+	public function removePostTypeSupport()
61
+	{
62
+		if (!$this->isReviewEditor() || $this->isReviewEditable()) {
63
+			return;
64
+		}
65
+		remove_post_type_support(Application::POST_TYPE, 'title');
66
+		remove_post_type_support(Application::POST_TYPE, 'editor');
67
+	}
68 68
 
69
-    /**
70
-     * @return bool
71
-     */
72
-    protected function isReviewEditable()
73
-    {
74
-        $postId = intval(filter_input(INPUT_GET, 'post'));
75
-        return $postId > 0
76
-            && 'local' == glsr(Database::class)->get($postId, 'review_type')
77
-            && $this->isReviewEditor();
78
-    }
69
+	/**
70
+	 * @return bool
71
+	 */
72
+	protected function isReviewEditable()
73
+	{
74
+		$postId = intval(filter_input(INPUT_GET, 'post'));
75
+		return $postId > 0
76
+			&& 'local' == glsr(Database::class)->get($postId, 'review_type')
77
+			&& $this->isReviewEditor();
78
+	}
79 79
 
80
-    /**
81
-     * @return bool
82
-     */
83
-    protected function isReviewEditor()
84
-    {
85
-        $screen = glsr_current_screen();
86
-        return 'post' == $screen->base
87
-            && Application::POST_TYPE == $screen->id
88
-            && Application::POST_TYPE == $screen->post_type;
89
-    }
80
+	/**
81
+	 * @return bool
82
+	 */
83
+	protected function isReviewEditor()
84
+	{
85
+		$screen = glsr_current_screen();
86
+		return 'post' == $screen->base
87
+			&& Application::POST_TYPE == $screen->id
88
+			&& Application::POST_TYPE == $screen->post_type;
89
+	}
90 90
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
     /**
11 11
      * @return array
12 12
      */
13
-    public function filterEditorSettings(array $settings)
13
+    public function filterEditorSettings( array $settings )
14 14
     {
15
-        if ($this->isReviewEditable()) {
15
+        if( $this->isReviewEditable() ) {
16 16
             $settings = [
17 17
                 'media_buttons' => false,
18 18
                 'quicktags' => false,
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
      * @param string $html
28 28
      * @return string
29 29
      */
30
-    public function filterEditorTextarea($html)
30
+    public function filterEditorTextarea( $html )
31 31
     {
32
-        if ($this->isReviewEditable()) {
33
-            $html = str_replace('<textarea', '<div id="ed_toolbar"></div><textarea', $html);
32
+        if( $this->isReviewEditable() ) {
33
+            $html = str_replace( '<textarea', '<div id="ed_toolbar"></div><textarea', $html );
34 34
         }
35 35
         return $html;
36 36
     }
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function removeAutosave()
42 42
     {
43
-        if (!$this->isReviewEditor() || $this->isReviewEditable()) {
43
+        if( !$this->isReviewEditor() || $this->isReviewEditable() ) {
44 44
             return;
45 45
         }
46
-        wp_deregister_script('autosave');
46
+        wp_deregister_script( 'autosave' );
47 47
     }
48 48
 
49 49
     /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function removeMetaBoxes()
53 53
     {
54
-        remove_meta_box('slugdiv', Application::POST_TYPE, 'advanced');
54
+        remove_meta_box( 'slugdiv', Application::POST_TYPE, 'advanced' );
55 55
     }
56 56
 
57 57
     /**
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function removePostTypeSupport()
61 61
     {
62
-        if (!$this->isReviewEditor() || $this->isReviewEditable()) {
62
+        if( !$this->isReviewEditor() || $this->isReviewEditable() ) {
63 63
             return;
64 64
         }
65
-        remove_post_type_support(Application::POST_TYPE, 'title');
66
-        remove_post_type_support(Application::POST_TYPE, 'editor');
65
+        remove_post_type_support( Application::POST_TYPE, 'title' );
66
+        remove_post_type_support( Application::POST_TYPE, 'editor' );
67 67
     }
68 68
 
69 69
     /**
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
      */
72 72
     protected function isReviewEditable()
73 73
     {
74
-        $postId = intval(filter_input(INPUT_GET, 'post'));
74
+        $postId = intval( filter_input( INPUT_GET, 'post' ) );
75 75
         return $postId > 0
76
-            && 'local' == glsr(Database::class)->get($postId, 'review_type')
76
+            && 'local' == glsr( Database::class )->get( $postId, 'review_type' )
77 77
             && $this->isReviewEditor();
78 78
     }
79 79
 
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController/Columns.php 2 patches
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -10,141 +10,141 @@
 block discarded – undo
10 10
 
11 11
 class Columns
12 12
 {
13
-    /**
14
-     * @param int $postId
15
-     * @return string
16
-     */
17
-    public function buildColumnAssignedTo($postId)
18
-    {
19
-        $assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
-        $column = '&mdash;';
21
-        if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
22
-            $column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
23
-                'href' => (string) get_the_permalink($assignedPost->ID),
24
-            ]);
25
-        }
26
-        return $column;
27
-    }
13
+	/**
14
+	 * @param int $postId
15
+	 * @return string
16
+	 */
17
+	public function buildColumnAssignedTo($postId)
18
+	{
19
+		$assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
+		$column = '&mdash;';
21
+		if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
22
+			$column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
23
+				'href' => (string) get_the_permalink($assignedPost->ID),
24
+			]);
25
+		}
26
+		return $column;
27
+	}
28 28
 
29
-    /**
30
-     * @param int $postId
31
-     * @return string
32
-     */
33
-    public function buildColumnPinned($postId)
34
-    {
35
-        $pinned = glsr(Database::class)->get($postId, 'pinned')
36
-            ? 'pinned '
37
-            : '';
38
-        return glsr(Builder::class)->i([
39
-            'class' => $pinned.'dashicons dashicons-sticky',
40
-            'data-id' => $postId,
41
-        ]);
42
-    }
29
+	/**
30
+	 * @param int $postId
31
+	 * @return string
32
+	 */
33
+	public function buildColumnPinned($postId)
34
+	{
35
+		$pinned = glsr(Database::class)->get($postId, 'pinned')
36
+			? 'pinned '
37
+			: '';
38
+		return glsr(Builder::class)->i([
39
+			'class' => $pinned.'dashicons dashicons-sticky',
40
+			'data-id' => $postId,
41
+		]);
42
+	}
43 43
 
44
-    /**
45
-     * @param int $postId
46
-     * @return string
47
-     */
48
-    public function buildColumnReviewer($postId)
49
-    {
50
-        return strval(glsr(Database::class)->get($postId, 'author'));
51
-    }
44
+	/**
45
+	 * @param int $postId
46
+	 * @return string
47
+	 */
48
+	public function buildColumnReviewer($postId)
49
+	{
50
+		return strval(glsr(Database::class)->get($postId, 'author'));
51
+	}
52 52
 
53
-    /**
54
-     * @param int $postId
55
-     * @param int|null $rating
56
-     * @return string
57
-     */
58
-    public function buildColumnRating($postId)
59
-    {
60
-        return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
61
-    }
53
+	/**
54
+	 * @param int $postId
55
+	 * @param int|null $rating
56
+	 * @return string
57
+	 */
58
+	public function buildColumnRating($postId)
59
+	{
60
+		return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
61
+	}
62 62
 
63
-    /**
64
-     * @param int $postId
65
-     * @return string
66
-     */
67
-    public function buildColumnReviewType($postId)
68
-    {
69
-        $type = glsr(Database::class)->get($postId, 'review_type');
70
-        return array_key_exists($type, glsr()->reviewTypes)
71
-            ? glsr()->reviewTypes[$type]
72
-            : __('Unsupported Type', 'site-reviews');
73
-    }
63
+	/**
64
+	 * @param int $postId
65
+	 * @return string
66
+	 */
67
+	public function buildColumnReviewType($postId)
68
+	{
69
+		$type = glsr(Database::class)->get($postId, 'review_type');
70
+		return array_key_exists($type, glsr()->reviewTypes)
71
+			? glsr()->reviewTypes[$type]
72
+			: __('Unsupported Type', 'site-reviews');
73
+	}
74 74
 
75
-    /**
76
-     * @param string $postType
77
-     * @return void
78
-     */
79
-    public function renderFilters($postType)
80
-    {
81
-        if (Application::POST_TYPE !== $postType) {
82
-            return;
83
-        }
84
-        if (!($status = filter_input(INPUT_GET, 'post_status'))) {
85
-            $status = 'publish';
86
-        }
87
-        $ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
88
-        $types = glsr(Database::class)->getReviewsMeta('review_type', $status);
89
-        $this->renderFilterRatings($ratings);
90
-        $this->renderFilterTypes($types);
91
-    }
75
+	/**
76
+	 * @param string $postType
77
+	 * @return void
78
+	 */
79
+	public function renderFilters($postType)
80
+	{
81
+		if (Application::POST_TYPE !== $postType) {
82
+			return;
83
+		}
84
+		if (!($status = filter_input(INPUT_GET, 'post_status'))) {
85
+			$status = 'publish';
86
+		}
87
+		$ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
88
+		$types = glsr(Database::class)->getReviewsMeta('review_type', $status);
89
+		$this->renderFilterRatings($ratings);
90
+		$this->renderFilterTypes($types);
91
+	}
92 92
 
93
-    /**
94
-     * @param string $column
95
-     * @param int $postId
96
-     * @return void
97
-     */
98
-    public function renderValues($column, $postId)
99
-    {
100
-        $method = glsr(Helper::class)->buildMethodName($column, 'buildColumn');
101
-        echo method_exists($this, $method)
102
-            ? call_user_func([$this, $method], $postId)
103
-            : apply_filters('site-reviews/columns/'.$column, '', $postId);
104
-    }
93
+	/**
94
+	 * @param string $column
95
+	 * @param int $postId
96
+	 * @return void
97
+	 */
98
+	public function renderValues($column, $postId)
99
+	{
100
+		$method = glsr(Helper::class)->buildMethodName($column, 'buildColumn');
101
+		echo method_exists($this, $method)
102
+			? call_user_func([$this, $method], $postId)
103
+			: apply_filters('site-reviews/columns/'.$column, '', $postId);
104
+	}
105 105
 
106
-    /**
107
-     * @param array $ratings
108
-     * @return void
109
-     */
110
-    protected function renderFilterRatings($ratings)
111
-    {
112
-        if (empty($ratings)) {
113
-            return;
114
-        }
115
-        $ratings = array_flip(array_reverse($ratings));
116
-        array_walk($ratings, function (&$value, $key) {
117
-            $label = _n('%s star', '%s stars', $key, 'site-reviews');
118
-            $value = sprintf($label, $key);
119
-        });
120
-        echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
121
-            'class' => 'screen-reader-text',
122
-            'for' => 'rating',
123
-        ]);
124
-        echo glsr(Builder::class)->select([
125
-            'name' => 'rating',
126
-            'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
127
-            'value' => filter_input(INPUT_GET, 'rating'),
128
-        ]);
129
-    }
106
+	/**
107
+	 * @param array $ratings
108
+	 * @return void
109
+	 */
110
+	protected function renderFilterRatings($ratings)
111
+	{
112
+		if (empty($ratings)) {
113
+			return;
114
+		}
115
+		$ratings = array_flip(array_reverse($ratings));
116
+		array_walk($ratings, function (&$value, $key) {
117
+			$label = _n('%s star', '%s stars', $key, 'site-reviews');
118
+			$value = sprintf($label, $key);
119
+		});
120
+		echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
121
+			'class' => 'screen-reader-text',
122
+			'for' => 'rating',
123
+		]);
124
+		echo glsr(Builder::class)->select([
125
+			'name' => 'rating',
126
+			'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
127
+			'value' => filter_input(INPUT_GET, 'rating'),
128
+		]);
129
+	}
130 130
 
131
-    /**
132
-     * @param array $types
133
-     * @return void
134
-     */
135
-    protected function renderFilterTypes($types)
136
-    {
137
-        if (count(glsr()->reviewTypes) < 2) {
138
-            return;
139
-        }
140
-        echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
141
-            'class' => 'screen-reader-text',
142
-            'for' => 'review_type',
143
-        ]);
144
-        echo glsr(Builder::class)->select([
145
-            'name' => 'review_type',
146
-            'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
147
-            'value' => filter_input(INPUT_GET, 'review_type'),
148
-        ]);
149
-    }
131
+	/**
132
+	 * @param array $types
133
+	 * @return void
134
+	 */
135
+	protected function renderFilterTypes($types)
136
+	{
137
+		if (count(glsr()->reviewTypes) < 2) {
138
+			return;
139
+		}
140
+		echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
141
+			'class' => 'screen-reader-text',
142
+			'for' => 'review_type',
143
+		]);
144
+		echo glsr(Builder::class)->select([
145
+			'name' => 'review_type',
146
+			'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
147
+			'value' => filter_input(INPUT_GET, 'review_type'),
148
+		]);
149
+	}
150 150
 }
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
      * @param int $postId
15 15
      * @return string
16 16
      */
17
-    public function buildColumnAssignedTo($postId)
17
+    public function buildColumnAssignedTo( $postId )
18 18
     {
19
-        $assignedPost = glsr(Database::class)->getAssignedToPost($postId);
19
+        $assignedPost = glsr( Database::class )->getAssignedToPost( $postId );
20 20
         $column = '&mdash;';
21
-        if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
22
-            $column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
23
-                'href' => (string) get_the_permalink($assignedPost->ID),
24
-            ]);
21
+        if( $assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status ) {
22
+            $column = glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [
23
+                'href' => (string)get_the_permalink( $assignedPost->ID ),
24
+            ] );
25 25
         }
26 26
         return $column;
27 27
     }
@@ -30,24 +30,24 @@  discard block
 block discarded – undo
30 30
      * @param int $postId
31 31
      * @return string
32 32
      */
33
-    public function buildColumnPinned($postId)
33
+    public function buildColumnPinned( $postId )
34 34
     {
35
-        $pinned = glsr(Database::class)->get($postId, 'pinned')
35
+        $pinned = glsr( Database::class )->get( $postId, 'pinned' )
36 36
             ? 'pinned '
37 37
             : '';
38
-        return glsr(Builder::class)->i([
38
+        return glsr( Builder::class )->i( [
39 39
             'class' => $pinned.'dashicons dashicons-sticky',
40 40
             'data-id' => $postId,
41
-        ]);
41
+        ] );
42 42
     }
43 43
 
44 44
     /**
45 45
      * @param int $postId
46 46
      * @return string
47 47
      */
48
-    public function buildColumnReviewer($postId)
48
+    public function buildColumnReviewer( $postId )
49 49
     {
50
-        return strval(glsr(Database::class)->get($postId, 'author'));
50
+        return strval( glsr( Database::class )->get( $postId, 'author' ) );
51 51
     }
52 52
 
53 53
     /**
@@ -55,39 +55,39 @@  discard block
 block discarded – undo
55 55
      * @param int|null $rating
56 56
      * @return string
57 57
      */
58
-    public function buildColumnRating($postId)
58
+    public function buildColumnRating( $postId )
59 59
     {
60
-        return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
60
+        return glsr_star_rating( intval( glsr( Database::class )->get( $postId, 'rating' ) ) );
61 61
     }
62 62
 
63 63
     /**
64 64
      * @param int $postId
65 65
      * @return string
66 66
      */
67
-    public function buildColumnReviewType($postId)
67
+    public function buildColumnReviewType( $postId )
68 68
     {
69
-        $type = glsr(Database::class)->get($postId, 'review_type');
70
-        return array_key_exists($type, glsr()->reviewTypes)
69
+        $type = glsr( Database::class )->get( $postId, 'review_type' );
70
+        return array_key_exists( $type, glsr()->reviewTypes )
71 71
             ? glsr()->reviewTypes[$type]
72
-            : __('Unsupported Type', 'site-reviews');
72
+            : __( 'Unsupported Type', 'site-reviews' );
73 73
     }
74 74
 
75 75
     /**
76 76
      * @param string $postType
77 77
      * @return void
78 78
      */
79
-    public function renderFilters($postType)
79
+    public function renderFilters( $postType )
80 80
     {
81
-        if (Application::POST_TYPE !== $postType) {
81
+        if( Application::POST_TYPE !== $postType ) {
82 82
             return;
83 83
         }
84
-        if (!($status = filter_input(INPUT_GET, 'post_status'))) {
84
+        if( !($status = filter_input( INPUT_GET, 'post_status' )) ) {
85 85
             $status = 'publish';
86 86
         }
87
-        $ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
88
-        $types = glsr(Database::class)->getReviewsMeta('review_type', $status);
89
-        $this->renderFilterRatings($ratings);
90
-        $this->renderFilterTypes($types);
87
+        $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status );
88
+        $types = glsr( Database::class )->getReviewsMeta( 'review_type', $status );
89
+        $this->renderFilterRatings( $ratings );
90
+        $this->renderFilterTypes( $types );
91 91
     }
92 92
 
93 93
     /**
@@ -95,56 +95,56 @@  discard block
 block discarded – undo
95 95
      * @param int $postId
96 96
      * @return void
97 97
      */
98
-    public function renderValues($column, $postId)
98
+    public function renderValues( $column, $postId )
99 99
     {
100
-        $method = glsr(Helper::class)->buildMethodName($column, 'buildColumn');
101
-        echo method_exists($this, $method)
102
-            ? call_user_func([$this, $method], $postId)
103
-            : apply_filters('site-reviews/columns/'.$column, '', $postId);
100
+        $method = glsr( Helper::class )->buildMethodName( $column, 'buildColumn' );
101
+        echo method_exists( $this, $method )
102
+            ? call_user_func( [$this, $method], $postId )
103
+            : apply_filters( 'site-reviews/columns/'.$column, '', $postId );
104 104
     }
105 105
 
106 106
     /**
107 107
      * @param array $ratings
108 108
      * @return void
109 109
      */
110
-    protected function renderFilterRatings($ratings)
110
+    protected function renderFilterRatings( $ratings )
111 111
     {
112
-        if (empty($ratings)) {
112
+        if( empty($ratings) ) {
113 113
             return;
114 114
         }
115
-        $ratings = array_flip(array_reverse($ratings));
116
-        array_walk($ratings, function (&$value, $key) {
117
-            $label = _n('%s star', '%s stars', $key, 'site-reviews');
118
-            $value = sprintf($label, $key);
115
+        $ratings = array_flip( array_reverse( $ratings ) );
116
+        array_walk( $ratings, function( &$value, $key ) {
117
+            $label = _n( '%s star', '%s stars', $key, 'site-reviews' );
118
+            $value = sprintf( $label, $key );
119 119
         });
120
-        echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
120
+        echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [
121 121
             'class' => 'screen-reader-text',
122 122
             'for' => 'rating',
123
-        ]);
124
-        echo glsr(Builder::class)->select([
123
+        ] );
124
+        echo glsr( Builder::class )->select( [
125 125
             'name' => 'rating',
126
-            'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
127
-            'value' => filter_input(INPUT_GET, 'rating'),
128
-        ]);
126
+            'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings,
127
+            'value' => filter_input( INPUT_GET, 'rating' ),
128
+        ] );
129 129
     }
130 130
 
131 131
     /**
132 132
      * @param array $types
133 133
      * @return void
134 134
      */
135
-    protected function renderFilterTypes($types)
135
+    protected function renderFilterTypes( $types )
136 136
     {
137
-        if (count(glsr()->reviewTypes) < 2) {
137
+        if( count( glsr()->reviewTypes ) < 2 ) {
138 138
             return;
139 139
         }
140
-        echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
140
+        echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [
141 141
             'class' => 'screen-reader-text',
142 142
             'for' => 'review_type',
143
-        ]);
144
-        echo glsr(Builder::class)->select([
143
+        ] );
144
+        echo glsr( Builder::class )->select( [
145 145
             'name' => 'review_type',
146
-            'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
147
-            'value' => filter_input(INPUT_GET, 'review_type'),
148
-        ]);
146
+            'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes,
147
+            'value' => filter_input( INPUT_GET, 'review_type' ),
148
+        ] );
149 149
     }
150 150
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController.php 2 patches
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -13,346 +13,346 @@
 block discarded – undo
13 13
 
14 14
 class ListTableController extends Controller
15 15
 {
16
-    /**
17
-     * @return void
18
-     * @action admin_action_approve
19
-     */
20
-    public function approve()
21
-    {
22
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
23
-            return;
24
-        }
25
-        check_admin_referer('approve-review_'.($postId = $this->getPostId()));
26
-        wp_update_post([
27
-            'ID' => $postId,
28
-            'post_status' => 'publish',
29
-        ]);
30
-        wp_safe_redirect(wp_get_referer());
31
-        exit;
32
-    }
16
+	/**
17
+	 * @return void
18
+	 * @action admin_action_approve
19
+	 */
20
+	public function approve()
21
+	{
22
+		if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
23
+			return;
24
+		}
25
+		check_admin_referer('approve-review_'.($postId = $this->getPostId()));
26
+		wp_update_post([
27
+			'ID' => $postId,
28
+			'post_status' => 'publish',
29
+		]);
30
+		wp_safe_redirect(wp_get_referer());
31
+		exit;
32
+	}
33 33
 
34
-    /**
35
-     * @param array $messages
36
-     * @return array
37
-     * @filter bulk_post_updated_messages
38
-     */
39
-    public function filterBulkUpdateMessages($messages, array $counts)
40
-    {
41
-        $messages = glsr(Helper::class)->consolidateArray($messages);
42
-        $messages[Application::POST_TYPE] = [
43
-            'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'),
44
-            'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'),
45
-            'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'),
46
-            'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'),
47
-            'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'),
48
-        ];
49
-        return $messages;
50
-    }
34
+	/**
35
+	 * @param array $messages
36
+	 * @return array
37
+	 * @filter bulk_post_updated_messages
38
+	 */
39
+	public function filterBulkUpdateMessages($messages, array $counts)
40
+	{
41
+		$messages = glsr(Helper::class)->consolidateArray($messages);
42
+		$messages[Application::POST_TYPE] = [
43
+			'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'),
44
+			'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'),
45
+			'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'),
46
+			'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'),
47
+			'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'),
48
+		];
49
+		return $messages;
50
+	}
51 51
 
52
-    /**
53
-     * @param array $columns
54
-     * @return array
55
-     * @filter manage_.Application::POST_TYPE._posts_columns
56
-     */
57
-    public function filterColumnsForPostType($columns)
58
-    {
59
-        $columns = glsr(Helper::class)->consolidateArray($columns);
60
-        $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
61
-        foreach ($postTypeColumns as $key => &$value) {
62
-            if (!array_key_exists($key, $columns) || !empty($value)) {
63
-                continue;
64
-            }
65
-            $value = $columns[$key];
66
-        }
67
-        if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) {
68
-            unset($postTypeColumns['review_type']);
69
-        }
70
-        return array_filter($postTypeColumns, 'strlen');
71
-    }
52
+	/**
53
+	 * @param array $columns
54
+	 * @return array
55
+	 * @filter manage_.Application::POST_TYPE._posts_columns
56
+	 */
57
+	public function filterColumnsForPostType($columns)
58
+	{
59
+		$columns = glsr(Helper::class)->consolidateArray($columns);
60
+		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
61
+		foreach ($postTypeColumns as $key => &$value) {
62
+			if (!array_key_exists($key, $columns) || !empty($value)) {
63
+				continue;
64
+			}
65
+			$value = $columns[$key];
66
+		}
67
+		if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) {
68
+			unset($postTypeColumns['review_type']);
69
+		}
70
+		return array_filter($postTypeColumns, 'strlen');
71
+	}
72 72
 
73
-    /**
74
-     * @param string $status
75
-     * @param WP_Post $post
76
-     * @return string
77
-     * @filter post_date_column_status
78
-     */
79
-    public function filterDateColumnStatus($status, $post)
80
-    {
81
-        if (Application::POST_TYPE == glsr_get($post, 'post_type')) {
82
-            $status = __('Submitted', 'site-reviews');
83
-        }
84
-        return $status;
85
-    }
73
+	/**
74
+	 * @param string $status
75
+	 * @param WP_Post $post
76
+	 * @return string
77
+	 * @filter post_date_column_status
78
+	 */
79
+	public function filterDateColumnStatus($status, $post)
80
+	{
81
+		if (Application::POST_TYPE == glsr_get($post, 'post_type')) {
82
+			$status = __('Submitted', 'site-reviews');
83
+		}
84
+		return $status;
85
+	}
86 86
 
87
-    /**
88
-     * @param array $hidden
89
-     * @param WP_Screen $post
90
-     * @return array
91
-     * @filter default_hidden_columns
92
-     */
93
-    public function filterDefaultHiddenColumns($hidden, $screen)
94
-    {
95
-        if (glsr_get($screen, 'id') == 'edit-'.Application::POST_TYPE) {
96
-            $hidden = glsr(Helper::class)->consolidateArray($hidden);
97
-            $hidden = ['reviewer'];
98
-        }
99
-        return $hidden;
100
-    }
87
+	/**
88
+	 * @param array $hidden
89
+	 * @param WP_Screen $post
90
+	 * @return array
91
+	 * @filter default_hidden_columns
92
+	 */
93
+	public function filterDefaultHiddenColumns($hidden, $screen)
94
+	{
95
+		if (glsr_get($screen, 'id') == 'edit-'.Application::POST_TYPE) {
96
+			$hidden = glsr(Helper::class)->consolidateArray($hidden);
97
+			$hidden = ['reviewer'];
98
+		}
99
+		return $hidden;
100
+	}
101 101
 
102
-    /**
103
-     * @param array $postStates
104
-     * @param WP_Post $post
105
-     * @return array
106
-     * @filter display_post_states
107
-     */
108
-    public function filterPostStates($postStates, $post)
109
-    {
110
-        $postStates = glsr(Helper::class)->consolidateArray($postStates);
111
-        if (Application::POST_TYPE == glsr_get($post, 'post_type') && array_key_exists('pending', $postStates)) {
112
-            $postStates['pending'] = __('Unapproved', 'site-reviews');
113
-        }
114
-        return $postStates;
115
-    }
102
+	/**
103
+	 * @param array $postStates
104
+	 * @param WP_Post $post
105
+	 * @return array
106
+	 * @filter display_post_states
107
+	 */
108
+	public function filterPostStates($postStates, $post)
109
+	{
110
+		$postStates = glsr(Helper::class)->consolidateArray($postStates);
111
+		if (Application::POST_TYPE == glsr_get($post, 'post_type') && array_key_exists('pending', $postStates)) {
112
+			$postStates['pending'] = __('Unapproved', 'site-reviews');
113
+		}
114
+		return $postStates;
115
+	}
116 116
 
117
-    /**
118
-     * @param array $actions
119
-     * @param WP_Post $post
120
-     * @return array
121
-     * @filter post_row_actions
122
-     */
123
-    public function filterRowActions($actions, $post)
124
-    {
125
-        if (Application::POST_TYPE != glsr_get($post, 'post_type') || 'trash' == $post->post_status) {
126
-            return $actions;
127
-        }
128
-        unset($actions['inline hide-if-no-js']); //Remove Quick-edit
129
-        $rowActions = [
130
-            'approve' => esc_attr__('Approve', 'site-reviews'),
131
-            'unapprove' => esc_attr__('Unapprove', 'site-reviews'),
132
-        ];
133
-        $newActions = [];
134
-        foreach ($rowActions as $key => $text) {
135
-            $newActions[$key] = glsr(Builder::class)->a($text, [
136
-                'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text),
137
-                'class' => 'glsr-change-status',
138
-                'href' => wp_nonce_url(
139
-                    admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID),
140
-                    $key.'-review_'.$post->ID
141
-                ),
142
-            ]);
143
-        }
144
-        return $newActions + glsr(Helper::class)->consolidateArray($actions);
145
-    }
117
+	/**
118
+	 * @param array $actions
119
+	 * @param WP_Post $post
120
+	 * @return array
121
+	 * @filter post_row_actions
122
+	 */
123
+	public function filterRowActions($actions, $post)
124
+	{
125
+		if (Application::POST_TYPE != glsr_get($post, 'post_type') || 'trash' == $post->post_status) {
126
+			return $actions;
127
+		}
128
+		unset($actions['inline hide-if-no-js']); //Remove Quick-edit
129
+		$rowActions = [
130
+			'approve' => esc_attr__('Approve', 'site-reviews'),
131
+			'unapprove' => esc_attr__('Unapprove', 'site-reviews'),
132
+		];
133
+		$newActions = [];
134
+		foreach ($rowActions as $key => $text) {
135
+			$newActions[$key] = glsr(Builder::class)->a($text, [
136
+				'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text),
137
+				'class' => 'glsr-change-status',
138
+				'href' => wp_nonce_url(
139
+					admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID),
140
+					$key.'-review_'.$post->ID
141
+				),
142
+			]);
143
+		}
144
+		return $newActions + glsr(Helper::class)->consolidateArray($actions);
145
+	}
146 146
 
147
-    /**
148
-     * @param array $columns
149
-     * @return array
150
-     * @filter manage_edit-.Application::POST_TYPE._sortable_columns
151
-     */
152
-    public function filterSortableColumns($columns)
153
-    {
154
-        $columns = glsr(Helper::class)->consolidateArray($columns);
155
-        $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
156
-        unset($postTypeColumns['cb']);
157
-        foreach ($postTypeColumns as $key => $value) {
158
-            if (glsr(Helper::class)->startsWith('taxonomy', $key)) {
159
-                continue;
160
-            }
161
-            $columns[$key] = $key;
162
-        }
163
-        return $columns;
164
-    }
147
+	/**
148
+	 * @param array $columns
149
+	 * @return array
150
+	 * @filter manage_edit-.Application::POST_TYPE._sortable_columns
151
+	 */
152
+	public function filterSortableColumns($columns)
153
+	{
154
+		$columns = glsr(Helper::class)->consolidateArray($columns);
155
+		$postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
156
+		unset($postTypeColumns['cb']);
157
+		foreach ($postTypeColumns as $key => $value) {
158
+			if (glsr(Helper::class)->startsWith('taxonomy', $key)) {
159
+				continue;
160
+			}
161
+			$columns[$key] = $key;
162
+		}
163
+		return $columns;
164
+	}
165 165
 
166
-    /**
167
-     * Customize the post_type status text.
168
-     * @param string $translation
169
-     * @param string $single
170
-     * @param string $plural
171
-     * @param int $number
172
-     * @param string $domain
173
-     * @return string
174
-     * @filter ngettext
175
-     */
176
-    public function filterStatusText($translation, $single, $plural, $number, $domain)
177
-    {
178
-        if ($this->canModifyTranslation($domain)) {
179
-            $strings = [
180
-                'Published' => __('Approved', 'site-reviews'),
181
-                'Pending' => __('Unapproved', 'site-reviews'),
182
-            ];
183
-            foreach ($strings as $search => $replace) {
184
-                if (false === strpos($single, $search)) {
185
-                    continue;
186
-                }
187
-                $translation = $this->getTranslation([
188
-                    'number' => $number,
189
-                    'plural' => str_replace($search, $replace, $plural),
190
-                    'single' => str_replace($search, $replace, $single),
191
-                ]);
192
-            }
193
-        }
194
-        return $translation;
195
-    }
166
+	/**
167
+	 * Customize the post_type status text.
168
+	 * @param string $translation
169
+	 * @param string $single
170
+	 * @param string $plural
171
+	 * @param int $number
172
+	 * @param string $domain
173
+	 * @return string
174
+	 * @filter ngettext
175
+	 */
176
+	public function filterStatusText($translation, $single, $plural, $number, $domain)
177
+	{
178
+		if ($this->canModifyTranslation($domain)) {
179
+			$strings = [
180
+				'Published' => __('Approved', 'site-reviews'),
181
+				'Pending' => __('Unapproved', 'site-reviews'),
182
+			];
183
+			foreach ($strings as $search => $replace) {
184
+				if (false === strpos($single, $search)) {
185
+					continue;
186
+				}
187
+				$translation = $this->getTranslation([
188
+					'number' => $number,
189
+					'plural' => str_replace($search, $replace, $plural),
190
+					'single' => str_replace($search, $replace, $single),
191
+				]);
192
+			}
193
+		}
194
+		return $translation;
195
+	}
196 196
 
197
-    /**
198
-     * @param string $columnName
199
-     * @param string $postType
200
-     * @return void
201
-     * @action bulk_edit_custom_box
202
-     */
203
-    public function renderBulkEditFields($columnName, $postType)
204
-    {
205
-        if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) {
206
-            glsr()->render('partials/editor/bulk-edit-assigned-to');
207
-        }
208
-    }
197
+	/**
198
+	 * @param string $columnName
199
+	 * @param string $postType
200
+	 * @return void
201
+	 * @action bulk_edit_custom_box
202
+	 */
203
+	public function renderBulkEditFields($columnName, $postType)
204
+	{
205
+		if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) {
206
+			glsr()->render('partials/editor/bulk-edit-assigned-to');
207
+		}
208
+	}
209 209
 
210
-    /**
211
-     * @param string $postType
212
-     * @return void
213
-     * @action restrict_manage_posts
214
-     */
215
-    public function renderColumnFilters($postType)
216
-    {
217
-        glsr(Columns::class)->renderFilters($postType);
218
-    }
210
+	/**
211
+	 * @param string $postType
212
+	 * @return void
213
+	 * @action restrict_manage_posts
214
+	 */
215
+	public function renderColumnFilters($postType)
216
+	{
217
+		glsr(Columns::class)->renderFilters($postType);
218
+	}
219 219
 
220
-    /**
221
-     * @param string $column
222
-     * @param string $postId
223
-     * @return void
224
-     * @action manage_posts_custom_column
225
-     */
226
-    public function renderColumnValues($column, $postId)
227
-    {
228
-        glsr(Columns::class)->renderValues($column, $postId);
229
-    }
220
+	/**
221
+	 * @param string $column
222
+	 * @param string $postId
223
+	 * @return void
224
+	 * @action manage_posts_custom_column
225
+	 */
226
+	public function renderColumnValues($column, $postId)
227
+	{
228
+		glsr(Columns::class)->renderValues($column, $postId);
229
+	}
230 230
 
231
-    /**
232
-     * @param int $postId
233
-     * @return void
234
-     * @action save_post_.Application::POST_TYPE
235
-     */
236
-    public function saveBulkEditFields($postId)
237
-    {
238
-        if (!current_user_can('edit_posts')) {
239
-            return;
240
-        }
241
-        $assignedTo = filter_input(INPUT_GET, 'assigned_to');
242
-        if ($assignedTo && get_post($assignedTo)) {
243
-            glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
244
-        }
245
-    }
231
+	/**
232
+	 * @param int $postId
233
+	 * @return void
234
+	 * @action save_post_.Application::POST_TYPE
235
+	 */
236
+	public function saveBulkEditFields($postId)
237
+	{
238
+		if (!current_user_can('edit_posts')) {
239
+			return;
240
+		}
241
+		$assignedTo = filter_input(INPUT_GET, 'assigned_to');
242
+		if ($assignedTo && get_post($assignedTo)) {
243
+			glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
244
+		}
245
+	}
246 246
 
247
-    /**
248
-     * @return void
249
-     * @action pre_get_posts
250
-     */
251
-    public function setQueryForColumn(WP_Query $query)
252
-    {
253
-        if (!$this->hasPermission($query)) {
254
-            return;
255
-        }
256
-        $this->setMetaQuery($query, [
257
-            'rating', 'review_type',
258
-        ]);
259
-        $this->setOrderby($query);
260
-    }
247
+	/**
248
+	 * @return void
249
+	 * @action pre_get_posts
250
+	 */
251
+	public function setQueryForColumn(WP_Query $query)
252
+	{
253
+		if (!$this->hasPermission($query)) {
254
+			return;
255
+		}
256
+		$this->setMetaQuery($query, [
257
+			'rating', 'review_type',
258
+		]);
259
+		$this->setOrderby($query);
260
+	}
261 261
 
262
-    /**
263
-     * @return void
264
-     * @action admin_action_unapprove
265
-     */
266
-    public function unapprove()
267
-    {
268
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
269
-            return;
270
-        }
271
-        check_admin_referer('unapprove-review_'.($postId = $this->getPostId()));
272
-        wp_update_post([
273
-            'ID' => $postId,
274
-            'post_status' => 'pending',
275
-        ]);
276
-        wp_safe_redirect(wp_get_referer());
277
-        exit;
278
-    }
262
+	/**
263
+	 * @return void
264
+	 * @action admin_action_unapprove
265
+	 */
266
+	public function unapprove()
267
+	{
268
+		if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
269
+			return;
270
+		}
271
+		check_admin_referer('unapprove-review_'.($postId = $this->getPostId()));
272
+		wp_update_post([
273
+			'ID' => $postId,
274
+			'post_status' => 'pending',
275
+		]);
276
+		wp_safe_redirect(wp_get_referer());
277
+		exit;
278
+	}
279 279
 
280
-    /**
281
-     * Check if the translation string can be modified.
282
-     * @param string $domain
283
-     * @return bool
284
-     */
285
-    protected function canModifyTranslation($domain = 'default')
286
-    {
287
-        $screen = glsr_current_screen();
288
-        return 'default' == $domain
289
-            && 'edit' == $screen->base
290
-            && Application::POST_TYPE == $screen->post_type;
291
-    }
280
+	/**
281
+	 * Check if the translation string can be modified.
282
+	 * @param string $domain
283
+	 * @return bool
284
+	 */
285
+	protected function canModifyTranslation($domain = 'default')
286
+	{
287
+		$screen = glsr_current_screen();
288
+		return 'default' == $domain
289
+			&& 'edit' == $screen->base
290
+			&& Application::POST_TYPE == $screen->post_type;
291
+	}
292 292
 
293
-    /**
294
-     * Get the modified translation string.
295
-     * @return string
296
-     */
297
-    protected function getTranslation(array $args)
298
-    {
299
-        $defaults = [
300
-            'number' => 0,
301
-            'plural' => '',
302
-            'single' => '',
303
-            'text' => '',
304
-        ];
305
-        $args = (object) wp_parse_args($args, $defaults);
306
-        $translations = get_translations_for_domain(Application::ID);
307
-        return $args->text
308
-            ? $translations->translate($args->text)
309
-            : $translations->translate_plural($args->single, $args->plural, $args->number);
310
-    }
293
+	/**
294
+	 * Get the modified translation string.
295
+	 * @return string
296
+	 */
297
+	protected function getTranslation(array $args)
298
+	{
299
+		$defaults = [
300
+			'number' => 0,
301
+			'plural' => '',
302
+			'single' => '',
303
+			'text' => '',
304
+		];
305
+		$args = (object) wp_parse_args($args, $defaults);
306
+		$translations = get_translations_for_domain(Application::ID);
307
+		return $args->text
308
+			? $translations->translate($args->text)
309
+			: $translations->translate_plural($args->single, $args->plural, $args->number);
310
+	}
311 311
 
312
-    /**
313
-     * @return bool
314
-     */
315
-    protected function hasPermission(WP_Query $query)
316
-    {
317
-        global $pagenow;
318
-        return is_admin()
319
-            && $query->is_main_query()
320
-            && Application::POST_TYPE == $query->get('post_type')
321
-            && 'edit.php' == $pagenow;
322
-    }
312
+	/**
313
+	 * @return bool
314
+	 */
315
+	protected function hasPermission(WP_Query $query)
316
+	{
317
+		global $pagenow;
318
+		return is_admin()
319
+			&& $query->is_main_query()
320
+			&& Application::POST_TYPE == $query->get('post_type')
321
+			&& 'edit.php' == $pagenow;
322
+	}
323 323
 
324
-    /**
325
-     * @return void
326
-     */
327
-    protected function setMetaQuery(WP_Query $query, array $metaKeys)
328
-    {
329
-        foreach ($metaKeys as $key) {
330
-            if (!($value = filter_input(INPUT_GET, $key))) {
331
-                continue;
332
-            }
333
-            $metaQuery = (array) $query->get('meta_query');
334
-            $metaQuery[] = [
335
-                'key' => glsr(Helper::class)->prefixString($key, '_'),
336
-                'value' => $value,
337
-            ];
338
-            $query->set('meta_query', $metaQuery);
339
-        }
340
-    }
324
+	/**
325
+	 * @return void
326
+	 */
327
+	protected function setMetaQuery(WP_Query $query, array $metaKeys)
328
+	{
329
+		foreach ($metaKeys as $key) {
330
+			if (!($value = filter_input(INPUT_GET, $key))) {
331
+				continue;
332
+			}
333
+			$metaQuery = (array) $query->get('meta_query');
334
+			$metaQuery[] = [
335
+				'key' => glsr(Helper::class)->prefixString($key, '_'),
336
+				'value' => $value,
337
+			];
338
+			$query->set('meta_query', $metaQuery);
339
+		}
340
+	}
341 341
 
342
-    /**
343
-     * @return void
344
-     */
345
-    protected function setOrderby(WP_Query $query)
346
-    {
347
-        $orderby = $query->get('orderby');
348
-        $columns = glsr()->postTypeColumns[Application::POST_TYPE];
349
-        unset($columns['cb'], $columns['title'], $columns['date']);
350
-        if (in_array($orderby, array_keys($columns))) {
351
-            if ('reviewer' == $orderby) {
352
-                $orderby = '_author';
353
-            }
354
-            $query->set('meta_key', $orderby);
355
-            $query->set('orderby', 'meta_value');
356
-        }
357
-    }
342
+	/**
343
+	 * @return void
344
+	 */
345
+	protected function setOrderby(WP_Query $query)
346
+	{
347
+		$orderby = $query->get('orderby');
348
+		$columns = glsr()->postTypeColumns[Application::POST_TYPE];
349
+		unset($columns['cb'], $columns['title'], $columns['date']);
350
+		if (in_array($orderby, array_keys($columns))) {
351
+			if ('reviewer' == $orderby) {
352
+				$orderby = '_author';
353
+			}
354
+			$query->set('meta_key', $orderby);
355
+			$query->set('orderby', 'meta_value');
356
+		}
357
+	}
358 358
 }
Please login to merge, or discard this patch.
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public function approve()
21 21
     {
22
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
22
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
23 23
             return;
24 24
         }
25
-        check_admin_referer('approve-review_'.($postId = $this->getPostId()));
26
-        wp_update_post([
25
+        check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) );
26
+        wp_update_post( [
27 27
             'ID' => $postId,
28 28
             'post_status' => 'publish',
29
-        ]);
30
-        wp_safe_redirect(wp_get_referer());
29
+        ] );
30
+        wp_safe_redirect( wp_get_referer() );
31 31
         exit;
32 32
     }
33 33
 
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
      * @return array
37 37
      * @filter bulk_post_updated_messages
38 38
      */
39
-    public function filterBulkUpdateMessages($messages, array $counts)
39
+    public function filterBulkUpdateMessages( $messages, array $counts )
40 40
     {
41
-        $messages = glsr(Helper::class)->consolidateArray($messages);
41
+        $messages = glsr( Helper::class )->consolidateArray( $messages );
42 42
         $messages[Application::POST_TYPE] = [
43
-            'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'),
44
-            'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'),
45
-            'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'),
46
-            'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'),
47
-            'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'),
43
+            'updated' => _n( '%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews' ),
44
+            'locked' => _n( '%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews' ),
45
+            'deleted' => _n( '%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews' ),
46
+            'trashed' => _n( '%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews' ),
47
+            'untrashed' => _n( '%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews' ),
48 48
         ];
49 49
         return $messages;
50 50
     }
@@ -54,20 +54,20 @@  discard block
 block discarded – undo
54 54
      * @return array
55 55
      * @filter manage_.Application::POST_TYPE._posts_columns
56 56
      */
57
-    public function filterColumnsForPostType($columns)
57
+    public function filterColumnsForPostType( $columns )
58 58
     {
59
-        $columns = glsr(Helper::class)->consolidateArray($columns);
59
+        $columns = glsr( Helper::class )->consolidateArray( $columns );
60 60
         $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
61
-        foreach ($postTypeColumns as $key => &$value) {
62
-            if (!array_key_exists($key, $columns) || !empty($value)) {
61
+        foreach( $postTypeColumns as $key => &$value ) {
62
+            if( !array_key_exists( $key, $columns ) || !empty($value) ) {
63 63
                 continue;
64 64
             }
65 65
             $value = $columns[$key];
66 66
         }
67
-        if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) {
67
+        if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) {
68 68
             unset($postTypeColumns['review_type']);
69 69
         }
70
-        return array_filter($postTypeColumns, 'strlen');
70
+        return array_filter( $postTypeColumns, 'strlen' );
71 71
     }
72 72
 
73 73
     /**
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
      * @return string
77 77
      * @filter post_date_column_status
78 78
      */
79
-    public function filterDateColumnStatus($status, $post)
79
+    public function filterDateColumnStatus( $status, $post )
80 80
     {
81
-        if (Application::POST_TYPE == glsr_get($post, 'post_type')) {
82
-            $status = __('Submitted', 'site-reviews');
81
+        if( Application::POST_TYPE == glsr_get( $post, 'post_type' ) ) {
82
+            $status = __( 'Submitted', 'site-reviews' );
83 83
         }
84 84
         return $status;
85 85
     }
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
      * @return array
91 91
      * @filter default_hidden_columns
92 92
      */
93
-    public function filterDefaultHiddenColumns($hidden, $screen)
93
+    public function filterDefaultHiddenColumns( $hidden, $screen )
94 94
     {
95
-        if (glsr_get($screen, 'id') == 'edit-'.Application::POST_TYPE) {
96
-            $hidden = glsr(Helper::class)->consolidateArray($hidden);
95
+        if( glsr_get( $screen, 'id' ) == 'edit-'.Application::POST_TYPE ) {
96
+            $hidden = glsr( Helper::class )->consolidateArray( $hidden );
97 97
             $hidden = ['reviewer'];
98 98
         }
99 99
         return $hidden;
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
      * @return array
106 106
      * @filter display_post_states
107 107
      */
108
-    public function filterPostStates($postStates, $post)
108
+    public function filterPostStates( $postStates, $post )
109 109
     {
110
-        $postStates = glsr(Helper::class)->consolidateArray($postStates);
111
-        if (Application::POST_TYPE == glsr_get($post, 'post_type') && array_key_exists('pending', $postStates)) {
112
-            $postStates['pending'] = __('Unapproved', 'site-reviews');
110
+        $postStates = glsr( Helper::class )->consolidateArray( $postStates );
111
+        if( Application::POST_TYPE == glsr_get( $post, 'post_type' ) && array_key_exists( 'pending', $postStates ) ) {
112
+            $postStates['pending'] = __( 'Unapproved', 'site-reviews' );
113 113
         }
114 114
         return $postStates;
115 115
     }
@@ -120,28 +120,28 @@  discard block
 block discarded – undo
120 120
      * @return array
121 121
      * @filter post_row_actions
122 122
      */
123
-    public function filterRowActions($actions, $post)
123
+    public function filterRowActions( $actions, $post )
124 124
     {
125
-        if (Application::POST_TYPE != glsr_get($post, 'post_type') || 'trash' == $post->post_status) {
125
+        if( Application::POST_TYPE != glsr_get( $post, 'post_type' ) || 'trash' == $post->post_status ) {
126 126
             return $actions;
127 127
         }
128 128
         unset($actions['inline hide-if-no-js']); //Remove Quick-edit
129 129
         $rowActions = [
130
-            'approve' => esc_attr__('Approve', 'site-reviews'),
131
-            'unapprove' => esc_attr__('Unapprove', 'site-reviews'),
130
+            'approve' => esc_attr__( 'Approve', 'site-reviews' ),
131
+            'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ),
132 132
         ];
133 133
         $newActions = [];
134
-        foreach ($rowActions as $key => $text) {
135
-            $newActions[$key] = glsr(Builder::class)->a($text, [
136
-                'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text),
134
+        foreach( $rowActions as $key => $text ) {
135
+            $newActions[$key] = glsr( Builder::class )->a( $text, [
136
+                'aria-label' => sprintf( esc_attr_x( '%s this review', 'Approve the review', 'site-reviews' ), $text ),
137 137
                 'class' => 'glsr-change-status',
138 138
                 'href' => wp_nonce_url(
139
-                    admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID),
139
+                    admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ),
140 140
                     $key.'-review_'.$post->ID
141 141
                 ),
142
-            ]);
142
+            ] );
143 143
         }
144
-        return $newActions + glsr(Helper::class)->consolidateArray($actions);
144
+        return $newActions + glsr( Helper::class )->consolidateArray( $actions );
145 145
     }
146 146
 
147 147
     /**
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
      * @return array
150 150
      * @filter manage_edit-.Application::POST_TYPE._sortable_columns
151 151
      */
152
-    public function filterSortableColumns($columns)
152
+    public function filterSortableColumns( $columns )
153 153
     {
154
-        $columns = glsr(Helper::class)->consolidateArray($columns);
154
+        $columns = glsr( Helper::class )->consolidateArray( $columns );
155 155
         $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
156 156
         unset($postTypeColumns['cb']);
157
-        foreach ($postTypeColumns as $key => $value) {
158
-            if (glsr(Helper::class)->startsWith('taxonomy', $key)) {
157
+        foreach( $postTypeColumns as $key => $value ) {
158
+            if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) ) {
159 159
                 continue;
160 160
             }
161 161
             $columns[$key] = $key;
@@ -173,22 +173,22 @@  discard block
 block discarded – undo
173 173
      * @return string
174 174
      * @filter ngettext
175 175
      */
176
-    public function filterStatusText($translation, $single, $plural, $number, $domain)
176
+    public function filterStatusText( $translation, $single, $plural, $number, $domain )
177 177
     {
178
-        if ($this->canModifyTranslation($domain)) {
178
+        if( $this->canModifyTranslation( $domain ) ) {
179 179
             $strings = [
180
-                'Published' => __('Approved', 'site-reviews'),
181
-                'Pending' => __('Unapproved', 'site-reviews'),
180
+                'Published' => __( 'Approved', 'site-reviews' ),
181
+                'Pending' => __( 'Unapproved', 'site-reviews' ),
182 182
             ];
183
-            foreach ($strings as $search => $replace) {
184
-                if (false === strpos($single, $search)) {
183
+            foreach( $strings as $search => $replace ) {
184
+                if( false === strpos( $single, $search ) ) {
185 185
                     continue;
186 186
                 }
187
-                $translation = $this->getTranslation([
187
+                $translation = $this->getTranslation( [
188 188
                     'number' => $number,
189
-                    'plural' => str_replace($search, $replace, $plural),
190
-                    'single' => str_replace($search, $replace, $single),
191
-                ]);
189
+                    'plural' => str_replace( $search, $replace, $plural ),
190
+                    'single' => str_replace( $search, $replace, $single ),
191
+                ] );
192 192
             }
193 193
         }
194 194
         return $translation;
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
      * @return void
201 201
      * @action bulk_edit_custom_box
202 202
      */
203
-    public function renderBulkEditFields($columnName, $postType)
203
+    public function renderBulkEditFields( $columnName, $postType )
204 204
     {
205
-        if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) {
206
-            glsr()->render('partials/editor/bulk-edit-assigned-to');
205
+        if( 'assigned_to' == $columnName && Application::POST_TYPE == $postType ) {
206
+            glsr()->render( 'partials/editor/bulk-edit-assigned-to' );
207 207
         }
208 208
     }
209 209
 
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
      * @return void
213 213
      * @action restrict_manage_posts
214 214
      */
215
-    public function renderColumnFilters($postType)
215
+    public function renderColumnFilters( $postType )
216 216
     {
217
-        glsr(Columns::class)->renderFilters($postType);
217
+        glsr( Columns::class )->renderFilters( $postType );
218 218
     }
219 219
 
220 220
     /**
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
      * @return void
224 224
      * @action manage_posts_custom_column
225 225
      */
226
-    public function renderColumnValues($column, $postId)
226
+    public function renderColumnValues( $column, $postId )
227 227
     {
228
-        glsr(Columns::class)->renderValues($column, $postId);
228
+        glsr( Columns::class )->renderValues( $column, $postId );
229 229
     }
230 230
 
231 231
     /**
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
      * @return void
234 234
      * @action save_post_.Application::POST_TYPE
235 235
      */
236
-    public function saveBulkEditFields($postId)
236
+    public function saveBulkEditFields( $postId )
237 237
     {
238
-        if (!current_user_can('edit_posts')) {
238
+        if( !current_user_can( 'edit_posts' ) ) {
239 239
             return;
240 240
         }
241
-        $assignedTo = filter_input(INPUT_GET, 'assigned_to');
242
-        if ($assignedTo && get_post($assignedTo)) {
243
-            glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
241
+        $assignedTo = filter_input( INPUT_GET, 'assigned_to' );
242
+        if( $assignedTo && get_post( $assignedTo ) ) {
243
+            glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo );
244 244
         }
245 245
     }
246 246
 
@@ -248,15 +248,15 @@  discard block
 block discarded – undo
248 248
      * @return void
249 249
      * @action pre_get_posts
250 250
      */
251
-    public function setQueryForColumn(WP_Query $query)
251
+    public function setQueryForColumn( WP_Query $query )
252 252
     {
253
-        if (!$this->hasPermission($query)) {
253
+        if( !$this->hasPermission( $query ) ) {
254 254
             return;
255 255
         }
256
-        $this->setMetaQuery($query, [
256
+        $this->setMetaQuery( $query, [
257 257
             'rating', 'review_type',
258
-        ]);
259
-        $this->setOrderby($query);
258
+        ] );
259
+        $this->setOrderby( $query );
260 260
     }
261 261
 
262 262
     /**
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
      */
266 266
     public function unapprove()
267 267
     {
268
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
268
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
269 269
             return;
270 270
         }
271
-        check_admin_referer('unapprove-review_'.($postId = $this->getPostId()));
272
-        wp_update_post([
271
+        check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) );
272
+        wp_update_post( [
273 273
             'ID' => $postId,
274 274
             'post_status' => 'pending',
275
-        ]);
276
-        wp_safe_redirect(wp_get_referer());
275
+        ] );
276
+        wp_safe_redirect( wp_get_referer() );
277 277
         exit;
278 278
     }
279 279
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      * @param string $domain
283 283
      * @return bool
284 284
      */
285
-    protected function canModifyTranslation($domain = 'default')
285
+    protected function canModifyTranslation( $domain = 'default' )
286 286
     {
287 287
         $screen = glsr_current_screen();
288 288
         return 'default' == $domain
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
      * Get the modified translation string.
295 295
      * @return string
296 296
      */
297
-    protected function getTranslation(array $args)
297
+    protected function getTranslation( array $args )
298 298
     {
299 299
         $defaults = [
300 300
             'number' => 0,
@@ -302,57 +302,57 @@  discard block
 block discarded – undo
302 302
             'single' => '',
303 303
             'text' => '',
304 304
         ];
305
-        $args = (object) wp_parse_args($args, $defaults);
306
-        $translations = get_translations_for_domain(Application::ID);
305
+        $args = (object)wp_parse_args( $args, $defaults );
306
+        $translations = get_translations_for_domain( Application::ID );
307 307
         return $args->text
308
-            ? $translations->translate($args->text)
309
-            : $translations->translate_plural($args->single, $args->plural, $args->number);
308
+            ? $translations->translate( $args->text )
309
+            : $translations->translate_plural( $args->single, $args->plural, $args->number );
310 310
     }
311 311
 
312 312
     /**
313 313
      * @return bool
314 314
      */
315
-    protected function hasPermission(WP_Query $query)
315
+    protected function hasPermission( WP_Query $query )
316 316
     {
317 317
         global $pagenow;
318 318
         return is_admin()
319 319
             && $query->is_main_query()
320
-            && Application::POST_TYPE == $query->get('post_type')
320
+            && Application::POST_TYPE == $query->get( 'post_type' )
321 321
             && 'edit.php' == $pagenow;
322 322
     }
323 323
 
324 324
     /**
325 325
      * @return void
326 326
      */
327
-    protected function setMetaQuery(WP_Query $query, array $metaKeys)
327
+    protected function setMetaQuery( WP_Query $query, array $metaKeys )
328 328
     {
329
-        foreach ($metaKeys as $key) {
330
-            if (!($value = filter_input(INPUT_GET, $key))) {
329
+        foreach( $metaKeys as $key ) {
330
+            if( !($value = filter_input( INPUT_GET, $key )) ) {
331 331
                 continue;
332 332
             }
333
-            $metaQuery = (array) $query->get('meta_query');
333
+            $metaQuery = (array)$query->get( 'meta_query' );
334 334
             $metaQuery[] = [
335
-                'key' => glsr(Helper::class)->prefixString($key, '_'),
335
+                'key' => glsr( Helper::class )->prefixString( $key, '_' ),
336 336
                 'value' => $value,
337 337
             ];
338
-            $query->set('meta_query', $metaQuery);
338
+            $query->set( 'meta_query', $metaQuery );
339 339
         }
340 340
     }
341 341
 
342 342
     /**
343 343
      * @return void
344 344
      */
345
-    protected function setOrderby(WP_Query $query)
345
+    protected function setOrderby( WP_Query $query )
346 346
     {
347
-        $orderby = $query->get('orderby');
347
+        $orderby = $query->get( 'orderby' );
348 348
         $columns = glsr()->postTypeColumns[Application::POST_TYPE];
349 349
         unset($columns['cb'], $columns['title'], $columns['date']);
350
-        if (in_array($orderby, array_keys($columns))) {
351
-            if ('reviewer' == $orderby) {
350
+        if( in_array( $orderby, array_keys( $columns ) ) ) {
351
+            if( 'reviewer' == $orderby ) {
352 352
                 $orderby = '_author';
353 353
             }
354
-            $query->set('meta_key', $orderby);
355
-            $query->set('orderby', 'meta_value');
354
+            $query->set( 'meta_key', $orderby );
355
+            $query->set( 'orderby', 'meta_value' );
356 356
         }
357 357
     }
358 358
 }
Please login to merge, or discard this patch.
plugin/Defaults/EmailDefaults.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@
 block discarded – undo
7 7
 
8 8
 class EmailDefaults extends Defaults
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    protected function defaults()
14
-    {
15
-        $fromName = wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES);
16
-        $fromEmail = glsr(OptionManager::class)->getWP('admin_email');
17
-        return [
18
-            'after' => '',
19
-            'attachments' => [],
20
-            'bcc' => '',
21
-            'before' => '',
22
-            'cc' => '',
23
-            'from' => $fromName.' <'.$fromEmail.'>',
24
-            'message' => '',
25
-            'reply-to' => '',
26
-            'subject' => '',
27
-            'template' => '',
28
-            'template-tags' => [],
29
-            'to' => '',
30
-        ];
31
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	protected function defaults()
14
+	{
15
+		$fromName = wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES);
16
+		$fromEmail = glsr(OptionManager::class)->getWP('admin_email');
17
+		return [
18
+			'after' => '',
19
+			'attachments' => [],
20
+			'bcc' => '',
21
+			'before' => '',
22
+			'cc' => '',
23
+			'from' => $fromName.' <'.$fromEmail.'>',
24
+			'message' => '',
25
+			'reply-to' => '',
26
+			'subject' => '',
27
+			'template' => '',
28
+			'template-tags' => [],
29
+			'to' => '',
30
+		];
31
+	}
32 32
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
      */
13 13
     protected function defaults()
14 14
     {
15
-        $fromName = wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES);
16
-        $fromEmail = glsr(OptionManager::class)->getWP('admin_email');
15
+        $fromName = wp_specialchars_decode( glsr( OptionManager::class )->getWP( 'blogname' ), ENT_QUOTES );
16
+        $fromEmail = glsr( OptionManager::class )->getWP( 'admin_email' );
17 17
         return [
18 18
             'after' => '',
19 19
             'attachments' => [],
Please login to merge, or discard this patch.
plugin/Database/SqlQueries.php 3 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param string $metaReviewId
21 21
 	 * @return int
22 22
 	 */
23
-    public function getPostIdFromReviewId($metaReviewId)
23
+	public function getPostIdFromReviewId($metaReviewId)
24 24
 	{
25 25
 		$postId = $this->db->get_var("
26 26
 			SELECT p.ID
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             AND m.meta_key = '_review_id'
31 31
 			AND m.meta_value = '{$metaReviewId}'
32 32
 		");
33
-        return intval($postId);
33
+		return intval($postId);
34 34
 	}
35 35
 
36 36
 	/**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param int $limit
39 39
 	 * @return array
40 40
 	 */
41
-    public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
41
+	public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
42 42
 	{
43 43
 		return (array) $this->db->get_results("
44 44
 			SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	 * @param string $metaKey
63 63
 	 * @return array
64 64
 	 */
65
-    public function getReviewCountsFor($metaKey)
65
+	public function getReviewCountsFor($metaKey)
66 66
 	{
67
-        $metaKey = glsr(Helper::class)->prefixString($metaKey);
67
+		$metaKey = glsr(Helper::class)->prefixString($metaKey);
68 68
 		return (array) $this->db->get_results("
69 69
 			SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
70 70
 			FROM {$this->db->posts} AS p
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param string $reviewType
81 81
 	 * @return array
82 82
 	 */
83
-    public function getReviewIdsByType($reviewType)
83
+	public function getReviewIdsByType($reviewType)
84 84
 	{
85 85
 		$results = $this->db->get_col("
86 86
 			SELECT DISTINCT m1.meta_value AS review_id
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             AND m2.meta_key = '_review_type'
93 93
 			AND m2.meta_value = '{$reviewType}'
94 94
 		");
95
-        return array_keys(array_flip($results));
95
+		return array_keys(array_flip($results));
96 96
 	}
97 97
 
98 98
 	/**
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	 * @param int $limit
101 101
 	 * @return array
102 102
 	 */
103
-    public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
103
+	public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
104 104
 	{
105
-        sort($postIds);
106
-        $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
107
-        $postIds = implode(',', $postIds);
105
+		sort($postIds);
106
+		$postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
107
+		$postIds = implode(',', $postIds);
108 108
 		return (array) $this->db->get_results("
109 109
 			SELECT p.ID, m.meta_value AS rating
110 110
 			FROM {$this->db->posts} AS p
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	 * @param string $status
126 126
 	 * @return array
127 127
 	 */
128
-    public function getReviewsMeta($key, $status = 'publish')
128
+	public function getReviewsMeta($key, $status = 'publish')
129 129
 	{
130
-        $key = glsr(Helper::class)->prefixString($key);
130
+		$key = glsr(Helper::class)->prefixString($key);
131 131
 		$values = $this->db->get_col("
132 132
 			SELECT DISTINCT m.meta_value
133 133
 			FROM {$this->db->postmeta} m
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 			GROUP BY p.ID -- remove duplicate meta_value entries
140 140
 			ORDER BY m.meta_id ASC -- sort by oldest meta_value
141 141
 		");
142
-        sort($values);
142
+		sort($values);
143 143
 		return $values;
144 144
 	}
145 145
 
@@ -147,34 +147,34 @@  discard block
 block discarded – undo
147 147
 	 * @param string $and
148 148
 	 * @return string
149 149
 	 */
150
-    protected function getAndForCounts(array $args, $and = '')
150
+	protected function getAndForCounts(array $args, $and = '')
151 151
 	{
152
-        $postIds = implode(',', array_filter(glsr_get($args, 'post_ids')));
153
-        $termIds = implode(',', array_filter(glsr_get($args, 'term_ids')));
154
-        if (!empty($args['type'])) {
155
-            $and.= "AND m2.meta_value = '{$args['type']}' ";
152
+		$postIds = implode(',', array_filter(glsr_get($args, 'post_ids')));
153
+		$termIds = implode(',', array_filter(glsr_get($args, 'term_ids')));
154
+		if (!empty($args['type'])) {
155
+			$and.= "AND m2.meta_value = '{$args['type']}' ";
156 156
 		}
157
-        if ($postIds) {
158
-            $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
157
+		if ($postIds) {
158
+			$and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
159 159
 		}
160
-        if ($termIds) {
161
-            $and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
160
+		if ($termIds) {
161
+			$and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
162 162
 		}
163
-        return apply_filters('site-reviews/query/and-for-counts', $and);
163
+		return apply_filters('site-reviews/query/and-for-counts', $and);
164 164
 	}
165 165
 
166 166
 	/**
167 167
 	 * @param string $innerJoin
168 168
 	 * @return string
169 169
 	 */
170
-    protected function getInnerJoinForCounts(array $args, $innerJoin = '')
170
+	protected function getInnerJoinForCounts(array $args, $innerJoin = '')
171 171
 	{
172
-        if (!empty(glsr_get($args, 'post_ids'))) {
173
-            $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
172
+		if (!empty(glsr_get($args, 'post_ids'))) {
173
+			$innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
174 174
 		}
175
-        if (!empty(glsr_get($args, 'term_ids'))) {
176
-            $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
175
+		if (!empty(glsr_get($args, 'term_ids'))) {
176
+			$innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
177 177
 		}
178
-        return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
178
+		return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
179 179
 	}
180 180
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -20,17 +20,17 @@  discard block
 block discarded – undo
20 20
 	 * @param string $metaReviewId
21 21
 	 * @return int
22 22
 	 */
23
-    public function getPostIdFromReviewId($metaReviewId)
23
+    public function getPostIdFromReviewId( $metaReviewId )
24 24
 	{
25
-		$postId = $this->db->get_var("
25
+		$postId = $this->db->get_var( "
26 26
 			SELECT p.ID
27 27
 			FROM {$this->db->posts} AS p
28 28
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
29 29
 			WHERE p.post_type = '{$this->postType}'
30 30
             AND m.meta_key = '_review_id'
31 31
 			AND m.meta_value = '{$metaReviewId}'
32
-		");
33
-        return intval($postId);
32
+		" );
33
+        return intval( $postId );
34 34
 	}
35 35
 
36 36
 	/**
@@ -38,23 +38,23 @@  discard block
 block discarded – undo
38 38
 	 * @param int $limit
39 39
 	 * @return array
40 40
 	 */
41
-    public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
41
+    public function getReviewCounts( array $args, $lastPostId = 0, $limit = 500 )
42 42
 	{
43
-		return (array) $this->db->get_results("
43
+		return (array)$this->db->get_results( "
44 44
 			SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
45 45
 			FROM {$this->db->posts} AS p
46 46
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
47 47
 			INNER JOIN {$this->db->postmeta} AS m2 ON p.ID = m2.post_id
48
-            {$this->getInnerJoinForCounts($args)}
48
+            {$this->getInnerJoinForCounts( $args )}
49 49
 			WHERE p.ID > {$lastPostId}
50 50
 			AND p.post_status = 'publish'
51 51
 			AND p.post_type = '{$this->postType}'
52 52
             AND m1.meta_key = '_rating'
53 53
             AND m2.meta_key = '_review_type'
54
-            {$this->getAndForCounts($args)}
54
+            {$this->getAndForCounts( $args )}
55 55
 			ORDER By p.ID ASC
56 56
 			LIMIT {$limit}
57
-		");
57
+		" );
58 58
 	}
59 59
 
60 60
 	/**
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 	 * @param string $metaKey
63 63
 	 * @return array
64 64
 	 */
65
-    public function getReviewCountsFor($metaKey)
65
+    public function getReviewCountsFor( $metaKey )
66 66
 	{
67
-        $metaKey = glsr(Helper::class)->prefixString($metaKey);
68
-		return (array) $this->db->get_results("
67
+        $metaKey = glsr( Helper::class )->prefixString( $metaKey );
68
+		return (array)$this->db->get_results( "
69 69
 			SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
70 70
 			FROM {$this->db->posts} AS p
71 71
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
72 72
 			WHERE p.post_type = '{$this->postType}'
73 73
 			AND m.meta_key = '{$metaKey}'
74 74
 			GROUP BY name
75
-		");
75
+		" );
76 76
 	}
77 77
 
78 78
 	/**
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @param string $reviewType
81 81
 	 * @return array
82 82
 	 */
83
-    public function getReviewIdsByType($reviewType)
83
+    public function getReviewIdsByType( $reviewType )
84 84
 	{
85
-		$results = $this->db->get_col("
85
+		$results = $this->db->get_col( "
86 86
 			SELECT DISTINCT m1.meta_value AS review_id
87 87
 			FROM {$this->db->posts} AS p
88 88
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
             AND m1.meta_key = '_review_id'
92 92
             AND m2.meta_key = '_review_type'
93 93
 			AND m2.meta_value = '{$reviewType}'
94
-		");
95
-        return array_keys(array_flip($results));
94
+		" );
95
+        return array_keys( array_flip( $results ) );
96 96
 	}
97 97
 
98 98
 	/**
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 	 * @param int $limit
101 101
 	 * @return array
102 102
 	 */
103
-    public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
103
+    public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 )
104 104
 	{
105
-        sort($postIds);
106
-        $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
107
-        $postIds = implode(',', $postIds);
108
-		return (array) $this->db->get_results("
105
+        sort( $postIds );
106
+        $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit );
107
+        $postIds = implode( ',', $postIds );
108
+		return (array)$this->db->get_results( "
109 109
 			SELECT p.ID, m.meta_value AS rating
110 110
 			FROM {$this->db->posts} AS p
111 111
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			GROUP BY p.ID
118 118
 			ORDER By p.ID ASC
119 119
 			LIMIT {$limit}
120
-		");
120
+		" );
121 121
 	}
122 122
 
123 123
 	/**
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 	 * @param string $status
126 126
 	 * @return array
127 127
 	 */
128
-    public function getReviewsMeta($key, $status = 'publish')
128
+    public function getReviewsMeta( $key, $status = 'publish' )
129 129
 	{
130
-        $key = glsr(Helper::class)->prefixString($key);
131
-		$values = $this->db->get_col("
130
+        $key = glsr( Helper::class )->prefixString( $key );
131
+		$values = $this->db->get_col( "
132 132
 			SELECT DISTINCT m.meta_value
133 133
 			FROM {$this->db->postmeta} m
134 134
 			LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 			AND p.post_status = '{$status}'
139 139
 			GROUP BY p.ID -- remove duplicate meta_value entries
140 140
 			ORDER BY m.meta_id ASC -- sort by oldest meta_value
141
-		");
142
-        sort($values);
141
+		" );
142
+        sort( $values );
143 143
 		return $values;
144 144
 	}
145 145
 
@@ -147,34 +147,34 @@  discard block
 block discarded – undo
147 147
 	 * @param string $and
148 148
 	 * @return string
149 149
 	 */
150
-    protected function getAndForCounts(array $args, $and = '')
150
+    protected function getAndForCounts( array $args, $and = '' )
151 151
 	{
152
-        $postIds = implode(',', array_filter(glsr_get($args, 'post_ids')));
153
-        $termIds = implode(',', array_filter(glsr_get($args, 'term_ids')));
154
-        if (!empty($args['type'])) {
155
-            $and.= "AND m2.meta_value = '{$args['type']}' ";
152
+        $postIds = implode( ',', array_filter( glsr_get( $args, 'post_ids' ) ) );
153
+        $termIds = implode( ',', array_filter( glsr_get( $args, 'term_ids' ) ) );
154
+        if( !empty($args['type']) ) {
155
+            $and .= "AND m2.meta_value = '{$args['type']}' ";
156 156
 		}
157
-        if ($postIds) {
158
-            $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
157
+        if( $postIds ) {
158
+            $and .= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
159 159
 		}
160
-        if ($termIds) {
161
-            $and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
160
+        if( $termIds ) {
161
+            $and .= "AND tr.term_taxonomy_id IN ({$termIds}) ";
162 162
 		}
163
-        return apply_filters('site-reviews/query/and-for-counts', $and);
163
+        return apply_filters( 'site-reviews/query/and-for-counts', $and );
164 164
 	}
165 165
 
166 166
 	/**
167 167
 	 * @param string $innerJoin
168 168
 	 * @return string
169 169
 	 */
170
-    protected function getInnerJoinForCounts(array $args, $innerJoin = '')
170
+    protected function getInnerJoinForCounts( array $args, $innerJoin = '' )
171 171
 	{
172
-        if (!empty(glsr_get($args, 'post_ids'))) {
173
-            $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
172
+        if( !empty(glsr_get( $args, 'post_ids' )) ) {
173
+            $innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
174 174
 		}
175
-        if (!empty(glsr_get($args, 'term_ids'))) {
176
-            $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
175
+        if( !empty(glsr_get( $args, 'term_ids' )) ) {
176
+            $innerJoin .= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
177 177
 		}
178
-        return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
178
+        return apply_filters( 'site-reviews/query/inner-join-for-counts', $innerJoin );
179 179
 	}
180 180
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @return int
22 22
 	 */
23 23
     public function getPostIdFromReviewId($metaReviewId)
24
-	{
24
+    {
25 25
 		$postId = $this->db->get_var("
26 26
 			SELECT p.ID
27 27
 			FROM {$this->db->posts} AS p
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @return array
40 40
 	 */
41 41
     public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
42
-	{
42
+    {
43 43
 		return (array) $this->db->get_results("
44 44
 			SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
45 45
 			FROM {$this->db->posts} AS p
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @return array
64 64
 	 */
65 65
     public function getReviewCountsFor($metaKey)
66
-	{
66
+    {
67 67
         $metaKey = glsr(Helper::class)->prefixString($metaKey);
68 68
 		return (array) $this->db->get_results("
69 69
 			SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @return array
82 82
 	 */
83 83
     public function getReviewIdsByType($reviewType)
84
-	{
84
+    {
85 85
 		$results = $this->db->get_col("
86 86
 			SELECT DISTINCT m1.meta_value AS review_id
87 87
 			FROM {$this->db->posts} AS p
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @return array
102 102
 	 */
103 103
     public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
104
-	{
104
+    {
105 105
         sort($postIds);
106 106
         $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
107 107
         $postIds = implode(',', $postIds);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @return array
127 127
 	 */
128 128
     public function getReviewsMeta($key, $status = 'publish')
129
-	{
129
+    {
130 130
         $key = glsr(Helper::class)->prefixString($key);
131 131
 		$values = $this->db->get_col("
132 132
 			SELECT DISTINCT m.meta_value
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @return string
149 149
 	 */
150 150
     protected function getAndForCounts(array $args, $and = '')
151
-	{
151
+    {
152 152
         $postIds = implode(',', array_filter(glsr_get($args, 'post_ids')));
153 153
         $termIds = implode(',', array_filter(glsr_get($args, 'term_ids')));
154 154
         if (!empty($args['type'])) {
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @return string
169 169
 	 */
170 170
     protected function getInnerJoinForCounts(array $args, $innerJoin = '')
171
-	{
171
+    {
172 172
         if (!empty(glsr_get($args, 'post_ids'))) {
173 173
             $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
174 174
 		}
Please login to merge, or discard this patch.
plugin/Database/OptionManager.php 2 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -7,155 +7,155 @@
 block discarded – undo
7 7
 
8 8
 class OptionManager
9 9
 {
10
-    /**
11
-     * @var array
12
-     */
13
-    protected $options;
10
+	/**
11
+	 * @var array
12
+	 */
13
+	protected $options;
14 14
 
15
-    /**
16
-     * @return string
17
-     */
18
-    public static function databaseKey($version = null)
19
-    {
20
-        if (null === $version) {
21
-            $version = explode('.', glsr()->version);
22
-            $version = array_shift($version);
23
-        }
24
-        return glsr(Helper::class)->snakeCase(
25
-            Application::ID.'-v'.intval($version)
26
-        );
27
-    }
15
+	/**
16
+	 * @return string
17
+	 */
18
+	public static function databaseKey($version = null)
19
+	{
20
+		if (null === $version) {
21
+			$version = explode('.', glsr()->version);
22
+			$version = array_shift($version);
23
+		}
24
+		return glsr(Helper::class)->snakeCase(
25
+			Application::ID.'-v'.intval($version)
26
+		);
27
+	}
28 28
 
29
-    /**
30
-     * @return array
31
-     */
32
-    public function all()
33
-    {
34
-        if (empty($this->options)) {
35
-            $this->reset();
36
-        }
37
-        return $this->options;
38
-    }
29
+	/**
30
+	 * @return array
31
+	 */
32
+	public function all()
33
+	{
34
+		if (empty($this->options)) {
35
+			$this->reset();
36
+		}
37
+		return $this->options;
38
+	}
39 39
 
40
-    /**
41
-     * @param string $path
42
-     * @return bool
43
-     */
44
-    public function delete($path)
45
-    {
46
-        $keys = explode('.', $path);
47
-        $last = array_pop($keys);
48
-        $options = $this->all();
49
-        $pointer = &$options;
50
-        foreach ($keys as $key) {
51
-            if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
52
-                continue;
53
-            }
54
-            $pointer = &$pointer[$key];
55
-        }
56
-        unset($pointer[$last]);
57
-        return $this->set($options);
58
-    }
40
+	/**
41
+	 * @param string $path
42
+	 * @return bool
43
+	 */
44
+	public function delete($path)
45
+	{
46
+		$keys = explode('.', $path);
47
+		$last = array_pop($keys);
48
+		$options = $this->all();
49
+		$pointer = &$options;
50
+		foreach ($keys as $key) {
51
+			if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
52
+				continue;
53
+			}
54
+			$pointer = &$pointer[$key];
55
+		}
56
+		unset($pointer[$last]);
57
+		return $this->set($options);
58
+	}
59 59
 
60
-    /**
61
-     * @param string $path
62
-     * @param mixed $fallback
63
-     * @param string $cast
64
-     * @return mixed
65
-     */
66
-    public function get($path = '', $fallback = '', $cast = '')
67
-    {
68
-        $result = glsr(Helper::class)->dataGet($this->all(), $path, $fallback);
69
-        return glsr(Helper::class)->castTo($cast, $result);
70
-    }
60
+	/**
61
+	 * @param string $path
62
+	 * @param mixed $fallback
63
+	 * @param string $cast
64
+	 * @return mixed
65
+	 */
66
+	public function get($path = '', $fallback = '', $cast = '')
67
+	{
68
+		$result = glsr(Helper::class)->dataGet($this->all(), $path, $fallback);
69
+		return glsr(Helper::class)->castTo($cast, $result);
70
+	}
71 71
 
72
-    /**
73
-     * @param string $path
74
-     * @return bool
75
-     */
76
-    public function getBool($path)
77
-    {
78
-        return 'yes' == $this->get($path)
79
-            ? true
80
-            : false;
81
-    }
72
+	/**
73
+	 * @param string $path
74
+	 * @return bool
75
+	 */
76
+	public function getBool($path)
77
+	{
78
+		return 'yes' == $this->get($path)
79
+			? true
80
+			: false;
81
+	}
82 82
 
83
-    /**
84
-     * @param string $path
85
-     * @param mixed $fallback
86
-     * @param string $cast
87
-     * @return mixed
88
-     */
89
-    public function getWP($path, $fallback = '', $cast = '')
90
-    {
91
-        $option = get_option($path, $fallback);
92
-        if (empty($option)) {
93
-            $option = $fallback;
94
-        }
95
-        return glsr(Helper::class)->castTo($cast, $option);
96
-    }
83
+	/**
84
+	 * @param string $path
85
+	 * @param mixed $fallback
86
+	 * @param string $cast
87
+	 * @return mixed
88
+	 */
89
+	public function getWP($path, $fallback = '', $cast = '')
90
+	{
91
+		$option = get_option($path, $fallback);
92
+		if (empty($option)) {
93
+			$option = $fallback;
94
+		}
95
+		return glsr(Helper::class)->castTo($cast, $option);
96
+	}
97 97
 
98
-    /**
99
-     * @return string
100
-     */
101
-    public function json()
102
-    {
103
-        return json_encode($this->all());
104
-    }
98
+	/**
99
+	 * @return string
100
+	 */
101
+	public function json()
102
+	{
103
+		return json_encode($this->all());
104
+	}
105 105
 
106
-    /**
107
-     * @return array
108
-     */
109
-    public function normalize(array $options = [])
110
-    {
111
-        $options = wp_parse_args(
112
-            glsr(Helper::class)->flattenArray($options),
113
-            glsr(DefaultsManager::class)->defaults()
114
-        );
115
-        array_walk($options, function (&$value) {
116
-            if (!is_string($value)) {
117
-                return;
118
-            }
119
-            $value = wp_kses($value, wp_kses_allowed_html('post'));
120
-        });
121
-        return glsr(Helper::class)->convertDotNotationArray($options);
122
-    }
106
+	/**
107
+	 * @return array
108
+	 */
109
+	public function normalize(array $options = [])
110
+	{
111
+		$options = wp_parse_args(
112
+			glsr(Helper::class)->flattenArray($options),
113
+			glsr(DefaultsManager::class)->defaults()
114
+		);
115
+		array_walk($options, function (&$value) {
116
+			if (!is_string($value)) {
117
+				return;
118
+			}
119
+			$value = wp_kses($value, wp_kses_allowed_html('post'));
120
+		});
121
+		return glsr(Helper::class)->convertDotNotationArray($options);
122
+	}
123 123
 
124
-    /**
125
-     * @return bool
126
-     */
127
-    public function isRecaptchaEnabled()
128
-    {
129
-        $integration = $this->get('settings.submissions.recaptcha.integration');
130
-        return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
131
-    }
124
+	/**
125
+	 * @return bool
126
+	 */
127
+	public function isRecaptchaEnabled()
128
+	{
129
+		$integration = $this->get('settings.submissions.recaptcha.integration');
130
+		return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
131
+	}
132 132
 
133
-    /**
134
-     * @return array
135
-     */
136
-    public function reset()
137
-    {
138
-        $options = $this->getWP(static::databaseKey(), []);
139
-        if (!is_array($options) || empty($options)) {
140
-            delete_option(static::databaseKey());
141
-            $options = wp_parse_args(glsr()->defaults, ['settings' => []]);
142
-        }
143
-        $this->options = $options;
144
-    }
133
+	/**
134
+	 * @return array
135
+	 */
136
+	public function reset()
137
+	{
138
+		$options = $this->getWP(static::databaseKey(), []);
139
+		if (!is_array($options) || empty($options)) {
140
+			delete_option(static::databaseKey());
141
+			$options = wp_parse_args(glsr()->defaults, ['settings' => []]);
142
+		}
143
+		$this->options = $options;
144
+	}
145 145
 
146
-    /**
147
-     * @param string|array $pathOrOptions
148
-     * @param mixed $value
149
-     * @return bool
150
-     */
151
-    public function set($pathOrOptions, $value = '')
152
-    {
153
-        if (is_string($pathOrOptions)) {
154
-            $pathOrOptions = glsr(Helper::class)->dataSet($this->all(), $pathOrOptions, $value);
155
-        }
156
-        if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
157
-            $this->reset();
158
-        }
159
-        return $result;
160
-    }
146
+	/**
147
+	 * @param string|array $pathOrOptions
148
+	 * @param mixed $value
149
+	 * @return bool
150
+	 */
151
+	public function set($pathOrOptions, $value = '')
152
+	{
153
+		if (is_string($pathOrOptions)) {
154
+			$pathOrOptions = glsr(Helper::class)->dataSet($this->all(), $pathOrOptions, $value);
155
+		}
156
+		if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
157
+			$this->reset();
158
+		}
159
+		return $result;
160
+	}
161 161
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
     /**
16 16
      * @return string
17 17
      */
18
-    public static function databaseKey($version = null)
18
+    public static function databaseKey( $version = null )
19 19
     {
20
-        if (null === $version) {
21
-            $version = explode('.', glsr()->version);
22
-            $version = array_shift($version);
20
+        if( null === $version ) {
21
+            $version = explode( '.', glsr()->version );
22
+            $version = array_shift( $version );
23 23
         }
24
-        return glsr(Helper::class)->snakeCase(
25
-            Application::ID.'-v'.intval($version)
24
+        return glsr( Helper::class )->snakeCase(
25
+            Application::ID.'-v'.intval( $version )
26 26
         );
27 27
     }
28 28
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function all()
33 33
     {
34
-        if (empty($this->options)) {
34
+        if( empty($this->options) ) {
35 35
             $this->reset();
36 36
         }
37 37
         return $this->options;
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
      * @param string $path
42 42
      * @return bool
43 43
      */
44
-    public function delete($path)
44
+    public function delete( $path )
45 45
     {
46
-        $keys = explode('.', $path);
47
-        $last = array_pop($keys);
46
+        $keys = explode( '.', $path );
47
+        $last = array_pop( $keys );
48 48
         $options = $this->all();
49 49
         $pointer = &$options;
50
-        foreach ($keys as $key) {
51
-            if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
50
+        foreach( $keys as $key ) {
51
+            if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) ) {
52 52
                 continue;
53 53
             }
54 54
             $pointer = &$pointer[$key];
55 55
         }
56 56
         unset($pointer[$last]);
57
-        return $this->set($options);
57
+        return $this->set( $options );
58 58
     }
59 59
 
60 60
     /**
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
      * @param string $cast
64 64
      * @return mixed
65 65
      */
66
-    public function get($path = '', $fallback = '', $cast = '')
66
+    public function get( $path = '', $fallback = '', $cast = '' )
67 67
     {
68
-        $result = glsr(Helper::class)->dataGet($this->all(), $path, $fallback);
69
-        return glsr(Helper::class)->castTo($cast, $result);
68
+        $result = glsr( Helper::class )->dataGet( $this->all(), $path, $fallback );
69
+        return glsr( Helper::class )->castTo( $cast, $result );
70 70
     }
71 71
 
72 72
     /**
73 73
      * @param string $path
74 74
      * @return bool
75 75
      */
76
-    public function getBool($path)
76
+    public function getBool( $path )
77 77
     {
78
-        return 'yes' == $this->get($path)
78
+        return 'yes' == $this->get( $path )
79 79
             ? true
80 80
             : false;
81 81
     }
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
      * @param string $cast
87 87
      * @return mixed
88 88
      */
89
-    public function getWP($path, $fallback = '', $cast = '')
89
+    public function getWP( $path, $fallback = '', $cast = '' )
90 90
     {
91
-        $option = get_option($path, $fallback);
92
-        if (empty($option)) {
91
+        $option = get_option( $path, $fallback );
92
+        if( empty($option) ) {
93 93
             $option = $fallback;
94 94
         }
95
-        return glsr(Helper::class)->castTo($cast, $option);
95
+        return glsr( Helper::class )->castTo( $cast, $option );
96 96
     }
97 97
 
98 98
     /**
@@ -100,25 +100,25 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function json()
102 102
     {
103
-        return json_encode($this->all());
103
+        return json_encode( $this->all() );
104 104
     }
105 105
 
106 106
     /**
107 107
      * @return array
108 108
      */
109
-    public function normalize(array $options = [])
109
+    public function normalize( array $options = [] )
110 110
     {
111 111
         $options = wp_parse_args(
112
-            glsr(Helper::class)->flattenArray($options),
113
-            glsr(DefaultsManager::class)->defaults()
112
+            glsr( Helper::class )->flattenArray( $options ),
113
+            glsr( DefaultsManager::class )->defaults()
114 114
         );
115
-        array_walk($options, function (&$value) {
116
-            if (!is_string($value)) {
115
+        array_walk( $options, function( &$value ) {
116
+            if( !is_string( $value ) ) {
117 117
                 return;
118 118
             }
119
-            $value = wp_kses($value, wp_kses_allowed_html('post'));
119
+            $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) );
120 120
         });
121
-        return glsr(Helper::class)->convertDotNotationArray($options);
121
+        return glsr( Helper::class )->convertDotNotationArray( $options );
122 122
     }
123 123
 
124 124
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function isRecaptchaEnabled()
128 128
     {
129
-        $integration = $this->get('settings.submissions.recaptcha.integration');
129
+        $integration = $this->get( 'settings.submissions.recaptcha.integration' );
130 130
         return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
131 131
     }
132 132
 
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function reset()
137 137
     {
138
-        $options = $this->getWP(static::databaseKey(), []);
139
-        if (!is_array($options) || empty($options)) {
140
-            delete_option(static::databaseKey());
141
-            $options = wp_parse_args(glsr()->defaults, ['settings' => []]);
138
+        $options = $this->getWP( static::databaseKey(), [] );
139
+        if( !is_array( $options ) || empty($options) ) {
140
+            delete_option( static::databaseKey() );
141
+            $options = wp_parse_args( glsr()->defaults, ['settings' => []] );
142 142
         }
143 143
         $this->options = $options;
144 144
     }
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
      * @param mixed $value
149 149
      * @return bool
150 150
      */
151
-    public function set($pathOrOptions, $value = '')
151
+    public function set( $pathOrOptions, $value = '' )
152 152
     {
153
-        if (is_string($pathOrOptions)) {
154
-            $pathOrOptions = glsr(Helper::class)->dataSet($this->all(), $pathOrOptions, $value);
153
+        if( is_string( $pathOrOptions ) ) {
154
+            $pathOrOptions = glsr( Helper::class )->dataSet( $this->all(), $pathOrOptions, $value );
155 155
         }
156
-        if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
156
+        if( $result = update_option( static::databaseKey(), (array)$pathOrOptions ) ) {
157 157
             $this->reset();
158 158
         }
159 159
         return $result;
Please login to merge, or discard this patch.