Passed
Push — master ( 054ae2...bf35ce )
by Paul
04:22
created
plugin/Database/Cache.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -6,63 +6,63 @@
 block discarded – undo
6 6
 
7 7
 class Cache
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    public function getCloudflareIps()
13
-    {
14
-        if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) {
15
-            $ipAddresses = array_fill_keys(['v4', 'v6'], []);
16
-            foreach (array_keys($ipAddresses) as $version) {
17
-                $url = 'https://www.cloudflare.com/ips-'.$version;
18
-                $response = wp_remote_get($url, ['sslverify' => false]);
19
-                if (is_wp_error($response)) {
20
-                    glsr_log()->error($response->get_error_message());
21
-                    continue;
22
-                }
23
-                if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) {
24
-                    glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']');
25
-                    continue;
26
-                }
27
-                $ipAddresses[$version] = array_filter(
28
-                    (array) preg_split('/\R/', wp_remote_retrieve_body($response))
29
-                );
30
-            }
31
-            set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS);
32
-        }
33
-        return $ipAddresses;
34
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	public function getCloudflareIps()
13
+	{
14
+		if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) {
15
+			$ipAddresses = array_fill_keys(['v4', 'v6'], []);
16
+			foreach (array_keys($ipAddresses) as $version) {
17
+				$url = 'https://www.cloudflare.com/ips-'.$version;
18
+				$response = wp_remote_get($url, ['sslverify' => false]);
19
+				if (is_wp_error($response)) {
20
+					glsr_log()->error($response->get_error_message());
21
+					continue;
22
+				}
23
+				if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) {
24
+					glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']');
25
+					continue;
26
+				}
27
+				$ipAddresses[$version] = array_filter(
28
+					(array) preg_split('/\R/', wp_remote_retrieve_body($response))
29
+				);
30
+			}
31
+			set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS);
32
+		}
33
+		return $ipAddresses;
34
+	}
35 35
 
36
-    /**
37
-     * @param string $metaKey
38
-     * @return array
39
-     */
40
-    public function getReviewCountsFor($metaKey)
41
-    {
42
-        $counts = wp_cache_get(Application::ID, $metaKey.'_count');
43
-        if (false === $counts) {
44
-            $counts = [];
45
-            $results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey);
46
-            foreach ($results as $result) {
47
-                $counts[$result->name] = $result->num_posts;
48
-            }
49
-            wp_cache_set(Application::ID, $counts, $metaKey.'_count');
50
-        }
51
-        return $counts;
52
-    }
36
+	/**
37
+	 * @param string $metaKey
38
+	 * @return array
39
+	 */
40
+	public function getReviewCountsFor($metaKey)
41
+	{
42
+		$counts = wp_cache_get(Application::ID, $metaKey.'_count');
43
+		if (false === $counts) {
44
+			$counts = [];
45
+			$results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey);
46
+			foreach ($results as $result) {
47
+				$counts[$result->name] = $result->num_posts;
48
+			}
49
+			wp_cache_set(Application::ID, $counts, $metaKey.'_count');
50
+		}
51
+		return $counts;
52
+	}
53 53
 
54
-    /**
55
-     * @return string
56
-     */
57
-    public function getRemotePostTest()
58
-    {
59
-        if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) {
60
-            $response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/');
61
-            $test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299))
62
-                ? 'Works'
63
-                : 'Does not work';
64
-            set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS);
65
-        }
66
-        return $test;
67
-    }
54
+	/**
55
+	 * @return string
56
+	 */
57
+	public function getRemotePostTest()
58
+	{
59
+		if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) {
60
+			$response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/');
61
+			$test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299))
62
+				? 'Works'
63
+				: 'Does not work';
64
+			set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS);
65
+		}
66
+		return $test;
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function getCloudflareIps()
13 13
     {
14
-        if (false === ($ipAddresses = get_transient(Application::ID.'_cloudflare_ips'))) {
15
-            $ipAddresses = array_fill_keys(['v4', 'v6'], []);
16
-            foreach (array_keys($ipAddresses) as $version) {
14
+        if( false === ($ipAddresses = get_transient( Application::ID.'_cloudflare_ips' )) ) {
15
+            $ipAddresses = array_fill_keys( ['v4', 'v6'], [] );
16
+            foreach( array_keys( $ipAddresses ) as $version ) {
17 17
                 $url = 'https://www.cloudflare.com/ips-'.$version;
18
-                $response = wp_remote_get($url, ['sslverify' => false]);
19
-                if (is_wp_error($response)) {
20
-                    glsr_log()->error($response->get_error_message());
18
+                $response = wp_remote_get( $url, ['sslverify' => false] );
19
+                if( is_wp_error( $response ) ) {
20
+                    glsr_log()->error( $response->get_error_message() );
21 21
                     continue;
22 22
                 }
23
-                if ('200' != ($statusCode = wp_remote_retrieve_response_code($response))) {
24
-                    glsr_log()->error('Unable to connect to '.$url.' ['.$statusCode.']');
23
+                if( '200' != ($statusCode = wp_remote_retrieve_response_code( $response )) ) {
24
+                    glsr_log()->error( 'Unable to connect to '.$url.' ['.$statusCode.']' );
25 25
                     continue;
26 26
                 }
27 27
                 $ipAddresses[$version] = array_filter(
28
-                    (array) preg_split('/\R/', wp_remote_retrieve_body($response))
28
+                    (array)preg_split( '/\R/', wp_remote_retrieve_body( $response ) )
29 29
                 );
30 30
             }
31
-            set_transient(Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS);
31
+            set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, WEEK_IN_SECONDS );
32 32
         }
33 33
         return $ipAddresses;
34 34
     }
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
      * @param string $metaKey
38 38
      * @return array
39 39
      */
40
-    public function getReviewCountsFor($metaKey)
40
+    public function getReviewCountsFor( $metaKey )
41 41
     {
42
-        $counts = wp_cache_get(Application::ID, $metaKey.'_count');
43
-        if (false === $counts) {
42
+        $counts = wp_cache_get( Application::ID, $metaKey.'_count' );
43
+        if( false === $counts ) {
44 44
             $counts = [];
45
-            $results = glsr(SqlQueries::class)->getReviewCountsFor($metaKey);
46
-            foreach ($results as $result) {
45
+            $results = glsr( SqlQueries::class )->getReviewCountsFor( $metaKey );
46
+            foreach( $results as $result ) {
47 47
                 $counts[$result->name] = $result->num_posts;
48 48
             }
49
-            wp_cache_set(Application::ID, $counts, $metaKey.'_count');
49
+            wp_cache_set( Application::ID, $counts, $metaKey.'_count' );
50 50
         }
51 51
         return $counts;
52 52
     }
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function getRemotePostTest()
58 58
     {
59
-        if (false === ($test = get_transient(Application::ID.'_remote_post_test'))) {
60
-            $response = wp_remote_post('https://api.wordpress.org/stats/php/1.0/');
61
-            $test = !is_wp_error($response) && in_array($response['response']['code'], range(200, 299))
59
+        if( false === ($test = get_transient( Application::ID.'_remote_post_test' )) ) {
60
+            $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' );
61
+            $test = !is_wp_error( $response ) && in_array( $response['response']['code'], range( 200, 299 ) )
62 62
                 ? 'Works'
63 63
                 : 'Does not work';
64
-            set_transient(Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS);
64
+            set_transient( Application::ID.'_remote_post_test', $test, WEEK_IN_SECONDS );
65 65
         }
66 66
         return $test;
67 67
     }
Please login to merge, or discard this patch.
plugin/Defaults/CreateReviewDefaults.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,41 +6,41 @@
 block discarded – undo
6 6
 
7 7
 class CreateReviewDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    protected $guarded = [
13
-        'assigned_to',
14
-        'content',
15
-        'date',
16
-        'pinned',
17
-        'response',
18
-        'review_id',
19
-        'review_type',
20
-        'title',
21
-    ];
9
+	/**
10
+	 * @var array
11
+	 */
12
+	protected $guarded = [
13
+		'assigned_to',
14
+		'content',
15
+		'date',
16
+		'pinned',
17
+		'response',
18
+		'review_id',
19
+		'review_type',
20
+		'title',
21
+	];
22 22
 
23
-    /**
24
-     * @return array
25
-     */
26
-    protected function defaults()
27
-    {
28
-        return [
29
-            'assigned_to' => '',
30
-            'author' => '',
31
-            'avatar' => '',
32
-            'content' => '',
33
-            'custom' => '',
34
-            'date' => '',
35
-            'email' => '',
36
-            'ip_address' => '',
37
-            'pinned' => false,
38
-            'rating' => '',
39
-            'response' => '',
40
-            'review_id' => md5(time().mt_rand()),
41
-            'review_type' => 'local',
42
-            'title' => '',
43
-            'url' => '',
44
-        ];
45
-    }
23
+	/**
24
+	 * @return array
25
+	 */
26
+	protected function defaults()
27
+	{
28
+		return [
29
+			'assigned_to' => '',
30
+			'author' => '',
31
+			'avatar' => '',
32
+			'content' => '',
33
+			'custom' => '',
34
+			'date' => '',
35
+			'email' => '',
36
+			'ip_address' => '',
37
+			'pinned' => false,
38
+			'rating' => '',
39
+			'response' => '',
40
+			'review_id' => md5(time().mt_rand()),
41
+			'review_type' => 'local',
42
+			'title' => '',
43
+			'url' => '',
44
+		];
45
+	}
46 46
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
             'pinned' => false,
38 38
             'rating' => '',
39 39
             'response' => '',
40
-            'review_id' => md5(time().mt_rand()),
40
+            'review_id' => md5( time().mt_rand() ),
41 41
             'review_type' => 'local',
42 42
             'title' => '',
43 43
             'url' => '',
Please login to merge, or discard this patch.
plugin/Modules/Validator/ValidateReview.php 2 patches
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -13,285 +13,285 @@
 block discarded – undo
13 13
 
14 14
 class ValidateReview
15 15
 {
16
-    const RECAPTCHA_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify';
16
+	const RECAPTCHA_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify';
17 17
 
18
-    const RECAPTCHA_DISABLED = 0;
19
-    const RECAPTCHA_EMPTY = 1;
20
-    const RECAPTCHA_FAILED = 2;
21
-    const RECAPTCHA_INVALID = 3;
22
-    const RECAPTCHA_VALID = 4;
18
+	const RECAPTCHA_DISABLED = 0;
19
+	const RECAPTCHA_EMPTY = 1;
20
+	const RECAPTCHA_FAILED = 2;
21
+	const RECAPTCHA_INVALID = 3;
22
+	const RECAPTCHA_VALID = 4;
23 23
 
24
-    const VALIDATION_RULES = [
25
-        'content' => 'required',
26
-        'email' => 'required|email',
27
-        'name' => 'required',
28
-        'rating' => 'required|number|between:1,5',
29
-        'terms' => 'accepted',
30
-        'title' => 'required',
31
-    ];
24
+	const VALIDATION_RULES = [
25
+		'content' => 'required',
26
+		'email' => 'required|email',
27
+		'name' => 'required',
28
+		'rating' => 'required|number|between:1,5',
29
+		'terms' => 'accepted',
30
+		'title' => 'required',
31
+	];
32 32
 
33
-    /**
34
-     * @var string|void
35
-     */
36
-    public $error;
33
+	/**
34
+	 * @var string|void
35
+	 */
36
+	public $error;
37 37
 
38
-    /**
39
-     * @var string
40
-     */
41
-    public $form_id;
38
+	/**
39
+	 * @var string
40
+	 */
41
+	public $form_id;
42 42
 
43
-    /**
44
-     * @var bool
45
-     */
46
-    public $recaptchaIsUnset = false;
43
+	/**
44
+	 * @var bool
45
+	 */
46
+	public $recaptchaIsUnset = false;
47 47
 
48
-    /**
49
-     * @var array
50
-     */
51
-    public $request;
48
+	/**
49
+	 * @var array
50
+	 */
51
+	public $request;
52 52
 
53
-    /**
54
-     * @var array
55
-     */
56
-    protected $options;
53
+	/**
54
+	 * @var array
55
+	 */
56
+	protected $options;
57 57
 
58
-    /**
59
-     * @return static
60
-     */
61
-    public function validate(array $request)
62
-    {
63
-        $request['ip_address'] = Helper::getIpAddress(); // required for Akismet and Blacklist validation
64
-        $this->form_id = $request['form_id'];
65
-        $this->options = glsr(OptionManager::class)->all();
66
-        $this->request = $this->validateRequest($request);
67
-        $this->validateCustom();
68
-        $this->validateHoneyPot();
69
-        $this->validateReviewLimits();
70
-        $this->validateBlacklist();
71
-        $this->validateAkismet();
72
-        $this->validateRecaptcha();
73
-        if (!empty($this->error)) {
74
-            $this->setSessionValues('message', $this->error);
75
-        }
76
-        return $this;
77
-    }
58
+	/**
59
+	 * @return static
60
+	 */
61
+	public function validate(array $request)
62
+	{
63
+		$request['ip_address'] = Helper::getIpAddress(); // required for Akismet and Blacklist validation
64
+		$this->form_id = $request['form_id'];
65
+		$this->options = glsr(OptionManager::class)->all();
66
+		$this->request = $this->validateRequest($request);
67
+		$this->validateCustom();
68
+		$this->validateHoneyPot();
69
+		$this->validateReviewLimits();
70
+		$this->validateBlacklist();
71
+		$this->validateAkismet();
72
+		$this->validateRecaptcha();
73
+		if (!empty($this->error)) {
74
+			$this->setSessionValues('message', $this->error);
75
+		}
76
+		return $this;
77
+	}
78 78
 
79
-    /**
80
-     * @param string $path
81
-     * @param mixed $fallback
82
-     * @return mixed
83
-     */
84
-    protected function getOption($path, $fallback = '')
85
-    {
86
-        return Arr::get($this->options, $path, $fallback);
87
-    }
79
+	/**
80
+	 * @param string $path
81
+	 * @param mixed $fallback
82
+	 * @return mixed
83
+	 */
84
+	protected function getOption($path, $fallback = '')
85
+	{
86
+		return Arr::get($this->options, $path, $fallback);
87
+	}
88 88
 
89
-    /**
90
-     * @return int
91
-     */
92
-    protected function getRecaptchaStatus()
93
-    {
94
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
95
-            return static::RECAPTCHA_DISABLED;
96
-        }
97
-        if (empty($this->request['_recaptcha-token'])) {
98
-            return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
99
-                ? static::RECAPTCHA_EMPTY
100
-                : static::RECAPTCHA_FAILED;
101
-        }
102
-        return $this->getRecaptchaTokenStatus();
103
-    }
89
+	/**
90
+	 * @return int
91
+	 */
92
+	protected function getRecaptchaStatus()
93
+	{
94
+		if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
95
+			return static::RECAPTCHA_DISABLED;
96
+		}
97
+		if (empty($this->request['_recaptcha-token'])) {
98
+			return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
99
+				? static::RECAPTCHA_EMPTY
100
+				: static::RECAPTCHA_FAILED;
101
+		}
102
+		return $this->getRecaptchaTokenStatus();
103
+	}
104 104
 
105
-    /**
106
-     * @return int
107
-     */
108
-    protected function getRecaptchaTokenStatus()
109
-    {
110
-        $endpoint = add_query_arg([
111
-            'remoteip' => Helper::getIpAddress(),
112
-            'response' => $this->request['_recaptcha-token'],
113
-            'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
114
-        ], static::RECAPTCHA_ENDPOINT);
115
-        if (is_wp_error($response = wp_remote_get($endpoint))) {
116
-            glsr_log()->error($response->get_error_message());
117
-            return static::RECAPTCHA_FAILED;
118
-        }
119
-        $response = json_decode(wp_remote_retrieve_body($response));
120
-        if (!empty($response->success)) {
121
-            return boolval($response->success)
122
-                ? static::RECAPTCHA_VALID
123
-                : static::RECAPTCHA_INVALID;
124
-        }
125
-        foreach ($response->{'error-codes'} as $error) {
126
-            glsr_log()->error('reCAPTCHA error: '.$error);
127
-        }
128
-        return static::RECAPTCHA_INVALID;
129
-    }
105
+	/**
106
+	 * @return int
107
+	 */
108
+	protected function getRecaptchaTokenStatus()
109
+	{
110
+		$endpoint = add_query_arg([
111
+			'remoteip' => Helper::getIpAddress(),
112
+			'response' => $this->request['_recaptcha-token'],
113
+			'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
114
+		], static::RECAPTCHA_ENDPOINT);
115
+		if (is_wp_error($response = wp_remote_get($endpoint))) {
116
+			glsr_log()->error($response->get_error_message());
117
+			return static::RECAPTCHA_FAILED;
118
+		}
119
+		$response = json_decode(wp_remote_retrieve_body($response));
120
+		if (!empty($response->success)) {
121
+			return boolval($response->success)
122
+				? static::RECAPTCHA_VALID
123
+				: static::RECAPTCHA_INVALID;
124
+		}
125
+		foreach ($response->{'error-codes'} as $error) {
126
+			glsr_log()->error('reCAPTCHA error: '.$error);
127
+		}
128
+		return static::RECAPTCHA_INVALID;
129
+	}
130 130
 
131
-    /**
132
-     * @return array
133
-     */
134
-    protected function getValidationRules(array $request)
135
-    {
136
-        $rules = array_intersect_key(
137
-            apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
138
-            array_flip($this->getOption('settings.submissions.required', []))
139
-        );
140
-        $excluded = explode(',', Arr::get($request, 'excluded'));
141
-        return array_diff_key($rules, array_flip($excluded));
142
-    }
131
+	/**
132
+	 * @return array
133
+	 */
134
+	protected function getValidationRules(array $request)
135
+	{
136
+		$rules = array_intersect_key(
137
+			apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
138
+			array_flip($this->getOption('settings.submissions.required', []))
139
+		);
140
+		$excluded = explode(',', Arr::get($request, 'excluded'));
141
+		return array_diff_key($rules, array_flip($excluded));
142
+	}
143 143
 
144
-    /**
145
-     * @return bool
146
-     */
147
-    protected function isRequestValid(array $request)
148
-    {
149
-        $rules = $this->getValidationRules($request);
150
-        $errors = glsr(Validator::class)->validate($request, $rules);
151
-        if (empty($errors)) {
152
-            return true;
153
-        }
154
-        $this->error = __('Please fix the submission errors.', 'site-reviews');
155
-        $this->setSessionValues('errors', $errors);
156
-        $this->setSessionValues('values', $request);
157
-        return false;
158
-    }
144
+	/**
145
+	 * @return bool
146
+	 */
147
+	protected function isRequestValid(array $request)
148
+	{
149
+		$rules = $this->getValidationRules($request);
150
+		$errors = glsr(Validator::class)->validate($request, $rules);
151
+		if (empty($errors)) {
152
+			return true;
153
+		}
154
+		$this->error = __('Please fix the submission errors.', 'site-reviews');
155
+		$this->setSessionValues('errors', $errors);
156
+		$this->setSessionValues('values', $request);
157
+		return false;
158
+	}
159 159
 
160
-    protected function setError($message, $loggedMessage = '')
161
-    {
162
-        $this->setSessionValues('errors', [], $loggedMessage);
163
-        $this->error = $message;
164
-    }
160
+	protected function setError($message, $loggedMessage = '')
161
+	{
162
+		$this->setSessionValues('errors', [], $loggedMessage);
163
+		$this->error = $message;
164
+	}
165 165
 
166
-    /**
167
-     * @param string $type
168
-     * @param mixed $value
169
-     * @param string $loggedMessage
170
-     * @return void
171
-     */
172
-    protected function setSessionValues($type, $value, $loggedMessage = '')
173
-    {
174
-        glsr()->sessionSet($this->form_id.$type, $value);
175
-        if (!empty($loggedMessage)) {
176
-            glsr_log()->warning($loggedMessage)->debug($this->request);
177
-        }
178
-    }
166
+	/**
167
+	 * @param string $type
168
+	 * @param mixed $value
169
+	 * @param string $loggedMessage
170
+	 * @return void
171
+	 */
172
+	protected function setSessionValues($type, $value, $loggedMessage = '')
173
+	{
174
+		glsr()->sessionSet($this->form_id.$type, $value);
175
+		if (!empty($loggedMessage)) {
176
+			glsr_log()->warning($loggedMessage)->debug($this->request);
177
+		}
178
+	}
179 179
 
180
-    /**
181
-     * @return void
182
-     */
183
-    protected function validateAkismet()
184
-    {
185
-        if (!empty($this->error)) {
186
-            return;
187
-        }
188
-        if (glsr(Akismet::class)->isSpam($this->request)) {
189
-            $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
190
-                'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
191
-            );
192
-        }
193
-    }
180
+	/**
181
+	 * @return void
182
+	 */
183
+	protected function validateAkismet()
184
+	{
185
+		if (!empty($this->error)) {
186
+			return;
187
+		}
188
+		if (glsr(Akismet::class)->isSpam($this->request)) {
189
+			$this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
190
+				'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
191
+			);
192
+		}
193
+	}
194 194
 
195
-    /**
196
-     * @return void
197
-     */
198
-    protected function validateBlacklist()
199
-    {
200
-        if (!empty($this->error)) {
201
-            return;
202
-        }
203
-        if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
204
-            return;
205
-        }
206
-        $blacklistAction = $this->getOption('settings.submissions.blacklist.action');
207
-        if ('reject' != $blacklistAction) {
208
-            $this->request['blacklisted'] = true;
209
-            return;
210
-        }
211
-        $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
212
-            'Blacklisted submission detected:'
213
-        );
214
-    }
195
+	/**
196
+	 * @return void
197
+	 */
198
+	protected function validateBlacklist()
199
+	{
200
+		if (!empty($this->error)) {
201
+			return;
202
+		}
203
+		if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
204
+			return;
205
+		}
206
+		$blacklistAction = $this->getOption('settings.submissions.blacklist.action');
207
+		if ('reject' != $blacklistAction) {
208
+			$this->request['blacklisted'] = true;
209
+			return;
210
+		}
211
+		$this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
212
+			'Blacklisted submission detected:'
213
+		);
214
+	}
215 215
 
216
-    /**
217
-     * @return void
218
-     */
219
-    protected function validateCustom()
220
-    {
221
-        if (!empty($this->error)) {
222
-            return;
223
-        }
224
-        $validated = apply_filters('site-reviews/validate/custom', true, $this->request);
225
-        if (true === $validated) {
226
-            return;
227
-        }
228
-        $errorMessage = is_string($validated)
229
-            ? $validated
230
-            : __('The review submission failed. Please notify the site administrator.', 'site-reviews');
231
-        $this->setError($errorMessage);
232
-        $this->setSessionValues('values', $this->request);
233
-    }
216
+	/**
217
+	 * @return void
218
+	 */
219
+	protected function validateCustom()
220
+	{
221
+		if (!empty($this->error)) {
222
+			return;
223
+		}
224
+		$validated = apply_filters('site-reviews/validate/custom', true, $this->request);
225
+		if (true === $validated) {
226
+			return;
227
+		}
228
+		$errorMessage = is_string($validated)
229
+			? $validated
230
+			: __('The review submission failed. Please notify the site administrator.', 'site-reviews');
231
+		$this->setError($errorMessage);
232
+		$this->setSessionValues('values', $this->request);
233
+	}
234 234
 
235
-    /**
236
-     * @return void
237
-     */
238
-    protected function validateHoneyPot()
239
-    {
240
-        if (!empty($this->error)) {
241
-            return;
242
-        }
243
-        if (!empty($this->request['gotcha'])) {
244
-            $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
245
-                'The Honeypot caught a bad submission:'
246
-            );
247
-        }
248
-    }
235
+	/**
236
+	 * @return void
237
+	 */
238
+	protected function validateHoneyPot()
239
+	{
240
+		if (!empty($this->error)) {
241
+			return;
242
+		}
243
+		if (!empty($this->request['gotcha'])) {
244
+			$this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
245
+				'The Honeypot caught a bad submission:'
246
+			);
247
+		}
248
+	}
249 249
 
250
-    /**
251
-     * @return void
252
-     */
253
-    protected function validateReviewLimits()
254
-    {
255
-        if (!empty($this->error)) {
256
-            return;
257
-        }
258
-        if (glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
259
-            $this->setError(__('You have already submitted a review.', 'site-reviews'));
260
-        }
261
-    }
250
+	/**
251
+	 * @return void
252
+	 */
253
+	protected function validateReviewLimits()
254
+	{
255
+		if (!empty($this->error)) {
256
+			return;
257
+		}
258
+		if (glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
259
+			$this->setError(__('You have already submitted a review.', 'site-reviews'));
260
+		}
261
+	}
262 262
 
263
-    /**
264
-     * @return void
265
-     */
266
-    protected function validateRecaptcha()
267
-    {
268
-        if (!empty($this->error)) {
269
-            return;
270
-        }
271
-        $status = $this->getRecaptchaStatus();
272
-        if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) {
273
-            return;
274
-        }
275
-        if (static::RECAPTCHA_EMPTY === $status) {
276
-            $this->setSessionValues('recaptcha', 'unset');
277
-            $this->recaptchaIsUnset = true;
278
-            return;
279
-        }
280
-        $this->setSessionValues('recaptcha', 'reset');
281
-        $errors = [
282
-            static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'),
283
-            static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'),
284
-        ];
285
-        $this->setError($errors[$status]);
286
-    }
263
+	/**
264
+	 * @return void
265
+	 */
266
+	protected function validateRecaptcha()
267
+	{
268
+		if (!empty($this->error)) {
269
+			return;
270
+		}
271
+		$status = $this->getRecaptchaStatus();
272
+		if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) {
273
+			return;
274
+		}
275
+		if (static::RECAPTCHA_EMPTY === $status) {
276
+			$this->setSessionValues('recaptcha', 'unset');
277
+			$this->recaptchaIsUnset = true;
278
+			return;
279
+		}
280
+		$this->setSessionValues('recaptcha', 'reset');
281
+		$errors = [
282
+			static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'),
283
+			static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'),
284
+		];
285
+		$this->setError($errors[$status]);
286
+	}
287 287
 
288
-    /**
289
-     * @return array
290
-     */
291
-    protected function validateRequest(array $request)
292
-    {
293
-        return $this->isRequestValid($request)
294
-            ? array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request)
295
-            : $request;
296
-    }
288
+	/**
289
+	 * @return array
290
+	 */
291
+	protected function validateRequest(array $request)
292
+	{
293
+		return $this->isRequestValid($request)
294
+			? array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request)
295
+			: $request;
296
+	}
297 297
 }
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -58,20 +58,20 @@  discard block
 block discarded – undo
58 58
     /**
59 59
      * @return static
60 60
      */
61
-    public function validate(array $request)
61
+    public function validate( array $request )
62 62
     {
63 63
         $request['ip_address'] = Helper::getIpAddress(); // required for Akismet and Blacklist validation
64 64
         $this->form_id = $request['form_id'];
65
-        $this->options = glsr(OptionManager::class)->all();
66
-        $this->request = $this->validateRequest($request);
65
+        $this->options = glsr( OptionManager::class )->all();
66
+        $this->request = $this->validateRequest( $request );
67 67
         $this->validateCustom();
68 68
         $this->validateHoneyPot();
69 69
         $this->validateReviewLimits();
70 70
         $this->validateBlacklist();
71 71
         $this->validateAkismet();
72 72
         $this->validateRecaptcha();
73
-        if (!empty($this->error)) {
74
-            $this->setSessionValues('message', $this->error);
73
+        if( !empty($this->error) ) {
74
+            $this->setSessionValues( 'message', $this->error );
75 75
         }
76 76
         return $this;
77 77
     }
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
      * @param mixed $fallback
82 82
      * @return mixed
83 83
      */
84
-    protected function getOption($path, $fallback = '')
84
+    protected function getOption( $path, $fallback = '' )
85 85
     {
86
-        return Arr::get($this->options, $path, $fallback);
86
+        return Arr::get( $this->options, $path, $fallback );
87 87
     }
88 88
 
89 89
     /**
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function getRecaptchaStatus()
93 93
     {
94
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
94
+        if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
95 95
             return static::RECAPTCHA_DISABLED;
96 96
         }
97
-        if (empty($this->request['_recaptcha-token'])) {
98
-            return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
97
+        if( empty($this->request['_recaptcha-token']) ) {
98
+            return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) )
99 99
                 ? static::RECAPTCHA_EMPTY
100 100
                 : static::RECAPTCHA_FAILED;
101 101
         }
@@ -107,23 +107,23 @@  discard block
 block discarded – undo
107 107
      */
108 108
     protected function getRecaptchaTokenStatus()
109 109
     {
110
-        $endpoint = add_query_arg([
110
+        $endpoint = add_query_arg( [
111 111
             'remoteip' => Helper::getIpAddress(),
112 112
             'response' => $this->request['_recaptcha-token'],
113
-            'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
114
-        ], static::RECAPTCHA_ENDPOINT);
115
-        if (is_wp_error($response = wp_remote_get($endpoint))) {
116
-            glsr_log()->error($response->get_error_message());
113
+            'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ),
114
+        ], static::RECAPTCHA_ENDPOINT );
115
+        if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) {
116
+            glsr_log()->error( $response->get_error_message() );
117 117
             return static::RECAPTCHA_FAILED;
118 118
         }
119
-        $response = json_decode(wp_remote_retrieve_body($response));
120
-        if (!empty($response->success)) {
121
-            return boolval($response->success)
119
+        $response = json_decode( wp_remote_retrieve_body( $response ) );
120
+        if( !empty($response->success) ) {
121
+            return boolval( $response->success )
122 122
                 ? static::RECAPTCHA_VALID
123 123
                 : static::RECAPTCHA_INVALID;
124 124
         }
125
-        foreach ($response->{'error-codes'} as $error) {
126
-            glsr_log()->error('reCAPTCHA error: '.$error);
125
+        foreach( $response->{'error-codes'} as $error ) {
126
+            glsr_log()->error( 'reCAPTCHA error: '.$error );
127 127
         }
128 128
         return static::RECAPTCHA_INVALID;
129 129
     }
@@ -131,35 +131,35 @@  discard block
 block discarded – undo
131 131
     /**
132 132
      * @return array
133 133
      */
134
-    protected function getValidationRules(array $request)
134
+    protected function getValidationRules( array $request )
135 135
     {
136 136
         $rules = array_intersect_key(
137
-            apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
138
-            array_flip($this->getOption('settings.submissions.required', []))
137
+            apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ),
138
+            array_flip( $this->getOption( 'settings.submissions.required', [] ) )
139 139
         );
140
-        $excluded = explode(',', Arr::get($request, 'excluded'));
141
-        return array_diff_key($rules, array_flip($excluded));
140
+        $excluded = explode( ',', Arr::get( $request, 'excluded' ) );
141
+        return array_diff_key( $rules, array_flip( $excluded ) );
142 142
     }
143 143
 
144 144
     /**
145 145
      * @return bool
146 146
      */
147
-    protected function isRequestValid(array $request)
147
+    protected function isRequestValid( array $request )
148 148
     {
149
-        $rules = $this->getValidationRules($request);
150
-        $errors = glsr(Validator::class)->validate($request, $rules);
151
-        if (empty($errors)) {
149
+        $rules = $this->getValidationRules( $request );
150
+        $errors = glsr( Validator::class )->validate( $request, $rules );
151
+        if( empty($errors) ) {
152 152
             return true;
153 153
         }
154
-        $this->error = __('Please fix the submission errors.', 'site-reviews');
155
-        $this->setSessionValues('errors', $errors);
156
-        $this->setSessionValues('values', $request);
154
+        $this->error = __( 'Please fix the submission errors.', 'site-reviews' );
155
+        $this->setSessionValues( 'errors', $errors );
156
+        $this->setSessionValues( 'values', $request );
157 157
         return false;
158 158
     }
159 159
 
160
-    protected function setError($message, $loggedMessage = '')
160
+    protected function setError( $message, $loggedMessage = '' )
161 161
     {
162
-        $this->setSessionValues('errors', [], $loggedMessage);
162
+        $this->setSessionValues( 'errors', [], $loggedMessage );
163 163
         $this->error = $message;
164 164
     }
165 165
 
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
      * @param string $loggedMessage
170 170
      * @return void
171 171
      */
172
-    protected function setSessionValues($type, $value, $loggedMessage = '')
172
+    protected function setSessionValues( $type, $value, $loggedMessage = '' )
173 173
     {
174
-        glsr()->sessionSet($this->form_id.$type, $value);
175
-        if (!empty($loggedMessage)) {
176
-            glsr_log()->warning($loggedMessage)->debug($this->request);
174
+        glsr()->sessionSet( $this->form_id.$type, $value );
175
+        if( !empty($loggedMessage) ) {
176
+            glsr_log()->warning( $loggedMessage )->debug( $this->request );
177 177
         }
178 178
     }
179 179
 
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
      */
183 183
     protected function validateAkismet()
184 184
     {
185
-        if (!empty($this->error)) {
185
+        if( !empty($this->error) ) {
186 186
             return;
187 187
         }
188
-        if (glsr(Akismet::class)->isSpam($this->request)) {
189
-            $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
188
+        if( glsr( Akismet::class )->isSpam( $this->request ) ) {
189
+            $this->setError( __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ),
190 190
                 'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
191 191
             );
192 192
         }
@@ -197,18 +197,18 @@  discard block
 block discarded – undo
197 197
      */
198 198
     protected function validateBlacklist()
199 199
     {
200
-        if (!empty($this->error)) {
200
+        if( !empty($this->error) ) {
201 201
             return;
202 202
         }
203
-        if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
203
+        if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) ) {
204 204
             return;
205 205
         }
206
-        $blacklistAction = $this->getOption('settings.submissions.blacklist.action');
207
-        if ('reject' != $blacklistAction) {
206
+        $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
207
+        if( 'reject' != $blacklistAction ) {
208 208
             $this->request['blacklisted'] = true;
209 209
             return;
210 210
         }
211
-        $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
211
+        $this->setError( __( 'Your review cannot be submitted at this time.', 'site-reviews' ),
212 212
             'Blacklisted submission detected:'
213 213
         );
214 214
     }
@@ -218,18 +218,18 @@  discard block
 block discarded – undo
218 218
      */
219 219
     protected function validateCustom()
220 220
     {
221
-        if (!empty($this->error)) {
221
+        if( !empty($this->error) ) {
222 222
             return;
223 223
         }
224
-        $validated = apply_filters('site-reviews/validate/custom', true, $this->request);
225
-        if (true === $validated) {
224
+        $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request );
225
+        if( true === $validated ) {
226 226
             return;
227 227
         }
228
-        $errorMessage = is_string($validated)
228
+        $errorMessage = is_string( $validated )
229 229
             ? $validated
230
-            : __('The review submission failed. Please notify the site administrator.', 'site-reviews');
231
-        $this->setError($errorMessage);
232
-        $this->setSessionValues('values', $this->request);
230
+            : __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
231
+        $this->setError( $errorMessage );
232
+        $this->setSessionValues( 'values', $this->request );
233 233
     }
234 234
 
235 235
     /**
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
      */
238 238
     protected function validateHoneyPot()
239 239
     {
240
-        if (!empty($this->error)) {
240
+        if( !empty($this->error) ) {
241 241
             return;
242 242
         }
243
-        if (!empty($this->request['gotcha'])) {
244
-            $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
243
+        if( !empty($this->request['gotcha']) ) {
244
+            $this->setError( __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ),
245 245
                 'The Honeypot caught a bad submission:'
246 246
             );
247 247
         }
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
      */
253 253
     protected function validateReviewLimits()
254 254
     {
255
-        if (!empty($this->error)) {
255
+        if( !empty($this->error) ) {
256 256
             return;
257 257
         }
258
-        if (glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
259
-            $this->setError(__('You have already submitted a review.', 'site-reviews'));
258
+        if( glsr( ReviewLimits::class )->hasReachedLimit( $this->request ) ) {
259
+            $this->setError( __( 'You have already submitted a review.', 'site-reviews' ) );
260 260
         }
261 261
     }
262 262
 
@@ -265,33 +265,33 @@  discard block
 block discarded – undo
265 265
      */
266 266
     protected function validateRecaptcha()
267 267
     {
268
-        if (!empty($this->error)) {
268
+        if( !empty($this->error) ) {
269 269
             return;
270 270
         }
271 271
         $status = $this->getRecaptchaStatus();
272
-        if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) {
272
+        if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) ) {
273 273
             return;
274 274
         }
275
-        if (static::RECAPTCHA_EMPTY === $status) {
276
-            $this->setSessionValues('recaptcha', 'unset');
275
+        if( static::RECAPTCHA_EMPTY === $status ) {
276
+            $this->setSessionValues( 'recaptcha', 'unset' );
277 277
             $this->recaptchaIsUnset = true;
278 278
             return;
279 279
         }
280
-        $this->setSessionValues('recaptcha', 'reset');
280
+        $this->setSessionValues( 'recaptcha', 'reset' );
281 281
         $errors = [
282
-            static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'),
283
-            static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'),
282
+            static::RECAPTCHA_FAILED => __( 'The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews' ),
283
+            static::RECAPTCHA_INVALID => __( 'The reCAPTCHA verification failed, please try again.', 'site-reviews' ),
284 284
         ];
285
-        $this->setError($errors[$status]);
285
+        $this->setError( $errors[$status] );
286 286
     }
287 287
 
288 288
     /**
289 289
      * @return array
290 290
      */
291
-    protected function validateRequest(array $request)
291
+    protected function validateRequest( array $request )
292 292
     {
293
-        return $this->isRequestValid($request)
294
-            ? array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request)
293
+        return $this->isRequestValid( $request )
294
+            ? array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request )
295 295
             : $request;
296 296
     }
297 297
 }
Please login to merge, or discard this patch.
plugin/Modules/System.php 2 patches
Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -12,377 +12,377 @@
 block discarded – undo
12 12
 
13 13
 class System
14 14
 {
15
-    const PAD = 40;
15
+	const PAD = 40;
16 16
 
17
-    /**
18
-     * @return string
19
-     */
20
-    public function __toString()
21
-    {
22
-        return $this->get();
23
-    }
17
+	/**
18
+	 * @return string
19
+	 */
20
+	public function __toString()
21
+	{
22
+		return $this->get();
23
+	}
24 24
 
25
-    /**
26
-     * @return string
27
-     */
28
-    public function get()
29
-    {
30
-        $details = [
31
-            'plugin' => 'Plugin Details',
32
-            'addon' => 'Addon Details',
33
-            'browser' => 'Browser Details',
34
-            'server' => 'Server Details',
35
-            'php' => 'PHP Configuration',
36
-            'wordpress' => 'WordPress Configuration',
37
-            'mu-plugin' => 'Must-Use Plugins',
38
-            'multisite-plugin' => 'Network Active Plugins',
39
-            'active-plugin' => 'Active Plugins',
40
-            'inactive-plugin' => 'Inactive Plugins',
41
-            'setting' => 'Plugin Settings',
42
-            'reviews' => 'Review Counts',
43
-        ];
44
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
45
-            $methodName = Helper::buildMethodName('get-'.$key.'-details');
46
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
47
-                return $carry.$this->implode(
48
-                    strtoupper($details[$key]),
49
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
50
-                );
51
-            }
52
-            return $carry;
53
-        });
54
-        return trim($systemInfo);
55
-    }
25
+	/**
26
+	 * @return string
27
+	 */
28
+	public function get()
29
+	{
30
+		$details = [
31
+			'plugin' => 'Plugin Details',
32
+			'addon' => 'Addon Details',
33
+			'browser' => 'Browser Details',
34
+			'server' => 'Server Details',
35
+			'php' => 'PHP Configuration',
36
+			'wordpress' => 'WordPress Configuration',
37
+			'mu-plugin' => 'Must-Use Plugins',
38
+			'multisite-plugin' => 'Network Active Plugins',
39
+			'active-plugin' => 'Active Plugins',
40
+			'inactive-plugin' => 'Inactive Plugins',
41
+			'setting' => 'Plugin Settings',
42
+			'reviews' => 'Review Counts',
43
+		];
44
+		$systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
45
+			$methodName = Helper::buildMethodName('get-'.$key.'-details');
46
+			if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
47
+				return $carry.$this->implode(
48
+					strtoupper($details[$key]),
49
+					apply_filters('site-reviews/system/'.$key, $systemDetails)
50
+				);
51
+			}
52
+			return $carry;
53
+		});
54
+		return trim($systemInfo);
55
+	}
56 56
 
57
-    /**
58
-     * @return array
59
-     */
60
-    public function getActivePluginDetails()
61
-    {
62
-        $plugins = get_plugins();
63
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
64
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
65
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
66
-    }
57
+	/**
58
+	 * @return array
59
+	 */
60
+	public function getActivePluginDetails()
61
+	{
62
+		$plugins = get_plugins();
63
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
64
+		$inactive = array_diff_key($plugins, array_flip($activePlugins));
65
+		return $this->normalizePluginList(array_diff_key($plugins, $inactive));
66
+	}
67 67
 
68
-    /**
69
-     * @return array
70
-     */
71
-    public function getAddonDetails()
72
-    {
73
-        $details = apply_filters('site-reviews/addon/system-info', []);
74
-        ksort($details);
75
-        return $details;
76
-    }
68
+	/**
69
+	 * @return array
70
+	 */
71
+	public function getAddonDetails()
72
+	{
73
+		$details = apply_filters('site-reviews/addon/system-info', []);
74
+		ksort($details);
75
+		return $details;
76
+	}
77 77
 
78
-    /**
79
-     * @return array
80
-     */
81
-    public function getBrowserDetails()
82
-    {
83
-        $browser = new Browser();
84
-        $name = esc_attr($browser->getName());
85
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
86
-        $version = esc_attr($browser->getVersion());
87
-        return [
88
-            'Browser Name' => sprintf('%s %s', $name, $version),
89
-            'Browser UA' => $userAgent,
90
-        ];
91
-    }
78
+	/**
79
+	 * @return array
80
+	 */
81
+	public function getBrowserDetails()
82
+	{
83
+		$browser = new Browser();
84
+		$name = esc_attr($browser->getName());
85
+		$userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
86
+		$version = esc_attr($browser->getVersion());
87
+		return [
88
+			'Browser Name' => sprintf('%s %s', $name, $version),
89
+			'Browser UA' => $userAgent,
90
+		];
91
+	}
92 92
 
93
-    /**
94
-     * @return array
95
-     */
96
-    public function getInactivePluginDetails()
97
-    {
98
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
99
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
100
-        $multisitePlugins = $this->getMultisitePluginDetails();
101
-        return empty($multisitePlugins)
102
-            ? $inactivePlugins
103
-            : array_diff($inactivePlugins, $multisitePlugins);
104
-    }
93
+	/**
94
+	 * @return array
95
+	 */
96
+	public function getInactivePluginDetails()
97
+	{
98
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
99
+		$inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
100
+		$multisitePlugins = $this->getMultisitePluginDetails();
101
+		return empty($multisitePlugins)
102
+			? $inactivePlugins
103
+			: array_diff($inactivePlugins, $multisitePlugins);
104
+	}
105 105
 
106
-    /**
107
-     * @return array
108
-     */
109
-    public function getMuPluginDetails()
110
-    {
111
-        if (empty($plugins = get_mu_plugins())) {
112
-            return [];
113
-        }
114
-        return $this->normalizePluginList($plugins);
115
-    }
106
+	/**
107
+	 * @return array
108
+	 */
109
+	public function getMuPluginDetails()
110
+	{
111
+		if (empty($plugins = get_mu_plugins())) {
112
+			return [];
113
+		}
114
+		return $this->normalizePluginList($plugins);
115
+	}
116 116
 
117
-    /**
118
-     * @return array
119
-     */
120
-    public function getMultisitePluginDetails()
121
-    {
122
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
123
-        if (!is_multisite() || empty($activePlugins)) {
124
-            return [];
125
-        }
126
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
127
-    }
117
+	/**
118
+	 * @return array
119
+	 */
120
+	public function getMultisitePluginDetails()
121
+	{
122
+		$activePlugins = (array) get_site_option('active_sitewide_plugins', []);
123
+		if (!is_multisite() || empty($activePlugins)) {
124
+			return [];
125
+		}
126
+		return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
127
+	}
128 128
 
129
-    /**
130
-     * @return array
131
-     */
132
-    public function getPhpDetails()
133
-    {
134
-        $displayErrors = $this->getINI('display_errors', null)
135
-            ? 'On ('.$this->getINI('display_errors').')'
136
-            : 'N/A';
137
-        $intlSupport = extension_loaded('intl')
138
-            ? phpversion('intl')
139
-            : 'false';
140
-        return [
141
-            'cURL' => var_export(function_exists('curl_init'), true),
142
-            'Default Charset' => $this->getINI('default_charset'),
143
-            'Display Errors' => $displayErrors,
144
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
145
-            'Intl' => $intlSupport,
146
-            'IPv6' => var_export(defined('AF_INET6'), true),
147
-            'Max Execution Time' => $this->getINI('max_execution_time'),
148
-            'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'),
149
-            'Max Input Vars' => $this->getINI('max_input_vars'),
150
-            'Memory Limit' => $this->getINI('memory_limit'),
151
-            'Post Max Size' => $this->getINI('post_max_size'),
152
-            'Sendmail Path' => $this->getINI('sendmail_path'),
153
-            'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')),
154
-            'Session Name' => esc_html($this->getINI('session.name')),
155
-            'Session Save Path' => esc_html($this->getINI('session.save_path')),
156
-            'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true),
157
-            'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true),
158
-            'Upload Max Filesize' => $this->getINI('upload_max_filesize'),
159
-        ];
160
-    }
129
+	/**
130
+	 * @return array
131
+	 */
132
+	public function getPhpDetails()
133
+	{
134
+		$displayErrors = $this->getINI('display_errors', null)
135
+			? 'On ('.$this->getINI('display_errors').')'
136
+			: 'N/A';
137
+		$intlSupport = extension_loaded('intl')
138
+			? phpversion('intl')
139
+			: 'false';
140
+		return [
141
+			'cURL' => var_export(function_exists('curl_init'), true),
142
+			'Default Charset' => $this->getINI('default_charset'),
143
+			'Display Errors' => $displayErrors,
144
+			'fsockopen' => var_export(function_exists('fsockopen'), true),
145
+			'Intl' => $intlSupport,
146
+			'IPv6' => var_export(defined('AF_INET6'), true),
147
+			'Max Execution Time' => $this->getINI('max_execution_time'),
148
+			'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'),
149
+			'Max Input Vars' => $this->getINI('max_input_vars'),
150
+			'Memory Limit' => $this->getINI('memory_limit'),
151
+			'Post Max Size' => $this->getINI('post_max_size'),
152
+			'Sendmail Path' => $this->getINI('sendmail_path'),
153
+			'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')),
154
+			'Session Name' => esc_html($this->getINI('session.name')),
155
+			'Session Save Path' => esc_html($this->getINI('session.save_path')),
156
+			'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true),
157
+			'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true),
158
+			'Upload Max Filesize' => $this->getINI('upload_max_filesize'),
159
+		];
160
+	}
161 161
 
162
-    /**
163
-     * @return array
164
-     */
165
-    public function getReviewsDetails()
166
-    {
167
-        $counts = glsr(CountsManager::class)->getCounts();
168
-        $counts = Arr::flattenArray($counts);
169
-        array_walk($counts, function (&$ratings) use ($counts) {
170
-            if (!is_array($ratings)) {
171
-                glsr_log()
172
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
173
-                    ->debug($ratings)
174
-                    ->debug($counts);
175
-                return;
176
-            }
177
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
178
-        });
179
-        ksort($counts);
180
-        return $counts;
181
-    }
162
+	/**
163
+	 * @return array
164
+	 */
165
+	public function getReviewsDetails()
166
+	{
167
+		$counts = glsr(CountsManager::class)->getCounts();
168
+		$counts = Arr::flattenArray($counts);
169
+		array_walk($counts, function (&$ratings) use ($counts) {
170
+			if (!is_array($ratings)) {
171
+				glsr_log()
172
+					->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
173
+					->debug($ratings)
174
+					->debug($counts);
175
+				return;
176
+			}
177
+			$ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
178
+		});
179
+		ksort($counts);
180
+		return $counts;
181
+	}
182 182
 
183
-    /**
184
-     * @return array
185
-     */
186
-    public function getServerDetails()
187
-    {
188
-        global $wpdb;
189
-        return [
190
-            'Host Name' => $this->getHostName(),
191
-            'MySQL Version' => $wpdb->db_version(),
192
-            'PHP Version' => PHP_VERSION,
193
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
194
-        ];
195
-    }
183
+	/**
184
+	 * @return array
185
+	 */
186
+	public function getServerDetails()
187
+	{
188
+		global $wpdb;
189
+		return [
190
+			'Host Name' => $this->getHostName(),
191
+			'MySQL Version' => $wpdb->db_version(),
192
+			'PHP Version' => PHP_VERSION,
193
+			'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
194
+		];
195
+	}
196 196
 
197
-    /**
198
-     * @return array
199
-     */
200
-    public function getSettingDetails()
201
-    {
202
-        $settings = glsr(OptionManager::class)->get('settings', []);
203
-        $settings = Arr::flattenArray($settings, true);
204
-        $settings = $this->purgeSensitiveData($settings);
205
-        ksort($settings);
206
-        $details = [];
207
-        foreach ($settings as $key => $value) {
208
-            if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) {
209
-                continue;
210
-            }
211
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
212
-            $details[$key] = $value;
213
-        }
214
-        return $details;
215
-    }
197
+	/**
198
+	 * @return array
199
+	 */
200
+	public function getSettingDetails()
201
+	{
202
+		$settings = glsr(OptionManager::class)->get('settings', []);
203
+		$settings = Arr::flattenArray($settings, true);
204
+		$settings = $this->purgeSensitiveData($settings);
205
+		ksort($settings);
206
+		$details = [];
207
+		foreach ($settings as $key => $value) {
208
+			if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) {
209
+				continue;
210
+			}
211
+			$value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
212
+			$details[$key] = $value;
213
+		}
214
+		return $details;
215
+	}
216 216
 
217
-    /**
218
-     * @return array
219
-     */
220
-    public function getPluginDetails()
221
-    {
222
-        return [
223
-            'Console level' => glsr(Console::class)->humanLevel(),
224
-            'Console size' => glsr(Console::class)->humanSize('0'),
225
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
226
-            'Version (current)' => glsr()->version,
227
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
228
-        ];
229
-    }
217
+	/**
218
+	 * @return array
219
+	 */
220
+	public function getPluginDetails()
221
+	{
222
+		return [
223
+			'Console level' => glsr(Console::class)->humanLevel(),
224
+			'Console size' => glsr(Console::class)->humanSize('0'),
225
+			'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
226
+			'Version (current)' => glsr()->version,
227
+			'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
228
+		];
229
+	}
230 230
 
231
-    /**
232
-     * @return array
233
-     */
234
-    public function getWordpressDetails()
235
-    {
236
-        global $wpdb;
237
-        $theme = wp_get_theme();
238
-        return [
239
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
240
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
241
-            'Home URL' => home_url(),
242
-            'Language' => get_locale(),
243
-            'Memory Limit' => WP_MEMORY_LIMIT,
244
-            'Multisite' => var_export(is_multisite(), true),
245
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
246
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
247
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
248
-            'Post Stati' => implode(', ', get_post_stati()),
249
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
250
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
251
-            'Site URL' => site_url(),
252
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'),
253
-            'Version' => get_bloginfo('version'),
254
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
255
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
256
-            'WP Memory Limit' => WP_MEMORY_LIMIT,
257
-        ];
258
-    }
231
+	/**
232
+	 * @return array
233
+	 */
234
+	public function getWordpressDetails()
235
+	{
236
+		global $wpdb;
237
+		$theme = wp_get_theme();
238
+		return [
239
+			'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
240
+			'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
241
+			'Home URL' => home_url(),
242
+			'Language' => get_locale(),
243
+			'Memory Limit' => WP_MEMORY_LIMIT,
244
+			'Multisite' => var_export(is_multisite(), true),
245
+			'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
246
+			'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
247
+			'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
248
+			'Post Stati' => implode(', ', get_post_stati()),
249
+			'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
250
+			'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
251
+			'Site URL' => site_url(),
252
+			'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'),
253
+			'Version' => get_bloginfo('version'),
254
+			'WP Debug' => var_export(defined('WP_DEBUG'), true),
255
+			'WP Max Upload Size' => size_format(wp_max_upload_size()),
256
+			'WP Memory Limit' => WP_MEMORY_LIMIT,
257
+		];
258
+	}
259 259
 
260
-    /**
261
-     * @return string
262
-     */
263
-    protected function detectWebhostProvider()
264
-    {
265
-        $checks = [
266
-            '.accountservergroup.com' => 'Site5',
267
-            '.gridserver.com' => 'MediaTemple Grid',
268
-            '.inmotionhosting.com' => 'InMotion Hosting',
269
-            '.ovh.net' => 'OVH',
270
-            '.pair.com' => 'pair Networks',
271
-            '.stabletransit.com' => 'Rackspace Cloud',
272
-            '.stratoserver.net' => 'STRATO',
273
-            '.sysfix.eu' => 'SysFix.eu Power Hosting',
274
-            'bluehost.com' => 'Bluehost',
275
-            'DH_USER' => 'DreamHost',
276
-            'Flywheel' => 'Flywheel',
277
-            'ipagemysql.com' => 'iPage',
278
-            'ipowermysql.com' => 'IPower',
279
-            'localhost:/tmp/mysql5.sock' => 'ICDSoft',
280
-            'mysqlv5' => 'NetworkSolutions',
281
-            'PAGELYBIN' => 'Pagely',
282
-            'secureserver.net' => 'GoDaddy',
283
-            'WPE_APIKEY' => 'WP Engine',
284
-        ];
285
-        foreach ($checks as $key => $value) {
286
-            if (!$this->isWebhostCheckValid($key)) {
287
-                continue;
288
-            }
289
-            return $value;
290
-        }
291
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
292
-    }
260
+	/**
261
+	 * @return string
262
+	 */
263
+	protected function detectWebhostProvider()
264
+	{
265
+		$checks = [
266
+			'.accountservergroup.com' => 'Site5',
267
+			'.gridserver.com' => 'MediaTemple Grid',
268
+			'.inmotionhosting.com' => 'InMotion Hosting',
269
+			'.ovh.net' => 'OVH',
270
+			'.pair.com' => 'pair Networks',
271
+			'.stabletransit.com' => 'Rackspace Cloud',
272
+			'.stratoserver.net' => 'STRATO',
273
+			'.sysfix.eu' => 'SysFix.eu Power Hosting',
274
+			'bluehost.com' => 'Bluehost',
275
+			'DH_USER' => 'DreamHost',
276
+			'Flywheel' => 'Flywheel',
277
+			'ipagemysql.com' => 'iPage',
278
+			'ipowermysql.com' => 'IPower',
279
+			'localhost:/tmp/mysql5.sock' => 'ICDSoft',
280
+			'mysqlv5' => 'NetworkSolutions',
281
+			'PAGELYBIN' => 'Pagely',
282
+			'secureserver.net' => 'GoDaddy',
283
+			'WPE_APIKEY' => 'WP Engine',
284
+		];
285
+		foreach ($checks as $key => $value) {
286
+			if (!$this->isWebhostCheckValid($key)) {
287
+				continue;
288
+			}
289
+			return $value;
290
+		}
291
+		return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
292
+	}
293 293
 
294
-    /**
295
-     * @return string
296
-     */
297
-    protected function getHostName()
298
-    {
299
-        return sprintf('%s (%s)',
300
-            $this->detectWebhostProvider(),
301
-            Helper::getIpAddress()
302
-        );
303
-    }
294
+	/**
295
+	 * @return string
296
+	 */
297
+	protected function getHostName()
298
+	{
299
+		return sprintf('%s (%s)',
300
+			$this->detectWebhostProvider(),
301
+			Helper::getIpAddress()
302
+		);
303
+	}
304 304
 
305
-    protected function getINI($name, $disabledValue = 'ini_get() is disabled.')
306
-    {
307
-        return function_exists('ini_get')
308
-            ? ini_get($name)
309
-            : $disabledValue;
310
-    }
305
+	protected function getINI($name, $disabledValue = 'ini_get() is disabled.')
306
+	{
307
+		return function_exists('ini_get')
308
+			? ini_get($name)
309
+			: $disabledValue;
310
+	}
311 311
 
312
-    /**
313
-     * @return array
314
-     */
315
-    protected function getWordpressPlugins()
316
-    {
317
-        $plugins = get_plugins();
318
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
319
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
320
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
321
-        return $active + $inactive;
322
-    }
312
+	/**
313
+	 * @return array
314
+	 */
315
+	protected function getWordpressPlugins()
316
+	{
317
+		$plugins = get_plugins();
318
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
319
+		$inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
320
+		$active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
321
+		return $active + $inactive;
322
+	}
323 323
 
324
-    /**
325
-     * @param string $title
326
-     * @return string
327
-     */
328
-    protected function implode($title, array $details)
329
-    {
330
-        $strings = ['['.$title.']'];
331
-        $padding = max(array_map('strlen', array_keys($details)));
332
-        $padding = max([$padding, static::PAD]);
333
-        foreach ($details as $key => $value) {
334
-            $strings[] = is_string($key)
335
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
336
-                : ' - '.$value;
337
-        }
338
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
339
-    }
324
+	/**
325
+	 * @param string $title
326
+	 * @return string
327
+	 */
328
+	protected function implode($title, array $details)
329
+	{
330
+		$strings = ['['.$title.']'];
331
+		$padding = max(array_map('strlen', array_keys($details)));
332
+		$padding = max([$padding, static::PAD]);
333
+		foreach ($details as $key => $value) {
334
+			$strings[] = is_string($key)
335
+				? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
336
+				: ' - '.$value;
337
+		}
338
+		return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
339
+	}
340 340
 
341
-    /**
342
-     * @param string $key
343
-     * @return bool
344
-     */
345
-    protected function isWebhostCheckValid($key)
346
-    {
347
-        return defined($key)
348
-            || filter_input(INPUT_SERVER, $key)
349
-            || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
350
-            || Str::contains(DB_HOST, $key)
351
-            || Str::contains(php_uname(), $key);
352
-    }
341
+	/**
342
+	 * @param string $key
343
+	 * @return bool
344
+	 */
345
+	protected function isWebhostCheckValid($key)
346
+	{
347
+		return defined($key)
348
+			|| filter_input(INPUT_SERVER, $key)
349
+			|| Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
350
+			|| Str::contains(DB_HOST, $key)
351
+			|| Str::contains(php_uname(), $key);
352
+	}
353 353
 
354
-    /**
355
-     * @return array
356
-     */
357
-    protected function normalizePluginList(array $plugins)
358
-    {
359
-        $plugins = array_map(function ($plugin) {
360
-            return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version'));
361
-        }, $plugins);
362
-        natcasesort($plugins);
363
-        return array_flip($plugins);
364
-    }
354
+	/**
355
+	 * @return array
356
+	 */
357
+	protected function normalizePluginList(array $plugins)
358
+	{
359
+		$plugins = array_map(function ($plugin) {
360
+			return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version'));
361
+		}, $plugins);
362
+		natcasesort($plugins);
363
+		return array_flip($plugins);
364
+	}
365 365
 
366
-    /**
367
-     * @return array
368
-     */
369
-    protected function purgeSensitiveData(array $settings)
370
-    {
371
-        $keys = [
372
-            'general.rebusify_serial',
373
-            'licenses.',
374
-            'submissions.recaptcha.key',
375
-            'submissions.recaptcha.secret',
376
-        ];
377
-        array_walk($settings, function (&$value, $setting) use ($keys) {
378
-            foreach ($keys as $key) {
379
-                if (!Str::startsWith($key, $setting) || empty($value)) {
380
-                    continue;
381
-                }
382
-                $value = str_repeat('•', 13);
383
-                return;
384
-            }
385
-        });
386
-        return $settings;
387
-    }
366
+	/**
367
+	 * @return array
368
+	 */
369
+	protected function purgeSensitiveData(array $settings)
370
+	{
371
+		$keys = [
372
+			'general.rebusify_serial',
373
+			'licenses.',
374
+			'submissions.recaptcha.key',
375
+			'submissions.recaptcha.secret',
376
+		];
377
+		array_walk($settings, function (&$value, $setting) use ($keys) {
378
+			foreach ($keys as $key) {
379
+				if (!Str::startsWith($key, $setting) || empty($value)) {
380
+					continue;
381
+				}
382
+				$value = str_repeat('•', 13);
383
+				return;
384
+			}
385
+		});
386
+		return $settings;
387
+	}
388 388
 }
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
             'setting' => 'Plugin Settings',
42 42
             'reviews' => 'Review Counts',
43 43
         ];
44
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
45
-            $methodName = Helper::buildMethodName('get-'.$key.'-details');
46
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
44
+        $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) {
45
+            $methodName = Helper::buildMethodName( 'get-'.$key.'-details' );
46
+            if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
47 47
                 return $carry.$this->implode(
48
-                    strtoupper($details[$key]),
49
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
48
+                    strtoupper( $details[$key] ),
49
+                    apply_filters( 'site-reviews/system/'.$key, $systemDetails )
50 50
                 );
51 51
             }
52 52
             return $carry;
53 53
         });
54
-        return trim($systemInfo);
54
+        return trim( $systemInfo );
55 55
     }
56 56
 
57 57
     /**
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
     public function getActivePluginDetails()
61 61
     {
62 62
         $plugins = get_plugins();
63
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
64
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
65
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
63
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
64
+        $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
65
+        return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
66 66
     }
67 67
 
68 68
     /**
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function getAddonDetails()
72 72
     {
73
-        $details = apply_filters('site-reviews/addon/system-info', []);
74
-        ksort($details);
73
+        $details = apply_filters( 'site-reviews/addon/system-info', [] );
74
+        ksort( $details );
75 75
         return $details;
76 76
     }
77 77
 
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
     public function getBrowserDetails()
82 82
     {
83 83
         $browser = new Browser();
84
-        $name = esc_attr($browser->getName());
85
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
86
-        $version = esc_attr($browser->getVersion());
84
+        $name = esc_attr( $browser->getName() );
85
+        $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() );
86
+        $version = esc_attr( $browser->getVersion() );
87 87
         return [
88
-            'Browser Name' => sprintf('%s %s', $name, $version),
88
+            'Browser Name' => sprintf( '%s %s', $name, $version ),
89 89
             'Browser UA' => $userAgent,
90 90
         ];
91 91
     }
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function getInactivePluginDetails()
97 97
     {
98
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
99
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
98
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
99
+        $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
100 100
         $multisitePlugins = $this->getMultisitePluginDetails();
101 101
         return empty($multisitePlugins)
102 102
             ? $inactivePlugins
103
-            : array_diff($inactivePlugins, $multisitePlugins);
103
+            : array_diff( $inactivePlugins, $multisitePlugins );
104 104
     }
105 105
 
106 106
     /**
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function getMuPluginDetails()
110 110
     {
111
-        if (empty($plugins = get_mu_plugins())) {
111
+        if( empty($plugins = get_mu_plugins()) ) {
112 112
             return [];
113 113
         }
114
-        return $this->normalizePluginList($plugins);
114
+        return $this->normalizePluginList( $plugins );
115 115
     }
116 116
 
117 117
     /**
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function getMultisitePluginDetails()
121 121
     {
122
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
123
-        if (!is_multisite() || empty($activePlugins)) {
122
+        $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] );
123
+        if( !is_multisite() || empty($activePlugins) ) {
124 124
             return [];
125 125
         }
126
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
126
+        return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) );
127 127
     }
128 128
 
129 129
     /**
@@ -131,31 +131,31 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function getPhpDetails()
133 133
     {
134
-        $displayErrors = $this->getINI('display_errors', null)
135
-            ? 'On ('.$this->getINI('display_errors').')'
134
+        $displayErrors = $this->getINI( 'display_errors', null )
135
+            ? 'On ('.$this->getINI( 'display_errors' ).')'
136 136
             : 'N/A';
137
-        $intlSupport = extension_loaded('intl')
138
-            ? phpversion('intl')
137
+        $intlSupport = extension_loaded( 'intl' )
138
+            ? phpversion( 'intl' )
139 139
             : 'false';
140 140
         return [
141
-            'cURL' => var_export(function_exists('curl_init'), true),
142
-            'Default Charset' => $this->getINI('default_charset'),
141
+            'cURL' => var_export( function_exists( 'curl_init' ), true ),
142
+            'Default Charset' => $this->getINI( 'default_charset' ),
143 143
             'Display Errors' => $displayErrors,
144
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
144
+            'fsockopen' => var_export( function_exists( 'fsockopen' ), true ),
145 145
             'Intl' => $intlSupport,
146
-            'IPv6' => var_export(defined('AF_INET6'), true),
147
-            'Max Execution Time' => $this->getINI('max_execution_time'),
148
-            'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'),
149
-            'Max Input Vars' => $this->getINI('max_input_vars'),
150
-            'Memory Limit' => $this->getINI('memory_limit'),
151
-            'Post Max Size' => $this->getINI('post_max_size'),
152
-            'Sendmail Path' => $this->getINI('sendmail_path'),
153
-            'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')),
154
-            'Session Name' => esc_html($this->getINI('session.name')),
155
-            'Session Save Path' => esc_html($this->getINI('session.save_path')),
156
-            'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true),
157
-            'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true),
158
-            'Upload Max Filesize' => $this->getINI('upload_max_filesize'),
146
+            'IPv6' => var_export( defined( 'AF_INET6' ), true ),
147
+            'Max Execution Time' => $this->getINI( 'max_execution_time' ),
148
+            'Max Input Nesting Level' => $this->getINI( 'max_input_nesting_level' ),
149
+            'Max Input Vars' => $this->getINI( 'max_input_vars' ),
150
+            'Memory Limit' => $this->getINI( 'memory_limit' ),
151
+            'Post Max Size' => $this->getINI( 'post_max_size' ),
152
+            'Sendmail Path' => $this->getINI( 'sendmail_path' ),
153
+            'Session Cookie Path' => esc_html( $this->getINI( 'session.cookie_path' ) ),
154
+            'Session Name' => esc_html( $this->getINI( 'session.name' ) ),
155
+            'Session Save Path' => esc_html( $this->getINI( 'session.save_path' ) ),
156
+            'Session Use Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_cookies', false ) ), true ),
157
+            'Session Use Only Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_only_cookies', false ) ), true ),
158
+            'Upload Max Filesize' => $this->getINI( 'upload_max_filesize' ),
159 159
         ];
160 160
     }
161 161
 
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function getReviewsDetails()
166 166
     {
167
-        $counts = glsr(CountsManager::class)->getCounts();
168
-        $counts = Arr::flattenArray($counts);
169
-        array_walk($counts, function (&$ratings) use ($counts) {
170
-            if (!is_array($ratings)) {
167
+        $counts = glsr( CountsManager::class )->getCounts();
168
+        $counts = Arr::flattenArray( $counts );
169
+        array_walk( $counts, function( &$ratings ) use ($counts) {
170
+            if( !is_array( $ratings ) ) {
171 171
                 glsr_log()
172
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
173
-                    ->debug($ratings)
174
-                    ->debug($counts);
172
+                    ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
173
+                    ->debug( $ratings )
174
+                    ->debug( $counts );
175 175
                 return;
176 176
             }
177
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
177
+            $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')';
178 178
         });
179
-        ksort($counts);
179
+        ksort( $counts );
180 180
         return $counts;
181 181
     }
182 182
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
             'Host Name' => $this->getHostName(),
191 191
             'MySQL Version' => $wpdb->db_version(),
192 192
             'PHP Version' => PHP_VERSION,
193
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
193
+            'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ),
194 194
         ];
195 195
     }
196 196
 
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
      */
200 200
     public function getSettingDetails()
201 201
     {
202
-        $settings = glsr(OptionManager::class)->get('settings', []);
203
-        $settings = Arr::flattenArray($settings, true);
204
-        $settings = $this->purgeSensitiveData($settings);
205
-        ksort($settings);
202
+        $settings = glsr( OptionManager::class )->get( 'settings', [] );
203
+        $settings = Arr::flattenArray( $settings, true );
204
+        $settings = $this->purgeSensitiveData( $settings );
205
+        ksort( $settings );
206 206
         $details = [];
207
-        foreach ($settings as $key => $value) {
208
-            if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) {
207
+        foreach( $settings as $key => $value ) {
208
+            if( Str::startsWith( 'strings', $key ) && Str::endsWith( 'id', $key ) ) {
209 209
                 continue;
210 210
             }
211
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
211
+            $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
212 212
             $details[$key] = $value;
213 213
         }
214 214
         return $details;
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
     public function getPluginDetails()
221 221
     {
222 222
         return [
223
-            'Console level' => glsr(Console::class)->humanLevel(),
224
-            'Console size' => glsr(Console::class)->humanSize('0'),
225
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
223
+            'Console level' => glsr( Console::class )->humanLevel(),
224
+            'Console size' => glsr( Console::class )->humanSize( '0' ),
225
+            'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ),
226 226
             'Version (current)' => glsr()->version,
227
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
227
+            'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ),
228 228
         ];
229 229
     }
230 230
 
@@ -236,23 +236,23 @@  discard block
 block discarded – undo
236 236
         global $wpdb;
237 237
         $theme = wp_get_theme();
238 238
         return [
239
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
240
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
239
+            'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ),
240
+            'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ),
241 241
             'Home URL' => home_url(),
242 242
             'Language' => get_locale(),
243 243
             'Memory Limit' => WP_MEMORY_LIMIT,
244
-            'Multisite' => var_export(is_multisite(), true),
245
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
246
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
247
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
248
-            'Post Stati' => implode(', ', get_post_stati()),
249
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
250
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
244
+            'Multisite' => var_export( is_multisite(), true ),
245
+            'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ),
246
+            'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ),
247
+            'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ),
248
+            'Post Stati' => implode( ', ', get_post_stati() ),
249
+            'Remote Post' => glsr( Cache::class )->getRemotePostTest(),
250
+            'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ),
251 251
             'Site URL' => site_url(),
252
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'),
253
-            'Version' => get_bloginfo('version'),
254
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
255
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
252
+            'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', $this->getINI( 'date.timezone' ).' (PHP)' ),
253
+            'Version' => get_bloginfo( 'version' ),
254
+            'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ),
255
+            'WP Max Upload Size' => size_format( wp_max_upload_size() ),
256 256
             'WP Memory Limit' => WP_MEMORY_LIMIT,
257 257
         ];
258 258
     }
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
             'secureserver.net' => 'GoDaddy',
283 283
             'WPE_APIKEY' => 'WP Engine',
284 284
         ];
285
-        foreach ($checks as $key => $value) {
286
-            if (!$this->isWebhostCheckValid($key)) {
285
+        foreach( $checks as $key => $value ) {
286
+            if( !$this->isWebhostCheckValid( $key ) ) {
287 287
                 continue;
288 288
             }
289 289
             return $value;
290 290
         }
291
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
291
+        return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
292 292
     }
293 293
 
294 294
     /**
@@ -296,16 +296,16 @@  discard block
 block discarded – undo
296 296
      */
297 297
     protected function getHostName()
298 298
     {
299
-        return sprintf('%s (%s)',
299
+        return sprintf( '%s (%s)',
300 300
             $this->detectWebhostProvider(),
301 301
             Helper::getIpAddress()
302 302
         );
303 303
     }
304 304
 
305
-    protected function getINI($name, $disabledValue = 'ini_get() is disabled.')
305
+    protected function getINI( $name, $disabledValue = 'ini_get() is disabled.' )
306 306
     {
307
-        return function_exists('ini_get')
308
-            ? ini_get($name)
307
+        return function_exists( 'ini_get' )
308
+            ? ini_get( $name )
309 309
             : $disabledValue;
310 310
     }
311 311
 
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
     protected function getWordpressPlugins()
316 316
     {
317 317
         $plugins = get_plugins();
318
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
319
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
320
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
318
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
319
+        $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
320
+        $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
321 321
         return $active + $inactive;
322 322
     }
323 323
 
@@ -325,48 +325,48 @@  discard block
 block discarded – undo
325 325
      * @param string $title
326 326
      * @return string
327 327
      */
328
-    protected function implode($title, array $details)
328
+    protected function implode( $title, array $details )
329 329
     {
330 330
         $strings = ['['.$title.']'];
331
-        $padding = max(array_map('strlen', array_keys($details)));
332
-        $padding = max([$padding, static::PAD]);
333
-        foreach ($details as $key => $value) {
334
-            $strings[] = is_string($key)
335
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
331
+        $padding = max( array_map( 'strlen', array_keys( $details ) ) );
332
+        $padding = max( [$padding, static::PAD] );
333
+        foreach( $details as $key => $value ) {
334
+            $strings[] = is_string( $key )
335
+                ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value )
336 336
                 : ' - '.$value;
337 337
         }
338
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
338
+        return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL;
339 339
     }
340 340
 
341 341
     /**
342 342
      * @param string $key
343 343
      * @return bool
344 344
      */
345
-    protected function isWebhostCheckValid($key)
345
+    protected function isWebhostCheckValid( $key )
346 346
     {
347
-        return defined($key)
348
-            || filter_input(INPUT_SERVER, $key)
349
-            || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
350
-            || Str::contains(DB_HOST, $key)
351
-            || Str::contains(php_uname(), $key);
347
+        return defined( $key )
348
+            || filter_input( INPUT_SERVER, $key )
349
+            || Str::contains( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key )
350
+            || Str::contains( DB_HOST, $key )
351
+            || Str::contains( php_uname(), $key );
352 352
     }
353 353
 
354 354
     /**
355 355
      * @return array
356 356
      */
357
-    protected function normalizePluginList(array $plugins)
357
+    protected function normalizePluginList( array $plugins )
358 358
     {
359
-        $plugins = array_map(function ($plugin) {
360
-            return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version'));
361
-        }, $plugins);
362
-        natcasesort($plugins);
363
-        return array_flip($plugins);
359
+        $plugins = array_map( function( $plugin ) {
360
+            return sprintf( '%s v%s', Arr::get( $plugin, 'Name' ), Arr::get( $plugin, 'Version' ) );
361
+        }, $plugins );
362
+        natcasesort( $plugins );
363
+        return array_flip( $plugins );
364 364
     }
365 365
 
366 366
     /**
367 367
      * @return array
368 368
      */
369
-    protected function purgeSensitiveData(array $settings)
369
+    protected function purgeSensitiveData( array $settings )
370 370
     {
371 371
         $keys = [
372 372
             'general.rebusify_serial',
@@ -374,12 +374,12 @@  discard block
 block discarded – undo
374 374
             'submissions.recaptcha.key',
375 375
             'submissions.recaptcha.secret',
376 376
         ];
377
-        array_walk($settings, function (&$value, $setting) use ($keys) {
378
-            foreach ($keys as $key) {
379
-                if (!Str::startsWith($key, $setting) || empty($value)) {
377
+        array_walk( $settings, function( &$value, $setting ) use ($keys) {
378
+            foreach( $keys as $key ) {
379
+                if( !Str::startsWith( $key, $setting ) || empty($value) ) {
380 380
                     continue;
381 381
                 }
382
-                $value = str_repeat('•', 13);
382
+                $value = str_repeat( '•', 13 );
383 383
                 return;
384 384
             }
385 385
         });
Please login to merge, or discard this patch.
plugin/Helper.php 2 patches
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -8,124 +8,124 @@
 block discarded – undo
8 8
 
9 9
 class Helper
10 10
 {
11
-    /**
12
-     * @param string $name
13
-     * @param string $path
14
-     * @return string
15
-     */
16
-    public static function buildClassName($name, $path = '')
17
-    {
18
-        $className = Str::camelCase($name);
19
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
20
-        return !empty($path)
21
-            ? __NAMESPACE__.'\\'.$path.'\\'.$className
22
-            : $className;
23
-    }
11
+	/**
12
+	 * @param string $name
13
+	 * @param string $path
14
+	 * @return string
15
+	 */
16
+	public static function buildClassName($name, $path = '')
17
+	{
18
+		$className = Str::camelCase($name);
19
+		$path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
20
+		return !empty($path)
21
+			? __NAMESPACE__.'\\'.$path.'\\'.$className
22
+			: $className;
23
+	}
24 24
 
25
-    /**
26
-     * @param string $name
27
-     * @param string $prefix
28
-     * @return string
29
-     */
30
-    public static function buildMethodName($name, $prefix = '')
31
-    {
32
-        return lcfirst($prefix.static::buildClassName($name));
33
-    }
25
+	/**
26
+	 * @param string $name
27
+	 * @param string $prefix
28
+	 * @return string
29
+	 */
30
+	public static function buildMethodName($name, $prefix = '')
31
+	{
32
+		return lcfirst($prefix.static::buildClassName($name));
33
+	}
34 34
 
35
-    /**
36
-     * @param string $name
37
-     * @return string
38
-     */
39
-    public static function buildPropertyName($name)
40
-    {
41
-        return lcfirst(static::buildClassName($name));
42
-    }
35
+	/**
36
+	 * @param string $name
37
+	 * @return string
38
+	 */
39
+	public static function buildPropertyName($name)
40
+	{
41
+		return lcfirst(static::buildClassName($name));
42
+	}
43 43
 
44
-    /**
45
-     * @param string $cast
46
-     * @param mixed $value
47
-     * @return mixed
48
-     */
49
-    public static function castTo($cast = '', $value)
50
-    {
51
-        switch ($cast) {
52
-            case 'array':
53
-                return (array) $value;
54
-            case 'bool':
55
-            case 'boolean':
56
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
57
-            case 'float':
58
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
59
-            case 'int':
60
-            case 'integer':
61
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
62
-            case 'object':
63
-                return (object) (array) $value;
64
-            case 'str':
65
-            case 'string':
66
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
67
-                    return (string) $value->__toString();
68
-                }
69
-                if (is_array($value) || is_object($value)) {
70
-                    return serialize($value);
71
-                }
72
-                return (string) $value;
73
-            default:
74
-                return $value;
75
-        }
76
-    }
44
+	/**
45
+	 * @param string $cast
46
+	 * @param mixed $value
47
+	 * @return mixed
48
+	 */
49
+	public static function castTo($cast = '', $value)
50
+	{
51
+		switch ($cast) {
52
+			case 'array':
53
+				return (array) $value;
54
+			case 'bool':
55
+			case 'boolean':
56
+				return filter_var($value, FILTER_VALIDATE_BOOLEAN);
57
+			case 'float':
58
+				return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
59
+			case 'int':
60
+			case 'integer':
61
+				return (int) filter_var($value, FILTER_VALIDATE_INT);
62
+			case 'object':
63
+				return (object) (array) $value;
64
+			case 'str':
65
+			case 'string':
66
+				if (is_object($value) && in_array('__toString', get_class_methods($value))) {
67
+					return (string) $value->__toString();
68
+				}
69
+				if (is_array($value) || is_object($value)) {
70
+					return serialize($value);
71
+				}
72
+				return (string) $value;
73
+			default:
74
+				return $value;
75
+		}
76
+	}
77 77
 
78
-    /**
79
-     * @param string $key
80
-     * @return mixed
81
-     */
82
-    public static function filterInput($key, array $request = [])
83
-    {
84
-        if (isset($request[$key])) {
85
-            return $request[$key];
86
-        }
87
-        $variable = filter_input(INPUT_POST, $key);
88
-        if (is_null($variable) && isset($_POST[$key])) {
89
-            $variable = $_POST[$key];
90
-        }
91
-        return $variable;
92
-    }
78
+	/**
79
+	 * @param string $key
80
+	 * @return mixed
81
+	 */
82
+	public static function filterInput($key, array $request = [])
83
+	{
84
+		if (isset($request[$key])) {
85
+			return $request[$key];
86
+		}
87
+		$variable = filter_input(INPUT_POST, $key);
88
+		if (is_null($variable) && isset($_POST[$key])) {
89
+			$variable = $_POST[$key];
90
+		}
91
+		return $variable;
92
+	}
93 93
 
94
-    /**
95
-     * @param string $key
96
-     * @return array
97
-     */
98
-    public static function filterInputArray($key)
99
-    {
100
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
101
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
102
-            $variable = $_POST[$key];
103
-        }
104
-        return (array) $variable;
105
-    }
94
+	/**
95
+	 * @param string $key
96
+	 * @return array
97
+	 */
98
+	public static function filterInputArray($key)
99
+	{
100
+		$variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
101
+		if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
102
+			$variable = $_POST[$key];
103
+		}
104
+		return (array) $variable;
105
+	}
106 106
 
107
-    /**
108
-     * @return string
109
-     */
110
-    public static function getIpAddress()
111
-    {
112
-        $whitelist = [];
113
-        $isUsingCloudflare = !empty(filter_input(INPUT_SERVER, 'CF-Connecting-IP'));
114
-        if (apply_filters('site-reviews/whip/whitelist/cloudflare', $isUsingCloudflare)) {
115
-            $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
116
-            $whitelist[Whip::CLOUDFLARE_HEADERS] = [Whip::IPV4 => $cloudflareIps['v4']];
117
-            if (defined('AF_INET6')) {
118
-                $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6'];
119
-            }
120
-        }
121
-        $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist);
122
-        $methods = apply_filters('site-reviews/whip/methods', Whip::ALL_METHODS);
123
-        $whip = new Whip($methods, $whitelist);
124
-        do_action_ref_array('site-reviews/whip', [$whip]);
125
-        if (false !== ($clientAddress = $whip->getValidIpAddress())) {
126
-            return (string) $clientAddress;
127
-        }
128
-        glsr_log()->error('Unable to detect IP address.');
129
-        return 'unknown';
130
-    }
107
+	/**
108
+	 * @return string
109
+	 */
110
+	public static function getIpAddress()
111
+	{
112
+		$whitelist = [];
113
+		$isUsingCloudflare = !empty(filter_input(INPUT_SERVER, 'CF-Connecting-IP'));
114
+		if (apply_filters('site-reviews/whip/whitelist/cloudflare', $isUsingCloudflare)) {
115
+			$cloudflareIps = glsr(Cache::class)->getCloudflareIps();
116
+			$whitelist[Whip::CLOUDFLARE_HEADERS] = [Whip::IPV4 => $cloudflareIps['v4']];
117
+			if (defined('AF_INET6')) {
118
+				$whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6'];
119
+			}
120
+		}
121
+		$whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist);
122
+		$methods = apply_filters('site-reviews/whip/methods', Whip::ALL_METHODS);
123
+		$whip = new Whip($methods, $whitelist);
124
+		do_action_ref_array('site-reviews/whip', [$whip]);
125
+		if (false !== ($clientAddress = $whip->getValidIpAddress())) {
126
+			return (string) $clientAddress;
127
+		}
128
+		glsr_log()->error('Unable to detect IP address.');
129
+		return 'unknown';
130
+	}
131 131
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
      * @param string $path
14 14
      * @return string
15 15
      */
16
-    public static function buildClassName($name, $path = '')
16
+    public static function buildClassName( $name, $path = '' )
17 17
     {
18
-        $className = Str::camelCase($name);
19
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
18
+        $className = Str::camelCase( $name );
19
+        $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' );
20 20
         return !empty($path)
21 21
             ? __NAMESPACE__.'\\'.$path.'\\'.$className
22 22
             : $className;
@@ -27,18 +27,18 @@  discard block
 block discarded – undo
27 27
      * @param string $prefix
28 28
      * @return string
29 29
      */
30
-    public static function buildMethodName($name, $prefix = '')
30
+    public static function buildMethodName( $name, $prefix = '' )
31 31
     {
32
-        return lcfirst($prefix.static::buildClassName($name));
32
+        return lcfirst( $prefix.static::buildClassName( $name ) );
33 33
     }
34 34
 
35 35
     /**
36 36
      * @param string $name
37 37
      * @return string
38 38
      */
39
-    public static function buildPropertyName($name)
39
+    public static function buildPropertyName( $name )
40 40
     {
41
-        return lcfirst(static::buildClassName($name));
41
+        return lcfirst( static::buildClassName( $name ) );
42 42
     }
43 43
 
44 44
     /**
@@ -46,30 +46,30 @@  discard block
 block discarded – undo
46 46
      * @param mixed $value
47 47
      * @return mixed
48 48
      */
49
-    public static function castTo($cast = '', $value)
49
+    public static function castTo( $cast = '', $value )
50 50
     {
51
-        switch ($cast) {
51
+        switch( $cast ) {
52 52
             case 'array':
53
-                return (array) $value;
53
+                return (array)$value;
54 54
             case 'bool':
55 55
             case 'boolean':
56
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
56
+                return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
57 57
             case 'float':
58
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
58
+                return (float)filter_var( $value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND );
59 59
             case 'int':
60 60
             case 'integer':
61
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
61
+                return (int)filter_var( $value, FILTER_VALIDATE_INT );
62 62
             case 'object':
63
-                return (object) (array) $value;
63
+                return (object)(array)$value;
64 64
             case 'str':
65 65
             case 'string':
66
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
67
-                    return (string) $value->__toString();
66
+                if( is_object( $value ) && in_array( '__toString', get_class_methods( $value ) ) ) {
67
+                    return (string)$value->__toString();
68 68
                 }
69
-                if (is_array($value) || is_object($value)) {
70
-                    return serialize($value);
69
+                if( is_array( $value ) || is_object( $value ) ) {
70
+                    return serialize( $value );
71 71
                 }
72
-                return (string) $value;
72
+                return (string)$value;
73 73
             default:
74 74
                 return $value;
75 75
         }
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
      * @param string $key
80 80
      * @return mixed
81 81
      */
82
-    public static function filterInput($key, array $request = [])
82
+    public static function filterInput( $key, array $request = [] )
83 83
     {
84
-        if (isset($request[$key])) {
84
+        if( isset($request[$key]) ) {
85 85
             return $request[$key];
86 86
         }
87
-        $variable = filter_input(INPUT_POST, $key);
88
-        if (is_null($variable) && isset($_POST[$key])) {
87
+        $variable = filter_input( INPUT_POST, $key );
88
+        if( is_null( $variable ) && isset($_POST[$key]) ) {
89 89
             $variable = $_POST[$key];
90 90
         }
91 91
         return $variable;
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
      * @param string $key
96 96
      * @return array
97 97
      */
98
-    public static function filterInputArray($key)
98
+    public static function filterInputArray( $key )
99 99
     {
100
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
101
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
100
+        $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
101
+        if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
102 102
             $variable = $_POST[$key];
103 103
         }
104
-        return (array) $variable;
104
+        return (array)$variable;
105 105
     }
106 106
 
107 107
     /**
@@ -110,22 +110,22 @@  discard block
 block discarded – undo
110 110
     public static function getIpAddress()
111 111
     {
112 112
         $whitelist = [];
113
-        $isUsingCloudflare = !empty(filter_input(INPUT_SERVER, 'CF-Connecting-IP'));
114
-        if (apply_filters('site-reviews/whip/whitelist/cloudflare', $isUsingCloudflare)) {
115
-            $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
113
+        $isUsingCloudflare = !empty(filter_input( INPUT_SERVER, 'CF-Connecting-IP' ));
114
+        if( apply_filters( 'site-reviews/whip/whitelist/cloudflare', $isUsingCloudflare ) ) {
115
+            $cloudflareIps = glsr( Cache::class )->getCloudflareIps();
116 116
             $whitelist[Whip::CLOUDFLARE_HEADERS] = [Whip::IPV4 => $cloudflareIps['v4']];
117
-            if (defined('AF_INET6')) {
117
+            if( defined( 'AF_INET6' ) ) {
118 118
                 $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6'];
119 119
             }
120 120
         }
121
-        $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist);
122
-        $methods = apply_filters('site-reviews/whip/methods', Whip::ALL_METHODS);
123
-        $whip = new Whip($methods, $whitelist);
124
-        do_action_ref_array('site-reviews/whip', [$whip]);
125
-        if (false !== ($clientAddress = $whip->getValidIpAddress())) {
126
-            return (string) $clientAddress;
121
+        $whitelist = apply_filters( 'site-reviews/whip/whitelist', $whitelist );
122
+        $methods = apply_filters( 'site-reviews/whip/methods', Whip::ALL_METHODS );
123
+        $whip = new Whip( $methods, $whitelist );
124
+        do_action_ref_array( 'site-reviews/whip', [$whip] );
125
+        if( false !== ($clientAddress = $whip->getValidIpAddress()) ) {
126
+            return (string)$clientAddress;
127 127
         }
128
-        glsr_log()->error('Unable to detect IP address.');
128
+        glsr_log()->error( 'Unable to detect IP address.' );
129 129
         return 'unknown';
130 130
     }
131 131
 }
Please login to merge, or discard this patch.
plugin/Defaults/ValidateReviewDefaults.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@
 block discarded – undo
6 6
 
7 7
 class ValidateReviewDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    protected function defaults()
13
-    {
14
-        return [
15
-            'assign_to' => '',
16
-            'category' => '',
17
-            'content' => '',
18
-            'email' => '',
19
-            'form_id' => '',
20
-            'ip_address' => '',
21
-            'name' => '',
22
-            'rating' => '0',
23
-            'terms' => '',
24
-            'title' => '',
25
-        ];
26
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	protected function defaults()
13
+	{
14
+		return [
15
+			'assign_to' => '',
16
+			'category' => '',
17
+			'content' => '',
18
+			'email' => '',
19
+			'form_id' => '',
20
+			'ip_address' => '',
21
+			'name' => '',
22
+			'rating' => '0',
23
+			'terms' => '',
24
+			'title' => '',
25
+		];
26
+	}
27 27
 }
Please login to merge, or discard this patch.
deprecated.php 2 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -3,134 +3,134 @@
 block discarded – undo
3 3
 defined('WPINC') || die;
4 4
 
5 5
 if (apply_filters('site-reviews/support/deprecated/v4', true)) {
6
-    // Unprotected review meta has been deprecated
7
-    add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) {
8
-        $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults());
9
-        if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) {
10
-            return $data;
11
-        }
12
-        glsr()->deprecated[] = sprintf(
13
-            'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.',
14
-            $metaKey
15
-        );
16
-        return get_post_meta($postId, '_'.$metaKey, $single);
17
-    }, 10, 4);
6
+	// Unprotected review meta has been deprecated
7
+	add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) {
8
+		$metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults());
9
+		if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) {
10
+			return $data;
11
+		}
12
+		glsr()->deprecated[] = sprintf(
13
+			'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.',
14
+			$metaKey
15
+		);
16
+		return get_post_meta($postId, '_'.$metaKey, $single);
17
+	}, 10, 4);
18 18
 
19
-    // Modules/Html/Template.php
20
-    add_filter('site-reviews/interpolate/reviews', function ($context, $template) {
21
-        $search = '{{ navigation }}';
22
-        if (false !== strpos($template, $search)) {
23
-            $context['navigation'] = $context['pagination'];
24
-            glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.';
25
-        }
26
-        return $context;
27
-    }, 10, 2);
19
+	// Modules/Html/Template.php
20
+	add_filter('site-reviews/interpolate/reviews', function ($context, $template) {
21
+		$search = '{{ navigation }}';
22
+		if (false !== strpos($template, $search)) {
23
+			$context['navigation'] = $context['pagination'];
24
+			glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.';
25
+		}
26
+		return $context;
27
+	}, 10, 2);
28 28
 
29
-    // Database/ReviewManager.php
30
-    add_action('site-reviews/review/created', function ($review) {
31
-        if (has_action('site-reviews/local/review/create')) {
32
-            glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.';
33
-            do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID);
34
-        }
35
-    }, 9);
29
+	// Database/ReviewManager.php
30
+	add_action('site-reviews/review/created', function ($review) {
31
+		if (has_action('site-reviews/local/review/create')) {
32
+			glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.';
33
+			do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID);
34
+		}
35
+	}, 9);
36 36
 
37
-    // Handlers/CreateReview.php
38
-    add_action('site-reviews/review/submitted', function ($review) {
39
-        if (has_action('site-reviews/local/review/submitted')) {
40
-            glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.';
41
-            do_action('site-reviews/local/review/submitted', null, $review);
42
-        }
43
-        if (has_filter('site-reviews/local/review/submitted/message')) {
44
-            glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.';
45
-        }
46
-    }, 9);
37
+	// Handlers/CreateReview.php
38
+	add_action('site-reviews/review/submitted', function ($review) {
39
+		if (has_action('site-reviews/local/review/submitted')) {
40
+			glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.';
41
+			do_action('site-reviews/local/review/submitted', null, $review);
42
+		}
43
+		if (has_filter('site-reviews/local/review/submitted/message')) {
44
+			glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.';
45
+		}
46
+	}, 9);
47 47
 
48
-    // Database/ReviewManager.php
49
-    add_filter('site-reviews/create/review-values', function ($values, $command) {
50
-        if (has_filter('site-reviews/local/review')) {
51
-            glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.';
52
-            return apply_filters('site-reviews/local/review', $values, $command);
53
-        }
54
-        return $values;
55
-    }, 9, 2);
48
+	// Database/ReviewManager.php
49
+	add_filter('site-reviews/create/review-values', function ($values, $command) {
50
+		if (has_filter('site-reviews/local/review')) {
51
+			glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.';
52
+			return apply_filters('site-reviews/local/review', $values, $command);
53
+		}
54
+		return $values;
55
+	}, 9, 2);
56 56
 
57
-    // Handlers/EnqueuePublicAssets.php
58
-    add_filter('site-reviews/enqueue/public/localize', function ($variables) {
59
-        if (has_filter('site-reviews/enqueue/localize')) {
60
-            glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.';
61
-            return apply_filters('site-reviews/enqueue/localize', $variables);
62
-        }
63
-        return $variables;
64
-    }, 9);
57
+	// Handlers/EnqueuePublicAssets.php
58
+	add_filter('site-reviews/enqueue/public/localize', function ($variables) {
59
+		if (has_filter('site-reviews/enqueue/localize')) {
60
+			glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.';
61
+			return apply_filters('site-reviews/enqueue/localize', $variables);
62
+		}
63
+		return $variables;
64
+	}, 9);
65 65
 
66
-    // Modules/Rating.php
67
-    add_filter('site-reviews/rating/average', function ($average) {
68
-        if (has_filter('site-reviews/average/rating')) {
69
-            glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.';
70
-        }
71
-        return $average;
72
-    }, 9);
66
+	// Modules/Rating.php
67
+	add_filter('site-reviews/rating/average', function ($average) {
68
+		if (has_filter('site-reviews/average/rating')) {
69
+			glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.';
70
+		}
71
+		return $average;
72
+	}, 9);
73 73
 
74
-    // Modules/Rating.php
75
-    add_filter('site-reviews/rating/ranking', function ($ranking) {
76
-        if (has_filter('site-reviews/bayesian/ranking')) {
77
-            glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.';
78
-        }
79
-        return $ranking;
80
-    }, 9);
74
+	// Modules/Rating.php
75
+	add_filter('site-reviews/rating/ranking', function ($ranking) {
76
+		if (has_filter('site-reviews/bayesian/ranking')) {
77
+			glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.';
78
+		}
79
+		return $ranking;
80
+	}, 9);
81 81
 
82
-    // Modules/Html/Partials/SiteReviews.php
83
-    add_filter('site-reviews/review/build/after', function ($renderedFields) {
84
-        if (has_filter('site-reviews/reviews/review/text')) {
85
-            glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.';
86
-        }
87
-        if (has_filter('site-reviews/reviews/review/title')) {
88
-            glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.';
89
-        }
90
-        return $renderedFields;
91
-    }, 9);
82
+	// Modules/Html/Partials/SiteReviews.php
83
+	add_filter('site-reviews/review/build/after', function ($renderedFields) {
84
+		if (has_filter('site-reviews/reviews/review/text')) {
85
+			glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.';
86
+		}
87
+		if (has_filter('site-reviews/reviews/review/title')) {
88
+			glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.';
89
+		}
90
+		return $renderedFields;
91
+	}, 9);
92 92
 
93
-    // Modules/Html/Partials/SiteReviews.php
94
-    add_filter('site-reviews/review/build/before', function ($review) {
95
-        if (has_filter('site-reviews/rendered/review')) {
96
-            glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.';
97
-        }
98
-        if (has_filter('site-reviews/rendered/review/meta/order')) {
99
-            glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).';
100
-        }
101
-        if (has_filter('site-reviews/rendered/review/order')) {
102
-            glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).';
103
-        }
104
-        if (has_filter('site-reviews/rendered/review-form/login-register')) {
105
-            glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).';
106
-        }
107
-        if (has_filter('site-reviews/reviews/navigation_links')) {
108
-            glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).';
109
-        }
110
-        return $review;
111
-    }, 9);
93
+	// Modules/Html/Partials/SiteReviews.php
94
+	add_filter('site-reviews/review/build/before', function ($review) {
95
+		if (has_filter('site-reviews/rendered/review')) {
96
+			glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.';
97
+		}
98
+		if (has_filter('site-reviews/rendered/review/meta/order')) {
99
+			glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).';
100
+		}
101
+		if (has_filter('site-reviews/rendered/review/order')) {
102
+			glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).';
103
+		}
104
+		if (has_filter('site-reviews/rendered/review-form/login-register')) {
105
+			glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).';
106
+		}
107
+		if (has_filter('site-reviews/reviews/navigation_links')) {
108
+			glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).';
109
+		}
110
+		return $review;
111
+	}, 9);
112 112
 
113
-    add_filter('site-reviews/validate/custom', function ($result, $request) {
114
-        if (has_filter('site-reviews/validate/review/submission')) {
115
-            glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.');
116
-            return apply_filters('site-reviews/validate/review/submission', $result, $request);
117
-        }
118
-        return $result;
119
-    }, 9, 2);
113
+	add_filter('site-reviews/validate/custom', function ($result, $request) {
114
+		if (has_filter('site-reviews/validate/review/submission')) {
115
+			glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.');
116
+			return apply_filters('site-reviews/validate/review/submission', $result, $request);
117
+		}
118
+		return $result;
119
+	}, 9, 2);
120 120
 
121
-    add_filter('site-reviews/views/file', function ($file, $view, $data) {
122
-        if (has_filter('site-reviews/addon/views/file')) {
123
-            glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.';
124
-            $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data);
125
-        }
126
-        return $file;
127
-    }, 9, 3);
121
+	add_filter('site-reviews/views/file', function ($file, $view, $data) {
122
+		if (has_filter('site-reviews/addon/views/file')) {
123
+			glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.';
124
+			$file = apply_filters('site-reviews/addon/views/file', $file, $view, $data);
125
+		}
126
+		return $file;
127
+	}, 9, 3);
128 128
 }
129 129
 
130 130
 add_action('wp_footer', function () {
131
-    $notices = array_keys(array_flip(glsr()->deprecated));
132
-    natsort($notices);
133
-    foreach ($notices as $notice) {
134
-        glsr_log()->warning($notice);
135
-    }
131
+	$notices = array_keys(array_flip(glsr()->deprecated));
132
+	natsort($notices);
133
+	foreach ($notices as $notice) {
134
+		glsr_log()->warning($notice);
135
+	}
136 136
 });
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,136 +1,136 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WPINC') || die;
3
+defined( 'WPINC' ) || die;
4 4
 
5
-if (apply_filters('site-reviews/support/deprecated/v4', true)) {
5
+if( apply_filters( 'site-reviews/support/deprecated/v4', true ) ) {
6 6
     // Unprotected review meta has been deprecated
7
-    add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) {
8
-        $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults());
9
-        if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) {
7
+    add_filter( 'get_post_metadata', function( $data, $postId, $metaKey, $single ) {
8
+        $metaKeys = array_keys( glsr( 'Defaults\CreateReviewDefaults' )->defaults() );
9
+        if( !in_array( $metaKey, $metaKeys ) || glsr()->post_type != get_post_type( $postId ) ) {
10 10
             return $data;
11 11
         }
12 12
         glsr()->deprecated[] = sprintf(
13 13
             'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.',
14 14
             $metaKey
15 15
         );
16
-        return get_post_meta($postId, '_'.$metaKey, $single);
17
-    }, 10, 4);
16
+        return get_post_meta( $postId, '_'.$metaKey, $single );
17
+    }, 10, 4 );
18 18
 
19 19
     // Modules/Html/Template.php
20
-    add_filter('site-reviews/interpolate/reviews', function ($context, $template) {
20
+    add_filter( 'site-reviews/interpolate/reviews', function( $context, $template ) {
21 21
         $search = '{{ navigation }}';
22
-        if (false !== strpos($template, $search)) {
22
+        if( false !== strpos( $template, $search ) ) {
23 23
             $context['navigation'] = $context['pagination'];
24 24
             glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.';
25 25
         }
26 26
         return $context;
27
-    }, 10, 2);
27
+    }, 10, 2 );
28 28
 
29 29
     // Database/ReviewManager.php
30
-    add_action('site-reviews/review/created', function ($review) {
31
-        if (has_action('site-reviews/local/review/create')) {
30
+    add_action( 'site-reviews/review/created', function( $review ) {
31
+        if( has_action( 'site-reviews/local/review/create' ) ) {
32 32
             glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.';
33
-            do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID);
33
+            do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID );
34 34
         }
35
-    }, 9);
35
+    }, 9 );
36 36
 
37 37
     // Handlers/CreateReview.php
38
-    add_action('site-reviews/review/submitted', function ($review) {
39
-        if (has_action('site-reviews/local/review/submitted')) {
38
+    add_action( 'site-reviews/review/submitted', function( $review ) {
39
+        if( has_action( 'site-reviews/local/review/submitted' ) ) {
40 40
             glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.';
41
-            do_action('site-reviews/local/review/submitted', null, $review);
41
+            do_action( 'site-reviews/local/review/submitted', null, $review );
42 42
         }
43
-        if (has_filter('site-reviews/local/review/submitted/message')) {
43
+        if( has_filter( 'site-reviews/local/review/submitted/message' ) ) {
44 44
             glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.';
45 45
         }
46
-    }, 9);
46
+    }, 9 );
47 47
 
48 48
     // Database/ReviewManager.php
49
-    add_filter('site-reviews/create/review-values', function ($values, $command) {
50
-        if (has_filter('site-reviews/local/review')) {
49
+    add_filter( 'site-reviews/create/review-values', function( $values, $command ) {
50
+        if( has_filter( 'site-reviews/local/review' ) ) {
51 51
             glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.';
52
-            return apply_filters('site-reviews/local/review', $values, $command);
52
+            return apply_filters( 'site-reviews/local/review', $values, $command );
53 53
         }
54 54
         return $values;
55
-    }, 9, 2);
55
+    }, 9, 2 );
56 56
 
57 57
     // Handlers/EnqueuePublicAssets.php
58
-    add_filter('site-reviews/enqueue/public/localize', function ($variables) {
59
-        if (has_filter('site-reviews/enqueue/localize')) {
58
+    add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) {
59
+        if( has_filter( 'site-reviews/enqueue/localize' ) ) {
60 60
             glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.';
61
-            return apply_filters('site-reviews/enqueue/localize', $variables);
61
+            return apply_filters( 'site-reviews/enqueue/localize', $variables );
62 62
         }
63 63
         return $variables;
64
-    }, 9);
64
+    }, 9 );
65 65
 
66 66
     // Modules/Rating.php
67
-    add_filter('site-reviews/rating/average', function ($average) {
68
-        if (has_filter('site-reviews/average/rating')) {
67
+    add_filter( 'site-reviews/rating/average', function( $average ) {
68
+        if( has_filter( 'site-reviews/average/rating' ) ) {
69 69
             glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.';
70 70
         }
71 71
         return $average;
72
-    }, 9);
72
+    }, 9 );
73 73
 
74 74
     // Modules/Rating.php
75
-    add_filter('site-reviews/rating/ranking', function ($ranking) {
76
-        if (has_filter('site-reviews/bayesian/ranking')) {
75
+    add_filter( 'site-reviews/rating/ranking', function( $ranking ) {
76
+        if( has_filter( 'site-reviews/bayesian/ranking' ) ) {
77 77
             glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.';
78 78
         }
79 79
         return $ranking;
80
-    }, 9);
80
+    }, 9 );
81 81
 
82 82
     // Modules/Html/Partials/SiteReviews.php
83
-    add_filter('site-reviews/review/build/after', function ($renderedFields) {
84
-        if (has_filter('site-reviews/reviews/review/text')) {
83
+    add_filter( 'site-reviews/review/build/after', function( $renderedFields ) {
84
+        if( has_filter( 'site-reviews/reviews/review/text' ) ) {
85 85
             glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.';
86 86
         }
87
-        if (has_filter('site-reviews/reviews/review/title')) {
87
+        if( has_filter( 'site-reviews/reviews/review/title' ) ) {
88 88
             glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.';
89 89
         }
90 90
         return $renderedFields;
91
-    }, 9);
91
+    }, 9 );
92 92
 
93 93
     // Modules/Html/Partials/SiteReviews.php
94
-    add_filter('site-reviews/review/build/before', function ($review) {
95
-        if (has_filter('site-reviews/rendered/review')) {
94
+    add_filter( 'site-reviews/review/build/before', function( $review ) {
95
+        if( has_filter( 'site-reviews/rendered/review' ) ) {
96 96
             glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.';
97 97
         }
98
-        if (has_filter('site-reviews/rendered/review/meta/order')) {
98
+        if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) {
99 99
             glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).';
100 100
         }
101
-        if (has_filter('site-reviews/rendered/review/order')) {
101
+        if( has_filter( 'site-reviews/rendered/review/order' ) ) {
102 102
             glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).';
103 103
         }
104
-        if (has_filter('site-reviews/rendered/review-form/login-register')) {
104
+        if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) {
105 105
             glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).';
106 106
         }
107
-        if (has_filter('site-reviews/reviews/navigation_links')) {
107
+        if( has_filter( 'site-reviews/reviews/navigation_links' ) ) {
108 108
             glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).';
109 109
         }
110 110
         return $review;
111
-    }, 9);
111
+    }, 9 );
112 112
 
113
-    add_filter('site-reviews/validate/custom', function ($result, $request) {
114
-        if (has_filter('site-reviews/validate/review/submission')) {
115
-            glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.');
116
-            return apply_filters('site-reviews/validate/review/submission', $result, $request);
113
+    add_filter( 'site-reviews/validate/custom', function( $result, $request ) {
114
+        if( has_filter( 'site-reviews/validate/review/submission' ) ) {
115
+            glsr_log()->warning( 'The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.' );
116
+            return apply_filters( 'site-reviews/validate/review/submission', $result, $request );
117 117
         }
118 118
         return $result;
119
-    }, 9, 2);
119
+    }, 9, 2 );
120 120
 
121
-    add_filter('site-reviews/views/file', function ($file, $view, $data) {
122
-        if (has_filter('site-reviews/addon/views/file')) {
121
+    add_filter( 'site-reviews/views/file', function( $file, $view, $data ) {
122
+        if( has_filter( 'site-reviews/addon/views/file' ) ) {
123 123
             glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.';
124
-            $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data);
124
+            $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data );
125 125
         }
126 126
         return $file;
127
-    }, 9, 3);
127
+    }, 9, 3 );
128 128
 }
129 129
 
130
-add_action('wp_footer', function () {
131
-    $notices = array_keys(array_flip(glsr()->deprecated));
132
-    natsort($notices);
133
-    foreach ($notices as $notice) {
134
-        glsr_log()->warning($notice);
130
+add_action( 'wp_footer', function() {
131
+    $notices = array_keys( array_flip( glsr()->deprecated ) );
132
+    natsort( $notices );
133
+    foreach( $notices as $notice ) {
134
+        glsr_log()->warning( $notice );
135 135
     }
136 136
 });
Please login to merge, or discard this patch.
plugin/Modules/Schema.php 2 patches
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -12,322 +12,322 @@
 block discarded – undo
12 12
 
13 13
 class Schema
14 14
 {
15
-    /**
16
-     * @var array
17
-     */
18
-    protected $args;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	protected $args;
19 19
 
20
-    /**
21
-     * @var array
22
-     */
23
-    protected $keyValues = [];
20
+	/**
21
+	 * @var array
22
+	 */
23
+	protected $keyValues = [];
24 24
 
25
-    /**
26
-     * @var array
27
-     */
28
-    protected $ratingCounts;
25
+	/**
26
+	 * @var array
27
+	 */
28
+	protected $ratingCounts;
29 29
 
30
-    /**
31
-     * @return array
32
-     */
33
-    public function build(array $args = [])
34
-    {
35
-        $this->args = $args;
36
-        $schema = $this->buildSummary($args);
37
-        $reviews = [];
38
-        foreach (glsr(ReviewManager::class)->get($this->args) as $review) {
39
-            // Only include critic reviews that have been directly produced by your site, not reviews from third-party sites or syndicated reviews.
40
-            // @see https://developers.google.com/search/docs/data-types/review
41
-            if ('local' != $review->review_type) {
42
-                continue;
43
-            }
44
-            $reviews[] = $this->buildReview($review);
45
-        }
46
-        if (!empty($reviews)) {
47
-            array_walk($reviews, function (&$review) {
48
-                unset($review['@context']);
49
-                unset($review['itemReviewed']);
50
-            });
51
-            $schema['review'] = $reviews;
52
-        }
53
-        return $schema;
54
-    }
30
+	/**
31
+	 * @return array
32
+	 */
33
+	public function build(array $args = [])
34
+	{
35
+		$this->args = $args;
36
+		$schema = $this->buildSummary($args);
37
+		$reviews = [];
38
+		foreach (glsr(ReviewManager::class)->get($this->args) as $review) {
39
+			// Only include critic reviews that have been directly produced by your site, not reviews from third-party sites or syndicated reviews.
40
+			// @see https://developers.google.com/search/docs/data-types/review
41
+			if ('local' != $review->review_type) {
42
+				continue;
43
+			}
44
+			$reviews[] = $this->buildReview($review);
45
+		}
46
+		if (!empty($reviews)) {
47
+			array_walk($reviews, function (&$review) {
48
+				unset($review['@context']);
49
+				unset($review['itemReviewed']);
50
+			});
51
+			$schema['review'] = $reviews;
52
+		}
53
+		return $schema;
54
+	}
55 55
 
56
-    /**
57
-     * @param array|null $args
58
-     * @return array
59
-     */
60
-    public function buildSummary($args = null)
61
-    {
62
-        if (is_array($args)) {
63
-            $this->args = $args;
64
-        }
65
-        $buildSummary = Helper::buildMethodName($this->getSchemaOptionValue('type'), 'buildSummaryFor');
66
-        $count = array_sum($this->getRatingCounts());
67
-        $schema = method_exists($this, $buildSummary)
68
-            ? $this->$buildSummary()
69
-            : $this->buildSummaryForCustom();
70
-        if (!empty($count)) {
71
-            $schema->aggregateRating(
72
-                $this->getSchemaType('AggregateRating')
73
-                    ->ratingValue($this->getRatingValue())
74
-                    ->reviewCount($count)
75
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
76
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
77
-            );
78
-        }
79
-        $schema = $schema->toArray();
80
-        return apply_filters('site-reviews/schema/'.$schema['@type'], $schema, $args);
81
-    }
56
+	/**
57
+	 * @param array|null $args
58
+	 * @return array
59
+	 */
60
+	public function buildSummary($args = null)
61
+	{
62
+		if (is_array($args)) {
63
+			$this->args = $args;
64
+		}
65
+		$buildSummary = Helper::buildMethodName($this->getSchemaOptionValue('type'), 'buildSummaryFor');
66
+		$count = array_sum($this->getRatingCounts());
67
+		$schema = method_exists($this, $buildSummary)
68
+			? $this->$buildSummary()
69
+			: $this->buildSummaryForCustom();
70
+		if (!empty($count)) {
71
+			$schema->aggregateRating(
72
+				$this->getSchemaType('AggregateRating')
73
+					->ratingValue($this->getRatingValue())
74
+					->reviewCount($count)
75
+					->bestRating(glsr()->constant('MAX_RATING', Rating::class))
76
+					->worstRating(glsr()->constant('MIN_RATING', Rating::class))
77
+			);
78
+		}
79
+		$schema = $schema->toArray();
80
+		return apply_filters('site-reviews/schema/'.$schema['@type'], $schema, $args);
81
+	}
82 82
 
83
-    /**
84
-     * @return void
85
-     */
86
-    public function render()
87
-    {
88
-        if (empty(glsr()->schemas)) {
89
-            return;
90
-        }
91
-        printf('<script type="application/ld+json">%s</script>', json_encode(
92
-            apply_filters('site-reviews/schema/all', glsr()->schemas),
93
-            JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
94
-        ));
95
-    }
83
+	/**
84
+	 * @return void
85
+	 */
86
+	public function render()
87
+	{
88
+		if (empty(glsr()->schemas)) {
89
+			return;
90
+		}
91
+		printf('<script type="application/ld+json">%s</script>', json_encode(
92
+			apply_filters('site-reviews/schema/all', glsr()->schemas),
93
+			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
94
+		));
95
+	}
96 96
 
97
-    /**
98
-     * @return void
99
-     */
100
-    public function store(array $schema)
101
-    {
102
-        $schemas = glsr()->schemas;
103
-        $schemas[] = $schema;
104
-        glsr()->schemas = array_map('unserialize', array_unique(array_map('serialize', $schemas)));
105
-    }
97
+	/**
98
+	 * @return void
99
+	 */
100
+	public function store(array $schema)
101
+	{
102
+		$schemas = glsr()->schemas;
103
+		$schemas[] = $schema;
104
+		glsr()->schemas = array_map('unserialize', array_unique(array_map('serialize', $schemas)));
105
+	}
106 106
 
107
-    /**
108
-     * @param Review $review
109
-     * @return array
110
-     */
111
-    protected function buildReview($review)
112
-    {
113
-        $schema = $this->getSchemaType('Review')
114
-            ->doIf(!in_array('title', $this->args['hide']), function ($schema) use ($review) {
115
-                $schema->name($review->title);
116
-            })
117
-            ->doIf(!in_array('excerpt', $this->args['hide']), function ($schema) use ($review) {
118
-                $schema->reviewBody($review->content);
119
-            })
120
-            ->datePublished((new DateTime($review->date)))
121
-            ->author($this->getSchemaType('Person')->name($review->author))
122
-            ->itemReviewed($this->getSchemaType()->name($this->getSchemaOptionValue('name')));
123
-        if (!empty($review->rating)) {
124
-            $schema->reviewRating(
125
-                $this->getSchemaType('Rating')
126
-                    ->ratingValue($review->rating)
127
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
128
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
129
-            );
130
-        }
131
-        return apply_filters('site-reviews/schema/review', $schema->toArray(), $review, $this->args);
132
-    }
107
+	/**
108
+	 * @param Review $review
109
+	 * @return array
110
+	 */
111
+	protected function buildReview($review)
112
+	{
113
+		$schema = $this->getSchemaType('Review')
114
+			->doIf(!in_array('title', $this->args['hide']), function ($schema) use ($review) {
115
+				$schema->name($review->title);
116
+			})
117
+			->doIf(!in_array('excerpt', $this->args['hide']), function ($schema) use ($review) {
118
+				$schema->reviewBody($review->content);
119
+			})
120
+			->datePublished((new DateTime($review->date)))
121
+			->author($this->getSchemaType('Person')->name($review->author))
122
+			->itemReviewed($this->getSchemaType()->name($this->getSchemaOptionValue('name')));
123
+		if (!empty($review->rating)) {
124
+			$schema->reviewRating(
125
+				$this->getSchemaType('Rating')
126
+					->ratingValue($review->rating)
127
+					->bestRating(glsr()->constant('MAX_RATING', Rating::class))
128
+					->worstRating(glsr()->constant('MIN_RATING', Rating::class))
129
+			);
130
+		}
131
+		return apply_filters('site-reviews/schema/review', $schema->toArray(), $review, $this->args);
132
+	}
133 133
 
134
-    /**
135
-     * @param mixed $schema
136
-     * @return mixed
137
-     */
138
-    protected function buildSchemaValues($schema, array $values = [])
139
-    {
140
-        foreach ($values as $value) {
141
-            $option = $this->getSchemaOptionValue($value);
142
-            if (empty($option)) {
143
-                continue;
144
-            }
145
-            $schema->$value($option);
146
-        }
147
-        return $schema;
148
-    }
134
+	/**
135
+	 * @param mixed $schema
136
+	 * @return mixed
137
+	 */
138
+	protected function buildSchemaValues($schema, array $values = [])
139
+	{
140
+		foreach ($values as $value) {
141
+			$option = $this->getSchemaOptionValue($value);
142
+			if (empty($option)) {
143
+				continue;
144
+			}
145
+			$schema->$value($option);
146
+		}
147
+		return $schema;
148
+	}
149 149
 
150
-    /**
151
-     * @return mixed
152
-     */
153
-    protected function buildSummaryForCustom()
154
-    {
155
-        return $this->buildSchemaValues($this->getSchemaType(), [
156
-            'description', 'image', 'name', 'url',
157
-        ]);
158
-    }
150
+	/**
151
+	 * @return mixed
152
+	 */
153
+	protected function buildSummaryForCustom()
154
+	{
155
+		return $this->buildSchemaValues($this->getSchemaType(), [
156
+			'description', 'image', 'name', 'url',
157
+		]);
158
+	}
159 159
 
160
-    /**
161
-     * @return mixed
162
-     */
163
-    protected function buildSummaryForLocalBusiness()
164
-    {
165
-        return $this->buildSchemaValues($this->buildSummaryForCustom(), [
166
-            'address', 'priceRange', 'telephone',
167
-        ]);
168
-    }
160
+	/**
161
+	 * @return mixed
162
+	 */
163
+	protected function buildSummaryForLocalBusiness()
164
+	{
165
+		return $this->buildSchemaValues($this->buildSummaryForCustom(), [
166
+			'address', 'priceRange', 'telephone',
167
+		]);
168
+	}
169 169
 
170
-    /**
171
-     * @return mixed
172
-     */
173
-    protected function buildSummaryForProduct()
174
-    {
175
-        $offerType = $this->getSchemaOption('offerType', 'AggregateOffer');
176
-        $offers = $this->buildSchemaValues($this->getSchemaType($offerType), [
177
-            'highPrice', 'lowPrice', 'price', 'priceCurrency',
178
-        ]);
179
-        return $this->buildSummaryForCustom()
180
-            ->doIf(!empty($offers->getProperties()), function ($schema) use ($offers) {
181
-                $schema->offers($offers);
182
-            })
183
-            ->setProperty('@id', $this->getSchemaOptionValue('url').'#product');
184
-    }
170
+	/**
171
+	 * @return mixed
172
+	 */
173
+	protected function buildSummaryForProduct()
174
+	{
175
+		$offerType = $this->getSchemaOption('offerType', 'AggregateOffer');
176
+		$offers = $this->buildSchemaValues($this->getSchemaType($offerType), [
177
+			'highPrice', 'lowPrice', 'price', 'priceCurrency',
178
+		]);
179
+		return $this->buildSummaryForCustom()
180
+			->doIf(!empty($offers->getProperties()), function ($schema) use ($offers) {
181
+				$schema->offers($offers);
182
+			})
183
+			->setProperty('@id', $this->getSchemaOptionValue('url').'#product');
184
+	}
185 185
 
186
-    /**
187
-     * @return array
188
-     */
189
-    protected function getRatingCounts()
190
-    {
191
-        if (!isset($this->ratingCounts)) {
192
-            $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($this->args);
193
-        }
194
-        return $this->ratingCounts;
195
-    }
186
+	/**
187
+	 * @return array
188
+	 */
189
+	protected function getRatingCounts()
190
+	{
191
+		if (!isset($this->ratingCounts)) {
192
+			$this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($this->args);
193
+		}
194
+		return $this->ratingCounts;
195
+	}
196 196
 
197
-    /**
198
-     * @return int|float
199
-     */
200
-    protected function getRatingValue()
201
-    {
202
-        return glsr(Rating::class)->getAverage($this->getRatingCounts());
203
-    }
197
+	/**
198
+	 * @return int|float
199
+	 */
200
+	protected function getRatingValue()
201
+	{
202
+		return glsr(Rating::class)->getAverage($this->getRatingCounts());
203
+	}
204 204
 
205
-    /**
206
-     * @param string $option
207
-     * @param string $fallback
208
-     * @return string
209
-     */
210
-    protected function getSchemaOption($option, $fallback)
211
-    {
212
-        $option = strtolower($option);
213
-        if ($schemaOption = trim((string) get_post_meta(intval(get_the_ID()), 'schema_'.$option, true))) {
214
-            return $schemaOption;
215
-        }
216
-        $setting = glsr(OptionManager::class)->get('settings.schema.'.$option);
217
-        if (is_array($setting)) {
218
-            return $this->getSchemaOptionDefault($setting, $fallback);
219
-        }
220
-        return !empty($setting)
221
-            ? $setting
222
-            : $fallback;
223
-    }
205
+	/**
206
+	 * @param string $option
207
+	 * @param string $fallback
208
+	 * @return string
209
+	 */
210
+	protected function getSchemaOption($option, $fallback)
211
+	{
212
+		$option = strtolower($option);
213
+		if ($schemaOption = trim((string) get_post_meta(intval(get_the_ID()), 'schema_'.$option, true))) {
214
+			return $schemaOption;
215
+		}
216
+		$setting = glsr(OptionManager::class)->get('settings.schema.'.$option);
217
+		if (is_array($setting)) {
218
+			return $this->getSchemaOptionDefault($setting, $fallback);
219
+		}
220
+		return !empty($setting)
221
+			? $setting
222
+			: $fallback;
223
+	}
224 224
 
225
-    /**
226
-     * @param string $fallback
227
-     * @return string
228
-     */
229
-    protected function getSchemaOptionDefault(array $setting, $fallback)
230
-    {
231
-        $setting = wp_parse_args($setting, [
232
-            'custom' => '',
233
-            'default' => $fallback,
234
-        ]);
235
-        return 'custom' != $setting['default']
236
-            ? $setting['default']
237
-            : $setting['custom'];
238
-    }
225
+	/**
226
+	 * @param string $fallback
227
+	 * @return string
228
+	 */
229
+	protected function getSchemaOptionDefault(array $setting, $fallback)
230
+	{
231
+		$setting = wp_parse_args($setting, [
232
+			'custom' => '',
233
+			'default' => $fallback,
234
+		]);
235
+		return 'custom' != $setting['default']
236
+			? $setting['default']
237
+			: $setting['custom'];
238
+	}
239 239
 
240
-    /**
241
-     * @param string $option
242
-     * @param string $fallback
243
-     * @return void|string
244
-     */
245
-    protected function getSchemaOptionValue($option, $fallback = 'post')
246
-    {
247
-        if (array_key_exists($option, $this->keyValues)) {
248
-            return $this->keyValues[$option];
249
-        }
250
-        $value = $this->getSchemaOption($option, $fallback);
251
-        if ($value != $fallback) {
252
-            return $this->setAndGetKeyValue($option, $value);
253
-        }
254
-        if (!is_single() && !is_page()) {
255
-            return;
256
-        }
257
-        $method = Helper::buildMethodName($option, 'getThing');
258
-        if (method_exists($this, $method)) {
259
-            return $this->setAndGetKeyValue($option, $this->$method());
260
-        }
261
-    }
240
+	/**
241
+	 * @param string $option
242
+	 * @param string $fallback
243
+	 * @return void|string
244
+	 */
245
+	protected function getSchemaOptionValue($option, $fallback = 'post')
246
+	{
247
+		if (array_key_exists($option, $this->keyValues)) {
248
+			return $this->keyValues[$option];
249
+		}
250
+		$value = $this->getSchemaOption($option, $fallback);
251
+		if ($value != $fallback) {
252
+			return $this->setAndGetKeyValue($option, $value);
253
+		}
254
+		if (!is_single() && !is_page()) {
255
+			return;
256
+		}
257
+		$method = Helper::buildMethodName($option, 'getThing');
258
+		if (method_exists($this, $method)) {
259
+			return $this->setAndGetKeyValue($option, $this->$method());
260
+		}
261
+	}
262 262
 
263
-    /**
264
-     * @param string|null $type
265
-     * @return mixed
266
-     */
267
-    protected function getSchemaType($type = null)
268
-    {
269
-        if (!is_string($type)) {
270
-            $type = $this->getSchemaOption('type', 'LocalBusiness');
271
-        }
272
-        $className = Helper::buildClassName($type, 'Modules\Schema');
273
-        return class_exists($className)
274
-            ? new $className()
275
-            : new UnknownType($type);
276
-    }
263
+	/**
264
+	 * @param string|null $type
265
+	 * @return mixed
266
+	 */
267
+	protected function getSchemaType($type = null)
268
+	{
269
+		if (!is_string($type)) {
270
+			$type = $this->getSchemaOption('type', 'LocalBusiness');
271
+		}
272
+		$className = Helper::buildClassName($type, 'Modules\Schema');
273
+		return class_exists($className)
274
+			? new $className()
275
+			: new UnknownType($type);
276
+	}
277 277
 
278
-    /**
279
-     * @return string
280
-     */
281
-    protected function getThingDescription()
282
-    {
283
-        $post = get_post();
284
-        $text = Arr::get($post, 'post_excerpt');
285
-        if (empty($text)) {
286
-            $text = Arr::get($post, 'post_content');
287
-        }
288
-        if (function_exists('excerpt_remove_blocks')) {
289
-            $text = excerpt_remove_blocks($text);
290
-        }
291
-        $text = strip_shortcodes($text);
292
-        $text = wpautop($text);
293
-        $text = wptexturize($text);
294
-        $text = wp_strip_all_tags($text);
295
-        $text = str_replace(']]>', ']]&gt;', $text);
296
-        return wp_trim_words($text, apply_filters('excerpt_length', 55));
297
-    }
278
+	/**
279
+	 * @return string
280
+	 */
281
+	protected function getThingDescription()
282
+	{
283
+		$post = get_post();
284
+		$text = Arr::get($post, 'post_excerpt');
285
+		if (empty($text)) {
286
+			$text = Arr::get($post, 'post_content');
287
+		}
288
+		if (function_exists('excerpt_remove_blocks')) {
289
+			$text = excerpt_remove_blocks($text);
290
+		}
291
+		$text = strip_shortcodes($text);
292
+		$text = wpautop($text);
293
+		$text = wptexturize($text);
294
+		$text = wp_strip_all_tags($text);
295
+		$text = str_replace(']]>', ']]&gt;', $text);
296
+		return wp_trim_words($text, apply_filters('excerpt_length', 55));
297
+	}
298 298
 
299
-    /**
300
-     * @return string
301
-     */
302
-    protected function getThingImage()
303
-    {
304
-        return (string) get_the_post_thumbnail_url(null, 'large');
305
-    }
299
+	/**
300
+	 * @return string
301
+	 */
302
+	protected function getThingImage()
303
+	{
304
+		return (string) get_the_post_thumbnail_url(null, 'large');
305
+	}
306 306
 
307
-    /**
308
-     * @return string
309
-     */
310
-    protected function getThingName()
311
-    {
312
-        return get_the_title();
313
-    }
307
+	/**
308
+	 * @return string
309
+	 */
310
+	protected function getThingName()
311
+	{
312
+		return get_the_title();
313
+	}
314 314
 
315
-    /**
316
-     * @return string
317
-     */
318
-    protected function getThingUrl()
319
-    {
320
-        return (string) get_the_permalink();
321
-    }
315
+	/**
316
+	 * @return string
317
+	 */
318
+	protected function getThingUrl()
319
+	{
320
+		return (string) get_the_permalink();
321
+	}
322 322
 
323
-    /**
324
-     * @param string $option
325
-     * @param string $value
326
-     * @return string
327
-     */
328
-    protected function setAndGetKeyValue($option, $value)
329
-    {
330
-        $this->keyValues[$option] = $value;
331
-        return $value;
332
-    }
323
+	/**
324
+	 * @param string $option
325
+	 * @param string $value
326
+	 * @return string
327
+	 */
328
+	protected function setAndGetKeyValue($option, $value)
329
+	{
330
+		$this->keyValues[$option] = $value;
331
+		return $value;
332
+	}
333 333
 }
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -30,21 +30,21 @@  discard block
 block discarded – undo
30 30
     /**
31 31
      * @return array
32 32
      */
33
-    public function build(array $args = [])
33
+    public function build( array $args = [] )
34 34
     {
35 35
         $this->args = $args;
36
-        $schema = $this->buildSummary($args);
36
+        $schema = $this->buildSummary( $args );
37 37
         $reviews = [];
38
-        foreach (glsr(ReviewManager::class)->get($this->args) as $review) {
38
+        foreach( glsr( ReviewManager::class )->get( $this->args ) as $review ) {
39 39
             // Only include critic reviews that have been directly produced by your site, not reviews from third-party sites or syndicated reviews.
40 40
             // @see https://developers.google.com/search/docs/data-types/review
41
-            if ('local' != $review->review_type) {
41
+            if( 'local' != $review->review_type ) {
42 42
                 continue;
43 43
             }
44
-            $reviews[] = $this->buildReview($review);
44
+            $reviews[] = $this->buildReview( $review );
45 45
         }
46
-        if (!empty($reviews)) {
47
-            array_walk($reviews, function (&$review) {
46
+        if( !empty($reviews) ) {
47
+            array_walk( $reviews, function( &$review ) {
48 48
                 unset($review['@context']);
49 49
                 unset($review['itemReviewed']);
50 50
             });
@@ -57,27 +57,27 @@  discard block
 block discarded – undo
57 57
      * @param array|null $args
58 58
      * @return array
59 59
      */
60
-    public function buildSummary($args = null)
60
+    public function buildSummary( $args = null )
61 61
     {
62
-        if (is_array($args)) {
62
+        if( is_array( $args ) ) {
63 63
             $this->args = $args;
64 64
         }
65
-        $buildSummary = Helper::buildMethodName($this->getSchemaOptionValue('type'), 'buildSummaryFor');
66
-        $count = array_sum($this->getRatingCounts());
67
-        $schema = method_exists($this, $buildSummary)
65
+        $buildSummary = Helper::buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' );
66
+        $count = array_sum( $this->getRatingCounts() );
67
+        $schema = method_exists( $this, $buildSummary )
68 68
             ? $this->$buildSummary()
69 69
             : $this->buildSummaryForCustom();
70
-        if (!empty($count)) {
70
+        if( !empty($count) ) {
71 71
             $schema->aggregateRating(
72
-                $this->getSchemaType('AggregateRating')
73
-                    ->ratingValue($this->getRatingValue())
74
-                    ->reviewCount($count)
75
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
76
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
72
+                $this->getSchemaType( 'AggregateRating' )
73
+                    ->ratingValue( $this->getRatingValue() )
74
+                    ->reviewCount( $count )
75
+                    ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) )
76
+                    ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) )
77 77
             );
78 78
         }
79 79
         $schema = $schema->toArray();
80
-        return apply_filters('site-reviews/schema/'.$schema['@type'], $schema, $args);
80
+        return apply_filters( 'site-reviews/schema/'.$schema['@type'], $schema, $args );
81 81
     }
82 82
 
83 83
     /**
@@ -85,64 +85,64 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function render()
87 87
     {
88
-        if (empty(glsr()->schemas)) {
88
+        if( empty(glsr()->schemas) ) {
89 89
             return;
90 90
         }
91
-        printf('<script type="application/ld+json">%s</script>', json_encode(
92
-            apply_filters('site-reviews/schema/all', glsr()->schemas),
91
+        printf( '<script type="application/ld+json">%s</script>', json_encode(
92
+            apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
93 93
             JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
94
-        ));
94
+        ) );
95 95
     }
96 96
 
97 97
     /**
98 98
      * @return void
99 99
      */
100
-    public function store(array $schema)
100
+    public function store( array $schema )
101 101
     {
102 102
         $schemas = glsr()->schemas;
103 103
         $schemas[] = $schema;
104
-        glsr()->schemas = array_map('unserialize', array_unique(array_map('serialize', $schemas)));
104
+        glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) );
105 105
     }
106 106
 
107 107
     /**
108 108
      * @param Review $review
109 109
      * @return array
110 110
      */
111
-    protected function buildReview($review)
111
+    protected function buildReview( $review )
112 112
     {
113
-        $schema = $this->getSchemaType('Review')
114
-            ->doIf(!in_array('title', $this->args['hide']), function ($schema) use ($review) {
115
-                $schema->name($review->title);
113
+        $schema = $this->getSchemaType( 'Review' )
114
+            ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use ($review) {
115
+                $schema->name( $review->title );
116 116
             })
117
-            ->doIf(!in_array('excerpt', $this->args['hide']), function ($schema) use ($review) {
118
-                $schema->reviewBody($review->content);
117
+            ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use ($review) {
118
+                $schema->reviewBody( $review->content );
119 119
             })
120
-            ->datePublished((new DateTime($review->date)))
121
-            ->author($this->getSchemaType('Person')->name($review->author))
122
-            ->itemReviewed($this->getSchemaType()->name($this->getSchemaOptionValue('name')));
123
-        if (!empty($review->rating)) {
120
+            ->datePublished( (new DateTime( $review->date )) )
121
+            ->author( $this->getSchemaType( 'Person' )->name( $review->author ) )
122
+            ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) );
123
+        if( !empty($review->rating) ) {
124 124
             $schema->reviewRating(
125
-                $this->getSchemaType('Rating')
126
-                    ->ratingValue($review->rating)
127
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
128
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
125
+                $this->getSchemaType( 'Rating' )
126
+                    ->ratingValue( $review->rating )
127
+                    ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) )
128
+                    ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) )
129 129
             );
130 130
         }
131
-        return apply_filters('site-reviews/schema/review', $schema->toArray(), $review, $this->args);
131
+        return apply_filters( 'site-reviews/schema/review', $schema->toArray(), $review, $this->args );
132 132
     }
133 133
 
134 134
     /**
135 135
      * @param mixed $schema
136 136
      * @return mixed
137 137
      */
138
-    protected function buildSchemaValues($schema, array $values = [])
138
+    protected function buildSchemaValues( $schema, array $values = [] )
139 139
     {
140
-        foreach ($values as $value) {
141
-            $option = $this->getSchemaOptionValue($value);
142
-            if (empty($option)) {
140
+        foreach( $values as $value ) {
141
+            $option = $this->getSchemaOptionValue( $value );
142
+            if( empty($option) ) {
143 143
                 continue;
144 144
             }
145
-            $schema->$value($option);
145
+            $schema->$value( $option );
146 146
         }
147 147
         return $schema;
148 148
     }
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
      */
153 153
     protected function buildSummaryForCustom()
154 154
     {
155
-        return $this->buildSchemaValues($this->getSchemaType(), [
155
+        return $this->buildSchemaValues( $this->getSchemaType(), [
156 156
             'description', 'image', 'name', 'url',
157
-        ]);
157
+        ] );
158 158
     }
159 159
 
160 160
     /**
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
      */
163 163
     protected function buildSummaryForLocalBusiness()
164 164
     {
165
-        return $this->buildSchemaValues($this->buildSummaryForCustom(), [
165
+        return $this->buildSchemaValues( $this->buildSummaryForCustom(), [
166 166
             'address', 'priceRange', 'telephone',
167
-        ]);
167
+        ] );
168 168
     }
169 169
 
170 170
     /**
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
      */
173 173
     protected function buildSummaryForProduct()
174 174
     {
175
-        $offerType = $this->getSchemaOption('offerType', 'AggregateOffer');
176
-        $offers = $this->buildSchemaValues($this->getSchemaType($offerType), [
175
+        $offerType = $this->getSchemaOption( 'offerType', 'AggregateOffer' );
176
+        $offers = $this->buildSchemaValues( $this->getSchemaType( $offerType ), [
177 177
             'highPrice', 'lowPrice', 'price', 'priceCurrency',
178
-        ]);
178
+        ] );
179 179
         return $this->buildSummaryForCustom()
180
-            ->doIf(!empty($offers->getProperties()), function ($schema) use ($offers) {
181
-                $schema->offers($offers);
180
+            ->doIf( !empty($offers->getProperties()), function( $schema ) use ($offers) {
181
+                $schema->offers( $offers );
182 182
             })
183
-            ->setProperty('@id', $this->getSchemaOptionValue('url').'#product');
183
+            ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' );
184 184
     }
185 185
 
186 186
     /**
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
      */
189 189
     protected function getRatingCounts()
190 190
     {
191
-        if (!isset($this->ratingCounts)) {
192
-            $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($this->args);
191
+        if( !isset($this->ratingCounts) ) {
192
+            $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args );
193 193
         }
194 194
         return $this->ratingCounts;
195 195
     }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      */
200 200
     protected function getRatingValue()
201 201
     {
202
-        return glsr(Rating::class)->getAverage($this->getRatingCounts());
202
+        return glsr( Rating::class )->getAverage( $this->getRatingCounts() );
203 203
     }
204 204
 
205 205
     /**
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
      * @param string $fallback
208 208
      * @return string
209 209
      */
210
-    protected function getSchemaOption($option, $fallback)
210
+    protected function getSchemaOption( $option, $fallback )
211 211
     {
212
-        $option = strtolower($option);
213
-        if ($schemaOption = trim((string) get_post_meta(intval(get_the_ID()), 'schema_'.$option, true))) {
212
+        $option = strtolower( $option );
213
+        if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) {
214 214
             return $schemaOption;
215 215
         }
216
-        $setting = glsr(OptionManager::class)->get('settings.schema.'.$option);
217
-        if (is_array($setting)) {
218
-            return $this->getSchemaOptionDefault($setting, $fallback);
216
+        $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option );
217
+        if( is_array( $setting ) ) {
218
+            return $this->getSchemaOptionDefault( $setting, $fallback );
219 219
         }
220 220
         return !empty($setting)
221 221
             ? $setting
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
      * @param string $fallback
227 227
      * @return string
228 228
      */
229
-    protected function getSchemaOptionDefault(array $setting, $fallback)
229
+    protected function getSchemaOptionDefault( array $setting, $fallback )
230 230
     {
231
-        $setting = wp_parse_args($setting, [
231
+        $setting = wp_parse_args( $setting, [
232 232
             'custom' => '',
233 233
             'default' => $fallback,
234
-        ]);
234
+        ] );
235 235
         return 'custom' != $setting['default']
236 236
             ? $setting['default']
237 237
             : $setting['custom'];
@@ -242,21 +242,21 @@  discard block
 block discarded – undo
242 242
      * @param string $fallback
243 243
      * @return void|string
244 244
      */
245
-    protected function getSchemaOptionValue($option, $fallback = 'post')
245
+    protected function getSchemaOptionValue( $option, $fallback = 'post' )
246 246
     {
247
-        if (array_key_exists($option, $this->keyValues)) {
247
+        if( array_key_exists( $option, $this->keyValues ) ) {
248 248
             return $this->keyValues[$option];
249 249
         }
250
-        $value = $this->getSchemaOption($option, $fallback);
251
-        if ($value != $fallback) {
252
-            return $this->setAndGetKeyValue($option, $value);
250
+        $value = $this->getSchemaOption( $option, $fallback );
251
+        if( $value != $fallback ) {
252
+            return $this->setAndGetKeyValue( $option, $value );
253 253
         }
254
-        if (!is_single() && !is_page()) {
254
+        if( !is_single() && !is_page() ) {
255 255
             return;
256 256
         }
257
-        $method = Helper::buildMethodName($option, 'getThing');
258
-        if (method_exists($this, $method)) {
259
-            return $this->setAndGetKeyValue($option, $this->$method());
257
+        $method = Helper::buildMethodName( $option, 'getThing' );
258
+        if( method_exists( $this, $method ) ) {
259
+            return $this->setAndGetKeyValue( $option, $this->$method() );
260 260
         }
261 261
     }
262 262
 
@@ -264,15 +264,15 @@  discard block
 block discarded – undo
264 264
      * @param string|null $type
265 265
      * @return mixed
266 266
      */
267
-    protected function getSchemaType($type = null)
267
+    protected function getSchemaType( $type = null )
268 268
     {
269
-        if (!is_string($type)) {
270
-            $type = $this->getSchemaOption('type', 'LocalBusiness');
269
+        if( !is_string( $type ) ) {
270
+            $type = $this->getSchemaOption( 'type', 'LocalBusiness' );
271 271
         }
272
-        $className = Helper::buildClassName($type, 'Modules\Schema');
273
-        return class_exists($className)
272
+        $className = Helper::buildClassName( $type, 'Modules\Schema' );
273
+        return class_exists( $className )
274 274
             ? new $className()
275
-            : new UnknownType($type);
275
+            : new UnknownType( $type );
276 276
     }
277 277
 
278 278
     /**
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
     protected function getThingDescription()
282 282
     {
283 283
         $post = get_post();
284
-        $text = Arr::get($post, 'post_excerpt');
285
-        if (empty($text)) {
286
-            $text = Arr::get($post, 'post_content');
284
+        $text = Arr::get( $post, 'post_excerpt' );
285
+        if( empty($text) ) {
286
+            $text = Arr::get( $post, 'post_content' );
287 287
         }
288
-        if (function_exists('excerpt_remove_blocks')) {
289
-            $text = excerpt_remove_blocks($text);
288
+        if( function_exists( 'excerpt_remove_blocks' ) ) {
289
+            $text = excerpt_remove_blocks( $text );
290 290
         }
291
-        $text = strip_shortcodes($text);
292
-        $text = wpautop($text);
293
-        $text = wptexturize($text);
294
-        $text = wp_strip_all_tags($text);
295
-        $text = str_replace(']]>', ']]&gt;', $text);
296
-        return wp_trim_words($text, apply_filters('excerpt_length', 55));
291
+        $text = strip_shortcodes( $text );
292
+        $text = wpautop( $text );
293
+        $text = wptexturize( $text );
294
+        $text = wp_strip_all_tags( $text );
295
+        $text = str_replace( ']]>', ']]&gt;', $text );
296
+        return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) );
297 297
     }
298 298
 
299 299
     /**
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
      */
302 302
     protected function getThingImage()
303 303
     {
304
-        return (string) get_the_post_thumbnail_url(null, 'large');
304
+        return (string)get_the_post_thumbnail_url( null, 'large' );
305 305
     }
306 306
 
307 307
     /**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
      */
318 318
     protected function getThingUrl()
319 319
     {
320
-        return (string) get_the_permalink();
320
+        return (string)get_the_permalink();
321 321
     }
322 322
 
323 323
     /**
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      * @param string $value
326 326
      * @return string
327 327
      */
328
-    protected function setAndGetKeyValue($option, $value)
328
+    protected function setAndGetKeyValue( $option, $value )
329 329
     {
330 330
         $this->keyValues[$option] = $value;
331 331
         return $value;
Please login to merge, or discard this patch.
plugin/Handlers/EnqueuePublicAssets.php 2 patches
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -9,148 +9,148 @@
 block discarded – undo
9 9
 
10 10
 class EnqueuePublicAssets
11 11
 {
12
-    /**
13
-     * @return void
14
-     */
15
-    public function handle()
16
-    {
17
-        $this->enqueueAssets();
18
-        $this->enqueuePolyfillService();
19
-        $this->enqueueRecaptchaScript();
20
-        $this->inlineScript();
21
-        $this->inlineStyles();
22
-    }
12
+	/**
13
+	 * @return void
14
+	 */
15
+	public function handle()
16
+	{
17
+		$this->enqueueAssets();
18
+		$this->enqueuePolyfillService();
19
+		$this->enqueueRecaptchaScript();
20
+		$this->inlineScript();
21
+		$this->inlineStyles();
22
+	}
23 23
 
24
-    /**
25
-     * @return void
26
-     */
27
-    public function enqueueAssets()
28
-    {
29
-        if (apply_filters('site-reviews/assets/css', true)) {
30
-            wp_enqueue_style(
31
-                Application::ID,
32
-                $this->getStylesheet(),
33
-                [],
34
-                glsr()->version
35
-            );
36
-        }
37
-        if (apply_filters('site-reviews/assets/js', true)) {
38
-            $dependencies = apply_filters('site-reviews/assets/polyfill', true)
39
-                ? [Application::ID.'/polyfill']
40
-                : [];
41
-            $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies);
42
-            wp_enqueue_script(
43
-                Application::ID,
44
-                glsr()->url('assets/scripts/'.Application::ID.'.js'),
45
-                $dependencies,
46
-                glsr()->version,
47
-                true
48
-            );
49
-        }
50
-    }
24
+	/**
25
+	 * @return void
26
+	 */
27
+	public function enqueueAssets()
28
+	{
29
+		if (apply_filters('site-reviews/assets/css', true)) {
30
+			wp_enqueue_style(
31
+				Application::ID,
32
+				$this->getStylesheet(),
33
+				[],
34
+				glsr()->version
35
+			);
36
+		}
37
+		if (apply_filters('site-reviews/assets/js', true)) {
38
+			$dependencies = apply_filters('site-reviews/assets/polyfill', true)
39
+				? [Application::ID.'/polyfill']
40
+				: [];
41
+			$dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies);
42
+			wp_enqueue_script(
43
+				Application::ID,
44
+				glsr()->url('assets/scripts/'.Application::ID.'.js'),
45
+				$dependencies,
46
+				glsr()->version,
47
+				true
48
+			);
49
+		}
50
+	}
51 51
 
52
-    /**
53
-     * @return void
54
-     */
55
-    public function enqueuePolyfillService()
56
-    {
57
-        if (!apply_filters('site-reviews/assets/polyfill', true)) {
58
-            return;
59
-        }
60
-        wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([
61
-            'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
62
-            'flags' => 'gated',
63
-        ], 'https://polyfill.io/v3/polyfill.min.js'));
64
-    }
52
+	/**
53
+	 * @return void
54
+	 */
55
+	public function enqueuePolyfillService()
56
+	{
57
+		if (!apply_filters('site-reviews/assets/polyfill', true)) {
58
+			return;
59
+		}
60
+		wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([
61
+			'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
62
+			'flags' => 'gated',
63
+		], 'https://polyfill.io/v3/polyfill.min.js'));
64
+	}
65 65
 
66
-    /**
67
-     * @return void
68
-     */
69
-    public function enqueueRecaptchaScript()
70
-    {
71
-        // wpforms-recaptcha
72
-        // google-recaptcha
73
-        // nf-google-recaptcha
74
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
75
-            return;
76
-        }
77
-        $language = apply_filters('site-reviews/recaptcha/language', get_locale());
78
-        wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([
79
-            'hl' => $language,
80
-            'render' => 'explicit',
81
-        ], 'https://www.google.com/recaptcha/api.js'));
82
-    }
66
+	/**
67
+	 * @return void
68
+	 */
69
+	public function enqueueRecaptchaScript()
70
+	{
71
+		// wpforms-recaptcha
72
+		// google-recaptcha
73
+		// nf-google-recaptcha
74
+		if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
75
+			return;
76
+		}
77
+		$language = apply_filters('site-reviews/recaptcha/language', get_locale());
78
+		wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([
79
+			'hl' => $language,
80
+			'render' => 'explicit',
81
+		], 'https://www.google.com/recaptcha/api.js'));
82
+	}
83 83
 
84
-    /**
85
-     * @return void
86
-     */
87
-    public function inlineScript()
88
-    {
89
-        $variables = [
90
-            'action' => Application::PREFIX.'action',
91
-            'ajaxpagination' => $this->getFixedSelectorsForPagination(),
92
-            'ajaxurl' => admin_url('admin-ajax.php'),
93
-            'nameprefix' => Application::ID,
94
-            'validationconfig' => glsr(Style::class)->validation,
95
-            'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(),
96
-        ];
97
-        $variables = apply_filters('site-reviews/enqueue/public/localize', $variables);
98
-        wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before');
99
-    }
84
+	/**
85
+	 * @return void
86
+	 */
87
+	public function inlineScript()
88
+	{
89
+		$variables = [
90
+			'action' => Application::PREFIX.'action',
91
+			'ajaxpagination' => $this->getFixedSelectorsForPagination(),
92
+			'ajaxurl' => admin_url('admin-ajax.php'),
93
+			'nameprefix' => Application::ID,
94
+			'validationconfig' => glsr(Style::class)->validation,
95
+			'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(),
96
+		];
97
+		$variables = apply_filters('site-reviews/enqueue/public/localize', $variables);
98
+		wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before');
99
+	}
100 100
 
101
-    /**
102
-     * @return void
103
-     */
104
-    public function inlineStyles()
105
-    {
106
-        $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css');
107
-        if (!apply_filters('site-reviews/assets/css', true)) {
108
-            return;
109
-        }
110
-        if (!file_exists($inlineStylesheetPath)) {
111
-            glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath);
112
-            return;
113
-        }
114
-        $inlineStylesheetValues = glsr()->config('inline-styles');
115
-        $stylesheet = str_replace(
116
-            array_keys($inlineStylesheetValues),
117
-            array_values($inlineStylesheetValues),
118
-            file_get_contents($inlineStylesheetPath)
119
-        );
120
-        wp_add_inline_style(Application::ID, $stylesheet);
121
-    }
101
+	/**
102
+	 * @return void
103
+	 */
104
+	public function inlineStyles()
105
+	{
106
+		$inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css');
107
+		if (!apply_filters('site-reviews/assets/css', true)) {
108
+			return;
109
+		}
110
+		if (!file_exists($inlineStylesheetPath)) {
111
+			glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath);
112
+			return;
113
+		}
114
+		$inlineStylesheetValues = glsr()->config('inline-styles');
115
+		$stylesheet = str_replace(
116
+			array_keys($inlineStylesheetValues),
117
+			array_values($inlineStylesheetValues),
118
+			file_get_contents($inlineStylesheetPath)
119
+		);
120
+		wp_add_inline_style(Application::ID, $stylesheet);
121
+	}
122 122
 
123
-    /**
124
-     * @return string
125
-     */
126
-    protected function buildInlineScript(array $variables)
127
-    {
128
-        $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
129
-        foreach ($variables as $key => $value) {
130
-            $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
131
-        }
132
-        $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
133
-        $optimizedScript = preg_replace($pattern, '$1$2', $script);
134
-        return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables);
135
-    }
123
+	/**
124
+	 * @return string
125
+	 */
126
+	protected function buildInlineScript(array $variables)
127
+	{
128
+		$script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
129
+		foreach ($variables as $key => $value) {
130
+			$script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
131
+		}
132
+		$pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
133
+		$optimizedScript = preg_replace($pattern, '$1$2', $script);
134
+		return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables);
135
+	}
136 136
 
137
-    /**
138
-     * @return array
139
-     */
140
-    protected function getFixedSelectorsForPagination()
141
-    {
142
-        $selectors = ['#wpadminbar', '.site-navigation-fixed'];
143
-        return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors);
144
-    }
137
+	/**
138
+	 * @return array
139
+	 */
140
+	protected function getFixedSelectorsForPagination()
141
+	{
142
+		$selectors = ['#wpadminbar', '.site-navigation-fixed'];
143
+		return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors);
144
+	}
145 145
 
146
-    /**
147
-     * @return string
148
-     */
149
-    protected function getStylesheet()
150
-    {
151
-        $currentStyle = glsr(Style::class)->style;
152
-        return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css'))
153
-            ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css')
154
-            : glsr()->url('assets/styles/'.Application::ID.'.css');
155
-    }
146
+	/**
147
+	 * @return string
148
+	 */
149
+	protected function getStylesheet()
150
+	{
151
+		$currentStyle = glsr(Style::class)->style;
152
+		return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css'))
153
+			? glsr()->url('assets/styles/custom/'.$currentStyle.'.css')
154
+			: glsr()->url('assets/styles/'.Application::ID.'.css');
155
+	}
156 156
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function enqueueAssets()
28 28
     {
29
-        if (apply_filters('site-reviews/assets/css', true)) {
29
+        if( apply_filters( 'site-reviews/assets/css', true ) ) {
30 30
             wp_enqueue_style(
31 31
                 Application::ID,
32 32
                 $this->getStylesheet(),
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
                 glsr()->version
35 35
             );
36 36
         }
37
-        if (apply_filters('site-reviews/assets/js', true)) {
38
-            $dependencies = apply_filters('site-reviews/assets/polyfill', true)
37
+        if( apply_filters( 'site-reviews/assets/js', true ) ) {
38
+            $dependencies = apply_filters( 'site-reviews/assets/polyfill', true )
39 39
                 ? [Application::ID.'/polyfill']
40 40
                 : [];
41
-            $dependencies = apply_filters('site-reviews/enqueue/public/dependencies', $dependencies);
41
+            $dependencies = apply_filters( 'site-reviews/enqueue/public/dependencies', $dependencies );
42 42
             wp_enqueue_script(
43 43
                 Application::ID,
44
-                glsr()->url('assets/scripts/'.Application::ID.'.js'),
44
+                glsr()->url( 'assets/scripts/'.Application::ID.'.js' ),
45 45
                 $dependencies,
46 46
                 glsr()->version,
47 47
                 true
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function enqueuePolyfillService()
56 56
     {
57
-        if (!apply_filters('site-reviews/assets/polyfill', true)) {
57
+        if( !apply_filters( 'site-reviews/assets/polyfill', true ) ) {
58 58
             return;
59 59
         }
60
-        wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([
60
+        wp_enqueue_script( Application::ID.'/polyfill', add_query_arg( [
61 61
             'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
62 62
             'flags' => 'gated',
63
-        ], 'https://polyfill.io/v3/polyfill.min.js'));
63
+        ], 'https://polyfill.io/v3/polyfill.min.js' ) );
64 64
     }
65 65
 
66 66
     /**
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
         // wpforms-recaptcha
72 72
         // google-recaptcha
73 73
         // nf-google-recaptcha
74
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
74
+        if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
75 75
             return;
76 76
         }
77
-        $language = apply_filters('site-reviews/recaptcha/language', get_locale());
78
-        wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([
77
+        $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() );
78
+        wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [
79 79
             'hl' => $language,
80 80
             'render' => 'explicit',
81
-        ], 'https://www.google.com/recaptcha/api.js'));
81
+        ], 'https://www.google.com/recaptcha/api.js' ) );
82 82
     }
83 83
 
84 84
     /**
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
         $variables = [
90 90
             'action' => Application::PREFIX.'action',
91 91
             'ajaxpagination' => $this->getFixedSelectorsForPagination(),
92
-            'ajaxurl' => admin_url('admin-ajax.php'),
92
+            'ajaxurl' => admin_url( 'admin-ajax.php' ),
93 93
             'nameprefix' => Application::ID,
94
-            'validationconfig' => glsr(Style::class)->validation,
95
-            'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(),
94
+            'validationconfig' => glsr( Style::class )->validation,
95
+            'validationstrings' => glsr( ValidationStringsDefaults::class )->defaults(),
96 96
         ];
97
-        $variables = apply_filters('site-reviews/enqueue/public/localize', $variables);
98
-        wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before');
97
+        $variables = apply_filters( 'site-reviews/enqueue/public/localize', $variables );
98
+        wp_add_inline_script( Application::ID, $this->buildInlineScript( $variables ), 'before' );
99 99
     }
100 100
 
101 101
     /**
@@ -103,35 +103,35 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function inlineStyles()
105 105
     {
106
-        $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css');
107
-        if (!apply_filters('site-reviews/assets/css', true)) {
106
+        $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' );
107
+        if( !apply_filters( 'site-reviews/assets/css', true ) ) {
108 108
             return;
109 109
         }
110
-        if (!file_exists($inlineStylesheetPath)) {
111
-            glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath);
110
+        if( !file_exists( $inlineStylesheetPath ) ) {
111
+            glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath );
112 112
             return;
113 113
         }
114
-        $inlineStylesheetValues = glsr()->config('inline-styles');
114
+        $inlineStylesheetValues = glsr()->config( 'inline-styles' );
115 115
         $stylesheet = str_replace(
116
-            array_keys($inlineStylesheetValues),
117
-            array_values($inlineStylesheetValues),
118
-            file_get_contents($inlineStylesheetPath)
116
+            array_keys( $inlineStylesheetValues ),
117
+            array_values( $inlineStylesheetValues ),
118
+            file_get_contents( $inlineStylesheetPath )
119 119
         );
120
-        wp_add_inline_style(Application::ID, $stylesheet);
120
+        wp_add_inline_style( Application::ID, $stylesheet );
121 121
     }
122 122
 
123 123
     /**
124 124
      * @return string
125 125
      */
126
-    protected function buildInlineScript(array $variables)
126
+    protected function buildInlineScript( array $variables )
127 127
     {
128 128
         $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
129
-        foreach ($variables as $key => $value) {
130
-            $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
129
+        foreach( $variables as $key => $value ) {
130
+            $script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) );
131 131
         }
132 132
         $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
133
-        $optimizedScript = preg_replace($pattern, '$1$2', $script);
134
-        return apply_filters('site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables);
133
+        $optimizedScript = preg_replace( $pattern, '$1$2', $script );
134
+        return apply_filters( 'site-reviews/enqueue/public/inline-script', $optimizedScript, $script, $variables );
135 135
     }
136 136
 
137 137
     /**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     protected function getFixedSelectorsForPagination()
141 141
     {
142 142
         $selectors = ['#wpadminbar', '.site-navigation-fixed'];
143
-        return apply_filters('site-reviews/enqueue/public/localize/ajax-pagination', $selectors);
143
+        return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors );
144 144
     }
145 145
 
146 146
     /**
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
      */
149 149
     protected function getStylesheet()
150 150
     {
151
-        $currentStyle = glsr(Style::class)->style;
152
-        return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css'))
153
-            ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css')
154
-            : glsr()->url('assets/styles/'.Application::ID.'.css');
151
+        $currentStyle = glsr( Style::class )->style;
152
+        return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) )
153
+            ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' )
154
+            : glsr()->url( 'assets/styles/'.Application::ID.'.css' );
155 155
     }
156 156
 }
Please login to merge, or discard this patch.