Passed
Push — master ( ae1954...aab291 )
by Paul
08:17 queued 04:15
created
plugin/Modules/Validator/ValidateReview.php 2 patches
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -12,288 +12,288 @@
 block discarded – undo
12 12
 
13 13
 class ValidateReview
14 14
 {
15
-    const RECAPTCHA_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify';
15
+	const RECAPTCHA_ENDPOINT = 'https://www.google.com/recaptcha/api/siteverify';
16 16
 
17
-    const RECAPTCHA_DISABLED = 0;
18
-    const RECAPTCHA_EMPTY = 1;
19
-    const RECAPTCHA_FAILED = 2;
20
-    const RECAPTCHA_INVALID = 3;
21
-    const RECAPTCHA_VALID = 4;
17
+	const RECAPTCHA_DISABLED = 0;
18
+	const RECAPTCHA_EMPTY = 1;
19
+	const RECAPTCHA_FAILED = 2;
20
+	const RECAPTCHA_INVALID = 3;
21
+	const RECAPTCHA_VALID = 4;
22 22
 
23
-    const VALIDATION_RULES = [
24
-        'content' => 'required',
25
-        'email' => 'required|email',
26
-        'name' => 'required',
27
-        'rating' => 'required|number|between:1,5',
28
-        'terms' => 'accepted',
29
-        'title' => 'required',
30
-    ];
23
+	const VALIDATION_RULES = [
24
+		'content' => 'required',
25
+		'email' => 'required|email',
26
+		'name' => 'required',
27
+		'rating' => 'required|number|between:1,5',
28
+		'terms' => 'accepted',
29
+		'title' => 'required',
30
+	];
31 31
 
32
-    /**
33
-     * @var string|void
34
-     */
35
-    public $error;
32
+	/**
33
+	 * @var string|void
34
+	 */
35
+	public $error;
36 36
 
37
-    /**
38
-     * @var string
39
-     */
40
-    public $form_id;
37
+	/**
38
+	 * @var string
39
+	 */
40
+	public $form_id;
41 41
 
42
-    /**
43
-     * @var bool
44
-     */
45
-    public $recaptchaIsUnset = false;
42
+	/**
43
+	 * @var bool
44
+	 */
45
+	public $recaptchaIsUnset = false;
46 46
 
47
-    /**
48
-     * @var array
49
-     */
50
-    public $request;
47
+	/**
48
+	 * @var array
49
+	 */
50
+	public $request;
51 51
 
52
-    /**
53
-     * @var array
54
-     */
55
-    protected $options;
52
+	/**
53
+	 * @var array
54
+	 */
55
+	protected $options;
56 56
 
57
-    /**
58
-     * @return static
59
-     */
60
-    public function validate(array $request)
61
-    {
62
-        $this->form_id = $request['form_id'];
63
-        $this->options = glsr(OptionManager::class)->all();
64
-        $this->request = $this->validateRequest($request);
65
-        $this->validateCustom();
66
-        $this->validateHoneyPot();
67
-        $this->validateReviewLimits();
68
-        $this->validateBlacklist();
69
-        $this->validateAkismet();
70
-        $this->validateRecaptcha();
71
-        if (!empty($this->error)) {
72
-            $this->setSessionValues('message', $this->error);
73
-        }
74
-        return $this;
75
-    }
57
+	/**
58
+	 * @return static
59
+	 */
60
+	public function validate(array $request)
61
+	{
62
+		$this->form_id = $request['form_id'];
63
+		$this->options = glsr(OptionManager::class)->all();
64
+		$this->request = $this->validateRequest($request);
65
+		$this->validateCustom();
66
+		$this->validateHoneyPot();
67
+		$this->validateReviewLimits();
68
+		$this->validateBlacklist();
69
+		$this->validateAkismet();
70
+		$this->validateRecaptcha();
71
+		if (!empty($this->error)) {
72
+			$this->setSessionValues('message', $this->error);
73
+		}
74
+		return $this;
75
+	}
76 76
 
77
-    /**
78
-     * @param string $path
79
-     * @param mixed $fallback
80
-     * @return mixed
81
-     */
82
-    protected function getOption($path, $fallback = '')
83
-    {
84
-        return glsr(Helper::class)->dataGet($this->options, $path, $fallback);
85
-    }
77
+	/**
78
+	 * @param string $path
79
+	 * @param mixed $fallback
80
+	 * @return mixed
81
+	 */
82
+	protected function getOption($path, $fallback = '')
83
+	{
84
+		return glsr(Helper::class)->dataGet($this->options, $path, $fallback);
85
+	}
86 86
 
87
-    /**
88
-     * @return int
89
-     */
90
-    protected function getRecaptchaStatus()
91
-    {
92
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
93
-            return static::RECAPTCHA_DISABLED;
94
-        }
95
-        if (empty($this->request['_recaptcha-token'])) {
96
-            return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
97
-                ? static::RECAPTCHA_EMPTY
98
-                : static::RECAPTCHA_FAILED;
99
-        }
100
-        return $this->getRecaptchaTokenStatus();
101
-    }
87
+	/**
88
+	 * @return int
89
+	 */
90
+	protected function getRecaptchaStatus()
91
+	{
92
+		if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
93
+			return static::RECAPTCHA_DISABLED;
94
+		}
95
+		if (empty($this->request['_recaptcha-token'])) {
96
+			return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
97
+				? static::RECAPTCHA_EMPTY
98
+				: static::RECAPTCHA_FAILED;
99
+		}
100
+		return $this->getRecaptchaTokenStatus();
101
+	}
102 102
 
103
-    /**
104
-     * @return int
105
-     */
106
-    protected function getRecaptchaTokenStatus()
107
-    {
108
-        $endpoint = add_query_arg([
109
-            'remoteip' => glsr(Helper::class)->getIpAddress(),
110
-            'response' => $this->request['_recaptcha-token'],
111
-            'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
112
-        ], static::RECAPTCHA_ENDPOINT);
113
-        if (is_wp_error($response = wp_remote_get($endpoint))) {
114
-            glsr_log()->error($response->get_error_message());
115
-            return static::RECAPTCHA_FAILED;
116
-        }
117
-        $response = json_decode(wp_remote_retrieve_body($response));
118
-        if (!empty($response->success)) {
119
-            return boolval($response->success)
120
-                ? static::RECAPTCHA_VALID
121
-                : static::RECAPTCHA_INVALID;
122
-        }
123
-        foreach ($response->{'error-codes'} as $error) {
124
-            glsr_log()->error('reCAPTCHA error: '.$error);
125
-        }
126
-        return static::RECAPTCHA_INVALID;
127
-    }
103
+	/**
104
+	 * @return int
105
+	 */
106
+	protected function getRecaptchaTokenStatus()
107
+	{
108
+		$endpoint = add_query_arg([
109
+			'remoteip' => glsr(Helper::class)->getIpAddress(),
110
+			'response' => $this->request['_recaptcha-token'],
111
+			'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
112
+		], static::RECAPTCHA_ENDPOINT);
113
+		if (is_wp_error($response = wp_remote_get($endpoint))) {
114
+			glsr_log()->error($response->get_error_message());
115
+			return static::RECAPTCHA_FAILED;
116
+		}
117
+		$response = json_decode(wp_remote_retrieve_body($response));
118
+		if (!empty($response->success)) {
119
+			return boolval($response->success)
120
+				? static::RECAPTCHA_VALID
121
+				: static::RECAPTCHA_INVALID;
122
+		}
123
+		foreach ($response->{'error-codes'} as $error) {
124
+			glsr_log()->error('reCAPTCHA error: '.$error);
125
+		}
126
+		return static::RECAPTCHA_INVALID;
127
+	}
128 128
 
129
-    /**
130
-     * @return array
131
-     */
132
-    protected function getValidationRules(array $request)
133
-    {
134
-        $rules = array_intersect_key(
135
-            apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
136
-            array_flip($this->getOption('settings.submissions.required', []))
137
-        );
138
-        $excluded = explode(',', glsr_get($request, 'excluded'));
139
-        return array_diff_key($rules, array_flip($excluded));
140
-    }
129
+	/**
130
+	 * @return array
131
+	 */
132
+	protected function getValidationRules(array $request)
133
+	{
134
+		$rules = array_intersect_key(
135
+			apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
136
+			array_flip($this->getOption('settings.submissions.required', []))
137
+		);
138
+		$excluded = explode(',', glsr_get($request, 'excluded'));
139
+		return array_diff_key($rules, array_flip($excluded));
140
+	}
141 141
 
142
-    /**
143
-     * @return bool
144
-     */
145
-    protected function isRequestValid(array $request)
146
-    {
147
-        $rules = $this->getValidationRules($request);
148
-        $errors = glsr(Validator::class)->validate($request, $rules);
149
-        if (empty($errors)) {
150
-            return true;
151
-        }
152
-        $this->setSessionValues('errors', $errors);
153
-        $this->setSessionValues('values', $request);
154
-        return false;
155
-    }
142
+	/**
143
+	 * @return bool
144
+	 */
145
+	protected function isRequestValid(array $request)
146
+	{
147
+		$rules = $this->getValidationRules($request);
148
+		$errors = glsr(Validator::class)->validate($request, $rules);
149
+		if (empty($errors)) {
150
+			return true;
151
+		}
152
+		$this->setSessionValues('errors', $errors);
153
+		$this->setSessionValues('values', $request);
154
+		return false;
155
+	}
156 156
 
157
-    protected function setError($message, $loggedMessage = '')
158
-    {
159
-        $this->setSessionValues('errors', [], $loggedMessage);
160
-        $this->error = $message;
161
-    }
157
+	protected function setError($message, $loggedMessage = '')
158
+	{
159
+		$this->setSessionValues('errors', [], $loggedMessage);
160
+		$this->error = $message;
161
+	}
162 162
 
163
-    /**
164
-     * @param string $type
165
-     * @param mixed $value
166
-     * @param string $loggedMessage
167
-     * @return void
168
-     */
169
-    protected function setSessionValues($type, $value, $loggedMessage = '')
170
-    {
171
-        glsr()->sessionSet($this->form_id.$type, $value);
172
-        if (!empty($loggedMessage)) {
173
-            glsr_log()->warning($loggedMessage)->debug($this->request);
174
-        }
175
-    }
163
+	/**
164
+	 * @param string $type
165
+	 * @param mixed $value
166
+	 * @param string $loggedMessage
167
+	 * @return void
168
+	 */
169
+	protected function setSessionValues($type, $value, $loggedMessage = '')
170
+	{
171
+		glsr()->sessionSet($this->form_id.$type, $value);
172
+		if (!empty($loggedMessage)) {
173
+			glsr_log()->warning($loggedMessage)->debug($this->request);
174
+		}
175
+	}
176 176
 
177
-    /**
178
-     * @return void
179
-     */
180
-    protected function validateAkismet()
181
-    {
182
-        if (!empty($this->error)) {
183
-            return;
184
-        }
185
-        if (!glsr(Akismet::class)->isSpam($this->request)) {
186
-            return;
187
-        }
188
-        $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
189
-            'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
190
-        );
191
-    }
177
+	/**
178
+	 * @return void
179
+	 */
180
+	protected function validateAkismet()
181
+	{
182
+		if (!empty($this->error)) {
183
+			return;
184
+		}
185
+		if (!glsr(Akismet::class)->isSpam($this->request)) {
186
+			return;
187
+		}
188
+		$this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
189
+			'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
190
+		);
191
+	}
192 192
 
193
-    /**
194
-     * @return void
195
-     */
196
-    protected function validateBlacklist()
197
-    {
198
-        if (!empty($this->error)) {
199
-            return;
200
-        }
201
-        if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
202
-            return;
203
-        }
204
-        $blacklistAction = $this->getOption('settings.submissions.blacklist.action');
205
-        if ('reject' != $blacklistAction) {
206
-            $this->request['blacklisted'] = true;
207
-            return;
208
-        }
209
-        $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
210
-            'Blacklisted submission detected:'
211
-        );
212
-    }
193
+	/**
194
+	 * @return void
195
+	 */
196
+	protected function validateBlacklist()
197
+	{
198
+		if (!empty($this->error)) {
199
+			return;
200
+		}
201
+		if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
202
+			return;
203
+		}
204
+		$blacklistAction = $this->getOption('settings.submissions.blacklist.action');
205
+		if ('reject' != $blacklistAction) {
206
+			$this->request['blacklisted'] = true;
207
+			return;
208
+		}
209
+		$this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
210
+			'Blacklisted submission detected:'
211
+		);
212
+	}
213 213
 
214
-    /**
215
-     * @return void
216
-     */
217
-    protected function validateCustom()
218
-    {
219
-        if (!empty($this->error)) {
220
-            return;
221
-        }
222
-        $validated = apply_filters('site-reviews/validate/custom', true, $this->request);
223
-        if (true === $validated) {
224
-            return;
225
-        }
226
-        $errorMessage = is_string($validated)
227
-            ? $validated
228
-            : __('The review submission failed. Please notify the site administrator.', 'site-reviews');
229
-        $this->setError($errorMessage);
230
-        $this->setSessionValues('values', $this->request);
231
-    }
214
+	/**
215
+	 * @return void
216
+	 */
217
+	protected function validateCustom()
218
+	{
219
+		if (!empty($this->error)) {
220
+			return;
221
+		}
222
+		$validated = apply_filters('site-reviews/validate/custom', true, $this->request);
223
+		if (true === $validated) {
224
+			return;
225
+		}
226
+		$errorMessage = is_string($validated)
227
+			? $validated
228
+			: __('The review submission failed. Please notify the site administrator.', 'site-reviews');
229
+		$this->setError($errorMessage);
230
+		$this->setSessionValues('values', $this->request);
231
+	}
232 232
 
233
-    /**
234
-     * @return void
235
-     */
236
-    protected function validateHoneyPot()
237
-    {
238
-        if (!empty($this->error)) {
239
-            return;
240
-        }
241
-        if (empty($this->request['gotcha'])) {
242
-            return;
243
-        }
244
-        $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
245
-            'The Honeypot caught a bad submission:'
246
-        );
247
-    }
233
+	/**
234
+	 * @return void
235
+	 */
236
+	protected function validateHoneyPot()
237
+	{
238
+		if (!empty($this->error)) {
239
+			return;
240
+		}
241
+		if (empty($this->request['gotcha'])) {
242
+			return;
243
+		}
244
+		$this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
245
+			'The Honeypot caught a bad submission:'
246
+		);
247
+	}
248 248
 
249
-    /**
250
-     * @return void
251
-     */
252
-    protected function validateReviewLimits()
253
-    {
254
-        if (!empty($this->error)) {
255
-            return;
256
-        }
257
-        if (!glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
258
-            return;
259
-        }
260
-        $this->setError(__('You have already submitted a review.', 'site-reviews'));
261
-    }
249
+	/**
250
+	 * @return void
251
+	 */
252
+	protected function validateReviewLimits()
253
+	{
254
+		if (!empty($this->error)) {
255
+			return;
256
+		}
257
+		if (!glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
258
+			return;
259
+		}
260
+		$this->setError(__('You have already submitted a review.', 'site-reviews'));
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
-        if (!$this->isRequestValid($request)) {
294
-            $this->error = __('Please fix the submission errors.', 'site-reviews');
295
-            return $request;
296
-        }
297
-        return array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request);
298
-    }
288
+	/**
289
+	 * @return array
290
+	 */
291
+	protected function validateRequest(array $request)
292
+	{
293
+		if (!$this->isRequestValid($request)) {
294
+			$this->error = __('Please fix the submission errors.', 'site-reviews');
295
+			return $request;
296
+		}
297
+		return array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request);
298
+	}
299 299
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -57,19 +57,19 @@  discard block
 block discarded – undo
57 57
     /**
58 58
      * @return static
59 59
      */
60
-    public function validate(array $request)
60
+    public function validate( array $request )
61 61
     {
62 62
         $this->form_id = $request['form_id'];
63
-        $this->options = glsr(OptionManager::class)->all();
64
-        $this->request = $this->validateRequest($request);
63
+        $this->options = glsr( OptionManager::class )->all();
64
+        $this->request = $this->validateRequest( $request );
65 65
         $this->validateCustom();
66 66
         $this->validateHoneyPot();
67 67
         $this->validateReviewLimits();
68 68
         $this->validateBlacklist();
69 69
         $this->validateAkismet();
70 70
         $this->validateRecaptcha();
71
-        if (!empty($this->error)) {
72
-            $this->setSessionValues('message', $this->error);
71
+        if( !empty($this->error) ) {
72
+            $this->setSessionValues( 'message', $this->error );
73 73
         }
74 74
         return $this;
75 75
     }
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
      * @param mixed $fallback
80 80
      * @return mixed
81 81
      */
82
-    protected function getOption($path, $fallback = '')
82
+    protected function getOption( $path, $fallback = '' )
83 83
     {
84
-        return glsr(Helper::class)->dataGet($this->options, $path, $fallback);
84
+        return glsr( Helper::class )->dataGet( $this->options, $path, $fallback );
85 85
     }
86 86
 
87 87
     /**
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
      */
90 90
     protected function getRecaptchaStatus()
91 91
     {
92
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
92
+        if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) {
93 93
             return static::RECAPTCHA_DISABLED;
94 94
         }
95
-        if (empty($this->request['_recaptcha-token'])) {
96
-            return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5))
95
+        if( empty($this->request['_recaptcha-token']) ) {
96
+            return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) )
97 97
                 ? static::RECAPTCHA_EMPTY
98 98
                 : static::RECAPTCHA_FAILED;
99 99
         }
@@ -105,23 +105,23 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function getRecaptchaTokenStatus()
107 107
     {
108
-        $endpoint = add_query_arg([
109
-            'remoteip' => glsr(Helper::class)->getIpAddress(),
108
+        $endpoint = add_query_arg( [
109
+            'remoteip' => glsr( Helper::class )->getIpAddress(),
110 110
             'response' => $this->request['_recaptcha-token'],
111
-            'secret' => $this->getOption('settings.submissions.recaptcha.secret'),
112
-        ], static::RECAPTCHA_ENDPOINT);
113
-        if (is_wp_error($response = wp_remote_get($endpoint))) {
114
-            glsr_log()->error($response->get_error_message());
111
+            'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ),
112
+        ], static::RECAPTCHA_ENDPOINT );
113
+        if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) {
114
+            glsr_log()->error( $response->get_error_message() );
115 115
             return static::RECAPTCHA_FAILED;
116 116
         }
117
-        $response = json_decode(wp_remote_retrieve_body($response));
118
-        if (!empty($response->success)) {
119
-            return boolval($response->success)
117
+        $response = json_decode( wp_remote_retrieve_body( $response ) );
118
+        if( !empty($response->success) ) {
119
+            return boolval( $response->success )
120 120
                 ? static::RECAPTCHA_VALID
121 121
                 : static::RECAPTCHA_INVALID;
122 122
         }
123
-        foreach ($response->{'error-codes'} as $error) {
124
-            glsr_log()->error('reCAPTCHA error: '.$error);
123
+        foreach( $response->{'error-codes'} as $error ) {
124
+            glsr_log()->error( 'reCAPTCHA error: '.$error );
125 125
         }
126 126
         return static::RECAPTCHA_INVALID;
127 127
     }
@@ -129,34 +129,34 @@  discard block
 block discarded – undo
129 129
     /**
130 130
      * @return array
131 131
      */
132
-    protected function getValidationRules(array $request)
132
+    protected function getValidationRules( array $request )
133 133
     {
134 134
         $rules = array_intersect_key(
135
-            apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request),
136
-            array_flip($this->getOption('settings.submissions.required', []))
135
+            apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ),
136
+            array_flip( $this->getOption( 'settings.submissions.required', [] ) )
137 137
         );
138
-        $excluded = explode(',', glsr_get($request, 'excluded'));
139
-        return array_diff_key($rules, array_flip($excluded));
138
+        $excluded = explode( ',', glsr_get( $request, 'excluded' ) );
139
+        return array_diff_key( $rules, array_flip( $excluded ) );
140 140
     }
141 141
 
142 142
     /**
143 143
      * @return bool
144 144
      */
145
-    protected function isRequestValid(array $request)
145
+    protected function isRequestValid( array $request )
146 146
     {
147
-        $rules = $this->getValidationRules($request);
148
-        $errors = glsr(Validator::class)->validate($request, $rules);
149
-        if (empty($errors)) {
147
+        $rules = $this->getValidationRules( $request );
148
+        $errors = glsr( Validator::class )->validate( $request, $rules );
149
+        if( empty($errors) ) {
150 150
             return true;
151 151
         }
152
-        $this->setSessionValues('errors', $errors);
153
-        $this->setSessionValues('values', $request);
152
+        $this->setSessionValues( 'errors', $errors );
153
+        $this->setSessionValues( 'values', $request );
154 154
         return false;
155 155
     }
156 156
 
157
-    protected function setError($message, $loggedMessage = '')
157
+    protected function setError( $message, $loggedMessage = '' )
158 158
     {
159
-        $this->setSessionValues('errors', [], $loggedMessage);
159
+        $this->setSessionValues( 'errors', [], $loggedMessage );
160 160
         $this->error = $message;
161 161
     }
162 162
 
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
      * @param string $loggedMessage
167 167
      * @return void
168 168
      */
169
-    protected function setSessionValues($type, $value, $loggedMessage = '')
169
+    protected function setSessionValues( $type, $value, $loggedMessage = '' )
170 170
     {
171
-        glsr()->sessionSet($this->form_id.$type, $value);
172
-        if (!empty($loggedMessage)) {
173
-            glsr_log()->warning($loggedMessage)->debug($this->request);
171
+        glsr()->sessionSet( $this->form_id.$type, $value );
172
+        if( !empty($loggedMessage) ) {
173
+            glsr_log()->warning( $loggedMessage )->debug( $this->request );
174 174
         }
175 175
     }
176 176
 
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
      */
180 180
     protected function validateAkismet()
181 181
     {
182
-        if (!empty($this->error)) {
182
+        if( !empty($this->error) ) {
183 183
             return;
184 184
         }
185
-        if (!glsr(Akismet::class)->isSpam($this->request)) {
185
+        if( !glsr( Akismet::class )->isSpam( $this->request ) ) {
186 186
             return;
187 187
         }
188
-        $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'),
188
+        $this->setError( __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ),
189 189
             'Akismet caught a spam submission (consider adding the IP address to the blacklist):'
190 190
         );
191 191
     }
@@ -195,18 +195,18 @@  discard block
 block discarded – undo
195 195
      */
196 196
     protected function validateBlacklist()
197 197
     {
198
-        if (!empty($this->error)) {
198
+        if( !empty($this->error) ) {
199 199
             return;
200 200
         }
201
-        if (!glsr(Blacklist::class)->isBlacklisted($this->request)) {
201
+        if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) ) {
202 202
             return;
203 203
         }
204
-        $blacklistAction = $this->getOption('settings.submissions.blacklist.action');
205
-        if ('reject' != $blacklistAction) {
204
+        $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
205
+        if( 'reject' != $blacklistAction ) {
206 206
             $this->request['blacklisted'] = true;
207 207
             return;
208 208
         }
209
-        $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'),
209
+        $this->setError( __( 'Your review cannot be submitted at this time.', 'site-reviews' ),
210 210
             'Blacklisted submission detected:'
211 211
         );
212 212
     }
@@ -216,18 +216,18 @@  discard block
 block discarded – undo
216 216
      */
217 217
     protected function validateCustom()
218 218
     {
219
-        if (!empty($this->error)) {
219
+        if( !empty($this->error) ) {
220 220
             return;
221 221
         }
222
-        $validated = apply_filters('site-reviews/validate/custom', true, $this->request);
223
-        if (true === $validated) {
222
+        $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request );
223
+        if( true === $validated ) {
224 224
             return;
225 225
         }
226
-        $errorMessage = is_string($validated)
226
+        $errorMessage = is_string( $validated )
227 227
             ? $validated
228
-            : __('The review submission failed. Please notify the site administrator.', 'site-reviews');
229
-        $this->setError($errorMessage);
230
-        $this->setSessionValues('values', $this->request);
228
+            : __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
229
+        $this->setError( $errorMessage );
230
+        $this->setSessionValues( 'values', $this->request );
231 231
     }
232 232
 
233 233
     /**
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
      */
236 236
     protected function validateHoneyPot()
237 237
     {
238
-        if (!empty($this->error)) {
238
+        if( !empty($this->error) ) {
239 239
             return;
240 240
         }
241
-        if (empty($this->request['gotcha'])) {
241
+        if( empty($this->request['gotcha']) ) {
242 242
             return;
243 243
         }
244
-        $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'),
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
     }
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
      */
252 252
     protected function validateReviewLimits()
253 253
     {
254
-        if (!empty($this->error)) {
254
+        if( !empty($this->error) ) {
255 255
             return;
256 256
         }
257
-        if (!glsr(ReviewLimits::class)->hasReachedLimit($this->request)) {
257
+        if( !glsr( ReviewLimits::class )->hasReachedLimit( $this->request ) ) {
258 258
             return;
259 259
         }
260
-        $this->setError(__('You have already submitted a review.', 'site-reviews'));
260
+        $this->setError( __( 'You have already submitted a review.', 'site-reviews' ) );
261 261
     }
262 262
 
263 263
     /**
@@ -265,35 +265,35 @@  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
-        if (!$this->isRequestValid($request)) {
294
-            $this->error = __('Please fix the submission errors.', 'site-reviews');
293
+        if( !$this->isRequestValid( $request ) ) {
294
+            $this->error = __( 'Please fix the submission errors.', 'site-reviews' );
295 295
             return $request;
296 296
         }
297
-        return array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request);
297
+        return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request );
298 298
     }
299 299
 }
Please login to merge, or discard this patch.
plugin/Modules/ReviewLimits.php 2 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -7,103 +7,103 @@
 block discarded – undo
7 7
 
8 8
 class ReviewLimits
9 9
 {
10
-    protected $request;
10
+	protected $request;
11 11
 
12
-    /**
13
-     * @return array
14
-     * @filter site-reviews/get/reviews/query
15
-     */
16
-    public function filterReviewsQuery(array $parameters, array $args)
17
-    {
18
-        if ($authorId = get_current_user_id()) {
19
-            $parameters['author'] = $authorId;
20
-        }
21
-        $parameters['post_status'] = ['pending', 'publish'];
22
-        return apply_filters('site-reviews/reviews-limits/query', $parameters, $args);
23
-    }
12
+	/**
13
+	 * @return array
14
+	 * @filter site-reviews/get/reviews/query
15
+	 */
16
+	public function filterReviewsQuery(array $parameters, array $args)
17
+	{
18
+		if ($authorId = get_current_user_id()) {
19
+			$parameters['author'] = $authorId;
20
+		}
21
+		$parameters['post_status'] = ['pending', 'publish'];
22
+		return apply_filters('site-reviews/reviews-limits/query', $parameters, $args);
23
+	}
24 24
 
25
-    /**
26
-     * @return bool
27
-     */
28
-    public function hasReachedLimit(array $request = [])
29
-    {
30
-        $this->request = $request;
31
-        $method = glsr(Helper::class)->buildMethodName(
32
-            glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy'
33
-        );
34
-        return method_exists($this, $method)
35
-            ? !call_user_func([$this, $method])
36
-            : false;
37
-    }
25
+	/**
26
+	 * @return bool
27
+	 */
28
+	public function hasReachedLimit(array $request = [])
29
+	{
30
+		$this->request = $request;
31
+		$method = glsr(Helper::class)->buildMethodName(
32
+			glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy'
33
+		);
34
+		return method_exists($this, $method)
35
+			? !call_user_func([$this, $method])
36
+			: false;
37
+	}
38 38
 
39
-    /**
40
-     * @param string $value
41
-     * @param string $whitelist
42
-     * @return bool
43
-     */
44
-    public function isWhitelisted($value, $whitelist)
45
-    {
46
-        if (empty($whitelist)) {
47
-            return false;
48
-        }
49
-        return in_array($value, array_filter(explode("\n", $whitelist), 'trim'));
50
-    }
39
+	/**
40
+	 * @param string $value
41
+	 * @param string $whitelist
42
+	 * @return bool
43
+	 */
44
+	public function isWhitelisted($value, $whitelist)
45
+	{
46
+		if (empty($whitelist)) {
47
+			return false;
48
+		}
49
+		return in_array($value, array_filter(explode("\n", $whitelist), 'trim'));
50
+	}
51 51
 
52
-    /**
53
-     * @param string $whitelistName
54
-     * @return string
55
-     */
56
-    protected function getWhitelist($whitelistName)
57
-    {
58
-        return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName);
59
-    }
52
+	/**
53
+	 * @param string $whitelistName
54
+	 * @return string
55
+	 */
56
+	protected function getWhitelist($whitelistName)
57
+	{
58
+		return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName);
59
+	}
60 60
 
61
-    /**
62
-     * @return bool
63
-     */
64
-    protected function validate($key, $value, $addMetaQuery = true)
65
-    {
66
-        if ($this->isWhitelisted($value, $this->getWhitelist($key))) {
67
-            return true;
68
-        }
69
-        add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2);
70
-        $args = ['assigned_to' => glsr_get($this->request, 'assign_to')];
71
-        if ($addMetaQuery) {
72
-            $args[$key] = $value;
73
-        }
74
-        $reviews = glsr_get_reviews($args);
75
-        remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5);
76
-        return 0 === count($reviews);
77
-    }
61
+	/**
62
+	 * @return bool
63
+	 */
64
+	protected function validate($key, $value, $addMetaQuery = true)
65
+	{
66
+		if ($this->isWhitelisted($value, $this->getWhitelist($key))) {
67
+			return true;
68
+		}
69
+		add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2);
70
+		$args = ['assigned_to' => glsr_get($this->request, 'assign_to')];
71
+		if ($addMetaQuery) {
72
+			$args[$key] = $value;
73
+		}
74
+		$reviews = glsr_get_reviews($args);
75
+		remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5);
76
+		return 0 === count($reviews);
77
+	}
78 78
 
79
-    /**
80
-     * @return bool
81
-     */
82
-    protected function validateByEmail()
83
-    {
84
-        glsr_log()->debug('Email is: '.glsr_get($this->request, 'email'));
85
-        return $this->validate('email', glsr_get($this->request, 'email'));
86
-    }
79
+	/**
80
+	 * @return bool
81
+	 */
82
+	protected function validateByEmail()
83
+	{
84
+		glsr_log()->debug('Email is: '.glsr_get($this->request, 'email'));
85
+		return $this->validate('email', glsr_get($this->request, 'email'));
86
+	}
87 87
 
88
-    /**
89
-     * @return bool
90
-     */
91
-    protected function validateByIpAddress()
92
-    {
93
-        glsr_log()->debug('IP Address is: '.glsr_get($this->request, 'ip_address'));
94
-        return $this->validate('ip_address', glsr_get($this->request, 'ip_address'));
95
-    }
88
+	/**
89
+	 * @return bool
90
+	 */
91
+	protected function validateByIpAddress()
92
+	{
93
+		glsr_log()->debug('IP Address is: '.glsr_get($this->request, 'ip_address'));
94
+		return $this->validate('ip_address', glsr_get($this->request, 'ip_address'));
95
+	}
96 96
 
97
-    /**
98
-     * @return bool
99
-     */
100
-    protected function validateByUsername()
101
-    {
102
-        $user = wp_get_current_user();
103
-        if (!$user->exists()) {
104
-            return true;
105
-        }
106
-        glsr_log()->debug('Username is: '.$user->user_login);
107
-        return $this->validate('username', $user->user_login, false);
108
-    }
97
+	/**
98
+	 * @return bool
99
+	 */
100
+	protected function validateByUsername()
101
+	{
102
+		$user = wp_get_current_user();
103
+		if (!$user->exists()) {
104
+			return true;
105
+		}
106
+		glsr_log()->debug('Username is: '.$user->user_login);
107
+		return $this->validate('username', $user->user_login, false);
108
+	}
109 109
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,26 +13,26 @@  discard block
 block discarded – undo
13 13
      * @return array
14 14
      * @filter site-reviews/get/reviews/query
15 15
      */
16
-    public function filterReviewsQuery(array $parameters, array $args)
16
+    public function filterReviewsQuery( array $parameters, array $args )
17 17
     {
18
-        if ($authorId = get_current_user_id()) {
18
+        if( $authorId = get_current_user_id() ) {
19 19
             $parameters['author'] = $authorId;
20 20
         }
21 21
         $parameters['post_status'] = ['pending', 'publish'];
22
-        return apply_filters('site-reviews/reviews-limits/query', $parameters, $args);
22
+        return apply_filters( 'site-reviews/reviews-limits/query', $parameters, $args );
23 23
     }
24 24
 
25 25
     /**
26 26
      * @return bool
27 27
      */
28
-    public function hasReachedLimit(array $request = [])
28
+    public function hasReachedLimit( array $request = [] )
29 29
     {
30 30
         $this->request = $request;
31
-        $method = glsr(Helper::class)->buildMethodName(
32
-            glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy'
31
+        $method = glsr( Helper::class )->buildMethodName(
32
+            glsr( OptionManager::class )->get( 'settings.submissions.limit' ), 'validateBy'
33 33
         );
34
-        return method_exists($this, $method)
35
-            ? !call_user_func([$this, $method])
34
+        return method_exists( $this, $method )
35
+            ? !call_user_func( [$this, $method] )
36 36
             : false;
37 37
     }
38 38
 
@@ -41,39 +41,39 @@  discard block
 block discarded – undo
41 41
      * @param string $whitelist
42 42
      * @return bool
43 43
      */
44
-    public function isWhitelisted($value, $whitelist)
44
+    public function isWhitelisted( $value, $whitelist )
45 45
     {
46
-        if (empty($whitelist)) {
46
+        if( empty($whitelist) ) {
47 47
             return false;
48 48
         }
49
-        return in_array($value, array_filter(explode("\n", $whitelist), 'trim'));
49
+        return in_array( $value, array_filter( explode( "\n", $whitelist ), 'trim' ) );
50 50
     }
51 51
 
52 52
     /**
53 53
      * @param string $whitelistName
54 54
      * @return string
55 55
      */
56
-    protected function getWhitelist($whitelistName)
56
+    protected function getWhitelist( $whitelistName )
57 57
     {
58
-        return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName);
58
+        return glsr( OptionManager::class )->get( 'settings.submissions.limit_whitelist.'.$whitelistName );
59 59
     }
60 60
 
61 61
     /**
62 62
      * @return bool
63 63
      */
64
-    protected function validate($key, $value, $addMetaQuery = true)
64
+    protected function validate( $key, $value, $addMetaQuery = true )
65 65
     {
66
-        if ($this->isWhitelisted($value, $this->getWhitelist($key))) {
66
+        if( $this->isWhitelisted( $value, $this->getWhitelist( $key ) ) ) {
67 67
             return true;
68 68
         }
69
-        add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2);
70
-        $args = ['assigned_to' => glsr_get($this->request, 'assign_to')];
71
-        if ($addMetaQuery) {
69
+        add_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2 );
70
+        $args = ['assigned_to' => glsr_get( $this->request, 'assign_to' )];
71
+        if( $addMetaQuery ) {
72 72
             $args[$key] = $value;
73 73
         }
74
-        $reviews = glsr_get_reviews($args);
75
-        remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5);
76
-        return 0 === count($reviews);
74
+        $reviews = glsr_get_reviews( $args );
75
+        remove_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5 );
76
+        return 0 === count( $reviews );
77 77
     }
78 78
 
79 79
     /**
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
      */
82 82
     protected function validateByEmail()
83 83
     {
84
-        glsr_log()->debug('Email is: '.glsr_get($this->request, 'email'));
85
-        return $this->validate('email', glsr_get($this->request, 'email'));
84
+        glsr_log()->debug( 'Email is: '.glsr_get( $this->request, 'email' ) );
85
+        return $this->validate( 'email', glsr_get( $this->request, 'email' ) );
86 86
     }
87 87
 
88 88
     /**
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
      */
91 91
     protected function validateByIpAddress()
92 92
     {
93
-        glsr_log()->debug('IP Address is: '.glsr_get($this->request, 'ip_address'));
94
-        return $this->validate('ip_address', glsr_get($this->request, 'ip_address'));
93
+        glsr_log()->debug( 'IP Address is: '.glsr_get( $this->request, 'ip_address' ) );
94
+        return $this->validate( 'ip_address', glsr_get( $this->request, 'ip_address' ) );
95 95
     }
96 96
 
97 97
     /**
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
     protected function validateByUsername()
101 101
     {
102 102
         $user = wp_get_current_user();
103
-        if (!$user->exists()) {
103
+        if( !$user->exists() ) {
104 104
             return true;
105 105
         }
106
-        glsr_log()->debug('Username is: '.$user->user_login);
107
-        return $this->validate('username', $user->user_login, false);
106
+        glsr_log()->debug( 'Username is: '.$user->user_login );
107
+        return $this->validate( 'username', $user->user_login, false );
108 108
     }
109 109
 }
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 2 patches
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -15,222 +15,222 @@
 block discarded – undo
15 15
 
16 16
 class AdminController extends Controller
17 17
 {
18
-    /**
19
-     * @return void
20
-     * @action admin_enqueue_scripts
21
-     */
22
-    public function enqueueAssets()
23
-    {
24
-        $command = new EnqueueAdminAssets([
25
-            'pointers' => [[
26
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
27
-                'id' => 'glsr-pointer-pinned',
28
-                'position' => [
29
-                    'edge' => 'right',
30
-                    'align' => 'middle',
31
-                ],
32
-                'screen' => Application::POST_TYPE,
33
-                'target' => '#misc-pub-pinned',
34
-                'title' => __('Pin Your Reviews', 'site-reviews'),
35
-            ]],
36
-        ]);
37
-        $this->execute($command);
38
-    }
39
-
40
-    /**
41
-     * @return array
42
-     * @filter plugin_action_links_site-reviews/site-reviews.php
43
-     */
44
-    public function filterActionLinks(array $links)
45
-    {
46
-        $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
47
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
48
-        ]);
49
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
50
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
51
-        ]);
52
-        return $links;
53
-    }
54
-
55
-    /**
56
-     * @param array $capabilities
57
-     * @param string $capability
58
-     * @return array
59
-     * @filter map_meta_cap
60
-     */
61
-    public function filterCreateCapability($capabilities, $capability)
62
-    {
63
-        if ($capability == 'create_'.Application::POST_TYPE) {
64
-            $capabilities[] = 'do_not_allow';
65
-        }
66
-        return $capabilities;
67
-    }
68
-
69
-    /**
70
-     * @param array $items
71
-     * @return array
72
-     * @filter dashboard_glance_items
73
-     */
74
-    public function filterDashboardGlanceItems($items)
75
-    {
76
-        $postCount = wp_count_posts(Application::POST_TYPE);
77
-        if (empty($postCount->publish)) {
78
-            return $items;
79
-        }
80
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
81
-        $text = sprintf($text, number_format_i18n($postCount->publish));
82
-        $items = glsr(Helper::class)->consolidateArray($items);
83
-        $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts)
84
-            ? glsr(Builder::class)->a($text, [
85
-                'class' => 'glsr-review-count',
86
-                'href' => 'edit.php?post_type='.Application::POST_TYPE,
87
-            ])
88
-            : glsr(Builder::class)->span($text, [
89
-                'class' => 'glsr-review-count',
90
-            ]);
91
-        return $items;
92
-    }
93
-
94
-    /**
95
-     * @param array $plugins
96
-     * @return array
97
-     * @filter mce_external_plugins
98
-     */
99
-    public function filterTinymcePlugins($plugins)
100
-    {
101
-        if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
102
-            $plugins = glsr(Helper::class)->consolidateArray($plugins);
103
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
104
-        }
105
-        return $plugins;
106
-    }
107
-
108
-    /**
109
-     * @return void
110
-     * @action admin_init
111
-     */
112
-    public function registerTinymcePopups()
113
-    {
114
-        $command = new RegisterTinymcePopups([
115
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
116
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
117
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
118
-        ]);
119
-        $this->execute($command);
120
-    }
121
-
122
-    /**
123
-     * @param string $editorId
124
-     * @return void|null
125
-     * @action media_buttons
126
-     */
127
-    public function renderTinymceButton($editorId)
128
-    {
129
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
130
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
131
-            return;
132
-        }
133
-        $shortcodes = [];
134
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
135
-            $shortcodes[$shortcode] = $values;
136
-        }
137
-        if (empty($shortcodes)) {
138
-            return;
139
-        }
140
-        glsr()->render('partials/editor/tinymce', [
141
-            'shortcodes' => $shortcodes,
142
-        ]);
143
-    }
144
-
145
-    /**
146
-     * @return void
147
-     */
148
-    public function routerClearConsole()
149
-    {
150
-        glsr(Console::class)->clear();
151
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
152
-    }
153
-
154
-    /**
155
-     * @return void
156
-     */
157
-    public function routerFetchConsole()
158
-    {
159
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
160
-    }
161
-
162
-    /**
163
-     * @param bool $showNotice
164
-     * @return void
165
-     */
166
-    public function routerCountReviews($showNotice = true)
167
-    {
168
-        glsr(CountsManager::class)->countAll();
169
-        glsr(OptionManager::class)->set('last_review_count', current_time('timestamp'));
170
-        if ($showNotice) {
171
-            glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
172
-        }
173
-    }
174
-
175
-    /**
176
-     * @return void
177
-     */
178
-    public function routerDownloadConsole()
179
-    {
180
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
181
-    }
182
-
183
-    /**
184
-     * @return void
185
-     */
186
-    public function routerDownloadSystemInfo()
187
-    {
188
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
189
-    }
190
-
191
-    /**
192
-     * @return void
193
-     */
194
-    public function routerExportSettings()
195
-    {
196
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
197
-    }
198
-
199
-    /**
200
-     * @return void
201
-     */
202
-    public function routerImportSettings()
203
-    {
204
-        $file = $_FILES['import-file'];
205
-        if (UPLOAD_ERR_OK !== $file['error']) {
206
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
207
-        }
208
-        if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) {
209
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
210
-        }
211
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
212
-        if (empty($settings)) {
213
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
214
-        }
215
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
216
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
217
-    }
218
-
219
-    /**
220
-     * @param int $errorCode
221
-     * @return string
222
-     */
223
-    protected function getUploadError($errorCode)
224
-    {
225
-        $errors = [
226
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
227
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
228
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
229
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
230
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
231
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
232
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
233
-        ];
234
-        return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
235
-    }
18
+	/**
19
+	 * @return void
20
+	 * @action admin_enqueue_scripts
21
+	 */
22
+	public function enqueueAssets()
23
+	{
24
+		$command = new EnqueueAdminAssets([
25
+			'pointers' => [[
26
+				'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
27
+				'id' => 'glsr-pointer-pinned',
28
+				'position' => [
29
+					'edge' => 'right',
30
+					'align' => 'middle',
31
+				],
32
+				'screen' => Application::POST_TYPE,
33
+				'target' => '#misc-pub-pinned',
34
+				'title' => __('Pin Your Reviews', 'site-reviews'),
35
+			]],
36
+		]);
37
+		$this->execute($command);
38
+	}
39
+
40
+	/**
41
+	 * @return array
42
+	 * @filter plugin_action_links_site-reviews/site-reviews.php
43
+	 */
44
+	public function filterActionLinks(array $links)
45
+	{
46
+		$links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
47
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
48
+		]);
49
+		$links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
50
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
51
+		]);
52
+		return $links;
53
+	}
54
+
55
+	/**
56
+	 * @param array $capabilities
57
+	 * @param string $capability
58
+	 * @return array
59
+	 * @filter map_meta_cap
60
+	 */
61
+	public function filterCreateCapability($capabilities, $capability)
62
+	{
63
+		if ($capability == 'create_'.Application::POST_TYPE) {
64
+			$capabilities[] = 'do_not_allow';
65
+		}
66
+		return $capabilities;
67
+	}
68
+
69
+	/**
70
+	 * @param array $items
71
+	 * @return array
72
+	 * @filter dashboard_glance_items
73
+	 */
74
+	public function filterDashboardGlanceItems($items)
75
+	{
76
+		$postCount = wp_count_posts(Application::POST_TYPE);
77
+		if (empty($postCount->publish)) {
78
+			return $items;
79
+		}
80
+		$text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
81
+		$text = sprintf($text, number_format_i18n($postCount->publish));
82
+		$items = glsr(Helper::class)->consolidateArray($items);
83
+		$items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts)
84
+			? glsr(Builder::class)->a($text, [
85
+				'class' => 'glsr-review-count',
86
+				'href' => 'edit.php?post_type='.Application::POST_TYPE,
87
+			])
88
+			: glsr(Builder::class)->span($text, [
89
+				'class' => 'glsr-review-count',
90
+			]);
91
+		return $items;
92
+	}
93
+
94
+	/**
95
+	 * @param array $plugins
96
+	 * @return array
97
+	 * @filter mce_external_plugins
98
+	 */
99
+	public function filterTinymcePlugins($plugins)
100
+	{
101
+		if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
102
+			$plugins = glsr(Helper::class)->consolidateArray($plugins);
103
+			$plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
104
+		}
105
+		return $plugins;
106
+	}
107
+
108
+	/**
109
+	 * @return void
110
+	 * @action admin_init
111
+	 */
112
+	public function registerTinymcePopups()
113
+	{
114
+		$command = new RegisterTinymcePopups([
115
+			'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
116
+			'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
117
+			'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
118
+		]);
119
+		$this->execute($command);
120
+	}
121
+
122
+	/**
123
+	 * @param string $editorId
124
+	 * @return void|null
125
+	 * @action media_buttons
126
+	 */
127
+	public function renderTinymceButton($editorId)
128
+	{
129
+		$allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
130
+		if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
131
+			return;
132
+		}
133
+		$shortcodes = [];
134
+		foreach (glsr()->mceShortcodes as $shortcode => $values) {
135
+			$shortcodes[$shortcode] = $values;
136
+		}
137
+		if (empty($shortcodes)) {
138
+			return;
139
+		}
140
+		glsr()->render('partials/editor/tinymce', [
141
+			'shortcodes' => $shortcodes,
142
+		]);
143
+	}
144
+
145
+	/**
146
+	 * @return void
147
+	 */
148
+	public function routerClearConsole()
149
+	{
150
+		glsr(Console::class)->clear();
151
+		glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
152
+	}
153
+
154
+	/**
155
+	 * @return void
156
+	 */
157
+	public function routerFetchConsole()
158
+	{
159
+		glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
160
+	}
161
+
162
+	/**
163
+	 * @param bool $showNotice
164
+	 * @return void
165
+	 */
166
+	public function routerCountReviews($showNotice = true)
167
+	{
168
+		glsr(CountsManager::class)->countAll();
169
+		glsr(OptionManager::class)->set('last_review_count', current_time('timestamp'));
170
+		if ($showNotice) {
171
+			glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
172
+		}
173
+	}
174
+
175
+	/**
176
+	 * @return void
177
+	 */
178
+	public function routerDownloadConsole()
179
+	{
180
+		$this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
181
+	}
182
+
183
+	/**
184
+	 * @return void
185
+	 */
186
+	public function routerDownloadSystemInfo()
187
+	{
188
+		$this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
189
+	}
190
+
191
+	/**
192
+	 * @return void
193
+	 */
194
+	public function routerExportSettings()
195
+	{
196
+		$this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
197
+	}
198
+
199
+	/**
200
+	 * @return void
201
+	 */
202
+	public function routerImportSettings()
203
+	{
204
+		$file = $_FILES['import-file'];
205
+		if (UPLOAD_ERR_OK !== $file['error']) {
206
+			return glsr(Notice::class)->addError($this->getUploadError($file['error']));
207
+		}
208
+		if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) {
209
+			return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
210
+		}
211
+		$settings = json_decode(file_get_contents($file['tmp_name']), true);
212
+		if (empty($settings)) {
213
+			return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
214
+		}
215
+		glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
216
+		glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
217
+	}
218
+
219
+	/**
220
+	 * @param int $errorCode
221
+	 * @return string
222
+	 */
223
+	protected function getUploadError($errorCode)
224
+	{
225
+		$errors = [
226
+			UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
227
+			UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
228
+			UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
229
+			UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
230
+			UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
231
+			UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
232
+			UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
233
+		];
234
+		return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
235
+	}
236 236
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function enqueueAssets()
23 23
     {
24
-        $command = new EnqueueAdminAssets([
24
+        $command = new EnqueueAdminAssets( [
25 25
             'pointers' => [[
26
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
26
+                'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
27 27
                 'id' => 'glsr-pointer-pinned',
28 28
                 'position' => [
29 29
                     'edge' => 'right',
@@ -31,24 +31,24 @@  discard block
 block discarded – undo
31 31
                 ],
32 32
                 'screen' => Application::POST_TYPE,
33 33
                 'target' => '#misc-pub-pinned',
34
-                'title' => __('Pin Your Reviews', 'site-reviews'),
34
+                'title' => __( 'Pin Your Reviews', 'site-reviews' ),
35 35
             ]],
36
-        ]);
37
-        $this->execute($command);
36
+        ] );
37
+        $this->execute( $command );
38 38
     }
39 39
 
40 40
     /**
41 41
      * @return array
42 42
      * @filter plugin_action_links_site-reviews/site-reviews.php
43 43
      */
44
-    public function filterActionLinks(array $links)
44
+    public function filterActionLinks( array $links )
45 45
     {
46
-        $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
47
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
48
-        ]);
49
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
50
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
51
-        ]);
46
+        $links['documentation'] = glsr( Builder::class )->a( __( 'Help', 'site-reviews' ), [
47
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=documentation' ),
48
+        ] );
49
+        $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
50
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
51
+        ] );
52 52
         return $links;
53 53
     }
54 54
 
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
      * @return array
59 59
      * @filter map_meta_cap
60 60
      */
61
-    public function filterCreateCapability($capabilities, $capability)
61
+    public function filterCreateCapability( $capabilities, $capability )
62 62
     {
63
-        if ($capability == 'create_'.Application::POST_TYPE) {
63
+        if( $capability == 'create_'.Application::POST_TYPE ) {
64 64
             $capabilities[] = 'do_not_allow';
65 65
         }
66 66
         return $capabilities;
@@ -71,23 +71,23 @@  discard block
 block discarded – undo
71 71
      * @return array
72 72
      * @filter dashboard_glance_items
73 73
      */
74
-    public function filterDashboardGlanceItems($items)
74
+    public function filterDashboardGlanceItems( $items )
75 75
     {
76
-        $postCount = wp_count_posts(Application::POST_TYPE);
77
-        if (empty($postCount->publish)) {
76
+        $postCount = wp_count_posts( Application::POST_TYPE );
77
+        if( empty($postCount->publish) ) {
78 78
             return $items;
79 79
         }
80
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
81
-        $text = sprintf($text, number_format_i18n($postCount->publish));
82
-        $items = glsr(Helper::class)->consolidateArray($items);
83
-        $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts)
84
-            ? glsr(Builder::class)->a($text, [
80
+        $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
81
+        $text = sprintf( $text, number_format_i18n( $postCount->publish ) );
82
+        $items = glsr( Helper::class )->consolidateArray( $items );
83
+        $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts )
84
+            ? glsr( Builder::class )->a( $text, [
85 85
                 'class' => 'glsr-review-count',
86 86
                 'href' => 'edit.php?post_type='.Application::POST_TYPE,
87
-            ])
88
-            : glsr(Builder::class)->span($text, [
87
+            ] )
88
+            : glsr( Builder::class )->span( $text, [
89 89
                 'class' => 'glsr-review-count',
90
-            ]);
90
+            ] );
91 91
         return $items;
92 92
     }
93 93
 
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
      * @return array
97 97
      * @filter mce_external_plugins
98 98
      */
99
-    public function filterTinymcePlugins($plugins)
99
+    public function filterTinymcePlugins( $plugins )
100 100
     {
101
-        if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
102
-            $plugins = glsr(Helper::class)->consolidateArray($plugins);
103
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
101
+        if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
102
+            $plugins = glsr( Helper::class )->consolidateArray( $plugins );
103
+            $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
104 104
         }
105 105
         return $plugins;
106 106
     }
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function registerTinymcePopups()
113 113
     {
114
-        $command = new RegisterTinymcePopups([
115
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
116
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
117
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
118
-        ]);
119
-        $this->execute($command);
114
+        $command = new RegisterTinymcePopups( [
115
+            'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
116
+            'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
117
+            'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
118
+        ] );
119
+        $this->execute( $command );
120 120
     }
121 121
 
122 122
     /**
@@ -124,22 +124,22 @@  discard block
 block discarded – undo
124 124
      * @return void|null
125 125
      * @action media_buttons
126 126
      */
127
-    public function renderTinymceButton($editorId)
127
+    public function renderTinymceButton( $editorId )
128 128
     {
129
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
130
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
129
+        $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId );
130
+        if( 'post' != glsr_current_screen()->base || !in_array( $editorId, $allowedEditors ) ) {
131 131
             return;
132 132
         }
133 133
         $shortcodes = [];
134
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
134
+        foreach( glsr()->mceShortcodes as $shortcode => $values ) {
135 135
             $shortcodes[$shortcode] = $values;
136 136
         }
137
-        if (empty($shortcodes)) {
137
+        if( empty($shortcodes) ) {
138 138
             return;
139 139
         }
140
-        glsr()->render('partials/editor/tinymce', [
140
+        glsr()->render( 'partials/editor/tinymce', [
141 141
             'shortcodes' => $shortcodes,
142
-        ]);
142
+        ] );
143 143
     }
144 144
 
145 145
     /**
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function routerClearConsole()
149 149
     {
150
-        glsr(Console::class)->clear();
151
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
150
+        glsr( Console::class )->clear();
151
+        glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
152 152
     }
153 153
 
154 154
     /**
@@ -156,19 +156,19 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function routerFetchConsole()
158 158
     {
159
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
159
+        glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) );
160 160
     }
161 161
 
162 162
     /**
163 163
      * @param bool $showNotice
164 164
      * @return void
165 165
      */
166
-    public function routerCountReviews($showNotice = true)
166
+    public function routerCountReviews( $showNotice = true )
167 167
     {
168
-        glsr(CountsManager::class)->countAll();
169
-        glsr(OptionManager::class)->set('last_review_count', current_time('timestamp'));
170
-        if ($showNotice) {
171
-            glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
168
+        glsr( CountsManager::class )->countAll();
169
+        glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) );
170
+        if( $showNotice ) {
171
+            glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) );
172 172
         }
173 173
     }
174 174
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function routerDownloadConsole()
179 179
     {
180
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
180
+        $this->download( Application::ID.'-console.txt', glsr( Console::class )->get() );
181 181
     }
182 182
 
183 183
     /**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function routerDownloadSystemInfo()
187 187
     {
188
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
188
+        $this->download( Application::ID.'-system-info.txt', glsr( System::class )->get() );
189 189
     }
190 190
 
191 191
     /**
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function routerExportSettings()
195 195
     {
196
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
196
+        $this->download( Application::ID.'-settings.json', glsr( OptionManager::class )->json() );
197 197
     }
198 198
 
199 199
     /**
@@ -202,35 +202,35 @@  discard block
 block discarded – undo
202 202
     public function routerImportSettings()
203 203
     {
204 204
         $file = $_FILES['import-file'];
205
-        if (UPLOAD_ERR_OK !== $file['error']) {
206
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
205
+        if( UPLOAD_ERR_OK !== $file['error'] ) {
206
+            return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
207 207
         }
208
-        if ('application/json' !== $file['type'] || !glsr(Helper::class)->endsWith('.json', $file['name'])) {
209
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
208
+        if( 'application/json' !== $file['type'] || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) {
209
+            return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
210 210
         }
211
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
212
-        if (empty($settings)) {
213
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
211
+        $settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
212
+        if( empty($settings) ) {
213
+            return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
214 214
         }
215
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
216
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
215
+        glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
216
+        glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
217 217
     }
218 218
 
219 219
     /**
220 220
      * @param int $errorCode
221 221
      * @return string
222 222
      */
223
-    protected function getUploadError($errorCode)
223
+    protected function getUploadError( $errorCode )
224 224
     {
225 225
         $errors = [
226
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
227
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
228
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
229
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
230
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
231
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
232
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
226
+            UPLOAD_ERR_INI_SIZE => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews' ),
227
+            UPLOAD_ERR_FORM_SIZE => __( 'The uploaded file is too big.', 'site-reviews' ),
228
+            UPLOAD_ERR_PARTIAL => __( 'The uploaded file was only partially uploaded.', 'site-reviews' ),
229
+            UPLOAD_ERR_NO_FILE => __( 'No file was uploaded.', 'site-reviews' ),
230
+            UPLOAD_ERR_NO_TMP_DIR => __( 'Missing a temporary folder.', 'site-reviews' ),
231
+            UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
232
+            UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
233 233
         ];
234
-        return glsr_get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
234
+        return glsr_get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) );
235 235
     }
236 236
 }
Please login to merge, or discard this patch.
plugin/Defaults/EmailDefaults.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
 
8 8
 class EmailDefaults extends Defaults
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    protected function defaults()
14
-    {
15
-        return [
16
-            'after' => '',
17
-            'attachments' => [],
18
-            'bcc' => '',
19
-            'before' => '',
20
-            'cc' => '',
21
-            'from' => $this->getFromName().' <'.$this->getFromEmail().'>',
22
-            'message' => '',
23
-            'reply-to' => '',
24
-            'subject' => '',
25
-            'template' => '',
26
-            'template-tags' => [],
27
-            'to' => '',
28
-        ];
29
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	protected function defaults()
14
+	{
15
+		return [
16
+			'after' => '',
17
+			'attachments' => [],
18
+			'bcc' => '',
19
+			'before' => '',
20
+			'cc' => '',
21
+			'from' => $this->getFromName().' <'.$this->getFromEmail().'>',
22
+			'message' => '',
23
+			'reply-to' => '',
24
+			'subject' => '',
25
+			'template' => '',
26
+			'template-tags' => [],
27
+			'to' => '',
28
+		];
29
+	}
30 30
 
31
-    /**
32
-     * @return string
33
-     */
34
-    protected function getFromEmail()
35
-    {
36
-        return glsr(OptionManager::class)->getWP('admin_email');
37
-    }
31
+	/**
32
+	 * @return string
33
+	 */
34
+	protected function getFromEmail()
35
+	{
36
+		return glsr(OptionManager::class)->getWP('admin_email');
37
+	}
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    protected function getFromName()
43
-    {
44
-        return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES);
45
-    }
39
+	/**
40
+	 * @return string
41
+	 */
42
+	protected function getFromName()
43
+	{
44
+		return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES);
45
+	}
46 46
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     protected function getFromEmail()
35 35
     {
36
-        return glsr(OptionManager::class)->getWP('admin_email');
36
+        return glsr( OptionManager::class )->getWP( 'admin_email' );
37 37
     }
38 38
 
39 39
     /**
@@ -41,6 +41,6 @@  discard block
 block discarded – undo
41 41
      */
42 42
     protected function getFromName()
43 43
     {
44
-        return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES);
44
+        return wp_specialchars_decode( glsr( OptionManager::class )->getWP( 'blogname' ), ENT_QUOTES );
45 45
     }
46 46
 }
Please login to merge, or discard this patch.
views/pages/welcome/whatsnew.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <p class="about-description">We think you'll love the changes in this new release!</p>
4 4
 <div class="is-fullwidth">
Please login to merge, or discard this patch.
views/pages/welcome/index.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <div class="glsr-welcome wrap about-wrap about-wrap-content">
4 4
     <h1>Welcome to <?= glsr()->name; ?></h1>
5 5
     <div class="about-text">Site Reviews is a free WordPress review plugin with advanced features that makes it easy to manage reviews on your website. Follow the instructions below to get started!</div>
6 6
     <div class="wp-badge">Version <?= glsr()->version; ?></div>
7 7
     <p class="about-buttons">
8
-        <a class="button" href="<?= admin_url('edit.php?post_type=site-review&page=documentation'); ?>">Documentation</a>
8
+        <a class="button" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation' ); ?>">Documentation</a>
9 9
         <a class="button" href="https://wordpress.org/support/plugin/site-reviews/">Support</a>
10 10
         <a target="_blank" class="button" href="https://www.facebook.com/sharer/sharer.php?u=https%3A//geminilabs.io/site-reviews"><span class="dashicons dashicons-facebook-alt"></span> Share</a>
11 11
         <a target="_blank" class="button" href="https://twitter.com/intent/tweet?text=Site Reviews is a fantastic WordPress review plugin with advanced features that makes it easy to manage reviews on your website.&url=https://geminilabs.io/site-reviews&hashtags=WordPress,reviewplugins,"><span class="dashicons dashicons-twitter"></span> Tweet</a>
12 12
     </p>
13 13
     <nav class="glsr-nav-tab-wrapper nav-tab-wrapper">
14
-        <?php foreach ($tabs as $id => $title) : ?>
14
+        <?php foreach( $tabs as $id => $title ) : ?>
15 15
         <a class="glsr-nav-tab nav-tab" href="#<?= $id; ?>"><?= $title; ?></a>
16 16
         <?php endforeach; ?>
17 17
     </nav>
18
-    <?php foreach ($tabs as $id => $title) : ?>
18
+    <?php foreach( $tabs as $id => $title ) : ?>
19 19
     <div class="glsr-nav-view ui-tabs-hide" id="<?= $id; ?>">
20
-        <?php $template->render('pages/welcome/'.$id, $data); ?>
20
+        <?php $template->render( 'pages/welcome/'.$id, $data ); ?>
21 21
     </div>
22 22
     <?php endforeach; ?>
23 23
     <input type="hidden" name="_active_tab">
Please login to merge, or discard this patch.
views/pages/documentation/hooks.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <p>Hooks (also known as <a href="https://developer.wordpress.org/plugins/hooks/index.html">Actions and Filters</a>) are used in your theme's <code>functions.php</code> file to make changes to the plugin.</p>
4 4
 
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
     <div class="glsr-card-header">
7 7
         <h3>Customise the order of the fields in the review submission form</h3>
8 8
         <button type="button" class="handlediv" aria-expanded="true">
9
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
9
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
10 10
             <span class="toggle-indicator" aria-hidden="true"></span>
11 11
         </button>
12 12
     </div>
13 13
     <div class="inside">
14 14
         <p>Use this hook to customise the order of the fields in the review submission form used by Site Reviews.</p>
15
-        <p>See the <code><a data-expand="#faq-07" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p>
15
+        <p>See the <code><a data-expand="#faq-07" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p>
16 16
         <pre><code class="php">/**
17 17
  * Customises the order of the fields used in the Site Reviews submission form.
18 18
  * Paste this in your active theme's functions.php file.
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
     <div class="glsr-card-header">
31 31
         <h3>Customise the star images</h3>
32 32
         <button type="button" class="handlediv" aria-expanded="true">
33
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
33
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
34 34
             <span class="toggle-indicator" aria-hidden="true"></span>
35 35
         </button>
36 36
     </div>
37 37
     <div class="inside">
38 38
         <p>Use this hook to customise the star images used by Site Reviews.</p>
39
-        <p>See the <code><a data-expand="#faq-11" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p>
39
+        <p>See the <code><a data-expand="#faq-11" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p>
40 40
         <pre><code class="php">/**
41 41
  * Customises the stars used by Site Reviews.
42 42
  * Paste this in your active theme's functions.php file.
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     <div class="glsr-card-header">
55 55
         <h3>Disable the plugin javascript</h3>
56 56
         <button type="button" class="handlediv" aria-expanded="true">
57
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
57
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
58 58
             <span class="toggle-indicator" aria-hidden="true"></span>
59 59
         </button>
60 60
     </div>
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     <div class="glsr-card-header">
74 74
         <h3>Disable the plugin stylesheet</h3>
75 75
         <button type="button" class="handlediv" aria-expanded="true">
76
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
76
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
77 77
             <span class="toggle-indicator" aria-hidden="true"></span>
78 78
         </button>
79 79
     </div>
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     <div class="glsr-card-header">
93 93
         <h3>Disable the polyfill.io script</h3>
94 94
         <button type="button" class="handlediv" aria-expanded="true">
95
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
95
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
96 96
             <span class="toggle-indicator" aria-hidden="true"></span>
97 97
         </button>
98 98
     </div>
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     <div class="glsr-card-header">
113 113
         <h3>Do something immediately after a review has been submitted</h3>
114 114
         <button type="button" class="handlediv" aria-expanded="true">
115
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
115
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
116 116
             <span class="toggle-indicator" aria-hidden="true"></span>
117 117
         </button>
118 118
     </div>
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
     <div class="glsr-card-header">
137 137
         <h3>Modify the schema</h3>
138 138
         <button type="button" class="handlediv" aria-expanded="true">
139
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
139
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
140 140
             <span class="toggle-indicator" aria-hidden="true"></span>
141 141
         </button>
142 142
     </div>
143 143
     <div class="inside">
144 144
         <p>Use this hook if you would like to modify the schema type properties.</p>
145 145
         <p>This hook is specific to the schema type. For example, to modify the schema properties for the LocalBusiness schema type you would use the <code>site-reviews/schema/LocalBusiness</code> hook, but to modify the schema properties for the Product schema type you would use the <code>site-reviews/schema/Product</code> hook.</p>
146
-        <p>See the <code><a data-expand="#faq-01" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p>
146
+        <p>See the <code><a data-expand="#faq-01" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p>
147 147
         <p>Make sure to use Google's <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test the schema after any custom modifications have been made.</p>
148 148
         <pre><code class="php">/**
149 149
  * Modifies the properties of the schema created by Site Reviews.
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     <div class="glsr-card-header">
164 164
         <h3>Modify the submitted review before it is saved</h3>
165 165
         <button type="button" class="handlediv" aria-expanded="true">
166
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
166
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
167 167
             <span class="toggle-indicator" aria-hidden="true"></span>
168 168
         </button>
169 169
     </div>
Please login to merge, or discard this patch.
views/pages/settings/schema.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3
-<p><?= __('The JSON-LD schema is disabled by default. To use it, please enable the option in your blocks or shortcodes. The schema appears in Google\'s search results and shows the star rating and other information about your reviews. If the schema has been enabled, you can use Google\'s <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test your pages for valid schema data.', 'site-reviews'); ?></p>
4
-<p><?= __('You may override any of these options on a per-post/page basis by using its Custom Field name and adding a custom value using the <a href="https://codex.wordpress.org/Using_Custom_Fields#Usage">Custom Fields</a> metabox.', 'site-reviews'); ?></p>
3
+<p><?= __( 'The JSON-LD schema is disabled by default. To use it, please enable the option in your blocks or shortcodes. The schema appears in Google\'s search results and shows the star rating and other information about your reviews. If the schema has been enabled, you can use Google\'s <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test your pages for valid schema data.', 'site-reviews' ); ?></p>
4
+<p><?= __( 'You may override any of these options on a per-post/page basis by using its Custom Field name and adding a custom value using the <a href="https://codex.wordpress.org/Using_Custom_Fields#Usage">Custom Fields</a> metabox.', 'site-reviews' ); ?></p>
5 5
 <table class="form-table">
6 6
     <tbody>
7 7
         {{ rows }}
Please login to merge, or discard this patch.
plugin/Controllers/MainController.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -10,94 +10,94 @@
 block discarded – undo
10 10
 
11 11
 class MainController extends Controller
12 12
 {
13
-    /**
14
-     * @return void
15
-     * @action init
16
-     */
17
-    public function registerPostType()
18
-    {
19
-        if (!glsr()->hasPermission()) {
20
-            return;
21
-        }
22
-        $command = new RegisterPostType([
23
-            'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE],
24
-            'columns' => [
25
-                'title' => '',
26
-                'category' => '',
27
-                'assigned_to' => __('Assigned To', 'site-reviews'),
28
-                'reviewer' => __('Author', 'site-reviews'),
29
-                'review_type' => __('Type', 'site-reviews'),
30
-                'rating' => __('Rating', 'site-reviews'),
31
-                'pinned' => __('Pinned', 'site-reviews'),
32
-                'date' => '',
33
-            ],
34
-            'menu_icon' => 'dashicons-star-half',
35
-            'menu_name' => glsr()->name,
36
-            'map_meta_cap' => true,
37
-            'plural' => __('Reviews', 'site-reviews'),
38
-            'post_type' => Application::POST_TYPE,
39
-            'rest_controller_class' => RestReviewController::class,
40
-            'show_in_rest' => true,
41
-            'single' => __('Review', 'site-reviews'),
42
-        ]);
43
-        $this->execute($command);
44
-    }
13
+	/**
14
+	 * @return void
15
+	 * @action init
16
+	 */
17
+	public function registerPostType()
18
+	{
19
+		if (!glsr()->hasPermission()) {
20
+			return;
21
+		}
22
+		$command = new RegisterPostType([
23
+			'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE],
24
+			'columns' => [
25
+				'title' => '',
26
+				'category' => '',
27
+				'assigned_to' => __('Assigned To', 'site-reviews'),
28
+				'reviewer' => __('Author', 'site-reviews'),
29
+				'review_type' => __('Type', 'site-reviews'),
30
+				'rating' => __('Rating', 'site-reviews'),
31
+				'pinned' => __('Pinned', 'site-reviews'),
32
+				'date' => '',
33
+			],
34
+			'menu_icon' => 'dashicons-star-half',
35
+			'menu_name' => glsr()->name,
36
+			'map_meta_cap' => true,
37
+			'plural' => __('Reviews', 'site-reviews'),
38
+			'post_type' => Application::POST_TYPE,
39
+			'rest_controller_class' => RestReviewController::class,
40
+			'show_in_rest' => true,
41
+			'single' => __('Review', 'site-reviews'),
42
+		]);
43
+		$this->execute($command);
44
+	}
45 45
 
46
-    /**
47
-     * @return void
48
-     * @action init
49
-     */
50
-    public function registerShortcodes()
51
-    {
52
-        $command = new RegisterShortcodes([
53
-            'site_reviews',
54
-            'site_reviews_form',
55
-            'site_reviews_summary',
56
-        ]);
57
-        $this->execute($command);
58
-    }
46
+	/**
47
+	 * @return void
48
+	 * @action init
49
+	 */
50
+	public function registerShortcodes()
51
+	{
52
+		$command = new RegisterShortcodes([
53
+			'site_reviews',
54
+			'site_reviews_form',
55
+			'site_reviews_summary',
56
+		]);
57
+		$this->execute($command);
58
+	}
59 59
 
60
-    /**
61
-     * @return void
62
-     * @action init
63
-     */
64
-    public function registerTaxonomy()
65
-    {
66
-        $command = new RegisterTaxonomy([
67
-            'hierarchical' => true,
68
-            'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'],
69
-            'public' => false,
70
-            'rest_controller_class' => RestCategoryController::class,
71
-            'show_admin_column' => true,
72
-            'show_in_rest' => true,
73
-            'show_ui' => true,
74
-        ]);
75
-        $this->execute($command);
76
-    }
60
+	/**
61
+	 * @return void
62
+	 * @action init
63
+	 */
64
+	public function registerTaxonomy()
65
+	{
66
+		$command = new RegisterTaxonomy([
67
+			'hierarchical' => true,
68
+			'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'],
69
+			'public' => false,
70
+			'rest_controller_class' => RestCategoryController::class,
71
+			'show_admin_column' => true,
72
+			'show_in_rest' => true,
73
+			'show_ui' => true,
74
+		]);
75
+		$this->execute($command);
76
+	}
77 77
 
78
-    /**
79
-     * @return void
80
-     * @action widgets_init
81
-     */
82
-    public function registerWidgets()
83
-    {
84
-        $command = new RegisterWidgets([
85
-            'site-reviews' => [
86
-                'class' => 'glsr-widget glsr-widget-site-reviews',
87
-                'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'),
88
-                'title' => __('Recent Reviews', 'site-reviews'),
89
-            ],
90
-            'site-reviews-form' => [
91
-                'class' => 'glsr-widget glsr-widget-site-reviews-form',
92
-                'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'),
93
-                'title' => __('Submit a Review', 'site-reviews'),
94
-            ],
95
-            'site-reviews-summary' => [
96
-                'class' => 'glsr-widget glsr-widget-site-reviews-summary',
97
-                'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'),
98
-                'title' => __('Summary of Reviews', 'site-reviews'),
99
-            ],
100
-        ]);
101
-        $this->execute($command);
102
-    }
78
+	/**
79
+	 * @return void
80
+	 * @action widgets_init
81
+	 */
82
+	public function registerWidgets()
83
+	{
84
+		$command = new RegisterWidgets([
85
+			'site-reviews' => [
86
+				'class' => 'glsr-widget glsr-widget-site-reviews',
87
+				'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'),
88
+				'title' => __('Recent Reviews', 'site-reviews'),
89
+			],
90
+			'site-reviews-form' => [
91
+				'class' => 'glsr-widget glsr-widget-site-reviews-form',
92
+				'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'),
93
+				'title' => __('Submit a Review', 'site-reviews'),
94
+			],
95
+			'site-reviews-summary' => [
96
+				'class' => 'glsr-widget glsr-widget-site-reviews-summary',
97
+				'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'),
98
+				'title' => __('Summary of Reviews', 'site-reviews'),
99
+			],
100
+		]);
101
+		$this->execute($command);
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -16,31 +16,31 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public function registerPostType()
18 18
     {
19
-        if (!glsr()->hasPermission()) {
19
+        if( !glsr()->hasPermission() ) {
20 20
             return;
21 21
         }
22
-        $command = new RegisterPostType([
22
+        $command = new RegisterPostType( [
23 23
             'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE],
24 24
             'columns' => [
25 25
                 'title' => '',
26 26
                 'category' => '',
27
-                'assigned_to' => __('Assigned To', 'site-reviews'),
28
-                'reviewer' => __('Author', 'site-reviews'),
29
-                'review_type' => __('Type', 'site-reviews'),
30
-                'rating' => __('Rating', 'site-reviews'),
31
-                'pinned' => __('Pinned', 'site-reviews'),
27
+                'assigned_to' => __( 'Assigned To', 'site-reviews' ),
28
+                'reviewer' => __( 'Author', 'site-reviews' ),
29
+                'review_type' => __( 'Type', 'site-reviews' ),
30
+                'rating' => __( 'Rating', 'site-reviews' ),
31
+                'pinned' => __( 'Pinned', 'site-reviews' ),
32 32
                 'date' => '',
33 33
             ],
34 34
             'menu_icon' => 'dashicons-star-half',
35 35
             'menu_name' => glsr()->name,
36 36
             'map_meta_cap' => true,
37
-            'plural' => __('Reviews', 'site-reviews'),
37
+            'plural' => __( 'Reviews', 'site-reviews' ),
38 38
             'post_type' => Application::POST_TYPE,
39 39
             'rest_controller_class' => RestReviewController::class,
40 40
             'show_in_rest' => true,
41
-            'single' => __('Review', 'site-reviews'),
42
-        ]);
43
-        $this->execute($command);
41
+            'single' => __( 'Review', 'site-reviews' ),
42
+        ] );
43
+        $this->execute( $command );
44 44
     }
45 45
 
46 46
     /**
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function registerShortcodes()
51 51
     {
52
-        $command = new RegisterShortcodes([
52
+        $command = new RegisterShortcodes( [
53 53
             'site_reviews',
54 54
             'site_reviews_form',
55 55
             'site_reviews_summary',
56
-        ]);
57
-        $this->execute($command);
56
+        ] );
57
+        $this->execute( $command );
58 58
     }
59 59
 
60 60
     /**
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function registerTaxonomy()
65 65
     {
66
-        $command = new RegisterTaxonomy([
66
+        $command = new RegisterTaxonomy( [
67 67
             'hierarchical' => true,
68
-            'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'],
68
+            'meta_box_cb' => [glsr( EditorController::class ), 'renderTaxonomyMetabox'],
69 69
             'public' => false,
70 70
             'rest_controller_class' => RestCategoryController::class,
71 71
             'show_admin_column' => true,
72 72
             'show_in_rest' => true,
73 73
             'show_ui' => true,
74
-        ]);
75
-        $this->execute($command);
74
+        ] );
75
+        $this->execute( $command );
76 76
     }
77 77
 
78 78
     /**
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function registerWidgets()
83 83
     {
84
-        $command = new RegisterWidgets([
84
+        $command = new RegisterWidgets( [
85 85
             'site-reviews' => [
86 86
                 'class' => 'glsr-widget glsr-widget-site-reviews',
87
-                'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'),
88
-                'title' => __('Recent Reviews', 'site-reviews'),
87
+                'description' => __( 'Site Reviews: Display your recent reviews.', 'site-reviews' ),
88
+                'title' => __( 'Recent Reviews', 'site-reviews' ),
89 89
             ],
90 90
             'site-reviews-form' => [
91 91
                 'class' => 'glsr-widget glsr-widget-site-reviews-form',
92
-                'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'),
93
-                'title' => __('Submit a Review', 'site-reviews'),
92
+                'description' => __( 'Site Reviews: Display a form to submit reviews.', 'site-reviews' ),
93
+                'title' => __( 'Submit a Review', 'site-reviews' ),
94 94
             ],
95 95
             'site-reviews-summary' => [
96 96
                 'class' => 'glsr-widget glsr-widget-site-reviews-summary',
97
-                'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'),
98
-                'title' => __('Summary of Reviews', 'site-reviews'),
97
+                'description' => __( 'Site Reviews: Display a summary of your reviews.', 'site-reviews' ),
98
+                'title' => __( 'Summary of Reviews', 'site-reviews' ),
99 99
             ],
100
-        ]);
101
-        $this->execute($command);
100
+        ] );
101
+        $this->execute( $command );
102 102
     }
103 103
 }
Please login to merge, or discard this patch.