Passed
Push — feature/rebusify ( 495106...67b08f )
by Paul
06:10 queued 02:03
created
plugin/Controllers/EditorController.php 2 patches
Indentation   +399 added lines, -399 removed lines patch added patch discarded remove patch
@@ -19,430 +19,430 @@
 block discarded – undo
19 19
 
20 20
 class EditorController extends Controller
21 21
 {
22
-    /**
23
-     * @return void
24
-     * @action admin_enqueue_scripts
25
-     */
26
-    public function customizePostStatusLabels()
27
-    {
28
-        glsr(Labels::class)->customizePostStatusLabels();
29
-    }
22
+	/**
23
+	 * @return void
24
+	 * @action admin_enqueue_scripts
25
+	 */
26
+	public function customizePostStatusLabels()
27
+	{
28
+		glsr(Labels::class)->customizePostStatusLabels();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $settings
33
-     * @return array
34
-     * @filter wp_editor_settings
35
-     */
36
-    public function filterEditorSettings($settings)
37
-    {
38
-        return glsr(Customization::class)->filterEditorSettings(
39
-            glsr(Helper::class)->consolidateArray($settings)
40
-        );
41
-    }
31
+	/**
32
+	 * @param array $settings
33
+	 * @return array
34
+	 * @filter wp_editor_settings
35
+	 */
36
+	public function filterEditorSettings($settings)
37
+	{
38
+		return glsr(Customization::class)->filterEditorSettings(
39
+			glsr(Helper::class)->consolidateArray($settings)
40
+		);
41
+	}
42 42
 
43
-    /**
44
-     * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
45
-     * @param string $html
46
-     * @return string
47
-     * @filter the_editor
48
-     */
49
-    public function filterEditorTextarea($html)
50
-    {
51
-        return glsr(Customization::class)->filterEditorTextarea($html);
52
-    }
43
+	/**
44
+	 * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
45
+	 * @param string $html
46
+	 * @return string
47
+	 * @filter the_editor
48
+	 */
49
+	public function filterEditorTextarea($html)
50
+	{
51
+		return glsr(Customization::class)->filterEditorTextarea($html);
52
+	}
53 53
 
54
-    /**
55
-     * @param bool $protected
56
-     * @param string $metaKey
57
-     * @param string $metaType
58
-     * @return bool
59
-     * @filter is_protected_meta
60
-     */
61
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
62
-    {
63
-        if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
64
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
65
-            $values = glsr(Helper::class)->prefixArrayKeys($values);
66
-            if (array_key_exists($metaKey, $values)) {
67
-                $protected = false;
68
-            }
69
-        }
70
-        return $protected;
71
-    }
54
+	/**
55
+	 * @param bool $protected
56
+	 * @param string $metaKey
57
+	 * @param string $metaType
58
+	 * @return bool
59
+	 * @filter is_protected_meta
60
+	 */
61
+	public function filterIsProtectedMeta($protected, $metaKey, $metaType)
62
+	{
63
+		if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
64
+			$values = glsr(CreateReviewDefaults::class)->unguarded();
65
+			$values = glsr(Helper::class)->prefixArrayKeys($values);
66
+			if (array_key_exists($metaKey, $values)) {
67
+				$protected = false;
68
+			}
69
+		}
70
+		return $protected;
71
+	}
72 72
 
73
-    /**
74
-     * @param string $translation
75
-     * @param string $test
76
-     * @param string $domain
77
-     * @return string
78
-     * @filter gettext
79
-     */
80
-    public function filterPostStatusLabels($translation, $text, $domain)
81
-    {
82
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
83
-    }
73
+	/**
74
+	 * @param string $translation
75
+	 * @param string $test
76
+	 * @param string $domain
77
+	 * @return string
78
+	 * @filter gettext
79
+	 */
80
+	public function filterPostStatusLabels($translation, $text, $domain)
81
+	{
82
+		return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
83
+	}
84 84
 
85
-    /**
86
-     * @param string $translation
87
-     * @param string $test
88
-     * @param string $domain
89
-     * @return string
90
-     * @filter gettext_with_context
91
-     */
92
-    public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain)
93
-    {
94
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
95
-    }
85
+	/**
86
+	 * @param string $translation
87
+	 * @param string $test
88
+	 * @param string $domain
89
+	 * @return string
90
+	 * @filter gettext_with_context
91
+	 */
92
+	public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain)
93
+	{
94
+		return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
95
+	}
96 96
 
97
-    /**
98
-     * @param array $messages
99
-     * @return array
100
-     * @filter post_updated_messages
101
-     */
102
-    public function filterUpdateMessages($messages)
103
-    {
104
-        return glsr(Labels::class)->filterUpdateMessages(
105
-            glsr(Helper::class)->consolidateArray($messages)
106
-        );
107
-    }
97
+	/**
98
+	 * @param array $messages
99
+	 * @return array
100
+	 * @filter post_updated_messages
101
+	 */
102
+	public function filterUpdateMessages($messages)
103
+	{
104
+		return glsr(Labels::class)->filterUpdateMessages(
105
+			glsr(Helper::class)->consolidateArray($messages)
106
+		);
107
+	}
108 108
 
109
-    /**
110
-     * @return void
111
-     * @action add_meta_boxes_{Application::POST_TYPE}
112
-     */
113
-    public function registerMetaBoxes($post)
114
-    {
115
-        add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
116
-        add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
117
-        if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
118
-            return;
119
-        }
120
-        add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
121
-    }
109
+	/**
110
+	 * @return void
111
+	 * @action add_meta_boxes_{Application::POST_TYPE}
112
+	 */
113
+	public function registerMetaBoxes($post)
114
+	{
115
+		add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
116
+		add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
117
+		if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
118
+			return;
119
+		}
120
+		add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
121
+	}
122 122
 
123
-    /**
124
-     * @return void
125
-     * @action admin_print_scripts
126
-     */
127
-    public function removeAutosave()
128
-    {
129
-        glsr(Customization::class)->removeAutosave();
130
-    }
123
+	/**
124
+	 * @return void
125
+	 * @action admin_print_scripts
126
+	 */
127
+	public function removeAutosave()
128
+	{
129
+		glsr(Customization::class)->removeAutosave();
130
+	}
131 131
 
132
-    /**
133
-     * @return void
134
-     * @action admin_menu
135
-     */
136
-    public function removeMetaBoxes()
137
-    {
138
-        glsr(Customization::class)->removeMetaBoxes();
139
-    }
132
+	/**
133
+	 * @return void
134
+	 * @action admin_menu
135
+	 */
136
+	public function removeMetaBoxes()
137
+	{
138
+		glsr(Customization::class)->removeMetaBoxes();
139
+	}
140 140
 
141
-    /**
142
-     * @return void
143
-     */
144
-    public function removePostTypeSupport()
145
-    {
146
-        glsr(Customization::class)->removePostTypeSupport();
147
-    }
141
+	/**
142
+	 * @return void
143
+	 */
144
+	public function removePostTypeSupport()
145
+	{
146
+		glsr(Customization::class)->removePostTypeSupport();
147
+	}
148 148
 
149
-    /**
150
-     * @param WP_Post $post
151
-     * @return void
152
-     * @callback add_meta_box
153
-     */
154
-    public function renderAssignedToMetabox($post)
155
-    {
156
-        if (!$this->isReviewPostType($post)) {
157
-            return;
158
-        }
159
-        $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
160
-        wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
161
-        glsr()->render('partials/editor/metabox-assigned-to', [
162
-            'id' => $assignedTo,
163
-            'template' => $this->buildAssignedToTemplate($assignedTo, $post),
164
-        ]);
165
-    }
149
+	/**
150
+	 * @param WP_Post $post
151
+	 * @return void
152
+	 * @callback add_meta_box
153
+	 */
154
+	public function renderAssignedToMetabox($post)
155
+	{
156
+		if (!$this->isReviewPostType($post)) {
157
+			return;
158
+		}
159
+		$assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
160
+		wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
161
+		glsr()->render('partials/editor/metabox-assigned-to', [
162
+			'id' => $assignedTo,
163
+			'template' => $this->buildAssignedToTemplate($assignedTo, $post),
164
+		]);
165
+	}
166 166
 
167
-    /**
168
-     * @param WP_Post $post
169
-     * @return void
170
-     * @callback add_meta_box
171
-     */
172
-    public function renderDetailsMetaBox($post)
173
-    {
174
-        if (!$this->isReviewPostType($post)) {
175
-            return;
176
-        }
177
-        $review = glsr_get_review($post);
178
-        glsr()->render('partials/editor/metabox-details', [
179
-            'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
180
-            'metabox' => $this->normalizeDetailsMetaBox($review),
181
-        ]);
182
-    }
167
+	/**
168
+	 * @param WP_Post $post
169
+	 * @return void
170
+	 * @callback add_meta_box
171
+	 */
172
+	public function renderDetailsMetaBox($post)
173
+	{
174
+		if (!$this->isReviewPostType($post)) {
175
+			return;
176
+		}
177
+		$review = glsr_get_review($post);
178
+		glsr()->render('partials/editor/metabox-details', [
179
+			'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
180
+			'metabox' => $this->normalizeDetailsMetaBox($review),
181
+		]);
182
+	}
183 183
 
184
-    /**
185
-     * @return void
186
-     * @action post_submitbox_misc_actions
187
-     */
188
-    public function renderPinnedInPublishMetaBox()
189
-    {
190
-        if (!$this->isReviewPostType(get_post())) {
191
-            return;
192
-        }
193
-        glsr(Template::class)->render('partials/editor/pinned', [
194
-            'context' => [
195
-                'no' => __('No', 'site-reviews'),
196
-                'yes' => __('Yes', 'site-reviews'),
197
-            ],
198
-            'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
199
-        ]);
200
-    }
184
+	/**
185
+	 * @return void
186
+	 * @action post_submitbox_misc_actions
187
+	 */
188
+	public function renderPinnedInPublishMetaBox()
189
+	{
190
+		if (!$this->isReviewPostType(get_post())) {
191
+			return;
192
+		}
193
+		glsr(Template::class)->render('partials/editor/pinned', [
194
+			'context' => [
195
+				'no' => __('No', 'site-reviews'),
196
+				'yes' => __('Yes', 'site-reviews'),
197
+			],
198
+			'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
199
+		]);
200
+	}
201 201
 
202
-    /**
203
-     * @param WP_Post $post
204
-     * @return void
205
-     * @callback add_meta_box
206
-     */
207
-    public function renderResponseMetaBox($post)
208
-    {
209
-        if (!$this->isReviewPostType($post)) {
210
-            return;
211
-        }
212
-        wp_nonce_field('response', '_nonce-response', false);
213
-        glsr()->render('partials/editor/metabox-response', [
214
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
215
-        ]);
216
-    }
202
+	/**
203
+	 * @param WP_Post $post
204
+	 * @return void
205
+	 * @callback add_meta_box
206
+	 */
207
+	public function renderResponseMetaBox($post)
208
+	{
209
+		if (!$this->isReviewPostType($post)) {
210
+			return;
211
+		}
212
+		wp_nonce_field('response', '_nonce-response', false);
213
+		glsr()->render('partials/editor/metabox-response', [
214
+			'response' => glsr(Database::class)->get($post->ID, 'response'),
215
+		]);
216
+	}
217 217
 
218
-    /**
219
-     * @param WP_Post $post
220
-     * @return void
221
-     * @action edit_form_after_title
222
-     */
223
-    public function renderReviewEditor($post)
224
-    {
225
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
226
-            return;
227
-        }
228
-        glsr()->render('partials/editor/review', [
229
-            'post' => $post,
230
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
231
-        ]);
232
-    }
218
+	/**
219
+	 * @param WP_Post $post
220
+	 * @return void
221
+	 * @action edit_form_after_title
222
+	 */
223
+	public function renderReviewEditor($post)
224
+	{
225
+		if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
226
+			return;
227
+		}
228
+		glsr()->render('partials/editor/review', [
229
+			'post' => $post,
230
+			'response' => glsr(Database::class)->get($post->ID, 'response'),
231
+		]);
232
+	}
233 233
 
234
-    /**
235
-     * @return void
236
-     * @action admin_head
237
-     */
238
-    public function renderReviewFields()
239
-    {
240
-        $screen = glsr_current_screen();
241
-        if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
242
-            return;
243
-        }
244
-        add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
245
-        add_action('edit_form_top', [$this, 'renderReviewNotice']);
246
-    }
234
+	/**
235
+	 * @return void
236
+	 * @action admin_head
237
+	 */
238
+	public function renderReviewFields()
239
+	{
240
+		$screen = glsr_current_screen();
241
+		if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
242
+			return;
243
+		}
244
+		add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
245
+		add_action('edit_form_top', [$this, 'renderReviewNotice']);
246
+	}
247 247
 
248
-    /**
249
-     * @param WP_Post $post
250
-     * @return void
251
-     * @action edit_form_top
252
-     */
253
-    public function renderReviewNotice($post)
254
-    {
255
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
256
-            return;
257
-        }
258
-        glsr(Notice::class)->addWarning(sprintf(
259
-            __('%s reviews are read-only.', 'site-reviews'),
260
-            glsr(Columns::class)->buildColumnReviewType($post->ID)
261
-        ));
262
-        glsr(Template::class)->render('partials/editor/notice', [
263
-            'context' => [
264
-                'notices' => glsr(Notice::class)->get(),
265
-            ],
266
-        ]);
267
-    }
248
+	/**
249
+	 * @param WP_Post $post
250
+	 * @return void
251
+	 * @action edit_form_top
252
+	 */
253
+	public function renderReviewNotice($post)
254
+	{
255
+		if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
256
+			return;
257
+		}
258
+		glsr(Notice::class)->addWarning(sprintf(
259
+			__('%s reviews are read-only.', 'site-reviews'),
260
+			glsr(Columns::class)->buildColumnReviewType($post->ID)
261
+		));
262
+		glsr(Template::class)->render('partials/editor/notice', [
263
+			'context' => [
264
+				'notices' => glsr(Notice::class)->get(),
265
+			],
266
+		]);
267
+	}
268 268
 
269
-    /**
270
-     * @param WP_Post $post
271
-     * @return void
272
-     * @see glsr_categories_meta_box()
273
-     * @callback register_taxonomy
274
-     */
275
-    public function renderTaxonomyMetabox($post)
276
-    {
277
-        if (!$this->isReviewPostType($post)) {
278
-            return;
279
-        }
280
-        glsr()->render('partials/editor/metabox-categories', [
281
-            'post' => $post,
282
-            'tax_name' => Application::TAXONOMY,
283
-            'taxonomy' => get_taxonomy(Application::TAXONOMY),
284
-        ]);
285
-    }
269
+	/**
270
+	 * @param WP_Post $post
271
+	 * @return void
272
+	 * @see glsr_categories_meta_box()
273
+	 * @callback register_taxonomy
274
+	 */
275
+	public function renderTaxonomyMetabox($post)
276
+	{
277
+		if (!$this->isReviewPostType($post)) {
278
+			return;
279
+		}
280
+		glsr()->render('partials/editor/metabox-categories', [
281
+			'post' => $post,
282
+			'tax_name' => Application::TAXONOMY,
283
+			'taxonomy' => get_taxonomy(Application::TAXONOMY),
284
+		]);
285
+	}
286 286
 
287
-    /**
288
-     * @return void
289
-     * @see $this->filterUpdateMessages()
290
-     * @action admin_action_revert
291
-     */
292
-    public function revertReview()
293
-    {
294
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
295
-            return;
296
-        }
297
-        check_admin_referer('revert-review_'.($postId = $this->getPostId()));
298
-        glsr(ReviewManager::class)->revert($postId);
299
-        $this->redirect($postId, 52);
300
-    }
287
+	/**
288
+	 * @return void
289
+	 * @see $this->filterUpdateMessages()
290
+	 * @action admin_action_revert
291
+	 */
292
+	public function revertReview()
293
+	{
294
+		if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
295
+			return;
296
+		}
297
+		check_admin_referer('revert-review_'.($postId = $this->getPostId()));
298
+		glsr(ReviewManager::class)->revert($postId);
299
+		$this->redirect($postId, 52);
300
+	}
301 301
 
302
-    /**
303
-     * @param int $postId
304
-     * @return void
305
-     * @action save_post_.Application::POST_TYPE
306
-     */
307
-    public function saveMetaboxes($postId)
308
-    {
309
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
310
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
311
-        do_action('site-reviews/review/saved', glsr_get_review($postId));
312
-    }
302
+	/**
303
+	 * @param int $postId
304
+	 * @return void
305
+	 * @action save_post_.Application::POST_TYPE
306
+	 */
307
+	public function saveMetaboxes($postId)
308
+	{
309
+		glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
310
+		glsr(Metaboxes::class)->saveResponseMetabox($postId);
311
+		do_action('site-reviews/review/saved', glsr_get_review($postId));
312
+	}
313 313
 
314
-    /**
315
-     * @param string $assignedTo
316
-     * @return string
317
-     */
318
-    protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
319
-    {
320
-        $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
321
-        if (!($assignedPost instanceof WP_Post)) {
322
-            return;
323
-        }
324
-        return glsr(Template::class)->build('partials/editor/assigned-post', [
325
-            'context' => [
326
-                'data.url' => (string) get_permalink($assignedPost),
327
-                'data.title' => get_the_title($assignedPost),
328
-            ],
329
-        ]);
330
-    }
314
+	/**
315
+	 * @param string $assignedTo
316
+	 * @return string
317
+	 */
318
+	protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
319
+	{
320
+		$assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
321
+		if (!($assignedPost instanceof WP_Post)) {
322
+			return;
323
+		}
324
+		return glsr(Template::class)->build('partials/editor/assigned-post', [
325
+			'context' => [
326
+				'data.url' => (string) get_permalink($assignedPost),
327
+				'data.title' => get_the_title($assignedPost),
328
+			],
329
+		]);
330
+	}
331 331
 
332
-    /**
333
-     * @return string
334
-     */
335
-    protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
336
-    {
337
-        $isModified = !glsr(Helper::class)->compareArrays(
338
-            [$review->title, $review->content, $review->date],
339
-            [
340
-                glsr(Database::class)->get($post->ID, 'title'),
341
-                glsr(Database::class)->get($post->ID, 'content'),
342
-                glsr(Database::class)->get($post->ID, 'date'),
343
-            ]
344
-        );
345
-        if ($isModified) {
346
-            $revertUrl = wp_nonce_url(
347
-                admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
348
-                'revert-review_'.$post->ID
349
-            );
350
-            return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
351
-                'class' => 'button button-large',
352
-                'href' => $revertUrl,
353
-                'id' => 'revert',
354
-            ]);
355
-        }
356
-        return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
357
-            'class' => 'button-large',
358
-            'disabled' => true,
359
-            'id' => 'revert',
360
-        ]);
361
-    }
332
+	/**
333
+	 * @return string
334
+	 */
335
+	protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
336
+	{
337
+		$isModified = !glsr(Helper::class)->compareArrays(
338
+			[$review->title, $review->content, $review->date],
339
+			[
340
+				glsr(Database::class)->get($post->ID, 'title'),
341
+				glsr(Database::class)->get($post->ID, 'content'),
342
+				glsr(Database::class)->get($post->ID, 'date'),
343
+			]
344
+		);
345
+		if ($isModified) {
346
+			$revertUrl = wp_nonce_url(
347
+				admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
348
+				'revert-review_'.$post->ID
349
+			);
350
+			return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
351
+				'class' => 'button button-large',
352
+				'href' => $revertUrl,
353
+				'id' => 'revert',
354
+			]);
355
+		}
356
+		return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
357
+			'class' => 'button-large',
358
+			'disabled' => true,
359
+			'id' => 'revert',
360
+		]);
361
+	}
362 362
 
363
-    /**
364
-     * @param object $review
365
-     * @return string|void
366
-     */
367
-    protected function getReviewType($review)
368
-    {
369
-        if (count(glsr()->reviewTypes) < 2) {
370
-            return;
371
-        }
372
-        $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
373
-            ? glsr()->reviewTypes[$review->review_type]
374
-            : __('Unknown', 'site-reviews');
375
-        if (!empty($review->url)) {
376
-            $reviewType = glsr(Builder::class)->a($reviewType, [
377
-                'href' => $review->url,
378
-                'target' => '_blank',
379
-            ]);
380
-        }
381
-        return $reviewType;
382
-    }
363
+	/**
364
+	 * @param object $review
365
+	 * @return string|void
366
+	 */
367
+	protected function getReviewType($review)
368
+	{
369
+		if (count(glsr()->reviewTypes) < 2) {
370
+			return;
371
+		}
372
+		$reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
373
+			? glsr()->reviewTypes[$review->review_type]
374
+			: __('Unknown', 'site-reviews');
375
+		if (!empty($review->url)) {
376
+			$reviewType = glsr(Builder::class)->a($reviewType, [
377
+				'href' => $review->url,
378
+				'target' => '_blank',
379
+			]);
380
+		}
381
+		return $reviewType;
382
+	}
383 383
 
384
-    /**
385
-     * @return bool
386
-     */
387
-    protected function isReviewEditable($post)
388
-    {
389
-        return $this->isReviewPostType($post)
390
-            && post_type_supports(Application::POST_TYPE, 'title')
391
-            && 'local' == glsr(Database::class)->get($post->ID, 'review_type');
392
-    }
384
+	/**
385
+	 * @return bool
386
+	 */
387
+	protected function isReviewEditable($post)
388
+	{
389
+		return $this->isReviewPostType($post)
390
+			&& post_type_supports(Application::POST_TYPE, 'title')
391
+			&& 'local' == glsr(Database::class)->get($post->ID, 'review_type');
392
+	}
393 393
 
394
-    /**
395
-     * @param mixed $post
396
-     * @return bool
397
-     */
398
-    protected function isReviewPostType($post)
399
-    {
400
-        return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
401
-    }
394
+	/**
395
+	 * @param mixed $post
396
+	 * @return bool
397
+	 */
398
+	protected function isReviewPostType($post)
399
+	{
400
+		return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
401
+	}
402 402
 
403
-    /**
404
-     * @return array
405
-     */
406
-    protected function normalizeDetailsMetaBox(Review $review)
407
-    {
408
-        $user = empty($review->user_id)
409
-            ? __('Unregistered user', 'site-reviews')
410
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
411
-                'href' => get_author_posts_url($review->user_id),
412
-            ]);
413
-        $email = empty($review->email)
414
-            ? '&mdash;'
415
-            : glsr(Builder::class)->a($review->email, [
416
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
417
-            ]);
418
-        $metabox = [
419
-            __('Rating', 'site-reviews') => glsr_star_rating($review->rating),
420
-            __('Type', 'site-reviews') => $this->getReviewType($review),
421
-            __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
422
-            __('Name', 'site-reviews') => $review->author,
423
-            __('Email', 'site-reviews') => $email,
424
-            __('User', 'site-reviews') => $user,
425
-            __('IP Address', 'site-reviews') => $review->ip_address,
426
-            __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
427
-        ];
428
-        return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
429
-    }
403
+	/**
404
+	 * @return array
405
+	 */
406
+	protected function normalizeDetailsMetaBox(Review $review)
407
+	{
408
+		$user = empty($review->user_id)
409
+			? __('Unregistered user', 'site-reviews')
410
+			: glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
411
+				'href' => get_author_posts_url($review->user_id),
412
+			]);
413
+		$email = empty($review->email)
414
+			? '&mdash;'
415
+			: glsr(Builder::class)->a($review->email, [
416
+				'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
417
+			]);
418
+		$metabox = [
419
+			__('Rating', 'site-reviews') => glsr_star_rating($review->rating),
420
+			__('Type', 'site-reviews') => $this->getReviewType($review),
421
+			__('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
422
+			__('Name', 'site-reviews') => $review->author,
423
+			__('Email', 'site-reviews') => $email,
424
+			__('User', 'site-reviews') => $user,
425
+			__('IP Address', 'site-reviews') => $review->ip_address,
426
+			__('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
427
+		];
428
+		return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
429
+	}
430 430
 
431
-    /**
432
-     * @param int $postId
433
-     * @param int $messageIndex
434
-     * @return void
435
-     */
436
-    protected function redirect($postId, $messageIndex)
437
-    {
438
-        $referer = wp_get_referer();
439
-        $hasReferer = !$referer
440
-            || false !== strpos($referer, 'post.php')
441
-            || false !== strpos($referer, 'post-new.php');
442
-        $redirectUri = $hasReferer
443
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
444
-            : get_edit_post_link($postId);
445
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
446
-        exit;
447
-    }
431
+	/**
432
+	 * @param int $postId
433
+	 * @param int $messageIndex
434
+	 * @return void
435
+	 */
436
+	protected function redirect($postId, $messageIndex)
437
+	{
438
+		$referer = wp_get_referer();
439
+		$hasReferer = !$referer
440
+			|| false !== strpos($referer, 'post.php')
441
+			|| false !== strpos($referer, 'post-new.php');
442
+		$redirectUri = $hasReferer
443
+			? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
444
+			: get_edit_post_link($postId);
445
+		wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
446
+		exit;
447
+	}
448 448
 }
Please login to merge, or discard this patch.
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function customizePostStatusLabels()
27 27
     {
28
-        glsr(Labels::class)->customizePostStatusLabels();
28
+        glsr( Labels::class )->customizePostStatusLabels();
29 29
     }
30 30
 
31 31
     /**
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
      * @return array
34 34
      * @filter wp_editor_settings
35 35
      */
36
-    public function filterEditorSettings($settings)
36
+    public function filterEditorSettings( $settings )
37 37
     {
38
-        return glsr(Customization::class)->filterEditorSettings(
39
-            glsr(Helper::class)->consolidateArray($settings)
38
+        return glsr( Customization::class )->filterEditorSettings(
39
+            glsr( Helper::class )->consolidateArray( $settings )
40 40
         );
41 41
     }
42 42
 
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * @return string
47 47
      * @filter the_editor
48 48
      */
49
-    public function filterEditorTextarea($html)
49
+    public function filterEditorTextarea( $html )
50 50
     {
51
-        return glsr(Customization::class)->filterEditorTextarea($html);
51
+        return glsr( Customization::class )->filterEditorTextarea( $html );
52 52
     }
53 53
 
54 54
     /**
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
      * @return bool
59 59
      * @filter is_protected_meta
60 60
      */
61
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
61
+    public function filterIsProtectedMeta( $protected, $metaKey, $metaType )
62 62
     {
63
-        if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
64
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
65
-            $values = glsr(Helper::class)->prefixArrayKeys($values);
66
-            if (array_key_exists($metaKey, $values)) {
63
+        if( 'post' == $metaType && Application::POST_TYPE == get_post_type() ) {
64
+            $values = glsr( CreateReviewDefaults::class )->unguarded();
65
+            $values = glsr( Helper::class )->prefixArrayKeys( $values );
66
+            if( array_key_exists( $metaKey, $values ) ) {
67 67
                 $protected = false;
68 68
             }
69 69
         }
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      * @return string
78 78
      * @filter gettext
79 79
      */
80
-    public function filterPostStatusLabels($translation, $text, $domain)
80
+    public function filterPostStatusLabels( $translation, $text, $domain )
81 81
     {
82
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
82
+        return glsr( Labels::class )->filterPostStatusLabels( $translation, $text, $domain );
83 83
     }
84 84
 
85 85
     /**
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
      * @return string
90 90
      * @filter gettext_with_context
91 91
      */
92
-    public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain)
92
+    public function filterPostStatusLabelsWithContext( $translation, $text, $context, $domain )
93 93
     {
94
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
94
+        return glsr( Labels::class )->filterPostStatusLabels( $translation, $text, $domain );
95 95
     }
96 96
 
97 97
     /**
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
      * @return array
100 100
      * @filter post_updated_messages
101 101
      */
102
-    public function filterUpdateMessages($messages)
102
+    public function filterUpdateMessages( $messages )
103 103
     {
104
-        return glsr(Labels::class)->filterUpdateMessages(
105
-            glsr(Helper::class)->consolidateArray($messages)
104
+        return glsr( Labels::class )->filterUpdateMessages(
105
+            glsr( Helper::class )->consolidateArray( $messages )
106 106
         );
107 107
     }
108 108
 
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
      * @return void
111 111
      * @action add_meta_boxes_{Application::POST_TYPE}
112 112
      */
113
-    public function registerMetaBoxes($post)
113
+    public function registerMetaBoxes( $post )
114 114
     {
115
-        add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
116
-        add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
117
-        if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
115
+        add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' );
116
+        add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' );
117
+        if( 'local' != glsr( Database::class )->get( $post->ID, 'review_type' ) ) {
118 118
             return;
119 119
         }
120
-        add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
120
+        add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' );
121 121
     }
122 122
 
123 123
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function removeAutosave()
128 128
     {
129
-        glsr(Customization::class)->removeAutosave();
129
+        glsr( Customization::class )->removeAutosave();
130 130
     }
131 131
 
132 132
     /**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function removeMetaBoxes()
137 137
     {
138
-        glsr(Customization::class)->removeMetaBoxes();
138
+        glsr( Customization::class )->removeMetaBoxes();
139 139
     }
140 140
 
141 141
     /**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function removePostTypeSupport()
145 145
     {
146
-        glsr(Customization::class)->removePostTypeSupport();
146
+        glsr( Customization::class )->removePostTypeSupport();
147 147
     }
148 148
 
149 149
     /**
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
      * @return void
152 152
      * @callback add_meta_box
153 153
      */
154
-    public function renderAssignedToMetabox($post)
154
+    public function renderAssignedToMetabox( $post )
155 155
     {
156
-        if (!$this->isReviewPostType($post)) {
156
+        if( !$this->isReviewPostType( $post ) ) {
157 157
             return;
158 158
         }
159
-        $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
160
-        wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
161
-        glsr()->render('partials/editor/metabox-assigned-to', [
159
+        $assignedTo = (string)glsr( Database::class )->get( $post->ID, 'assigned_to' );
160
+        wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false );
161
+        glsr()->render( 'partials/editor/metabox-assigned-to', [
162 162
             'id' => $assignedTo,
163
-            'template' => $this->buildAssignedToTemplate($assignedTo, $post),
164
-        ]);
163
+            'template' => $this->buildAssignedToTemplate( $assignedTo, $post ),
164
+        ] );
165 165
     }
166 166
 
167 167
     /**
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
      * @return void
170 170
      * @callback add_meta_box
171 171
      */
172
-    public function renderDetailsMetaBox($post)
172
+    public function renderDetailsMetaBox( $post )
173 173
     {
174
-        if (!$this->isReviewPostType($post)) {
174
+        if( !$this->isReviewPostType( $post ) ) {
175 175
             return;
176 176
         }
177
-        $review = glsr_get_review($post);
178
-        glsr()->render('partials/editor/metabox-details', [
179
-            'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
180
-            'metabox' => $this->normalizeDetailsMetaBox($review),
181
-        ]);
177
+        $review = glsr_get_review( $post );
178
+        glsr()->render( 'partials/editor/metabox-details', [
179
+            'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ),
180
+            'metabox' => $this->normalizeDetailsMetaBox( $review ),
181
+        ] );
182 182
     }
183 183
 
184 184
     /**
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function renderPinnedInPublishMetaBox()
189 189
     {
190
-        if (!$this->isReviewPostType(get_post())) {
190
+        if( !$this->isReviewPostType( get_post() ) ) {
191 191
             return;
192 192
         }
193
-        glsr(Template::class)->render('partials/editor/pinned', [
193
+        glsr( Template::class )->render( 'partials/editor/pinned', [
194 194
             'context' => [
195
-                'no' => __('No', 'site-reviews'),
196
-                'yes' => __('Yes', 'site-reviews'),
195
+                'no' => __( 'No', 'site-reviews' ),
196
+                'yes' => __( 'Yes', 'site-reviews' ),
197 197
             ],
198
-            'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
199
-        ]);
198
+            'pinned' => wp_validate_boolean( glsr( Database::class )->get( get_the_ID(), 'pinned' ) ),
199
+        ] );
200 200
     }
201 201
 
202 202
     /**
@@ -204,15 +204,15 @@  discard block
 block discarded – undo
204 204
      * @return void
205 205
      * @callback add_meta_box
206 206
      */
207
-    public function renderResponseMetaBox($post)
207
+    public function renderResponseMetaBox( $post )
208 208
     {
209
-        if (!$this->isReviewPostType($post)) {
209
+        if( !$this->isReviewPostType( $post ) ) {
210 210
             return;
211 211
         }
212
-        wp_nonce_field('response', '_nonce-response', false);
213
-        glsr()->render('partials/editor/metabox-response', [
214
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
215
-        ]);
212
+        wp_nonce_field( 'response', '_nonce-response', false );
213
+        glsr()->render( 'partials/editor/metabox-response', [
214
+            'response' => glsr( Database::class )->get( $post->ID, 'response' ),
215
+        ] );
216 216
     }
217 217
 
218 218
     /**
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
      * @return void
221 221
      * @action edit_form_after_title
222 222
      */
223
-    public function renderReviewEditor($post)
223
+    public function renderReviewEditor( $post )
224 224
     {
225
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
225
+        if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) {
226 226
             return;
227 227
         }
228
-        glsr()->render('partials/editor/review', [
228
+        glsr()->render( 'partials/editor/review', [
229 229
             'post' => $post,
230
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
231
-        ]);
230
+            'response' => glsr( Database::class )->get( $post->ID, 'response' ),
231
+        ] );
232 232
     }
233 233
 
234 234
     /**
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
     public function renderReviewFields()
239 239
     {
240 240
         $screen = glsr_current_screen();
241
-        if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
241
+        if( 'post' != $screen->base || Application::POST_TYPE != $screen->post_type ) {
242 242
             return;
243 243
         }
244
-        add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
245
-        add_action('edit_form_top', [$this, 'renderReviewNotice']);
244
+        add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] );
245
+        add_action( 'edit_form_top', [$this, 'renderReviewNotice'] );
246 246
     }
247 247
 
248 248
     /**
@@ -250,20 +250,20 @@  discard block
 block discarded – undo
250 250
      * @return void
251 251
      * @action edit_form_top
252 252
      */
253
-    public function renderReviewNotice($post)
253
+    public function renderReviewNotice( $post )
254 254
     {
255
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
255
+        if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) {
256 256
             return;
257 257
         }
258
-        glsr(Notice::class)->addWarning(sprintf(
259
-            __('%s reviews are read-only.', 'site-reviews'),
260
-            glsr(Columns::class)->buildColumnReviewType($post->ID)
261
-        ));
262
-        glsr(Template::class)->render('partials/editor/notice', [
258
+        glsr( Notice::class )->addWarning( sprintf(
259
+            __( '%s reviews are read-only.', 'site-reviews' ),
260
+            glsr( Columns::class )->buildColumnReviewType( $post->ID )
261
+        ) );
262
+        glsr( Template::class )->render( 'partials/editor/notice', [
263 263
             'context' => [
264
-                'notices' => glsr(Notice::class)->get(),
264
+                'notices' => glsr( Notice::class )->get(),
265 265
             ],
266
-        ]);
266
+        ] );
267 267
     }
268 268
 
269 269
     /**
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
      * @see glsr_categories_meta_box()
273 273
      * @callback register_taxonomy
274 274
      */
275
-    public function renderTaxonomyMetabox($post)
275
+    public function renderTaxonomyMetabox( $post )
276 276
     {
277
-        if (!$this->isReviewPostType($post)) {
277
+        if( !$this->isReviewPostType( $post ) ) {
278 278
             return;
279 279
         }
280
-        glsr()->render('partials/editor/metabox-categories', [
280
+        glsr()->render( 'partials/editor/metabox-categories', [
281 281
             'post' => $post,
282 282
             'tax_name' => Application::TAXONOMY,
283
-            'taxonomy' => get_taxonomy(Application::TAXONOMY),
284
-        ]);
283
+            'taxonomy' => get_taxonomy( Application::TAXONOMY ),
284
+        ] );
285 285
     }
286 286
 
287 287
     /**
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
      */
292 292
     public function revertReview()
293 293
     {
294
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
294
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
295 295
             return;
296 296
         }
297
-        check_admin_referer('revert-review_'.($postId = $this->getPostId()));
298
-        glsr(ReviewManager::class)->revert($postId);
299
-        $this->redirect($postId, 52);
297
+        check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) );
298
+        glsr( ReviewManager::class )->revert( $postId );
299
+        $this->redirect( $postId, 52 );
300 300
     }
301 301
 
302 302
     /**
@@ -304,79 +304,79 @@  discard block
 block discarded – undo
304 304
      * @return void
305 305
      * @action save_post_.Application::POST_TYPE
306 306
      */
307
-    public function saveMetaboxes($postId)
307
+    public function saveMetaboxes( $postId )
308 308
     {
309
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
310
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
311
-        do_action('site-reviews/review/saved', glsr_get_review($postId));
309
+        glsr( Metaboxes::class )->saveAssignedToMetabox( $postId );
310
+        glsr( Metaboxes::class )->saveResponseMetabox( $postId );
311
+        do_action( 'site-reviews/review/saved', glsr_get_review( $postId ) );
312 312
     }
313 313
 
314 314
     /**
315 315
      * @param string $assignedTo
316 316
      * @return string
317 317
      */
318
-    protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
318
+    protected function buildAssignedToTemplate( $assignedTo, WP_Post $post )
319 319
     {
320
-        $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
321
-        if (!($assignedPost instanceof WP_Post)) {
320
+        $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo );
321
+        if( !($assignedPost instanceof WP_Post) ) {
322 322
             return;
323 323
         }
324
-        return glsr(Template::class)->build('partials/editor/assigned-post', [
324
+        return glsr( Template::class )->build( 'partials/editor/assigned-post', [
325 325
             'context' => [
326
-                'data.url' => (string) get_permalink($assignedPost),
327
-                'data.title' => get_the_title($assignedPost),
326
+                'data.url' => (string)get_permalink( $assignedPost ),
327
+                'data.title' => get_the_title( $assignedPost ),
328 328
             ],
329
-        ]);
329
+        ] );
330 330
     }
331 331
 
332 332
     /**
333 333
      * @return string
334 334
      */
335
-    protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
335
+    protected function buildDetailsMetaBoxRevertButton( Review $review, WP_Post $post )
336 336
     {
337
-        $isModified = !glsr(Helper::class)->compareArrays(
337
+        $isModified = !glsr( Helper::class )->compareArrays(
338 338
             [$review->title, $review->content, $review->date],
339 339
             [
340
-                glsr(Database::class)->get($post->ID, 'title'),
341
-                glsr(Database::class)->get($post->ID, 'content'),
342
-                glsr(Database::class)->get($post->ID, 'date'),
340
+                glsr( Database::class )->get( $post->ID, 'title' ),
341
+                glsr( Database::class )->get( $post->ID, 'content' ),
342
+                glsr( Database::class )->get( $post->ID, 'date' ),
343 343
             ]
344 344
         );
345
-        if ($isModified) {
345
+        if( $isModified ) {
346 346
             $revertUrl = wp_nonce_url(
347
-                admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
347
+                admin_url( 'post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID ),
348 348
                 'revert-review_'.$post->ID
349 349
             );
350
-            return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
350
+            return glsr( Builder::class )->a( __( 'Revert Changes', 'site-reviews' ), [
351 351
                 'class' => 'button button-large',
352 352
                 'href' => $revertUrl,
353 353
                 'id' => 'revert',
354
-            ]);
354
+            ] );
355 355
         }
356
-        return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
356
+        return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [
357 357
             'class' => 'button-large',
358 358
             'disabled' => true,
359 359
             'id' => 'revert',
360
-        ]);
360
+        ] );
361 361
     }
362 362
 
363 363
     /**
364 364
      * @param object $review
365 365
      * @return string|void
366 366
      */
367
-    protected function getReviewType($review)
367
+    protected function getReviewType( $review )
368 368
     {
369
-        if (count(glsr()->reviewTypes) < 2) {
369
+        if( count( glsr()->reviewTypes ) < 2 ) {
370 370
             return;
371 371
         }
372
-        $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
372
+        $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes )
373 373
             ? glsr()->reviewTypes[$review->review_type]
374
-            : __('Unknown', 'site-reviews');
375
-        if (!empty($review->url)) {
376
-            $reviewType = glsr(Builder::class)->a($reviewType, [
374
+            : __( 'Unknown', 'site-reviews' );
375
+        if( !empty($review->url) ) {
376
+            $reviewType = glsr( Builder::class )->a( $reviewType, [
377 377
                 'href' => $review->url,
378 378
                 'target' => '_blank',
379
-            ]);
379
+            ] );
380 380
         }
381 381
         return $reviewType;
382 382
     }
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
     /**
385 385
      * @return bool
386 386
      */
387
-    protected function isReviewEditable($post)
387
+    protected function isReviewEditable( $post )
388 388
     {
389
-        return $this->isReviewPostType($post)
390
-            && post_type_supports(Application::POST_TYPE, 'title')
391
-            && 'local' == glsr(Database::class)->get($post->ID, 'review_type');
389
+        return $this->isReviewPostType( $post )
390
+            && post_type_supports( Application::POST_TYPE, 'title' )
391
+            && 'local' == glsr( Database::class )->get( $post->ID, 'review_type' );
392 392
     }
393 393
 
394 394
     /**
395 395
      * @param mixed $post
396 396
      * @return bool
397 397
      */
398
-    protected function isReviewPostType($post)
398
+    protected function isReviewPostType( $post )
399 399
     {
400 400
         return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
401 401
     }
@@ -403,29 +403,29 @@  discard block
 block discarded – undo
403 403
     /**
404 404
      * @return array
405 405
      */
406
-    protected function normalizeDetailsMetaBox(Review $review)
406
+    protected function normalizeDetailsMetaBox( Review $review )
407 407
     {
408 408
         $user = empty($review->user_id)
409
-            ? __('Unregistered user', 'site-reviews')
410
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
411
-                'href' => get_author_posts_url($review->user_id),
412
-            ]);
409
+            ? __( 'Unregistered user', 'site-reviews' )
410
+            : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [
411
+                'href' => get_author_posts_url( $review->user_id ),
412
+            ] );
413 413
         $email = empty($review->email)
414 414
             ? '&mdash;'
415
-            : glsr(Builder::class)->a($review->email, [
416
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
417
-            ]);
415
+            : glsr( Builder::class )->a( $review->email, [
416
+                'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ),
417
+            ] );
418 418
         $metabox = [
419
-            __('Rating', 'site-reviews') => glsr_star_rating($review->rating),
420
-            __('Type', 'site-reviews') => $this->getReviewType($review),
421
-            __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
422
-            __('Name', 'site-reviews') => $review->author,
423
-            __('Email', 'site-reviews') => $email,
424
-            __('User', 'site-reviews') => $user,
425
-            __('IP Address', 'site-reviews') => $review->ip_address,
426
-            __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
419
+            __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ),
420
+            __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ),
421
+            __( 'Date', 'site-reviews' ) => get_date_from_gmt( $review->date, 'F j, Y' ),
422
+            __( 'Name', 'site-reviews' ) => $review->author,
423
+            __( 'Email', 'site-reviews' ) => $email,
424
+            __( 'User', 'site-reviews' ) => $user,
425
+            __( 'IP Address', 'site-reviews' ) => $review->ip_address,
426
+            __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ),
427 427
         ];
428
-        return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
428
+        return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) );
429 429
     }
430 430
 
431 431
     /**
@@ -433,16 +433,16 @@  discard block
 block discarded – undo
433 433
      * @param int $messageIndex
434 434
      * @return void
435 435
      */
436
-    protected function redirect($postId, $messageIndex)
436
+    protected function redirect( $postId, $messageIndex )
437 437
     {
438 438
         $referer = wp_get_referer();
439 439
         $hasReferer = !$referer
440
-            || false !== strpos($referer, 'post.php')
441
-            || false !== strpos($referer, 'post-new.php');
440
+            || false !== strpos( $referer, 'post.php' )
441
+            || false !== strpos( $referer, 'post-new.php' );
442 442
         $redirectUri = $hasReferer
443
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
444
-            : get_edit_post_link($postId);
445
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
443
+            ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer )
444
+            : get_edit_post_link( $postId );
445
+        wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) );
446 446
         exit;
447 447
     }
448 448
 }
Please login to merge, or discard this patch.
site-reviews.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 defined('WPINC') || die;
19 19
 
20 20
 if (!class_exists('GL_Plugin_Check_v3')) {
21
-    require_once __DIR__.'/activate.php';
21
+	require_once __DIR__.'/activate.php';
22 22
 }
23 23
 $check = new GL_Plugin_Check_v3(__FILE__);
24 24
 if (!$check->canProceed()) {
25
-    return;
25
+	return;
26 26
 }
27 27
 require_once __DIR__.'/autoload.php';
28 28
 require_once __DIR__.'/compatibility.php';
@@ -37,5 +37,5 @@  discard block
 block discarded – undo
37 37
 $app->init();
38 38
 
39 39
 if (defined('WP_ENV') && WP_ENV == 'development') {
40
-    add_filter('site-reviews/console/level', '__return_zero', 1);
40
+	add_filter('site-reviews/console/level', '__return_zero', 1);
41 41
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@  discard block
 block discarded – undo
15 15
  * Text Domain: site-reviews
16 16
  * Domain Path: languages
17 17
  */
18
-defined('WPINC') || die;
18
+defined( 'WPINC' ) || die;
19 19
 
20
-if (!class_exists('GL_Plugin_Check_v3')) {
20
+if( !class_exists( 'GL_Plugin_Check_v3' ) ) {
21 21
     require_once __DIR__.'/activate.php';
22 22
 }
23
-$check = new GL_Plugin_Check_v3(__FILE__);
24
-if (!$check->canProceed()) {
23
+$check = new GL_Plugin_Check_v3( __FILE__ );
24
+if( !$check->canProceed() ) {
25 25
     return;
26 26
 }
27 27
 require_once __DIR__.'/autoload.php';
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 require_once __DIR__.'/helpers.php';
31 31
 
32 32
 $app = new GeminiLabs\SiteReviews\Application();
33
-$app->make('Provider')->register($app);
34
-register_activation_hook(__FILE__, array($app, 'activate'));
35
-register_deactivation_hook(__FILE__, array($app, 'deactivate'));
36
-register_shutdown_function(array($app, 'catchFatalError'));
33
+$app->make( 'Provider' )->register( $app );
34
+register_activation_hook( __FILE__, array( $app, 'activate' ) );
35
+register_deactivation_hook( __FILE__, array( $app, 'deactivate' ) );
36
+register_shutdown_function( array( $app, 'catchFatalError' ) );
37 37
 $app->init();
38 38
 
39
-if (defined('WP_ENV') && WP_ENV == 'development') {
40
-    add_filter('site-reviews/console/level', '__return_zero', 1);
39
+if( defined( 'WP_ENV' ) && WP_ENV == 'development' ) {
40
+    add_filter( 'site-reviews/console/level', '__return_zero', 1 );
41 41
 }
Please login to merge, or discard this patch.
plugin/Modules/Rebusify.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -6,81 +6,81 @@
 block discarded – undo
6 6
 
7 7
 class Rebusify
8 8
 {
9
-    const API_URL = 'https://www.rebusify.com/api/rbs/';
9
+	const API_URL = 'https://www.rebusify.com/api/rbs/';
10 10
 
11
-    /**
12
-     * @return void|array
13
-     */
14
-    public function sendReview(Review $review)
15
-    {
16
-        return $this->send('index.php', [
17
-            'body' => $this->getBodyForReview($review),
18
-            'timeout' => 120,
19
-        ]);
20
-    }
11
+	/**
12
+	 * @return void|array
13
+	 */
14
+	public function sendReview(Review $review)
15
+	{
16
+		return $this->send('index.php', [
17
+			'body' => $this->getBodyForReview($review),
18
+			'timeout' => 120,
19
+		]);
20
+	}
21 21
 
22
-    /**
23
-     * @return void|array
24
-     */
25
-    public function sendReviewResponse(Review $review)
26
-    {
27
-        return $this->send('fetch_customer_reply.php', [
28
-            'body' => $this->getBodyForResponse($review),
29
-        ]);
30
-    }
22
+	/**
23
+	 * @return void|array
24
+	 */
25
+	public function sendReviewResponse(Review $review)
26
+	{
27
+		return $this->send('fetch_customer_reply.php', [
28
+			'body' => $this->getBodyForResponse($review),
29
+		]);
30
+	}
31 31
 
32
-    /**
33
-     * @return array
34
-     */
35
-    protected function getBodyForResponse(Review $review)
36
-    {
37
-        $rebusifyResponse = [
38
-            'reply' => $review->response, // what is the 300 character limit for?
39
-            'review_id' => '', // @todo
40
-            'review_transaction_id' => '', // @todo
41
-            'type' => 'M',
42
-        ];
43
-        return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review);
44
-    }
32
+	/**
33
+	 * @return array
34
+	 */
35
+	protected function getBodyForResponse(Review $review)
36
+	{
37
+		$rebusifyResponse = [
38
+			'reply' => $review->response, // what is the 300 character limit for?
39
+			'review_id' => '', // @todo
40
+			'review_transaction_id' => '', // @todo
41
+			'type' => 'M',
42
+		];
43
+		return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review);
44
+	}
45 45
 
46
-    /**
47
-     * @return array
48
-     */
49
-    protected function getBodyForReview(Review $review)
50
-    {
51
-        $rebusifyReview = [
52
-            'domain' => get_site_url(),
53
-            'firstname' => $review->name, // what is the 25 character limit for?
54
-            'rate' => $review->rating,
55
-            'review_transaction_id' => '', // @todo
56
-            'reviews' => $review->content, // what is the 280 character limit for?
57
-            'title' => $review->title, // what is the 35 character limit for?
58
-            'transaction' => '', // @todo
59
-        ];
60
-        return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review);
61
-    }
46
+	/**
47
+	 * @return array
48
+	 */
49
+	protected function getBodyForReview(Review $review)
50
+	{
51
+		$rebusifyReview = [
52
+			'domain' => get_site_url(),
53
+			'firstname' => $review->name, // what is the 25 character limit for?
54
+			'rate' => $review->rating,
55
+			'review_transaction_id' => '', // @todo
56
+			'reviews' => $review->content, // what is the 280 character limit for?
57
+			'title' => $review->title, // what is the 35 character limit for?
58
+			'transaction' => '', // @todo
59
+		];
60
+		return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review);
61
+	}
62 62
 
63
-    /**
64
-     * @return void|array
65
-     */
66
-    protected function send($endpoint, $args)
67
-    {
68
-        $args = wp_parse_args($args, [
69
-            'blocking' => false,
70
-            'body' => [],
71
-            'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
72
-            'redirection' => 5,
73
-            'sslverify' => false,
74
-            'timeout' => 5,
75
-        ]);
76
-        $response = wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args);
77
-        if (is_wp_error($response)) {
78
-            glsr_log()->error('REBUSIFY: '.$response->get_error_message());
79
-            return;
80
-        }
81
-        if (200 === wp_remote_retrieve_response_code($response)) {
82
-            $responsedata = wp_remote_retrieve_body($response);
83
-            return json_decode($responsedata, true);
84
-        }
85
-    }
63
+	/**
64
+	 * @return void|array
65
+	 */
66
+	protected function send($endpoint, $args)
67
+	{
68
+		$args = wp_parse_args($args, [
69
+			'blocking' => false,
70
+			'body' => [],
71
+			'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
72
+			'redirection' => 5,
73
+			'sslverify' => false,
74
+			'timeout' => 5,
75
+		]);
76
+		$response = wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args);
77
+		if (is_wp_error($response)) {
78
+			glsr_log()->error('REBUSIFY: '.$response->get_error_message());
79
+			return;
80
+		}
81
+		if (200 === wp_remote_retrieve_response_code($response)) {
82
+			$responsedata = wp_remote_retrieve_body($response);
83
+			return json_decode($responsedata, true);
84
+		}
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -11,28 +11,28 @@  discard block
 block discarded – undo
11 11
     /**
12 12
      * @return void|array
13 13
      */
14
-    public function sendReview(Review $review)
14
+    public function sendReview( Review $review )
15 15
     {
16
-        return $this->send('index.php', [
17
-            'body' => $this->getBodyForReview($review),
16
+        return $this->send( 'index.php', [
17
+            'body' => $this->getBodyForReview( $review ),
18 18
             'timeout' => 120,
19
-        ]);
19
+        ] );
20 20
     }
21 21
 
22 22
     /**
23 23
      * @return void|array
24 24
      */
25
-    public function sendReviewResponse(Review $review)
25
+    public function sendReviewResponse( Review $review )
26 26
     {
27
-        return $this->send('fetch_customer_reply.php', [
28
-            'body' => $this->getBodyForResponse($review),
29
-        ]);
27
+        return $this->send( 'fetch_customer_reply.php', [
28
+            'body' => $this->getBodyForResponse( $review ),
29
+        ] );
30 30
     }
31 31
 
32 32
     /**
33 33
      * @return array
34 34
      */
35
-    protected function getBodyForResponse(Review $review)
35
+    protected function getBodyForResponse( Review $review )
36 36
     {
37 37
         $rebusifyResponse = [
38 38
             'reply' => $review->response, // what is the 300 character limit for?
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
             'review_transaction_id' => '', // @todo
41 41
             'type' => 'M',
42 42
         ];
43
-        return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review);
43
+        return apply_filters( 'site-reviews/rebusify/response', $rebusifyResponse, $review );
44 44
     }
45 45
 
46 46
     /**
47 47
      * @return array
48 48
      */
49
-    protected function getBodyForReview(Review $review)
49
+    protected function getBodyForReview( Review $review )
50 50
     {
51 51
         $rebusifyReview = [
52 52
             'domain' => get_site_url(),
@@ -57,30 +57,30 @@  discard block
 block discarded – undo
57 57
             'title' => $review->title, // what is the 35 character limit for?
58 58
             'transaction' => '', // @todo
59 59
         ];
60
-        return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review);
60
+        return apply_filters( 'site-reviews/rebusify/review', $rebusifyReview, $review );
61 61
     }
62 62
 
63 63
     /**
64 64
      * @return void|array
65 65
      */
66
-    protected function send($endpoint, $args)
66
+    protected function send( $endpoint, $args )
67 67
     {
68
-        $args = wp_parse_args($args, [
68
+        $args = wp_parse_args( $args, [
69 69
             'blocking' => false,
70 70
             'body' => [],
71 71
             'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
72 72
             'redirection' => 5,
73 73
             'sslverify' => false,
74 74
             'timeout' => 5,
75
-        ]);
76
-        $response = wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args);
77
-        if (is_wp_error($response)) {
78
-            glsr_log()->error('REBUSIFY: '.$response->get_error_message());
75
+        ] );
76
+        $response = wp_remote_post( trailingslashit( static::API_URL ).$endpoint, $args );
77
+        if( is_wp_error( $response ) ) {
78
+            glsr_log()->error( 'REBUSIFY: '.$response->get_error_message() );
79 79
             return;
80 80
         }
81
-        if (200 === wp_remote_retrieve_response_code($response)) {
82
-            $responsedata = wp_remote_retrieve_body($response);
83
-            return json_decode($responsedata, true);
81
+        if( 200 === wp_remote_retrieve_response_code( $response ) ) {
82
+            $responsedata = wp_remote_retrieve_body( $response );
83
+            return json_decode( $responsedata, true );
84 84
         }
85 85
     }
86 86
 }
Please login to merge, or discard this patch.
plugin/Database/ReviewManager.php 2 patches
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -16,204 +16,204 @@
 block discarded – undo
16 16
 
17 17
 class ReviewManager
18 18
 {
19
-    /**
20
-     * @return false|Review
21
-     */
22
-    public function create(CreateReview $command)
23
-    {
24
-        $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command);
25
-        $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command);
26
-        $reviewValues = glsr(Helper::class)->prefixArrayKeys($reviewValues);
27
-        unset($reviewValues['json']); // @todo remove the need for this
28
-        $postValues = [
29
-            'comment_status' => 'closed',
30
-            'meta_input' => $reviewValues,
31
-            'ping_status' => 'closed',
32
-            'post_content' => $reviewValues['_content'],
33
-            'post_date' => $reviewValues['_date'],
34
-            'post_date_gmt' => get_gmt_from_date($reviewValues['_date']),
35
-            'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'],
36
-            'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted),
37
-            'post_title' => $reviewValues['_title'],
38
-            'post_type' => Application::POST_TYPE,
39
-        ];
40
-        $postId = wp_insert_post($postValues, true);
41
-        if (is_wp_error($postId)) {
42
-            glsr_log()->error($postId->get_error_message())->debug($postValues);
43
-            return false;
44
-        }
45
-        $this->setTerms($postId, $command->category);
46
-        $review = $this->single(get_post($postId));
47
-        do_action('site-reviews/review/created', $review, $command);
48
-        return $review;
49
-    }
19
+	/**
20
+	 * @return false|Review
21
+	 */
22
+	public function create(CreateReview $command)
23
+	{
24
+		$reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command);
25
+		$reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command);
26
+		$reviewValues = glsr(Helper::class)->prefixArrayKeys($reviewValues);
27
+		unset($reviewValues['json']); // @todo remove the need for this
28
+		$postValues = [
29
+			'comment_status' => 'closed',
30
+			'meta_input' => $reviewValues,
31
+			'ping_status' => 'closed',
32
+			'post_content' => $reviewValues['_content'],
33
+			'post_date' => $reviewValues['_date'],
34
+			'post_date_gmt' => get_gmt_from_date($reviewValues['_date']),
35
+			'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'],
36
+			'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted),
37
+			'post_title' => $reviewValues['_title'],
38
+			'post_type' => Application::POST_TYPE,
39
+		];
40
+		$postId = wp_insert_post($postValues, true);
41
+		if (is_wp_error($postId)) {
42
+			glsr_log()->error($postId->get_error_message())->debug($postValues);
43
+			return false;
44
+		}
45
+		$this->setTerms($postId, $command->category);
46
+		$review = $this->single(get_post($postId));
47
+		do_action('site-reviews/review/created', $review, $command);
48
+		return $review;
49
+	}
50 50
 
51
-    /**
52
-     * @param string $metaReviewId
53
-     * @return void
54
-     */
55
-    public function delete($metaReviewId)
56
-    {
57
-        if ($postId = $this->getPostId($metaReviewId)) {
58
-            wp_delete_post($postId, true);
59
-        }
60
-    }
51
+	/**
52
+	 * @param string $metaReviewId
53
+	 * @return void
54
+	 */
55
+	public function delete($metaReviewId)
56
+	{
57
+		if ($postId = $this->getPostId($metaReviewId)) {
58
+			wp_delete_post($postId, true);
59
+		}
60
+	}
61 61
 
62
-    /**
63
-     * @return object
64
-     */
65
-    public function get(array $args = [])
66
-    {
67
-        $args = glsr(ReviewsDefaults::class)->merge($args);
68
-        $metaQuery = glsr(QueryBuilder::class)->buildQuery(
69
-            ['assigned_to', 'type', 'rating'],
70
-            $args
71
-        );
72
-        $taxQuery = glsr(QueryBuilder::class)->buildQuery(
73
-            ['category'],
74
-            ['category' => $this->normalizeTermIds($args['category'])]
75
-        );
76
-        $paged = glsr(QueryBuilder::class)->getPaged(
77
-            wp_validate_boolean($args['pagination'])
78
-        );
79
-        $parameters = [
80
-            'meta_key' => '_pinned',
81
-            'meta_query' => $metaQuery,
82
-            'offset' => $args['offset'],
83
-            'order' => $args['order'],
84
-            'orderby' => 'meta_value '.$args['orderby'],
85
-            'paged' => glsr_get($args, 'paged', $paged),
86
-            'post__in' => $args['post__in'],
87
-            'post__not_in' => $args['post__not_in'],
88
-            'post_status' => 'publish',
89
-            'post_type' => Application::POST_TYPE,
90
-            'posts_per_page' => $args['count'],
91
-            'tax_query' => $taxQuery,
92
-        ];
93
-        $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args);
94
-        $query = new WP_Query($parameters);
95
-        $results = array_map([$this, 'single'], $query->posts);
96
-        $reviews = new Reviews($results, $query->max_num_pages, $args);
97
-        return apply_filters('site-reviews/get/reviews', $reviews, $query);
98
-    }
62
+	/**
63
+	 * @return object
64
+	 */
65
+	public function get(array $args = [])
66
+	{
67
+		$args = glsr(ReviewsDefaults::class)->merge($args);
68
+		$metaQuery = glsr(QueryBuilder::class)->buildQuery(
69
+			['assigned_to', 'type', 'rating'],
70
+			$args
71
+		);
72
+		$taxQuery = glsr(QueryBuilder::class)->buildQuery(
73
+			['category'],
74
+			['category' => $this->normalizeTermIds($args['category'])]
75
+		);
76
+		$paged = glsr(QueryBuilder::class)->getPaged(
77
+			wp_validate_boolean($args['pagination'])
78
+		);
79
+		$parameters = [
80
+			'meta_key' => '_pinned',
81
+			'meta_query' => $metaQuery,
82
+			'offset' => $args['offset'],
83
+			'order' => $args['order'],
84
+			'orderby' => 'meta_value '.$args['orderby'],
85
+			'paged' => glsr_get($args, 'paged', $paged),
86
+			'post__in' => $args['post__in'],
87
+			'post__not_in' => $args['post__not_in'],
88
+			'post_status' => 'publish',
89
+			'post_type' => Application::POST_TYPE,
90
+			'posts_per_page' => $args['count'],
91
+			'tax_query' => $taxQuery,
92
+		];
93
+		$parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args);
94
+		$query = new WP_Query($parameters);
95
+		$results = array_map([$this, 'single'], $query->posts);
96
+		$reviews = new Reviews($results, $query->max_num_pages, $args);
97
+		return apply_filters('site-reviews/get/reviews', $reviews, $query);
98
+	}
99 99
 
100
-    /**
101
-     * @param string $metaReviewId
102
-     * @return int
103
-     */
104
-    public function getPostId($metaReviewId)
105
-    {
106
-        return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId);
107
-    }
100
+	/**
101
+	 * @param string $metaReviewId
102
+	 * @return int
103
+	 */
104
+	public function getPostId($metaReviewId)
105
+	{
106
+		return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId);
107
+	}
108 108
 
109
-    /**
110
-     * @return array
111
-     */
112
-    public function getRatingCounts(array $args = [])
113
-    {
114
-        $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args);
115
-        $counts = glsr(CountsManager::class)->get([
116
-            'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']),
117
-            'term_ids' => $this->normalizeTermIds($args['category']),
118
-            'type' => $args['type'],
119
-        ]);
120
-        return glsr(CountsManager::class)->flatten($counts, [
121
-            'min' => $args['rating'],
122
-        ]);
123
-    }
109
+	/**
110
+	 * @return array
111
+	 */
112
+	public function getRatingCounts(array $args = [])
113
+	{
114
+		$args = glsr(SiteReviewsSummaryDefaults::class)->filter($args);
115
+		$counts = glsr(CountsManager::class)->get([
116
+			'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']),
117
+			'term_ids' => $this->normalizeTermIds($args['category']),
118
+			'type' => $args['type'],
119
+		]);
120
+		return glsr(CountsManager::class)->flatten($counts, [
121
+			'min' => $args['rating'],
122
+		]);
123
+	}
124 124
 
125
-    /**
126
-     * @param string $commaSeparatedTermIds
127
-     * @return array
128
-     */
129
-    public function normalizeTermIds($commaSeparatedTermIds)
130
-    {
131
-        $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id');
132
-        return array_unique(array_map('intval', $termIds));
133
-    }
125
+	/**
126
+	 * @param string $commaSeparatedTermIds
127
+	 * @return array
128
+	 */
129
+	public function normalizeTermIds($commaSeparatedTermIds)
130
+	{
131
+		$termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id');
132
+		return array_unique(array_map('intval', $termIds));
133
+	}
134 134
 
135
-    /**
136
-     * @param string $commaSeparatedTermIds
137
-     * @return array
138
-     */
139
-    public function normalizeTerms($commaSeparatedTermIds)
140
-    {
141
-        $terms = [];
142
-        $termIds = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds);
143
-        foreach ($termIds as $termId) {
144
-            if (is_numeric($termId)) {
145
-                $termId = intval($termId);
146
-            }
147
-            $term = term_exists($termId, Application::TAXONOMY);
148
-            if (!isset($term['term_id'])) {
149
-                continue;
150
-            }
151
-            $terms[] = $term;
152
-        }
153
-        return $terms;
154
-    }
135
+	/**
136
+	 * @param string $commaSeparatedTermIds
137
+	 * @return array
138
+	 */
139
+	public function normalizeTerms($commaSeparatedTermIds)
140
+	{
141
+		$terms = [];
142
+		$termIds = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds);
143
+		foreach ($termIds as $termId) {
144
+			if (is_numeric($termId)) {
145
+				$termId = intval($termId);
146
+			}
147
+			$term = term_exists($termId, Application::TAXONOMY);
148
+			if (!isset($term['term_id'])) {
149
+				continue;
150
+			}
151
+			$terms[] = $term;
152
+		}
153
+		return $terms;
154
+	}
155 155
 
156
-    /**
157
-     * @param int $postId
158
-     * @return void
159
-     */
160
-    public function revert($postId)
161
-    {
162
-        if (Application::POST_TYPE != get_post_field('post_type', $postId)) {
163
-            return;
164
-        }
165
-        delete_post_meta($postId, '_edit_last');
166
-        $result = wp_update_post([
167
-            'ID' => $postId,
168
-            'post_content' => glsr(Database::class)->get($postId, 'content'),
169
-            'post_date' => glsr(Database::class)->get($postId, 'date'),
170
-            'post_title' => glsr(Database::class)->get($postId, 'title'),
171
-        ]);
172
-        if (is_wp_error($result)) {
173
-            glsr_log()->error($result->get_error_message());
174
-            return;
175
-        }
176
-        do_action('site-reviews/review/reverted', glsr_get_review($postId));
177
-    }
156
+	/**
157
+	 * @param int $postId
158
+	 * @return void
159
+	 */
160
+	public function revert($postId)
161
+	{
162
+		if (Application::POST_TYPE != get_post_field('post_type', $postId)) {
163
+			return;
164
+		}
165
+		delete_post_meta($postId, '_edit_last');
166
+		$result = wp_update_post([
167
+			'ID' => $postId,
168
+			'post_content' => glsr(Database::class)->get($postId, 'content'),
169
+			'post_date' => glsr(Database::class)->get($postId, 'date'),
170
+			'post_title' => glsr(Database::class)->get($postId, 'title'),
171
+		]);
172
+		if (is_wp_error($result)) {
173
+			glsr_log()->error($result->get_error_message());
174
+			return;
175
+		}
176
+		do_action('site-reviews/review/reverted', glsr_get_review($postId));
177
+	}
178 178
 
179
-    /**
180
-     * @return Review
181
-     */
182
-    public function single(WP_Post $post)
183
-    {
184
-        if (Application::POST_TYPE != $post->post_type) {
185
-            $post = new WP_Post((object) []);
186
-        }
187
-        $review = new Review($post);
188
-        return apply_filters('site-reviews/get/review', $review, $post);
189
-    }
179
+	/**
180
+	 * @return Review
181
+	 */
182
+	public function single(WP_Post $post)
183
+	{
184
+		if (Application::POST_TYPE != $post->post_type) {
185
+			$post = new WP_Post((object) []);
186
+		}
187
+		$review = new Review($post);
188
+		return apply_filters('site-reviews/get/review', $review, $post);
189
+	}
190 190
 
191
-    /**
192
-     * @param bool $isBlacklisted
193
-     * @return string
194
-     */
195
-    protected function getNewPostStatus(array $reviewValues, $isBlacklisted)
196
-    {
197
-        $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval');
198
-        return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted)
199
-            ? 'pending'
200
-            : 'publish';
201
-    }
191
+	/**
192
+	 * @param bool $isBlacklisted
193
+	 * @return string
194
+	 */
195
+	protected function getNewPostStatus(array $reviewValues, $isBlacklisted)
196
+	{
197
+		$requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval');
198
+		return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted)
199
+			? 'pending'
200
+			: 'publish';
201
+	}
202 202
 
203
-    /**
204
-     * @param int $postId
205
-     * @param string $termIds
206
-     * @return void
207
-     */
208
-    protected function setTerms($postId, $termIds)
209
-    {
210
-        $termIds = $this->normalizeTermIds($termIds);
211
-        if (empty($termIds)) {
212
-            return;
213
-        }
214
-        $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY);
215
-        if (is_wp_error($termTaxonomyIds)) {
216
-            glsr_log()->error($termTaxonomyIds->get_error_message());
217
-        }
218
-    }
203
+	/**
204
+	 * @param int $postId
205
+	 * @param string $termIds
206
+	 * @return void
207
+	 */
208
+	protected function setTerms($postId, $termIds)
209
+	{
210
+		$termIds = $this->normalizeTermIds($termIds);
211
+		if (empty($termIds)) {
212
+			return;
213
+		}
214
+		$termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY);
215
+		if (is_wp_error($termTaxonomyIds)) {
216
+			glsr_log()->error($termTaxonomyIds->get_error_message());
217
+		}
218
+	}
219 219
 }
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @return false|Review
21 21
      */
22
-    public function create(CreateReview $command)
22
+    public function create( CreateReview $command )
23 23
     {
24
-        $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command);
25
-        $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command);
26
-        $reviewValues = glsr(Helper::class)->prefixArrayKeys($reviewValues);
24
+        $reviewValues = glsr( CreateReviewDefaults::class )->restrict( (array)$command );
25
+        $reviewValues = apply_filters( 'site-reviews/create/review-values', $reviewValues, $command );
26
+        $reviewValues = glsr( Helper::class )->prefixArrayKeys( $reviewValues );
27 27
         unset($reviewValues['json']); // @todo remove the need for this
28 28
         $postValues = [
29 29
             'comment_status' => 'closed',
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
             'ping_status' => 'closed',
32 32
             'post_content' => $reviewValues['_content'],
33 33
             'post_date' => $reviewValues['_date'],
34
-            'post_date_gmt' => get_gmt_from_date($reviewValues['_date']),
34
+            'post_date_gmt' => get_gmt_from_date( $reviewValues['_date'] ),
35 35
             'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'],
36
-            'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted),
36
+            'post_status' => $this->getNewPostStatus( $reviewValues, $command->blacklisted ),
37 37
             'post_title' => $reviewValues['_title'],
38 38
             'post_type' => Application::POST_TYPE,
39 39
         ];
40
-        $postId = wp_insert_post($postValues, true);
41
-        if (is_wp_error($postId)) {
42
-            glsr_log()->error($postId->get_error_message())->debug($postValues);
40
+        $postId = wp_insert_post( $postValues, true );
41
+        if( is_wp_error( $postId ) ) {
42
+            glsr_log()->error( $postId->get_error_message() )->debug( $postValues );
43 43
             return false;
44 44
         }
45
-        $this->setTerms($postId, $command->category);
46
-        $review = $this->single(get_post($postId));
47
-        do_action('site-reviews/review/created', $review, $command);
45
+        $this->setTerms( $postId, $command->category );
46
+        $review = $this->single( get_post( $postId ) );
47
+        do_action( 'site-reviews/review/created', $review, $command );
48 48
         return $review;
49 49
     }
50 50
 
@@ -52,29 +52,29 @@  discard block
 block discarded – undo
52 52
      * @param string $metaReviewId
53 53
      * @return void
54 54
      */
55
-    public function delete($metaReviewId)
55
+    public function delete( $metaReviewId )
56 56
     {
57
-        if ($postId = $this->getPostId($metaReviewId)) {
58
-            wp_delete_post($postId, true);
57
+        if( $postId = $this->getPostId( $metaReviewId ) ) {
58
+            wp_delete_post( $postId, true );
59 59
         }
60 60
     }
61 61
 
62 62
     /**
63 63
      * @return object
64 64
      */
65
-    public function get(array $args = [])
65
+    public function get( array $args = [] )
66 66
     {
67
-        $args = glsr(ReviewsDefaults::class)->merge($args);
68
-        $metaQuery = glsr(QueryBuilder::class)->buildQuery(
67
+        $args = glsr( ReviewsDefaults::class )->merge( $args );
68
+        $metaQuery = glsr( QueryBuilder::class )->buildQuery(
69 69
             ['assigned_to', 'type', 'rating'],
70 70
             $args
71 71
         );
72
-        $taxQuery = glsr(QueryBuilder::class)->buildQuery(
72
+        $taxQuery = glsr( QueryBuilder::class )->buildQuery(
73 73
             ['category'],
74
-            ['category' => $this->normalizeTermIds($args['category'])]
74
+            ['category' => $this->normalizeTermIds( $args['category'] )]
75 75
         );
76
-        $paged = glsr(QueryBuilder::class)->getPaged(
77
-            wp_validate_boolean($args['pagination'])
76
+        $paged = glsr( QueryBuilder::class )->getPaged(
77
+            wp_validate_boolean( $args['pagination'] )
78 78
         );
79 79
         $parameters = [
80 80
             'meta_key' => '_pinned',
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'offset' => $args['offset'],
83 83
             'order' => $args['order'],
84 84
             'orderby' => 'meta_value '.$args['orderby'],
85
-            'paged' => glsr_get($args, 'paged', $paged),
85
+            'paged' => glsr_get( $args, 'paged', $paged ),
86 86
             'post__in' => $args['post__in'],
87 87
             'post__not_in' => $args['post__not_in'],
88 88
             'post_status' => 'publish',
@@ -90,62 +90,62 @@  discard block
 block discarded – undo
90 90
             'posts_per_page' => $args['count'],
91 91
             'tax_query' => $taxQuery,
92 92
         ];
93
-        $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args);
94
-        $query = new WP_Query($parameters);
95
-        $results = array_map([$this, 'single'], $query->posts);
96
-        $reviews = new Reviews($results, $query->max_num_pages, $args);
97
-        return apply_filters('site-reviews/get/reviews', $reviews, $query);
93
+        $parameters = apply_filters( 'site-reviews/get/reviews/query', $parameters, $args );
94
+        $query = new WP_Query( $parameters );
95
+        $results = array_map( [$this, 'single'], $query->posts );
96
+        $reviews = new Reviews( $results, $query->max_num_pages, $args );
97
+        return apply_filters( 'site-reviews/get/reviews', $reviews, $query );
98 98
     }
99 99
 
100 100
     /**
101 101
      * @param string $metaReviewId
102 102
      * @return int
103 103
      */
104
-    public function getPostId($metaReviewId)
104
+    public function getPostId( $metaReviewId )
105 105
     {
106
-        return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId);
106
+        return glsr( SqlQueries::class )->getPostIdFromReviewId( $metaReviewId );
107 107
     }
108 108
 
109 109
     /**
110 110
      * @return array
111 111
      */
112
-    public function getRatingCounts(array $args = [])
112
+    public function getRatingCounts( array $args = [] )
113 113
     {
114
-        $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args);
115
-        $counts = glsr(CountsManager::class)->get([
116
-            'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']),
117
-            'term_ids' => $this->normalizeTermIds($args['category']),
114
+        $args = glsr( SiteReviewsSummaryDefaults::class )->filter( $args );
115
+        $counts = glsr( CountsManager::class )->get( [
116
+            'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ),
117
+            'term_ids' => $this->normalizeTermIds( $args['category'] ),
118 118
             'type' => $args['type'],
119
-        ]);
120
-        return glsr(CountsManager::class)->flatten($counts, [
119
+        ] );
120
+        return glsr( CountsManager::class )->flatten( $counts, [
121 121
             'min' => $args['rating'],
122
-        ]);
122
+        ] );
123 123
     }
124 124
 
125 125
     /**
126 126
      * @param string $commaSeparatedTermIds
127 127
      * @return array
128 128
      */
129
-    public function normalizeTermIds($commaSeparatedTermIds)
129
+    public function normalizeTermIds( $commaSeparatedTermIds )
130 130
     {
131
-        $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id');
132
-        return array_unique(array_map('intval', $termIds));
131
+        $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' );
132
+        return array_unique( array_map( 'intval', $termIds ) );
133 133
     }
134 134
 
135 135
     /**
136 136
      * @param string $commaSeparatedTermIds
137 137
      * @return array
138 138
      */
139
-    public function normalizeTerms($commaSeparatedTermIds)
139
+    public function normalizeTerms( $commaSeparatedTermIds )
140 140
     {
141 141
         $terms = [];
142
-        $termIds = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds);
143
-        foreach ($termIds as $termId) {
144
-            if (is_numeric($termId)) {
145
-                $termId = intval($termId);
142
+        $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds );
143
+        foreach( $termIds as $termId ) {
144
+            if( is_numeric( $termId ) ) {
145
+                $termId = intval( $termId );
146 146
             }
147
-            $term = term_exists($termId, Application::TAXONOMY);
148
-            if (!isset($term['term_id'])) {
147
+            $term = term_exists( $termId, Application::TAXONOMY );
148
+            if( !isset($term['term_id']) ) {
149 149
                 continue;
150 150
             }
151 151
             $terms[] = $term;
@@ -157,44 +157,44 @@  discard block
 block discarded – undo
157 157
      * @param int $postId
158 158
      * @return void
159 159
      */
160
-    public function revert($postId)
160
+    public function revert( $postId )
161 161
     {
162
-        if (Application::POST_TYPE != get_post_field('post_type', $postId)) {
162
+        if( Application::POST_TYPE != get_post_field( 'post_type', $postId ) ) {
163 163
             return;
164 164
         }
165
-        delete_post_meta($postId, '_edit_last');
166
-        $result = wp_update_post([
165
+        delete_post_meta( $postId, '_edit_last' );
166
+        $result = wp_update_post( [
167 167
             'ID' => $postId,
168
-            'post_content' => glsr(Database::class)->get($postId, 'content'),
169
-            'post_date' => glsr(Database::class)->get($postId, 'date'),
170
-            'post_title' => glsr(Database::class)->get($postId, 'title'),
171
-        ]);
172
-        if (is_wp_error($result)) {
173
-            glsr_log()->error($result->get_error_message());
168
+            'post_content' => glsr( Database::class )->get( $postId, 'content' ),
169
+            'post_date' => glsr( Database::class )->get( $postId, 'date' ),
170
+            'post_title' => glsr( Database::class )->get( $postId, 'title' ),
171
+        ] );
172
+        if( is_wp_error( $result ) ) {
173
+            glsr_log()->error( $result->get_error_message() );
174 174
             return;
175 175
         }
176
-        do_action('site-reviews/review/reverted', glsr_get_review($postId));
176
+        do_action( 'site-reviews/review/reverted', glsr_get_review( $postId ) );
177 177
     }
178 178
 
179 179
     /**
180 180
      * @return Review
181 181
      */
182
-    public function single(WP_Post $post)
182
+    public function single( WP_Post $post )
183 183
     {
184
-        if (Application::POST_TYPE != $post->post_type) {
185
-            $post = new WP_Post((object) []);
184
+        if( Application::POST_TYPE != $post->post_type ) {
185
+            $post = new WP_Post( (object)[] );
186 186
         }
187
-        $review = new Review($post);
188
-        return apply_filters('site-reviews/get/review', $review, $post);
187
+        $review = new Review( $post );
188
+        return apply_filters( 'site-reviews/get/review', $review, $post );
189 189
     }
190 190
 
191 191
     /**
192 192
      * @param bool $isBlacklisted
193 193
      * @return string
194 194
      */
195
-    protected function getNewPostStatus(array $reviewValues, $isBlacklisted)
195
+    protected function getNewPostStatus( array $reviewValues, $isBlacklisted )
196 196
     {
197
-        $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval');
197
+        $requireApproval = glsr( OptionManager::class )->getBool( 'settings.general.require.approval' );
198 198
         return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted)
199 199
             ? 'pending'
200 200
             : 'publish';
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
      * @param string $termIds
206 206
      * @return void
207 207
      */
208
-    protected function setTerms($postId, $termIds)
208
+    protected function setTerms( $postId, $termIds )
209 209
     {
210
-        $termIds = $this->normalizeTermIds($termIds);
211
-        if (empty($termIds)) {
210
+        $termIds = $this->normalizeTermIds( $termIds );
211
+        if( empty($termIds) ) {
212 212
             return;
213 213
         }
214
-        $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY);
215
-        if (is_wp_error($termTaxonomyIds)) {
216
-            glsr_log()->error($termTaxonomyIds->get_error_message());
214
+        $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY );
215
+        if( is_wp_error( $termTaxonomyIds ) ) {
216
+            glsr_log()->error( $termTaxonomyIds->get_error_message() );
217 217
         }
218 218
     }
219 219
 }
Please login to merge, or discard this patch.
plugin/Controllers/SettingsController.php 3 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,8 @@
 block discarded – undo
108 108
                 constant($integrationClass.'::PLUGIN_NAME')
109 109
             ));
110 110
             return false;
111
-        } elseif (!glsr($integrationClass)->isSupported()) {
111
+        }
112
+        elseif (!glsr($integrationClass)->isSupported()) {
112 113
             glsr(Notice::class)->addError(sprintf(
113 114
                 __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
114 115
                 constant($integrationClass.'::PLUGIN_NAME'),
Please login to merge, or discard this patch.
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -9,112 +9,112 @@
 block discarded – undo
9 9
 
10 10
 class SettingsController extends Controller
11 11
 {
12
-    /**
13
-     * @param mixed $input
14
-     * @return array
15
-     * @callback register_setting
16
-     */
17
-    public function callbackRegisterSettings($input)
18
-    {
19
-        $settings = glsr(Helper::class)->consolidateArray($input);
20
-        if (1 === count($settings) && array_key_exists('settings', $settings)) {
21
-            $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
22
-            $options = $this->sanitizeGeneral($input, $options);
23
-            $options = $this->sanitizeSubmissions($input, $options);
24
-            $options = $this->sanitizeTranslations($input, $options);
25
-            if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
26
-                glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
27
-            }
28
-            return $options;
29
-        }
30
-        return $input;
31
-    }
12
+	/**
13
+	 * @param mixed $input
14
+	 * @return array
15
+	 * @callback register_setting
16
+	 */
17
+	public function callbackRegisterSettings($input)
18
+	{
19
+		$settings = glsr(Helper::class)->consolidateArray($input);
20
+		if (1 === count($settings) && array_key_exists('settings', $settings)) {
21
+			$options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
22
+			$options = $this->sanitizeGeneral($input, $options);
23
+			$options = $this->sanitizeSubmissions($input, $options);
24
+			$options = $this->sanitizeTranslations($input, $options);
25
+			if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
26
+				glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
27
+			}
28
+			return $options;
29
+		}
30
+		return $input;
31
+	}
32 32
 
33
-    /**
34
-     * @return void
35
-     * @action admin_init
36
-     */
37
-    public function registerSettings()
38
-    {
39
-        register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
40
-            'sanitize_callback' => [$this, 'callbackRegisterSettings'],
41
-        ]);
42
-    }
33
+	/**
34
+	 * @return void
35
+	 * @action admin_init
36
+	 */
37
+	public function registerSettings()
38
+	{
39
+		register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
40
+			'sanitize_callback' => [$this, 'callbackRegisterSettings'],
41
+		]);
42
+	}
43 43
 
44
-    /**
45
-     * @return array
46
-     */
47
-    protected function sanitizeGeneral(array $input, array $options)
48
-    {
49
-        $inputForm = $input['settings']['general'];
50
-        if (!$this->hasMultilingualIntegration($inputForm['support']['multilingual'])) {
51
-            $options['settings']['general']['support']['multilingual'] = '';
52
-        }
53
-        if ('' == trim($inputForm['notification_message'])) {
54
-            $options['settings']['general']['notification_message'] = glsr()->defaults['settings']['general']['notification_message'];
55
-        }
56
-        $options['settings']['general']['notifications'] = glsr_get($inputForm, 'notifications', []);
57
-        return $options;
58
-    }
44
+	/**
45
+	 * @return array
46
+	 */
47
+	protected function sanitizeGeneral(array $input, array $options)
48
+	{
49
+		$inputForm = $input['settings']['general'];
50
+		if (!$this->hasMultilingualIntegration($inputForm['support']['multilingual'])) {
51
+			$options['settings']['general']['support']['multilingual'] = '';
52
+		}
53
+		if ('' == trim($inputForm['notification_message'])) {
54
+			$options['settings']['general']['notification_message'] = glsr()->defaults['settings']['general']['notification_message'];
55
+		}
56
+		$options['settings']['general']['notifications'] = glsr_get($inputForm, 'notifications', []);
57
+		return $options;
58
+	}
59 59
 
60
-    /**
61
-     * @return array
62
-     */
63
-    protected function sanitizeSubmissions(array $input, array $options)
64
-    {
65
-        $inputForm = $input['settings']['submissions'];
66
-        $options['settings']['submissions']['required'] = isset($inputForm['required'])
67
-            ? $inputForm['required']
68
-            : [];
69
-        return $options;
70
-    }
60
+	/**
61
+	 * @return array
62
+	 */
63
+	protected function sanitizeSubmissions(array $input, array $options)
64
+	{
65
+		$inputForm = $input['settings']['submissions'];
66
+		$options['settings']['submissions']['required'] = isset($inputForm['required'])
67
+			? $inputForm['required']
68
+			: [];
69
+		return $options;
70
+	}
71 71
 
72
-    /**
73
-     * @return array
74
-     */
75
-    protected function sanitizeTranslations(array $input, array $options)
76
-    {
77
-        if (isset($input['settings']['strings'])) {
78
-            $options['settings']['strings'] = array_values(array_filter($input['settings']['strings']));
79
-            $allowedTags = [
80
-                'a' => ['class' => [], 'href' => [], 'target' => []],
81
-                'span' => ['class' => []],
82
-            ];
83
-            array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
84
-                if (isset($string['s2'])) {
85
-                    $string['s2'] = wp_kses($string['s2'], $allowedTags);
86
-                }
87
-                if (isset($string['p2'])) {
88
-                    $string['p2'] = wp_kses($string['p2'], $allowedTags);
89
-                }
90
-            });
91
-        }
92
-        return $options;
93
-    }
72
+	/**
73
+	 * @return array
74
+	 */
75
+	protected function sanitizeTranslations(array $input, array $options)
76
+	{
77
+		if (isset($input['settings']['strings'])) {
78
+			$options['settings']['strings'] = array_values(array_filter($input['settings']['strings']));
79
+			$allowedTags = [
80
+				'a' => ['class' => [], 'href' => [], 'target' => []],
81
+				'span' => ['class' => []],
82
+			];
83
+			array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
84
+				if (isset($string['s2'])) {
85
+					$string['s2'] = wp_kses($string['s2'], $allowedTags);
86
+				}
87
+				if (isset($string['p2'])) {
88
+					$string['p2'] = wp_kses($string['p2'], $allowedTags);
89
+				}
90
+			});
91
+		}
92
+		return $options;
93
+	}
94 94
 
95
-    /**
96
-     * @return bool
97
-     */
98
-    protected function hasMultilingualIntegration($integration)
99
-    {
100
-        if (!in_array($integration, ['polylang', 'wpml'])) {
101
-            return false;
102
-        }
103
-        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration);
104
-        if (!glsr($integrationClass)->isActive()) {
105
-            glsr(Notice::class)->addError(sprintf(
106
-                __('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
107
-                constant($integrationClass.'::PLUGIN_NAME')
108
-            ));
109
-            return false;
110
-        } elseif (!glsr($integrationClass)->isSupported()) {
111
-            glsr(Notice::class)->addError(sprintf(
112
-                __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
113
-                constant($integrationClass.'::PLUGIN_NAME'),
114
-                constant($integrationClass.'::SUPPORTED_VERSION')
115
-            ));
116
-            return false;
117
-        }
118
-        return true;
119
-    }
95
+	/**
96
+	 * @return bool
97
+	 */
98
+	protected function hasMultilingualIntegration($integration)
99
+	{
100
+		if (!in_array($integration, ['polylang', 'wpml'])) {
101
+			return false;
102
+		}
103
+		$integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration);
104
+		if (!glsr($integrationClass)->isActive()) {
105
+			glsr(Notice::class)->addError(sprintf(
106
+				__('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
107
+				constant($integrationClass.'::PLUGIN_NAME')
108
+			));
109
+			return false;
110
+		} elseif (!glsr($integrationClass)->isSupported()) {
111
+			glsr(Notice::class)->addError(sprintf(
112
+				__('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
113
+				constant($integrationClass.'::PLUGIN_NAME'),
114
+				constant($integrationClass.'::SUPPORTED_VERSION')
115
+			));
116
+			return false;
117
+		}
118
+		return true;
119
+	}
120 120
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
      * @return array
15 15
      * @callback register_setting
16 16
      */
17
-    public function callbackRegisterSettings($input)
17
+    public function callbackRegisterSettings( $input )
18 18
     {
19
-        $settings = glsr(Helper::class)->consolidateArray($input);
20
-        if (1 === count($settings) && array_key_exists('settings', $settings)) {
21
-            $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
22
-            $options = $this->sanitizeGeneral($input, $options);
23
-            $options = $this->sanitizeSubmissions($input, $options);
24
-            $options = $this->sanitizeTranslations($input, $options);
25
-            if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
26
-                glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
19
+        $settings = glsr( Helper::class )->consolidateArray( $input );
20
+        if( 1 === count( $settings ) && array_key_exists( 'settings', $settings ) ) {
21
+            $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input );
22
+            $options = $this->sanitizeGeneral( $input, $options );
23
+            $options = $this->sanitizeSubmissions( $input, $options );
24
+            $options = $this->sanitizeTranslations( $input, $options );
25
+            if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) {
26
+                glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) );
27 27
             }
28 28
             return $options;
29 29
         }
@@ -36,31 +36,31 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function registerSettings()
38 38
     {
39
-        register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
39
+        register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [
40 40
             'sanitize_callback' => [$this, 'callbackRegisterSettings'],
41
-        ]);
41
+        ] );
42 42
     }
43 43
 
44 44
     /**
45 45
      * @return array
46 46
      */
47
-    protected function sanitizeGeneral(array $input, array $options)
47
+    protected function sanitizeGeneral( array $input, array $options )
48 48
     {
49 49
         $inputForm = $input['settings']['general'];
50
-        if (!$this->hasMultilingualIntegration($inputForm['support']['multilingual'])) {
50
+        if( !$this->hasMultilingualIntegration( $inputForm['support']['multilingual'] ) ) {
51 51
             $options['settings']['general']['support']['multilingual'] = '';
52 52
         }
53
-        if ('' == trim($inputForm['notification_message'])) {
53
+        if( '' == trim( $inputForm['notification_message'] ) ) {
54 54
             $options['settings']['general']['notification_message'] = glsr()->defaults['settings']['general']['notification_message'];
55 55
         }
56
-        $options['settings']['general']['notifications'] = glsr_get($inputForm, 'notifications', []);
56
+        $options['settings']['general']['notifications'] = glsr_get( $inputForm, 'notifications', [] );
57 57
         return $options;
58 58
     }
59 59
 
60 60
     /**
61 61
      * @return array
62 62
      */
63
-    protected function sanitizeSubmissions(array $input, array $options)
63
+    protected function sanitizeSubmissions( array $input, array $options )
64 64
     {
65 65
         $inputForm = $input['settings']['submissions'];
66 66
         $options['settings']['submissions']['required'] = isset($inputForm['required'])
@@ -72,20 +72,20 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * @return array
74 74
      */
75
-    protected function sanitizeTranslations(array $input, array $options)
75
+    protected function sanitizeTranslations( array $input, array $options )
76 76
     {
77
-        if (isset($input['settings']['strings'])) {
78
-            $options['settings']['strings'] = array_values(array_filter($input['settings']['strings']));
77
+        if( isset($input['settings']['strings']) ) {
78
+            $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) );
79 79
             $allowedTags = [
80 80
                 'a' => ['class' => [], 'href' => [], 'target' => []],
81 81
                 'span' => ['class' => []],
82 82
             ];
83
-            array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
84
-                if (isset($string['s2'])) {
85
-                    $string['s2'] = wp_kses($string['s2'], $allowedTags);
83
+            array_walk( $options['settings']['strings'], function( &$string ) use ($allowedTags) {
84
+                if( isset($string['s2']) ) {
85
+                    $string['s2'] = wp_kses( $string['s2'], $allowedTags );
86 86
                 }
87
-                if (isset($string['p2'])) {
88
-                    $string['p2'] = wp_kses($string['p2'], $allowedTags);
87
+                if( isset($string['p2']) ) {
88
+                    $string['p2'] = wp_kses( $string['p2'], $allowedTags );
89 89
                 }
90 90
             });
91 91
         }
@@ -95,24 +95,24 @@  discard block
 block discarded – undo
95 95
     /**
96 96
      * @return bool
97 97
      */
98
-    protected function hasMultilingualIntegration($integration)
98
+    protected function hasMultilingualIntegration( $integration )
99 99
     {
100
-        if (!in_array($integration, ['polylang', 'wpml'])) {
100
+        if( !in_array( $integration, ['polylang', 'wpml'] ) ) {
101 101
             return false;
102 102
         }
103
-        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration);
104
-        if (!glsr($integrationClass)->isActive()) {
105
-            glsr(Notice::class)->addError(sprintf(
106
-                __('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
107
-                constant($integrationClass.'::PLUGIN_NAME')
108
-            ));
103
+        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst( $integration );
104
+        if( !glsr( $integrationClass )->isActive() ) {
105
+            glsr( Notice::class )->addError( sprintf(
106
+                __( 'Please install/activate the %s plugin to enable integration.', 'site-reviews' ),
107
+                constant( $integrationClass.'::PLUGIN_NAME' )
108
+            ) );
109 109
             return false;
110
-        } elseif (!glsr($integrationClass)->isSupported()) {
111
-            glsr(Notice::class)->addError(sprintf(
112
-                __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
113
-                constant($integrationClass.'::PLUGIN_NAME'),
114
-                constant($integrationClass.'::SUPPORTED_VERSION')
115
-            ));
110
+        } elseif( !glsr( $integrationClass )->isSupported() ) {
111
+            glsr( Notice::class )->addError( sprintf(
112
+                __( 'Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews' ),
113
+                constant( $integrationClass.'::PLUGIN_NAME' ),
114
+                constant( $integrationClass.'::SUPPORTED_VERSION' )
115
+            ) );
116 116
             return false;
117 117
         }
118 118
         return true;
Please login to merge, or discard this patch.
plugin/Contracts/MultilingualContract.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -4,29 +4,29 @@
 block discarded – undo
4 4
 
5 5
 interface MultilingualContract
6 6
 {
7
-    /**
8
-     * @param int|string $postId
9
-     * @return \WP_Post|void|null
10
-     */
11
-    public function getPost($postId);
7
+	/**
8
+	 * @param int|string $postId
9
+	 * @return \WP_Post|void|null
10
+	 */
11
+	public function getPost($postId);
12 12
 
13
-    /**
14
-     * @return array
15
-     */
16
-    public function getPostIds(array $postIds);
13
+	/**
14
+	 * @return array
15
+	 */
16
+	public function getPostIds(array $postIds);
17 17
 
18
-    /**
19
-     * @return bool
20
-     */
21
-    public function isActive();
18
+	/**
19
+	 * @return bool
20
+	 */
21
+	public function isActive();
22 22
 
23
-    /**
24
-     * @return bool
25
-     */
26
-    public function isEnabled();
23
+	/**
24
+	 * @return bool
25
+	 */
26
+	public function isEnabled();
27 27
 
28
-    /**
29
-     * @return bool
30
-     */
31
-    public function isSupported();
28
+	/**
29
+	 * @return bool
30
+	 */
31
+	public function isSupported();
32 32
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
      * @param int|string $postId
9 9
      * @return \WP_Post|void|null
10 10
      */
11
-    public function getPost($postId);
11
+    public function getPost( $postId );
12 12
 
13 13
     /**
14 14
      * @return array
15 15
      */
16
-    public function getPostIds(array $postIds);
16
+    public function getPostIds( array $postIds );
17 17
 
18 18
     /**
19 19
      * @return bool
Please login to merge, or discard this patch.
plugin/Modules/System.php 2 patches
Indentation   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -10,368 +10,368 @@
 block discarded – undo
10 10
 
11 11
 class System
12 12
 {
13
-    const PAD = 40;
13
+	const PAD = 40;
14 14
 
15
-    /**
16
-     * @return string
17
-     */
18
-    public function __toString()
19
-    {
20
-        return $this->get();
21
-    }
15
+	/**
16
+	 * @return string
17
+	 */
18
+	public function __toString()
19
+	{
20
+		return $this->get();
21
+	}
22 22
 
23
-    /**
24
-     * @return string
25
-     */
26
-    public function get()
27
-    {
28
-        $details = [
29
-            'plugin' => 'Plugin Details',
30
-            'addon' => 'Addon Details',
31
-            'browser' => 'Browser Details',
32
-            'server' => 'Server Details',
33
-            'php' => 'PHP Configuration',
34
-            'wordpress' => 'WordPress Configuration',
35
-            'mu-plugin' => 'Must-Use Plugins',
36
-            'multisite-plugin' => 'Network Active Plugins',
37
-            'active-plugin' => 'Active Plugins',
38
-            'inactive-plugin' => 'Inactive Plugins',
39
-            'setting' => 'Plugin Settings',
40
-            'reviews' => 'Review Counts',
41
-        ];
42
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
-            $methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
45
-                return $carry.$this->implode(
46
-                    strtoupper($details[$key]),
47
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
48
-                );
49
-            }
50
-            return $carry;
51
-        });
52
-        return trim($systemInfo);
53
-    }
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function get()
27
+	{
28
+		$details = [
29
+			'plugin' => 'Plugin Details',
30
+			'addon' => 'Addon Details',
31
+			'browser' => 'Browser Details',
32
+			'server' => 'Server Details',
33
+			'php' => 'PHP Configuration',
34
+			'wordpress' => 'WordPress Configuration',
35
+			'mu-plugin' => 'Must-Use Plugins',
36
+			'multisite-plugin' => 'Network Active Plugins',
37
+			'active-plugin' => 'Active Plugins',
38
+			'inactive-plugin' => 'Inactive Plugins',
39
+			'setting' => 'Plugin Settings',
40
+			'reviews' => 'Review Counts',
41
+		];
42
+		$systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
+			$methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
+			if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
45
+				return $carry.$this->implode(
46
+					strtoupper($details[$key]),
47
+					apply_filters('site-reviews/system/'.$key, $systemDetails)
48
+				);
49
+			}
50
+			return $carry;
51
+		});
52
+		return trim($systemInfo);
53
+	}
54 54
 
55
-    /**
56
-     * @return array
57
-     */
58
-    public function getActivePluginDetails()
59
-    {
60
-        $plugins = get_plugins();
61
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
63
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
64
-    }
55
+	/**
56
+	 * @return array
57
+	 */
58
+	public function getActivePluginDetails()
59
+	{
60
+		$plugins = get_plugins();
61
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
+		$inactive = array_diff_key($plugins, array_flip($activePlugins));
63
+		return $this->normalizePluginList(array_diff_key($plugins, $inactive));
64
+	}
65 65
 
66
-    /**
67
-     * @return array
68
-     */
69
-    public function getAddonDetails()
70
-    {
71
-        $details = apply_filters('site-reviews/addon/system-info', []);
72
-        ksort($details);
73
-        return $details;
74
-    }
66
+	/**
67
+	 * @return array
68
+	 */
69
+	public function getAddonDetails()
70
+	{
71
+		$details = apply_filters('site-reviews/addon/system-info', []);
72
+		ksort($details);
73
+		return $details;
74
+	}
75 75
 
76
-    /**
77
-     * @return array
78
-     */
79
-    public function getBrowserDetails()
80
-    {
81
-        $browser = new Browser();
82
-        $name = esc_attr($browser->getName());
83
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
-        $version = esc_attr($browser->getVersion());
85
-        return [
86
-            'Browser Name' => sprintf('%s %s', $name, $version),
87
-            'Browser UA' => $userAgent,
88
-        ];
89
-    }
76
+	/**
77
+	 * @return array
78
+	 */
79
+	public function getBrowserDetails()
80
+	{
81
+		$browser = new Browser();
82
+		$name = esc_attr($browser->getName());
83
+		$userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
+		$version = esc_attr($browser->getVersion());
85
+		return [
86
+			'Browser Name' => sprintf('%s %s', $name, $version),
87
+			'Browser UA' => $userAgent,
88
+		];
89
+	}
90 90
 
91
-    /**
92
-     * @return array
93
-     */
94
-    public function getInactivePluginDetails()
95
-    {
96
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
98
-        $multisitePlugins = $this->getMultisitePluginDetails();
99
-        return empty($multisitePlugins)
100
-            ? $inactivePlugins
101
-            : array_diff($inactivePlugins, $multisitePlugins);
102
-    }
91
+	/**
92
+	 * @return array
93
+	 */
94
+	public function getInactivePluginDetails()
95
+	{
96
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
+		$inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
98
+		$multisitePlugins = $this->getMultisitePluginDetails();
99
+		return empty($multisitePlugins)
100
+			? $inactivePlugins
101
+			: array_diff($inactivePlugins, $multisitePlugins);
102
+	}
103 103
 
104
-    /**
105
-     * @return array
106
-     */
107
-    public function getMuPluginDetails()
108
-    {
109
-        if (empty($plugins = get_mu_plugins())) {
110
-            return [];
111
-        }
112
-        return $this->normalizePluginList($plugins);
113
-    }
104
+	/**
105
+	 * @return array
106
+	 */
107
+	public function getMuPluginDetails()
108
+	{
109
+		if (empty($plugins = get_mu_plugins())) {
110
+			return [];
111
+		}
112
+		return $this->normalizePluginList($plugins);
113
+	}
114 114
 
115
-    /**
116
-     * @return array
117
-     */
118
-    public function getMultisitePluginDetails()
119
-    {
120
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
-        if (!is_multisite() || empty($activePlugins)) {
122
-            return [];
123
-        }
124
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
125
-    }
115
+	/**
116
+	 * @return array
117
+	 */
118
+	public function getMultisitePluginDetails()
119
+	{
120
+		$activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
+		if (!is_multisite() || empty($activePlugins)) {
122
+			return [];
123
+		}
124
+		return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
125
+	}
126 126
 
127
-    /**
128
-     * @return array
129
-     */
130
-    public function getPhpDetails()
131
-    {
132
-        $displayErrors = ini_get('display_errors')
133
-            ? 'On ('.ini_get('display_errors').')'
134
-            : 'N/A';
135
-        $intlSupport = extension_loaded('intl')
136
-            ? phpversion('intl')
137
-            : 'false';
138
-        return [
139
-            'cURL' => var_export(function_exists('curl_init'), true),
140
-            'Default Charset' => ini_get('default_charset'),
141
-            'Display Errors' => $displayErrors,
142
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
143
-            'Intl' => $intlSupport,
144
-            'IPv6' => var_export(defined('AF_INET6'), true),
145
-            'Max Execution Time' => ini_get('max_execution_time'),
146
-            'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
-            'Max Input Vars' => ini_get('max_input_vars'),
148
-            'Memory Limit' => ini_get('memory_limit'),
149
-            'Post Max Size' => ini_get('post_max_size'),
150
-            'Sendmail Path' => ini_get('sendmail_path'),
151
-            'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
-            'Session Name' => esc_html(ini_get('session.name')),
153
-            'Session Save Path' => esc_html(ini_get('session.save_path')),
154
-            'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
-            'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
-            'Upload Max Filesize' => ini_get('upload_max_filesize'),
157
-        ];
158
-    }
127
+	/**
128
+	 * @return array
129
+	 */
130
+	public function getPhpDetails()
131
+	{
132
+		$displayErrors = ini_get('display_errors')
133
+			? 'On ('.ini_get('display_errors').')'
134
+			: 'N/A';
135
+		$intlSupport = extension_loaded('intl')
136
+			? phpversion('intl')
137
+			: 'false';
138
+		return [
139
+			'cURL' => var_export(function_exists('curl_init'), true),
140
+			'Default Charset' => ini_get('default_charset'),
141
+			'Display Errors' => $displayErrors,
142
+			'fsockopen' => var_export(function_exists('fsockopen'), true),
143
+			'Intl' => $intlSupport,
144
+			'IPv6' => var_export(defined('AF_INET6'), true),
145
+			'Max Execution Time' => ini_get('max_execution_time'),
146
+			'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
+			'Max Input Vars' => ini_get('max_input_vars'),
148
+			'Memory Limit' => ini_get('memory_limit'),
149
+			'Post Max Size' => ini_get('post_max_size'),
150
+			'Sendmail Path' => ini_get('sendmail_path'),
151
+			'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
+			'Session Name' => esc_html(ini_get('session.name')),
153
+			'Session Save Path' => esc_html(ini_get('session.save_path')),
154
+			'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
+			'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
+			'Upload Max Filesize' => ini_get('upload_max_filesize'),
157
+		];
158
+	}
159 159
 
160
-    /**
161
-     * @return array
162
-     */
163
-    public function getReviewsDetails()
164
-    {
165
-        $counts = glsr(CountsManager::class)->getCounts();
166
-        $counts = glsr(Helper::class)->flattenArray($counts);
167
-        array_walk($counts, function (&$ratings) use ($counts) {
168
-            if (!is_array($ratings)) {
169
-                glsr_log()
170
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
-                    ->debug($ratings)
172
-                    ->debug($counts);
173
-                return;
174
-            }
175
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
176
-        });
177
-        ksort($counts);
178
-        return $counts;
179
-    }
160
+	/**
161
+	 * @return array
162
+	 */
163
+	public function getReviewsDetails()
164
+	{
165
+		$counts = glsr(CountsManager::class)->getCounts();
166
+		$counts = glsr(Helper::class)->flattenArray($counts);
167
+		array_walk($counts, function (&$ratings) use ($counts) {
168
+			if (!is_array($ratings)) {
169
+				glsr_log()
170
+					->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
+					->debug($ratings)
172
+					->debug($counts);
173
+				return;
174
+			}
175
+			$ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
176
+		});
177
+		ksort($counts);
178
+		return $counts;
179
+	}
180 180
 
181
-    /**
182
-     * @return array
183
-     */
184
-    public function getServerDetails()
185
-    {
186
-        global $wpdb;
187
-        return [
188
-            'Host Name' => $this->getHostName(),
189
-            'MySQL Version' => $wpdb->db_version(),
190
-            'PHP Version' => PHP_VERSION,
191
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
192
-        ];
193
-    }
181
+	/**
182
+	 * @return array
183
+	 */
184
+	public function getServerDetails()
185
+	{
186
+		global $wpdb;
187
+		return [
188
+			'Host Name' => $this->getHostName(),
189
+			'MySQL Version' => $wpdb->db_version(),
190
+			'PHP Version' => PHP_VERSION,
191
+			'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
192
+		];
193
+	}
194 194
 
195
-    /**
196
-     * @return array
197
-     */
198
-    public function getSettingDetails()
199
-    {
200
-        $helper = glsr(Helper::class);
201
-        $settings = glsr(OptionManager::class)->get('settings', []);
202
-        $settings = $helper->flattenArray($settings, true);
203
-        $settings = $this->purgeSensitiveData($settings);
204
-        ksort($settings);
205
-        $details = [];
206
-        foreach ($settings as $key => $value) {
207
-            if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
208
-                continue;
209
-            }
210
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
211
-            $details[$key] = $value;
212
-        }
213
-        return $details;
214
-    }
195
+	/**
196
+	 * @return array
197
+	 */
198
+	public function getSettingDetails()
199
+	{
200
+		$helper = glsr(Helper::class);
201
+		$settings = glsr(OptionManager::class)->get('settings', []);
202
+		$settings = $helper->flattenArray($settings, true);
203
+		$settings = $this->purgeSensitiveData($settings);
204
+		ksort($settings);
205
+		$details = [];
206
+		foreach ($settings as $key => $value) {
207
+			if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
208
+				continue;
209
+			}
210
+			$value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
211
+			$details[$key] = $value;
212
+		}
213
+		return $details;
214
+	}
215 215
 
216
-    /**
217
-     * @return array
218
-     */
219
-    public function getPluginDetails()
220
-    {
221
-        return [
222
-            'Console level' => glsr(Console::class)->humanLevel(),
223
-            'Console size' => glsr(Console::class)->humanSize('0'),
224
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
225
-            'Version (current)' => glsr()->version,
226
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
227
-        ];
228
-    }
216
+	/**
217
+	 * @return array
218
+	 */
219
+	public function getPluginDetails()
220
+	{
221
+		return [
222
+			'Console level' => glsr(Console::class)->humanLevel(),
223
+			'Console size' => glsr(Console::class)->humanSize('0'),
224
+			'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
225
+			'Version (current)' => glsr()->version,
226
+			'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
227
+		];
228
+	}
229 229
 
230
-    /**
231
-     * @return array
232
-     */
233
-    public function getWordpressDetails()
234
-    {
235
-        global $wpdb;
236
-        $theme = wp_get_theme();
237
-        return [
238
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
240
-            'Home URL' => home_url(),
241
-            'Language' => get_locale(),
242
-            'Memory Limit' => WP_MEMORY_LIMIT,
243
-            'Multisite' => var_export(is_multisite(), true),
244
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
-            'Post Stati' => implode(', ', get_post_stati()),
248
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
250
-            'Site URL' => site_url(),
251
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
-            'Version' => get_bloginfo('version'),
253
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
255
-            'WP Memory Limit' => WP_MEMORY_LIMIT,
256
-        ];
257
-    }
230
+	/**
231
+	 * @return array
232
+	 */
233
+	public function getWordpressDetails()
234
+	{
235
+		global $wpdb;
236
+		$theme = wp_get_theme();
237
+		return [
238
+			'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
+			'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
240
+			'Home URL' => home_url(),
241
+			'Language' => get_locale(),
242
+			'Memory Limit' => WP_MEMORY_LIMIT,
243
+			'Multisite' => var_export(is_multisite(), true),
244
+			'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
+			'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
+			'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
+			'Post Stati' => implode(', ', get_post_stati()),
248
+			'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
+			'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
250
+			'Site URL' => site_url(),
251
+			'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
+			'Version' => get_bloginfo('version'),
253
+			'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
+			'WP Max Upload Size' => size_format(wp_max_upload_size()),
255
+			'WP Memory Limit' => WP_MEMORY_LIMIT,
256
+		];
257
+	}
258 258
 
259
-    /**
260
-     * @return string
261
-     */
262
-    protected function detectWebhostProvider()
263
-    {
264
-        $checks = [
265
-            '.accountservergroup.com' => 'Site5',
266
-            '.gridserver.com' => 'MediaTemple Grid',
267
-            '.inmotionhosting.com' => 'InMotion Hosting',
268
-            '.ovh.net' => 'OVH',
269
-            '.pair.com' => 'pair Networks',
270
-            '.stabletransit.com' => 'Rackspace Cloud',
271
-            '.stratoserver.net' => 'STRATO',
272
-            '.sysfix.eu' => 'SysFix.eu Power Hosting',
273
-            'bluehost.com' => 'Bluehost',
274
-            'DH_USER' => 'DreamHost',
275
-            'Flywheel' => 'Flywheel',
276
-            'ipagemysql.com' => 'iPage',
277
-            'ipowermysql.com' => 'IPower',
278
-            'localhost:/tmp/mysql5.sock' => 'ICDSoft',
279
-            'mysqlv5' => 'NetworkSolutions',
280
-            'PAGELYBIN' => 'Pagely',
281
-            'secureserver.net' => 'GoDaddy',
282
-            'WPE_APIKEY' => 'WP Engine',
283
-        ];
284
-        foreach ($checks as $key => $value) {
285
-            if (!$this->isWebhostCheckValid($key)) {
286
-                continue;
287
-            }
288
-            return $value;
289
-        }
290
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
291
-    }
259
+	/**
260
+	 * @return string
261
+	 */
262
+	protected function detectWebhostProvider()
263
+	{
264
+		$checks = [
265
+			'.accountservergroup.com' => 'Site5',
266
+			'.gridserver.com' => 'MediaTemple Grid',
267
+			'.inmotionhosting.com' => 'InMotion Hosting',
268
+			'.ovh.net' => 'OVH',
269
+			'.pair.com' => 'pair Networks',
270
+			'.stabletransit.com' => 'Rackspace Cloud',
271
+			'.stratoserver.net' => 'STRATO',
272
+			'.sysfix.eu' => 'SysFix.eu Power Hosting',
273
+			'bluehost.com' => 'Bluehost',
274
+			'DH_USER' => 'DreamHost',
275
+			'Flywheel' => 'Flywheel',
276
+			'ipagemysql.com' => 'iPage',
277
+			'ipowermysql.com' => 'IPower',
278
+			'localhost:/tmp/mysql5.sock' => 'ICDSoft',
279
+			'mysqlv5' => 'NetworkSolutions',
280
+			'PAGELYBIN' => 'Pagely',
281
+			'secureserver.net' => 'GoDaddy',
282
+			'WPE_APIKEY' => 'WP Engine',
283
+		];
284
+		foreach ($checks as $key => $value) {
285
+			if (!$this->isWebhostCheckValid($key)) {
286
+				continue;
287
+			}
288
+			return $value;
289
+		}
290
+		return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
291
+	}
292 292
 
293
-    /**
294
-     * @return string
295
-     */
296
-    protected function getHostName()
297
-    {
298
-        return sprintf('%s (%s)',
299
-            $this->detectWebhostProvider(),
300
-            glsr(Helper::class)->getIpAddress()
301
-        );
302
-    }
293
+	/**
294
+	 * @return string
295
+	 */
296
+	protected function getHostName()
297
+	{
298
+		return sprintf('%s (%s)',
299
+			$this->detectWebhostProvider(),
300
+			glsr(Helper::class)->getIpAddress()
301
+		);
302
+	}
303 303
 
304
-    /**
305
-     * @return array
306
-     */
307
-    protected function getWordpressPlugins()
308
-    {
309
-        $plugins = get_plugins();
310
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
313
-        return $active + $inactive;
314
-    }
304
+	/**
305
+	 * @return array
306
+	 */
307
+	protected function getWordpressPlugins()
308
+	{
309
+		$plugins = get_plugins();
310
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
+		$inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
+		$active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
313
+		return $active + $inactive;
314
+	}
315 315
 
316
-    /**
317
-     * @param string $title
318
-     * @return string
319
-     */
320
-    protected function implode($title, array $details)
321
-    {
322
-        $strings = ['['.$title.']'];
323
-        $padding = max(array_map('strlen', array_keys($details)));
324
-        $padding = max([$padding, static::PAD]);
325
-        foreach ($details as $key => $value) {
326
-            $strings[] = is_string($key)
327
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
328
-                : ' - '.$value;
329
-        }
330
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
331
-    }
316
+	/**
317
+	 * @param string $title
318
+	 * @return string
319
+	 */
320
+	protected function implode($title, array $details)
321
+	{
322
+		$strings = ['['.$title.']'];
323
+		$padding = max(array_map('strlen', array_keys($details)));
324
+		$padding = max([$padding, static::PAD]);
325
+		foreach ($details as $key => $value) {
326
+			$strings[] = is_string($key)
327
+				? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
328
+				: ' - '.$value;
329
+		}
330
+		return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
331
+	}
332 332
 
333
-    /**
334
-     * @param string $key
335
-     * @return bool
336
-     */
337
-    protected function isWebhostCheckValid($key)
338
-    {
339
-        return defined($key)
340
-            || filter_input(INPUT_SERVER, $key)
341
-            || false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
-            || false !== strpos(DB_HOST, $key)
343
-            || false !== strpos(php_uname(), $key);
344
-    }
333
+	/**
334
+	 * @param string $key
335
+	 * @return bool
336
+	 */
337
+	protected function isWebhostCheckValid($key)
338
+	{
339
+		return defined($key)
340
+			|| filter_input(INPUT_SERVER, $key)
341
+			|| false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
+			|| false !== strpos(DB_HOST, $key)
343
+			|| false !== strpos(php_uname(), $key);
344
+	}
345 345
 
346
-    /**
347
-     * @return array
348
-     */
349
-    protected function normalizePluginList(array $plugins)
350
-    {
351
-        $plugins = array_map(function ($plugin) {
352
-            return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
-        }, $plugins);
354
-        natcasesort($plugins);
355
-        return array_flip($plugins);
356
-    }
346
+	/**
347
+	 * @return array
348
+	 */
349
+	protected function normalizePluginList(array $plugins)
350
+	{
351
+		$plugins = array_map(function ($plugin) {
352
+			return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
+		}, $plugins);
354
+		natcasesort($plugins);
355
+		return array_flip($plugins);
356
+	}
357 357
 
358
-    /**
359
-     * @return array
360
-     */
361
-    protected function purgeSensitiveData(array $settings)
362
-    {
363
-        $keys = [
364
-            'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
365
-        ];
366
-        array_walk($settings, function (&$value, $setting) use ($keys) {
367
-            foreach ($keys as $key) {
368
-                if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
369
-                    continue;
370
-                }
371
-                $value = str_repeat('•', 13);
372
-                return;
373
-            }
374
-        });
375
-        return $settings;
376
-    }
358
+	/**
359
+	 * @return array
360
+	 */
361
+	protected function purgeSensitiveData(array $settings)
362
+	{
363
+		$keys = [
364
+			'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
365
+		];
366
+		array_walk($settings, function (&$value, $setting) use ($keys) {
367
+			foreach ($keys as $key) {
368
+				if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
369
+					continue;
370
+				}
371
+				$value = str_repeat('•', 13);
372
+				return;
373
+			}
374
+		});
375
+		return $settings;
376
+	}
377 377
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
             'setting' => 'Plugin Settings',
40 40
             'reviews' => 'Review Counts',
41 41
         ];
42
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
-            $methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
42
+        $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) {
43
+            $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
44
+            if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
45 45
                 return $carry.$this->implode(
46
-                    strtoupper($details[$key]),
47
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
46
+                    strtoupper( $details[$key] ),
47
+                    apply_filters( 'site-reviews/system/'.$key, $systemDetails )
48 48
                 );
49 49
             }
50 50
             return $carry;
51 51
         });
52
-        return trim($systemInfo);
52
+        return trim( $systemInfo );
53 53
     }
54 54
 
55 55
     /**
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     public function getActivePluginDetails()
59 59
     {
60 60
         $plugins = get_plugins();
61
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
63
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
61
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
62
+        $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
63
+        return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
64 64
     }
65 65
 
66 66
     /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function getAddonDetails()
70 70
     {
71
-        $details = apply_filters('site-reviews/addon/system-info', []);
72
-        ksort($details);
71
+        $details = apply_filters( 'site-reviews/addon/system-info', [] );
72
+        ksort( $details );
73 73
         return $details;
74 74
     }
75 75
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
     public function getBrowserDetails()
80 80
     {
81 81
         $browser = new Browser();
82
-        $name = esc_attr($browser->getName());
83
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
-        $version = esc_attr($browser->getVersion());
82
+        $name = esc_attr( $browser->getName() );
83
+        $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() );
84
+        $version = esc_attr( $browser->getVersion() );
85 85
         return [
86
-            'Browser Name' => sprintf('%s %s', $name, $version),
86
+            'Browser Name' => sprintf( '%s %s', $name, $version ),
87 87
             'Browser UA' => $userAgent,
88 88
         ];
89 89
     }
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getInactivePluginDetails()
95 95
     {
96
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
96
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
97
+        $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
98 98
         $multisitePlugins = $this->getMultisitePluginDetails();
99 99
         return empty($multisitePlugins)
100 100
             ? $inactivePlugins
101
-            : array_diff($inactivePlugins, $multisitePlugins);
101
+            : array_diff( $inactivePlugins, $multisitePlugins );
102 102
     }
103 103
 
104 104
     /**
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function getMuPluginDetails()
108 108
     {
109
-        if (empty($plugins = get_mu_plugins())) {
109
+        if( empty($plugins = get_mu_plugins()) ) {
110 110
             return [];
111 111
         }
112
-        return $this->normalizePluginList($plugins);
112
+        return $this->normalizePluginList( $plugins );
113 113
     }
114 114
 
115 115
     /**
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function getMultisitePluginDetails()
119 119
     {
120
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
-        if (!is_multisite() || empty($activePlugins)) {
120
+        $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] );
121
+        if( !is_multisite() || empty($activePlugins) ) {
122 122
             return [];
123 123
         }
124
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
124
+        return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) );
125 125
     }
126 126
 
127 127
     /**
@@ -129,31 +129,31 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function getPhpDetails()
131 131
     {
132
-        $displayErrors = ini_get('display_errors')
133
-            ? 'On ('.ini_get('display_errors').')'
132
+        $displayErrors = ini_get( 'display_errors' )
133
+            ? 'On ('.ini_get( 'display_errors' ).')'
134 134
             : 'N/A';
135
-        $intlSupport = extension_loaded('intl')
136
-            ? phpversion('intl')
135
+        $intlSupport = extension_loaded( 'intl' )
136
+            ? phpversion( 'intl' )
137 137
             : 'false';
138 138
         return [
139
-            'cURL' => var_export(function_exists('curl_init'), true),
140
-            'Default Charset' => ini_get('default_charset'),
139
+            'cURL' => var_export( function_exists( 'curl_init' ), true ),
140
+            'Default Charset' => ini_get( 'default_charset' ),
141 141
             'Display Errors' => $displayErrors,
142
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
142
+            'fsockopen' => var_export( function_exists( 'fsockopen' ), true ),
143 143
             'Intl' => $intlSupport,
144
-            'IPv6' => var_export(defined('AF_INET6'), true),
145
-            'Max Execution Time' => ini_get('max_execution_time'),
146
-            'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
-            'Max Input Vars' => ini_get('max_input_vars'),
148
-            'Memory Limit' => ini_get('memory_limit'),
149
-            'Post Max Size' => ini_get('post_max_size'),
150
-            'Sendmail Path' => ini_get('sendmail_path'),
151
-            'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
-            'Session Name' => esc_html(ini_get('session.name')),
153
-            'Session Save Path' => esc_html(ini_get('session.save_path')),
154
-            'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
-            'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
-            'Upload Max Filesize' => ini_get('upload_max_filesize'),
144
+            'IPv6' => var_export( defined( 'AF_INET6' ), true ),
145
+            'Max Execution Time' => ini_get( 'max_execution_time' ),
146
+            'Max Input Nesting Level' => ini_get( 'max_input_nesting_level' ),
147
+            'Max Input Vars' => ini_get( 'max_input_vars' ),
148
+            'Memory Limit' => ini_get( 'memory_limit' ),
149
+            'Post Max Size' => ini_get( 'post_max_size' ),
150
+            'Sendmail Path' => ini_get( 'sendmail_path' ),
151
+            'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
152
+            'Session Name' => esc_html( ini_get( 'session.name' ) ),
153
+            'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
154
+            'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
155
+            'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
156
+            'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
157 157
         ];
158 158
     }
159 159
 
@@ -162,19 +162,19 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function getReviewsDetails()
164 164
     {
165
-        $counts = glsr(CountsManager::class)->getCounts();
166
-        $counts = glsr(Helper::class)->flattenArray($counts);
167
-        array_walk($counts, function (&$ratings) use ($counts) {
168
-            if (!is_array($ratings)) {
165
+        $counts = glsr( CountsManager::class )->getCounts();
166
+        $counts = glsr( Helper::class )->flattenArray( $counts );
167
+        array_walk( $counts, function( &$ratings ) use ($counts) {
168
+            if( !is_array( $ratings ) ) {
169 169
                 glsr_log()
170
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
-                    ->debug($ratings)
172
-                    ->debug($counts);
170
+                    ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
171
+                    ->debug( $ratings )
172
+                    ->debug( $counts );
173 173
                 return;
174 174
             }
175
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
175
+            $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')';
176 176
         });
177
-        ksort($counts);
177
+        ksort( $counts );
178 178
         return $counts;
179 179
     }
180 180
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             'Host Name' => $this->getHostName(),
189 189
             'MySQL Version' => $wpdb->db_version(),
190 190
             'PHP Version' => PHP_VERSION,
191
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
191
+            'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ),
192 192
         ];
193 193
     }
194 194
 
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function getSettingDetails()
199 199
     {
200
-        $helper = glsr(Helper::class);
201
-        $settings = glsr(OptionManager::class)->get('settings', []);
202
-        $settings = $helper->flattenArray($settings, true);
203
-        $settings = $this->purgeSensitiveData($settings);
204
-        ksort($settings);
200
+        $helper = glsr( Helper::class );
201
+        $settings = glsr( OptionManager::class )->get( 'settings', [] );
202
+        $settings = $helper->flattenArray( $settings, true );
203
+        $settings = $this->purgeSensitiveData( $settings );
204
+        ksort( $settings );
205 205
         $details = [];
206
-        foreach ($settings as $key => $value) {
207
-            if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
206
+        foreach( $settings as $key => $value ) {
207
+            if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) ) {
208 208
                 continue;
209 209
             }
210
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
210
+            $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
211 211
             $details[$key] = $value;
212 212
         }
213 213
         return $details;
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
     public function getPluginDetails()
220 220
     {
221 221
         return [
222
-            'Console level' => glsr(Console::class)->humanLevel(),
223
-            'Console size' => glsr(Console::class)->humanSize('0'),
224
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
222
+            'Console level' => glsr( Console::class )->humanLevel(),
223
+            'Console size' => glsr( Console::class )->humanSize( '0' ),
224
+            'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ),
225 225
             'Version (current)' => glsr()->version,
226
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
226
+            'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ),
227 227
         ];
228 228
     }
229 229
 
@@ -235,23 +235,23 @@  discard block
 block discarded – undo
235 235
         global $wpdb;
236 236
         $theme = wp_get_theme();
237 237
         return [
238
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
238
+            'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ),
239
+            'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ),
240 240
             'Home URL' => home_url(),
241 241
             'Language' => get_locale(),
242 242
             'Memory Limit' => WP_MEMORY_LIMIT,
243
-            'Multisite' => var_export(is_multisite(), true),
244
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
-            'Post Stati' => implode(', ', get_post_stati()),
248
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
243
+            'Multisite' => var_export( is_multisite(), true ),
244
+            'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ),
245
+            'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ),
246
+            'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ),
247
+            'Post Stati' => implode( ', ', get_post_stati() ),
248
+            'Remote Post' => glsr( Cache::class )->getRemotePostTest(),
249
+            'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ),
250 250
             'Site URL' => site_url(),
251
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
-            'Version' => get_bloginfo('version'),
253
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
251
+            'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', ini_get( 'date.timezone' ).' (PHP)' ),
252
+            'Version' => get_bloginfo( 'version' ),
253
+            'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ),
254
+            'WP Max Upload Size' => size_format( wp_max_upload_size() ),
255 255
             'WP Memory Limit' => WP_MEMORY_LIMIT,
256 256
         ];
257 257
     }
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
             'secureserver.net' => 'GoDaddy',
282 282
             'WPE_APIKEY' => 'WP Engine',
283 283
         ];
284
-        foreach ($checks as $key => $value) {
285
-            if (!$this->isWebhostCheckValid($key)) {
284
+        foreach( $checks as $key => $value ) {
285
+            if( !$this->isWebhostCheckValid( $key ) ) {
286 286
                 continue;
287 287
             }
288 288
             return $value;
289 289
         }
290
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
290
+        return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
291 291
     }
292 292
 
293 293
     /**
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
      */
296 296
     protected function getHostName()
297 297
     {
298
-        return sprintf('%s (%s)',
298
+        return sprintf( '%s (%s)',
299 299
             $this->detectWebhostProvider(),
300
-            glsr(Helper::class)->getIpAddress()
300
+            glsr( Helper::class )->getIpAddress()
301 301
         );
302 302
     }
303 303
 
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
     protected function getWordpressPlugins()
308 308
     {
309 309
         $plugins = get_plugins();
310
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
310
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
311
+        $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
312
+        $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
313 313
         return $active + $inactive;
314 314
     }
315 315
 
@@ -317,58 +317,58 @@  discard block
 block discarded – undo
317 317
      * @param string $title
318 318
      * @return string
319 319
      */
320
-    protected function implode($title, array $details)
320
+    protected function implode( $title, array $details )
321 321
     {
322 322
         $strings = ['['.$title.']'];
323
-        $padding = max(array_map('strlen', array_keys($details)));
324
-        $padding = max([$padding, static::PAD]);
325
-        foreach ($details as $key => $value) {
326
-            $strings[] = is_string($key)
327
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
323
+        $padding = max( array_map( 'strlen', array_keys( $details ) ) );
324
+        $padding = max( [$padding, static::PAD] );
325
+        foreach( $details as $key => $value ) {
326
+            $strings[] = is_string( $key )
327
+                ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value )
328 328
                 : ' - '.$value;
329 329
         }
330
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
330
+        return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL;
331 331
     }
332 332
 
333 333
     /**
334 334
      * @param string $key
335 335
      * @return bool
336 336
      */
337
-    protected function isWebhostCheckValid($key)
337
+    protected function isWebhostCheckValid( $key )
338 338
     {
339
-        return defined($key)
340
-            || filter_input(INPUT_SERVER, $key)
341
-            || false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
-            || false !== strpos(DB_HOST, $key)
343
-            || false !== strpos(php_uname(), $key);
339
+        return defined( $key )
340
+            || filter_input( INPUT_SERVER, $key )
341
+            || false !== strpos( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key )
342
+            || false !== strpos( DB_HOST, $key )
343
+            || false !== strpos( php_uname(), $key );
344 344
     }
345 345
 
346 346
     /**
347 347
      * @return array
348 348
      */
349
-    protected function normalizePluginList(array $plugins)
349
+    protected function normalizePluginList( array $plugins )
350 350
     {
351
-        $plugins = array_map(function ($plugin) {
352
-            return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
-        }, $plugins);
354
-        natcasesort($plugins);
355
-        return array_flip($plugins);
351
+        $plugins = array_map( function( $plugin ) {
352
+            return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' ) );
353
+        }, $plugins );
354
+        natcasesort( $plugins );
355
+        return array_flip( $plugins );
356 356
     }
357 357
 
358 358
     /**
359 359
      * @return array
360 360
      */
361
-    protected function purgeSensitiveData(array $settings)
361
+    protected function purgeSensitiveData( array $settings )
362 362
     {
363 363
         $keys = [
364 364
             'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
365 365
         ];
366
-        array_walk($settings, function (&$value, $setting) use ($keys) {
367
-            foreach ($keys as $key) {
368
-                if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
366
+        array_walk( $settings, function( &$value, $setting ) use ($keys) {
367
+            foreach( $keys as $key ) {
368
+                if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) ) {
369 369
                     continue;
370 370
                 }
371
-                $value = str_repeat('•', 13);
371
+                $value = str_repeat( '•', 13 );
372 372
                 return;
373 373
             }
374 374
         });
Please login to merge, or discard this patch.
plugin/Modules/Schema.php 2 patches
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -12,291 +12,291 @@
 block discarded – undo
12 12
 
13 13
 class Schema
14 14
 {
15
-    /**
16
-     * @var array
17
-     */
18
-    protected $args;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	protected $args;
19 19
 
20
-    /**
21
-     * @var array
22
-     */
23
-    protected $ratingCounts;
20
+	/**
21
+	 * @var array
22
+	 */
23
+	protected $ratingCounts;
24 24
 
25
-    /**
26
-     * @return array
27
-     */
28
-    public function build(array $args = [])
29
-    {
30
-        $this->args = $args;
31
-        $schema = $this->buildSummary($args);
32
-        $reviews = [];
33
-        foreach (glsr(ReviewManager::class)->get($this->args) as $review) {
34
-            // Only include critic reviews that have been directly produced by your site, not reviews from third-party sites or syndicated reviews.
35
-            // @see https://developers.google.com/search/docs/data-types/review
36
-            if ('local' != $review->review_type) {
37
-                continue;
38
-            }
39
-            $reviews[] = $this->buildReview($review);
40
-        }
41
-        if (!empty($reviews)) {
42
-            array_walk($reviews, function (&$review) {
43
-                unset($review['@context']);
44
-                unset($review['itemReviewed']);
45
-            });
46
-            $schema['review'] = $reviews;
47
-        }
48
-        return $schema;
49
-    }
25
+	/**
26
+	 * @return array
27
+	 */
28
+	public function build(array $args = [])
29
+	{
30
+		$this->args = $args;
31
+		$schema = $this->buildSummary($args);
32
+		$reviews = [];
33
+		foreach (glsr(ReviewManager::class)->get($this->args) as $review) {
34
+			// Only include critic reviews that have been directly produced by your site, not reviews from third-party sites or syndicated reviews.
35
+			// @see https://developers.google.com/search/docs/data-types/review
36
+			if ('local' != $review->review_type) {
37
+				continue;
38
+			}
39
+			$reviews[] = $this->buildReview($review);
40
+		}
41
+		if (!empty($reviews)) {
42
+			array_walk($reviews, function (&$review) {
43
+				unset($review['@context']);
44
+				unset($review['itemReviewed']);
45
+			});
46
+			$schema['review'] = $reviews;
47
+		}
48
+		return $schema;
49
+	}
50 50
 
51
-    /**
52
-     * @param array|null $args
53
-     * @return array
54
-     */
55
-    public function buildSummary($args = null)
56
-    {
57
-        if (is_array($args)) {
58
-            $this->args = $args;
59
-        }
60
-        $buildSummary = glsr(Helper::class)->buildMethodName($this->getSchemaOptionValue('type'), 'buildSummaryFor');
61
-        $count = array_sum($this->getRatingCounts());
62
-        $schema = method_exists($this, $buildSummary)
63
-            ? $this->$buildSummary()
64
-            : $this->buildSummaryForCustom();
65
-        if (!empty($count)) {
66
-            $schema->aggregateRating(
67
-                $this->getSchemaType('AggregateRating')
68
-                    ->ratingValue($this->getRatingValue())
69
-                    ->reviewCount($count)
70
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
71
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
72
-            );
73
-        }
74
-        $schema = $schema->toArray();
75
-        return apply_filters('site-reviews/schema/'.$schema['@type'], $schema, $args);
76
-    }
51
+	/**
52
+	 * @param array|null $args
53
+	 * @return array
54
+	 */
55
+	public function buildSummary($args = null)
56
+	{
57
+		if (is_array($args)) {
58
+			$this->args = $args;
59
+		}
60
+		$buildSummary = glsr(Helper::class)->buildMethodName($this->getSchemaOptionValue('type'), 'buildSummaryFor');
61
+		$count = array_sum($this->getRatingCounts());
62
+		$schema = method_exists($this, $buildSummary)
63
+			? $this->$buildSummary()
64
+			: $this->buildSummaryForCustom();
65
+		if (!empty($count)) {
66
+			$schema->aggregateRating(
67
+				$this->getSchemaType('AggregateRating')
68
+					->ratingValue($this->getRatingValue())
69
+					->reviewCount($count)
70
+					->bestRating(glsr()->constant('MAX_RATING', Rating::class))
71
+					->worstRating(glsr()->constant('MIN_RATING', Rating::class))
72
+			);
73
+		}
74
+		$schema = $schema->toArray();
75
+		return apply_filters('site-reviews/schema/'.$schema['@type'], $schema, $args);
76
+	}
77 77
 
78
-    /**
79
-     * @return void
80
-     */
81
-    public function render()
82
-    {
83
-        if (empty(glsr()->schemas)) {
84
-            return;
85
-        }
86
-        printf('<script type="application/ld+json">%s</script>', json_encode(
87
-            apply_filters('site-reviews/schema/all', glsr()->schemas),
88
-            JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
89
-        ));
90
-    }
78
+	/**
79
+	 * @return void
80
+	 */
81
+	public function render()
82
+	{
83
+		if (empty(glsr()->schemas)) {
84
+			return;
85
+		}
86
+		printf('<script type="application/ld+json">%s</script>', json_encode(
87
+			apply_filters('site-reviews/schema/all', glsr()->schemas),
88
+			JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
89
+		));
90
+	}
91 91
 
92
-    /**
93
-     * @return void
94
-     */
95
-    public function store(array $schema)
96
-    {
97
-        $schemas = glsr()->schemas;
98
-        $schemas[] = $schema;
99
-        glsr()->schemas = array_map('unserialize', array_unique(array_map('serialize', $schemas)));
100
-    }
92
+	/**
93
+	 * @return void
94
+	 */
95
+	public function store(array $schema)
96
+	{
97
+		$schemas = glsr()->schemas;
98
+		$schemas[] = $schema;
99
+		glsr()->schemas = array_map('unserialize', array_unique(array_map('serialize', $schemas)));
100
+	}
101 101
 
102
-    /**
103
-     * @param Review $review
104
-     * @return array
105
-     */
106
-    protected function buildReview($review)
107
-    {
108
-        $schema = $this->getSchemaType('Review')
109
-            ->doIf(!in_array('title', $this->args['hide']), function ($schema) use ($review) {
110
-                $schema->name($review->title);
111
-            })
112
-            ->doIf(!in_array('excerpt', $this->args['hide']), function ($schema) use ($review) {
113
-                $schema->reviewBody($review->content);
114
-            })
115
-            ->datePublished((new DateTime($review->date)))
116
-            ->author($this->getSchemaType('Person')->name($review->author))
117
-            ->itemReviewed($this->getSchemaType()->name($this->getSchemaOptionValue('name')));
118
-        if (!empty($review->rating)) {
119
-            $schema->reviewRating(
120
-                $this->getSchemaType('Rating')
121
-                    ->ratingValue($review->rating)
122
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
123
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
124
-            );
125
-        }
126
-        return apply_filters('site-reviews/schema/review', $schema->toArray(), $review, $this->args);
127
-    }
102
+	/**
103
+	 * @param Review $review
104
+	 * @return array
105
+	 */
106
+	protected function buildReview($review)
107
+	{
108
+		$schema = $this->getSchemaType('Review')
109
+			->doIf(!in_array('title', $this->args['hide']), function ($schema) use ($review) {
110
+				$schema->name($review->title);
111
+			})
112
+			->doIf(!in_array('excerpt', $this->args['hide']), function ($schema) use ($review) {
113
+				$schema->reviewBody($review->content);
114
+			})
115
+			->datePublished((new DateTime($review->date)))
116
+			->author($this->getSchemaType('Person')->name($review->author))
117
+			->itemReviewed($this->getSchemaType()->name($this->getSchemaOptionValue('name')));
118
+		if (!empty($review->rating)) {
119
+			$schema->reviewRating(
120
+				$this->getSchemaType('Rating')
121
+					->ratingValue($review->rating)
122
+					->bestRating(glsr()->constant('MAX_RATING', Rating::class))
123
+					->worstRating(glsr()->constant('MIN_RATING', Rating::class))
124
+			);
125
+		}
126
+		return apply_filters('site-reviews/schema/review', $schema->toArray(), $review, $this->args);
127
+	}
128 128
 
129
-    /**
130
-     * @param mixed $schema
131
-     * @return mixed
132
-     */
133
-    protected function buildSchemaValues($schema, array $values = [])
134
-    {
135
-        foreach ($values as $value) {
136
-            $option = $this->getSchemaOptionValue($value);
137
-            if (empty($option)) {
138
-                continue;
139
-            }
140
-            $schema->$value($option);
141
-        }
142
-        return $schema;
143
-    }
129
+	/**
130
+	 * @param mixed $schema
131
+	 * @return mixed
132
+	 */
133
+	protected function buildSchemaValues($schema, array $values = [])
134
+	{
135
+		foreach ($values as $value) {
136
+			$option = $this->getSchemaOptionValue($value);
137
+			if (empty($option)) {
138
+				continue;
139
+			}
140
+			$schema->$value($option);
141
+		}
142
+		return $schema;
143
+	}
144 144
 
145
-    /**
146
-     * @return mixed
147
-     */
148
-    protected function buildSummaryForCustom()
149
-    {
150
-        return $this->buildSchemaValues($this->getSchemaType(), [
151
-            'description', 'image', 'name', 'url',
152
-        ]);
153
-    }
145
+	/**
146
+	 * @return mixed
147
+	 */
148
+	protected function buildSummaryForCustom()
149
+	{
150
+		return $this->buildSchemaValues($this->getSchemaType(), [
151
+			'description', 'image', 'name', 'url',
152
+		]);
153
+	}
154 154
 
155
-    /**
156
-     * @return mixed
157
-     */
158
-    protected function buildSummaryForLocalBusiness()
159
-    {
160
-        return $this->buildSchemaValues($this->buildSummaryForCustom(), [
161
-            'address', 'priceRange', 'telephone',
162
-        ]);
163
-    }
155
+	/**
156
+	 * @return mixed
157
+	 */
158
+	protected function buildSummaryForLocalBusiness()
159
+	{
160
+		return $this->buildSchemaValues($this->buildSummaryForCustom(), [
161
+			'address', 'priceRange', 'telephone',
162
+		]);
163
+	}
164 164
 
165
-    /**
166
-     * @return mixed
167
-     */
168
-    protected function buildSummaryForProduct()
169
-    {
170
-        $offerType = $this->getSchemaOption('offerType', 'AggregateOffer');
171
-        $offers = $this->buildSchemaValues($this->getSchemaType($offerType), [
172
-            'highPrice', 'lowPrice', 'price', 'priceCurrency',
173
-        ]);
174
-        return $this->buildSummaryForCustom()
175
-            ->doIf(!empty($offers->getProperties()), function ($schema) use ($offers) {
176
-                $schema->offers($offers);
177
-            })
178
-            ->setProperty('@id', $this->getSchemaOptionValue('url').'#product');
179
-    }
165
+	/**
166
+	 * @return mixed
167
+	 */
168
+	protected function buildSummaryForProduct()
169
+	{
170
+		$offerType = $this->getSchemaOption('offerType', 'AggregateOffer');
171
+		$offers = $this->buildSchemaValues($this->getSchemaType($offerType), [
172
+			'highPrice', 'lowPrice', 'price', 'priceCurrency',
173
+		]);
174
+		return $this->buildSummaryForCustom()
175
+			->doIf(!empty($offers->getProperties()), function ($schema) use ($offers) {
176
+				$schema->offers($offers);
177
+			})
178
+			->setProperty('@id', $this->getSchemaOptionValue('url').'#product');
179
+	}
180 180
 
181
-    /**
182
-     * @return array
183
-     */
184
-    protected function getRatingCounts()
185
-    {
186
-        if (!isset($this->ratingCounts)) {
187
-            $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($this->args);
188
-        }
189
-        return $this->ratingCounts;
190
-    }
181
+	/**
182
+	 * @return array
183
+	 */
184
+	protected function getRatingCounts()
185
+	{
186
+		if (!isset($this->ratingCounts)) {
187
+			$this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($this->args);
188
+		}
189
+		return $this->ratingCounts;
190
+	}
191 191
 
192
-    /**
193
-     * @return int|float
194
-     */
195
-    protected function getRatingValue()
196
-    {
197
-        return glsr(Rating::class)->getAverage($this->getRatingCounts());
198
-    }
192
+	/**
193
+	 * @return int|float
194
+	 */
195
+	protected function getRatingValue()
196
+	{
197
+		return glsr(Rating::class)->getAverage($this->getRatingCounts());
198
+	}
199 199
 
200
-    /**
201
-     * @param string $option
202
-     * @param string $fallback
203
-     * @return string
204
-     */
205
-    protected function getSchemaOption($option, $fallback)
206
-    {
207
-        $option = strtolower($option);
208
-        if ($schemaOption = trim((string) get_post_meta(intval(get_the_ID()), 'schema_'.$option, true))) {
209
-            return $schemaOption;
210
-        }
211
-        $setting = glsr(OptionManager::class)->get('settings.schema.'.$option);
212
-        if (is_array($setting)) {
213
-            return $this->getSchemaOptionDefault($setting, $fallback);
214
-        }
215
-        return !empty($setting)
216
-            ? $setting
217
-            : $fallback;
218
-    }
200
+	/**
201
+	 * @param string $option
202
+	 * @param string $fallback
203
+	 * @return string
204
+	 */
205
+	protected function getSchemaOption($option, $fallback)
206
+	{
207
+		$option = strtolower($option);
208
+		if ($schemaOption = trim((string) get_post_meta(intval(get_the_ID()), 'schema_'.$option, true))) {
209
+			return $schemaOption;
210
+		}
211
+		$setting = glsr(OptionManager::class)->get('settings.schema.'.$option);
212
+		if (is_array($setting)) {
213
+			return $this->getSchemaOptionDefault($setting, $fallback);
214
+		}
215
+		return !empty($setting)
216
+			? $setting
217
+			: $fallback;
218
+	}
219 219
 
220
-    /**
221
-     * @param string $fallback
222
-     * @return string
223
-     */
224
-    protected function getSchemaOptionDefault(array $setting, $fallback)
225
-    {
226
-        $setting = wp_parse_args($setting, [
227
-            'custom' => '',
228
-            'default' => $fallback,
229
-        ]);
230
-        return 'custom' != $setting['default']
231
-            ? $setting['default']
232
-            : $setting['custom'];
233
-    }
220
+	/**
221
+	 * @param string $fallback
222
+	 * @return string
223
+	 */
224
+	protected function getSchemaOptionDefault(array $setting, $fallback)
225
+	{
226
+		$setting = wp_parse_args($setting, [
227
+			'custom' => '',
228
+			'default' => $fallback,
229
+		]);
230
+		return 'custom' != $setting['default']
231
+			? $setting['default']
232
+			: $setting['custom'];
233
+	}
234 234
 
235
-    /**
236
-     * @param string $option
237
-     * @param string $fallback
238
-     * @return void|string
239
-     */
240
-    protected function getSchemaOptionValue($option, $fallback = 'post')
241
-    {
242
-        $value = $this->getSchemaOption($option, $fallback);
243
-        if ($value != $fallback) {
244
-            return $value;
245
-        }
246
-        if (!is_single() && !is_page()) {
247
-            return;
248
-        }
249
-        $method = glsr(Helper::class)->buildMethodName($option, 'getThing');
250
-        if (method_exists($this, $method)) {
251
-            return $this->$method();
252
-        }
253
-    }
235
+	/**
236
+	 * @param string $option
237
+	 * @param string $fallback
238
+	 * @return void|string
239
+	 */
240
+	protected function getSchemaOptionValue($option, $fallback = 'post')
241
+	{
242
+		$value = $this->getSchemaOption($option, $fallback);
243
+		if ($value != $fallback) {
244
+			return $value;
245
+		}
246
+		if (!is_single() && !is_page()) {
247
+			return;
248
+		}
249
+		$method = glsr(Helper::class)->buildMethodName($option, 'getThing');
250
+		if (method_exists($this, $method)) {
251
+			return $this->$method();
252
+		}
253
+	}
254 254
 
255
-    /**
256
-     * @param string|null $type
257
-     * @return mixed
258
-     */
259
-    protected function getSchemaType($type = null)
260
-    {
261
-        if (!is_string($type)) {
262
-            $type = $this->getSchemaOption('type', 'LocalBusiness');
263
-        }
264
-        $className = glsr(Helper::class)->buildClassName($type, 'Modules\Schema');
265
-        return class_exists($className)
266
-            ? new $className()
267
-            : new UnknownType($type);
268
-    }
255
+	/**
256
+	 * @param string|null $type
257
+	 * @return mixed
258
+	 */
259
+	protected function getSchemaType($type = null)
260
+	{
261
+		if (!is_string($type)) {
262
+			$type = $this->getSchemaOption('type', 'LocalBusiness');
263
+		}
264
+		$className = glsr(Helper::class)->buildClassName($type, 'Modules\Schema');
265
+		return class_exists($className)
266
+			? new $className()
267
+			: new UnknownType($type);
268
+	}
269 269
 
270
-    /**
271
-     * @return string
272
-     */
273
-    protected function getThingDescription()
274
-    {
275
-        $description = strip_shortcodes(wp_strip_all_tags(get_the_excerpt()));
276
-        return wp_trim_words($description, apply_filters('excerpt_length', 55));
277
-    }
270
+	/**
271
+	 * @return string
272
+	 */
273
+	protected function getThingDescription()
274
+	{
275
+		$description = strip_shortcodes(wp_strip_all_tags(get_the_excerpt()));
276
+		return wp_trim_words($description, apply_filters('excerpt_length', 55));
277
+	}
278 278
 
279
-    /**
280
-     * @return string
281
-     */
282
-    protected function getThingImage()
283
-    {
284
-        return (string) get_the_post_thumbnail_url(null, 'large');
285
-    }
279
+	/**
280
+	 * @return string
281
+	 */
282
+	protected function getThingImage()
283
+	{
284
+		return (string) get_the_post_thumbnail_url(null, 'large');
285
+	}
286 286
 
287
-    /**
288
-     * @return string
289
-     */
290
-    protected function getThingName()
291
-    {
292
-        return get_the_title();
293
-    }
287
+	/**
288
+	 * @return string
289
+	 */
290
+	protected function getThingName()
291
+	{
292
+		return get_the_title();
293
+	}
294 294
 
295
-    /**
296
-     * @return string
297
-     */
298
-    protected function getThingUrl()
299
-    {
300
-        return (string) get_the_permalink();
301
-    }
295
+	/**
296
+	 * @return string
297
+	 */
298
+	protected function getThingUrl()
299
+	{
300
+		return (string) get_the_permalink();
301
+	}
302 302
 }
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -25,21 +25,21 @@  discard block
 block discarded – undo
25 25
     /**
26 26
      * @return array
27 27
      */
28
-    public function build(array $args = [])
28
+    public function build( array $args = [] )
29 29
     {
30 30
         $this->args = $args;
31
-        $schema = $this->buildSummary($args);
31
+        $schema = $this->buildSummary( $args );
32 32
         $reviews = [];
33
-        foreach (glsr(ReviewManager::class)->get($this->args) as $review) {
33
+        foreach( glsr( ReviewManager::class )->get( $this->args ) as $review ) {
34 34
             // Only include critic reviews that have been directly produced by your site, not reviews from third-party sites or syndicated reviews.
35 35
             // @see https://developers.google.com/search/docs/data-types/review
36
-            if ('local' != $review->review_type) {
36
+            if( 'local' != $review->review_type ) {
37 37
                 continue;
38 38
             }
39
-            $reviews[] = $this->buildReview($review);
39
+            $reviews[] = $this->buildReview( $review );
40 40
         }
41
-        if (!empty($reviews)) {
42
-            array_walk($reviews, function (&$review) {
41
+        if( !empty($reviews) ) {
42
+            array_walk( $reviews, function( &$review ) {
43 43
                 unset($review['@context']);
44 44
                 unset($review['itemReviewed']);
45 45
             });
@@ -52,27 +52,27 @@  discard block
 block discarded – undo
52 52
      * @param array|null $args
53 53
      * @return array
54 54
      */
55
-    public function buildSummary($args = null)
55
+    public function buildSummary( $args = null )
56 56
     {
57
-        if (is_array($args)) {
57
+        if( is_array( $args ) ) {
58 58
             $this->args = $args;
59 59
         }
60
-        $buildSummary = glsr(Helper::class)->buildMethodName($this->getSchemaOptionValue('type'), 'buildSummaryFor');
61
-        $count = array_sum($this->getRatingCounts());
62
-        $schema = method_exists($this, $buildSummary)
60
+        $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' );
61
+        $count = array_sum( $this->getRatingCounts() );
62
+        $schema = method_exists( $this, $buildSummary )
63 63
             ? $this->$buildSummary()
64 64
             : $this->buildSummaryForCustom();
65
-        if (!empty($count)) {
65
+        if( !empty($count) ) {
66 66
             $schema->aggregateRating(
67
-                $this->getSchemaType('AggregateRating')
68
-                    ->ratingValue($this->getRatingValue())
69
-                    ->reviewCount($count)
70
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
71
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
67
+                $this->getSchemaType( 'AggregateRating' )
68
+                    ->ratingValue( $this->getRatingValue() )
69
+                    ->reviewCount( $count )
70
+                    ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) )
71
+                    ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) )
72 72
             );
73 73
         }
74 74
         $schema = $schema->toArray();
75
-        return apply_filters('site-reviews/schema/'.$schema['@type'], $schema, $args);
75
+        return apply_filters( 'site-reviews/schema/'.$schema['@type'], $schema, $args );
76 76
     }
77 77
 
78 78
     /**
@@ -80,64 +80,64 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function render()
82 82
     {
83
-        if (empty(glsr()->schemas)) {
83
+        if( empty(glsr()->schemas) ) {
84 84
             return;
85 85
         }
86
-        printf('<script type="application/ld+json">%s</script>', json_encode(
87
-            apply_filters('site-reviews/schema/all', glsr()->schemas),
86
+        printf( '<script type="application/ld+json">%s</script>', json_encode(
87
+            apply_filters( 'site-reviews/schema/all', glsr()->schemas ),
88 88
             JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
89
-        ));
89
+        ) );
90 90
     }
91 91
 
92 92
     /**
93 93
      * @return void
94 94
      */
95
-    public function store(array $schema)
95
+    public function store( array $schema )
96 96
     {
97 97
         $schemas = glsr()->schemas;
98 98
         $schemas[] = $schema;
99
-        glsr()->schemas = array_map('unserialize', array_unique(array_map('serialize', $schemas)));
99
+        glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) );
100 100
     }
101 101
 
102 102
     /**
103 103
      * @param Review $review
104 104
      * @return array
105 105
      */
106
-    protected function buildReview($review)
106
+    protected function buildReview( $review )
107 107
     {
108
-        $schema = $this->getSchemaType('Review')
109
-            ->doIf(!in_array('title', $this->args['hide']), function ($schema) use ($review) {
110
-                $schema->name($review->title);
108
+        $schema = $this->getSchemaType( 'Review' )
109
+            ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use ($review) {
110
+                $schema->name( $review->title );
111 111
             })
112
-            ->doIf(!in_array('excerpt', $this->args['hide']), function ($schema) use ($review) {
113
-                $schema->reviewBody($review->content);
112
+            ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use ($review) {
113
+                $schema->reviewBody( $review->content );
114 114
             })
115
-            ->datePublished((new DateTime($review->date)))
116
-            ->author($this->getSchemaType('Person')->name($review->author))
117
-            ->itemReviewed($this->getSchemaType()->name($this->getSchemaOptionValue('name')));
118
-        if (!empty($review->rating)) {
115
+            ->datePublished( (new DateTime( $review->date )) )
116
+            ->author( $this->getSchemaType( 'Person' )->name( $review->author ) )
117
+            ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) );
118
+        if( !empty($review->rating) ) {
119 119
             $schema->reviewRating(
120
-                $this->getSchemaType('Rating')
121
-                    ->ratingValue($review->rating)
122
-                    ->bestRating(glsr()->constant('MAX_RATING', Rating::class))
123
-                    ->worstRating(glsr()->constant('MIN_RATING', Rating::class))
120
+                $this->getSchemaType( 'Rating' )
121
+                    ->ratingValue( $review->rating )
122
+                    ->bestRating( glsr()->constant( 'MAX_RATING', Rating::class ) )
123
+                    ->worstRating( glsr()->constant( 'MIN_RATING', Rating::class ) )
124 124
             );
125 125
         }
126
-        return apply_filters('site-reviews/schema/review', $schema->toArray(), $review, $this->args);
126
+        return apply_filters( 'site-reviews/schema/review', $schema->toArray(), $review, $this->args );
127 127
     }
128 128
 
129 129
     /**
130 130
      * @param mixed $schema
131 131
      * @return mixed
132 132
      */
133
-    protected function buildSchemaValues($schema, array $values = [])
133
+    protected function buildSchemaValues( $schema, array $values = [] )
134 134
     {
135
-        foreach ($values as $value) {
136
-            $option = $this->getSchemaOptionValue($value);
137
-            if (empty($option)) {
135
+        foreach( $values as $value ) {
136
+            $option = $this->getSchemaOptionValue( $value );
137
+            if( empty($option) ) {
138 138
                 continue;
139 139
             }
140
-            $schema->$value($option);
140
+            $schema->$value( $option );
141 141
         }
142 142
         return $schema;
143 143
     }
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
      */
148 148
     protected function buildSummaryForCustom()
149 149
     {
150
-        return $this->buildSchemaValues($this->getSchemaType(), [
150
+        return $this->buildSchemaValues( $this->getSchemaType(), [
151 151
             'description', 'image', 'name', 'url',
152
-        ]);
152
+        ] );
153 153
     }
154 154
 
155 155
     /**
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
      */
158 158
     protected function buildSummaryForLocalBusiness()
159 159
     {
160
-        return $this->buildSchemaValues($this->buildSummaryForCustom(), [
160
+        return $this->buildSchemaValues( $this->buildSummaryForCustom(), [
161 161
             'address', 'priceRange', 'telephone',
162
-        ]);
162
+        ] );
163 163
     }
164 164
 
165 165
     /**
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
      */
168 168
     protected function buildSummaryForProduct()
169 169
     {
170
-        $offerType = $this->getSchemaOption('offerType', 'AggregateOffer');
171
-        $offers = $this->buildSchemaValues($this->getSchemaType($offerType), [
170
+        $offerType = $this->getSchemaOption( 'offerType', 'AggregateOffer' );
171
+        $offers = $this->buildSchemaValues( $this->getSchemaType( $offerType ), [
172 172
             'highPrice', 'lowPrice', 'price', 'priceCurrency',
173
-        ]);
173
+        ] );
174 174
         return $this->buildSummaryForCustom()
175
-            ->doIf(!empty($offers->getProperties()), function ($schema) use ($offers) {
176
-                $schema->offers($offers);
175
+            ->doIf( !empty($offers->getProperties()), function( $schema ) use ($offers) {
176
+                $schema->offers( $offers );
177 177
             })
178
-            ->setProperty('@id', $this->getSchemaOptionValue('url').'#product');
178
+            ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' );
179 179
     }
180 180
 
181 181
     /**
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
      */
184 184
     protected function getRatingCounts()
185 185
     {
186
-        if (!isset($this->ratingCounts)) {
187
-            $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($this->args);
186
+        if( !isset($this->ratingCounts) ) {
187
+            $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args );
188 188
         }
189 189
         return $this->ratingCounts;
190 190
     }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     protected function getRatingValue()
196 196
     {
197
-        return glsr(Rating::class)->getAverage($this->getRatingCounts());
197
+        return glsr( Rating::class )->getAverage( $this->getRatingCounts() );
198 198
     }
199 199
 
200 200
     /**
@@ -202,15 +202,15 @@  discard block
 block discarded – undo
202 202
      * @param string $fallback
203 203
      * @return string
204 204
      */
205
-    protected function getSchemaOption($option, $fallback)
205
+    protected function getSchemaOption( $option, $fallback )
206 206
     {
207
-        $option = strtolower($option);
208
-        if ($schemaOption = trim((string) get_post_meta(intval(get_the_ID()), 'schema_'.$option, true))) {
207
+        $option = strtolower( $option );
208
+        if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) {
209 209
             return $schemaOption;
210 210
         }
211
-        $setting = glsr(OptionManager::class)->get('settings.schema.'.$option);
212
-        if (is_array($setting)) {
213
-            return $this->getSchemaOptionDefault($setting, $fallback);
211
+        $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option );
212
+        if( is_array( $setting ) ) {
213
+            return $this->getSchemaOptionDefault( $setting, $fallback );
214 214
         }
215 215
         return !empty($setting)
216 216
             ? $setting
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
      * @param string $fallback
222 222
      * @return string
223 223
      */
224
-    protected function getSchemaOptionDefault(array $setting, $fallback)
224
+    protected function getSchemaOptionDefault( array $setting, $fallback )
225 225
     {
226
-        $setting = wp_parse_args($setting, [
226
+        $setting = wp_parse_args( $setting, [
227 227
             'custom' => '',
228 228
             'default' => $fallback,
229
-        ]);
229
+        ] );
230 230
         return 'custom' != $setting['default']
231 231
             ? $setting['default']
232 232
             : $setting['custom'];
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
      * @param string $fallback
238 238
      * @return void|string
239 239
      */
240
-    protected function getSchemaOptionValue($option, $fallback = 'post')
240
+    protected function getSchemaOptionValue( $option, $fallback = 'post' )
241 241
     {
242
-        $value = $this->getSchemaOption($option, $fallback);
243
-        if ($value != $fallback) {
242
+        $value = $this->getSchemaOption( $option, $fallback );
243
+        if( $value != $fallback ) {
244 244
             return $value;
245 245
         }
246
-        if (!is_single() && !is_page()) {
246
+        if( !is_single() && !is_page() ) {
247 247
             return;
248 248
         }
249
-        $method = glsr(Helper::class)->buildMethodName($option, 'getThing');
250
-        if (method_exists($this, $method)) {
249
+        $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' );
250
+        if( method_exists( $this, $method ) ) {
251 251
             return $this->$method();
252 252
         }
253 253
     }
@@ -256,15 +256,15 @@  discard block
 block discarded – undo
256 256
      * @param string|null $type
257 257
      * @return mixed
258 258
      */
259
-    protected function getSchemaType($type = null)
259
+    protected function getSchemaType( $type = null )
260 260
     {
261
-        if (!is_string($type)) {
262
-            $type = $this->getSchemaOption('type', 'LocalBusiness');
261
+        if( !is_string( $type ) ) {
262
+            $type = $this->getSchemaOption( 'type', 'LocalBusiness' );
263 263
         }
264
-        $className = glsr(Helper::class)->buildClassName($type, 'Modules\Schema');
265
-        return class_exists($className)
264
+        $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' );
265
+        return class_exists( $className )
266 266
             ? new $className()
267
-            : new UnknownType($type);
267
+            : new UnknownType( $type );
268 268
     }
269 269
 
270 270
     /**
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
      */
273 273
     protected function getThingDescription()
274 274
     {
275
-        $description = strip_shortcodes(wp_strip_all_tags(get_the_excerpt()));
276
-        return wp_trim_words($description, apply_filters('excerpt_length', 55));
275
+        $description = strip_shortcodes( wp_strip_all_tags( get_the_excerpt() ) );
276
+        return wp_trim_words( $description, apply_filters( 'excerpt_length', 55 ) );
277 277
     }
278 278
 
279 279
     /**
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      */
282 282
     protected function getThingImage()
283 283
     {
284
-        return (string) get_the_post_thumbnail_url(null, 'large');
284
+        return (string)get_the_post_thumbnail_url( null, 'large' );
285 285
     }
286 286
 
287 287
     /**
@@ -297,6 +297,6 @@  discard block
 block discarded – undo
297 297
      */
298 298
     protected function getThingUrl()
299 299
     {
300
-        return (string) get_the_permalink();
300
+        return (string)get_the_permalink();
301 301
     }
302 302
 }
Please login to merge, or discard this patch.
plugin/HelperTraits/Arr.php 3 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -221,7 +221,8 @@
 block discarded – undo
221 221
                 if ($flattenValue) {
222 222
                     $value = '['.implode(', ', $value).']';
223 223
                 }
224
-            } elseif (is_array($value)) {
224
+            }
225
+            elseif (is_array($value)) {
225 226
                 $result = array_merge($result, $this->flattenArray($value, $flattenValue, $newKey));
226 227
                 continue;
227 228
             }
Please login to merge, or discard this patch.
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -4,188 +4,188 @@
 block discarded – undo
4 4
 
5 5
 trait Arr
6 6
 {
7
-    /**
8
-     * @return bool
9
-     */
10
-    public function compareArrays(array $arr1, array $arr2)
11
-    {
12
-        sort($arr1);
13
-        sort($arr2);
14
-        return $arr1 == $arr2;
15
-    }
7
+	/**
8
+	 * @return bool
9
+	 */
10
+	public function compareArrays(array $arr1, array $arr2)
11
+	{
12
+		sort($arr1);
13
+		sort($arr2);
14
+		return $arr1 == $arr2;
15
+	}
16 16
 
17
-    /**
18
-     * @param mixed $array
19
-     * @return array
20
-     */
21
-    public function consolidateArray($array)
22
-    {
23
-        return is_array($array) || is_object($array)
24
-            ? (array) $array
25
-            : [];
26
-    }
17
+	/**
18
+	 * @param mixed $array
19
+	 * @return array
20
+	 */
21
+	public function consolidateArray($array)
22
+	{
23
+		return is_array($array) || is_object($array)
24
+			? (array) $array
25
+			: [];
26
+	}
27 27
 
28
-    /**
29
-     * @return array
30
-     */
31
-    public function convertDotNotationArray(array $array)
32
-    {
33
-        $results = [];
34
-        foreach ($array as $path => $value) {
35
-            $results = $this->dataSet($results, $path, $value);
36
-        }
37
-        return $results;
38
-    }
28
+	/**
29
+	 * @return array
30
+	 */
31
+	public function convertDotNotationArray(array $array)
32
+	{
33
+		$results = [];
34
+		foreach ($array as $path => $value) {
35
+			$results = $this->dataSet($results, $path, $value);
36
+		}
37
+		return $results;
38
+	}
39 39
 
40
-    /**
41
-     * @param string $string
42
-     * @param mixed $callback
43
-     * @return array
44
-     */
45
-    public function convertStringToArray($string, $callback = null)
46
-    {
47
-        $array = array_map('trim', explode(',', $string));
48
-        return $callback
49
-            ? array_filter($array, $callback)
50
-            : array_filter($array);
51
-    }
40
+	/**
41
+	 * @param string $string
42
+	 * @param mixed $callback
43
+	 * @return array
44
+	 */
45
+	public function convertStringToArray($string, $callback = null)
46
+	{
47
+		$array = array_map('trim', explode(',', $string));
48
+		return $callback
49
+			? array_filter($array, $callback)
50
+			: array_filter($array);
51
+	}
52 52
 
53
-    /**
54
-     * Get a value from an array of values using a dot-notation path as reference.
55
-     * @param array $data
56
-     * @param string $path
57
-     * @param mixed $fallback
58
-     * @return mixed
59
-     */
60
-    public function dataGet($data, $path = '', $fallback = '')
61
-    {
62
-        $data = $this->consolidateArray($data);
63
-        $keys = explode('.', $path);
64
-        foreach ($keys as $key) {
65
-            if (!isset($data[$key])) {
66
-                return $fallback;
67
-            }
68
-            $data = $data[$key];
69
-        }
70
-        return $data;
71
-    }
53
+	/**
54
+	 * Get a value from an array of values using a dot-notation path as reference.
55
+	 * @param array $data
56
+	 * @param string $path
57
+	 * @param mixed $fallback
58
+	 * @return mixed
59
+	 */
60
+	public function dataGet($data, $path = '', $fallback = '')
61
+	{
62
+		$data = $this->consolidateArray($data);
63
+		$keys = explode('.', $path);
64
+		foreach ($keys as $key) {
65
+			if (!isset($data[$key])) {
66
+				return $fallback;
67
+			}
68
+			$data = $data[$key];
69
+		}
70
+		return $data;
71
+	}
72 72
 
73
-    /**
74
-     * Set a value to an array of values using a dot-notation path as reference.
75
-     * @param string $path
76
-     * @param mixed $value
77
-     * @return array
78
-     */
79
-    public function dataSet(array $data, $path, $value)
80
-    {
81
-        $token = strtok($path, '.');
82
-        $ref = &$data;
83
-        while (false !== $token) {
84
-            $ref = $this->consolidateArray($ref);
85
-            $ref = &$ref[$token];
86
-            $token = strtok('.');
87
-        }
88
-        $ref = $value;
89
-        return $data;
90
-    }
73
+	/**
74
+	 * Set a value to an array of values using a dot-notation path as reference.
75
+	 * @param string $path
76
+	 * @param mixed $value
77
+	 * @return array
78
+	 */
79
+	public function dataSet(array $data, $path, $value)
80
+	{
81
+		$token = strtok($path, '.');
82
+		$ref = &$data;
83
+		while (false !== $token) {
84
+			$ref = $this->consolidateArray($ref);
85
+			$ref = &$ref[$token];
86
+			$token = strtok('.');
87
+		}
88
+		$ref = $value;
89
+		return $data;
90
+	}
91 91
 
92
-    /**
93
-     * @param bool $flattenValue
94
-     * @param string $prefix
95
-     * @return array
96
-     */
97
-    public function flattenArray(array $array, $flattenValue = false, $prefix = '')
98
-    {
99
-        $result = [];
100
-        foreach ($array as $key => $value) {
101
-            $newKey = ltrim($prefix.'.'.$key, '.');
102
-            if ($this->isIndexedFlatArray($value)) {
103
-                if ($flattenValue) {
104
-                    $value = '['.implode(', ', $value).']';
105
-                }
106
-            } elseif (is_array($value)) {
107
-                $result = array_merge($result, $this->flattenArray($value, $flattenValue, $newKey));
108
-                continue;
109
-            }
110
-            $result[$newKey] = $value;
111
-        }
112
-        return $result;
113
-    }
92
+	/**
93
+	 * @param bool $flattenValue
94
+	 * @param string $prefix
95
+	 * @return array
96
+	 */
97
+	public function flattenArray(array $array, $flattenValue = false, $prefix = '')
98
+	{
99
+		$result = [];
100
+		foreach ($array as $key => $value) {
101
+			$newKey = ltrim($prefix.'.'.$key, '.');
102
+			if ($this->isIndexedFlatArray($value)) {
103
+				if ($flattenValue) {
104
+					$value = '['.implode(', ', $value).']';
105
+				}
106
+			} elseif (is_array($value)) {
107
+				$result = array_merge($result, $this->flattenArray($value, $flattenValue, $newKey));
108
+				continue;
109
+			}
110
+			$result[$newKey] = $value;
111
+		}
112
+		return $result;
113
+	}
114 114
 
115
-    /**
116
-     * @param string $key
117
-     * @param string $position
118
-     * @return array
119
-     */
120
-    public function insertInArray(array $array, array $insert, $key, $position = 'before')
121
-    {
122
-        $keyPosition = intval(array_search($key, array_keys($array)));
123
-        if ('after' == $position) {
124
-            ++$keyPosition;
125
-        }
126
-        if (false !== $keyPosition) {
127
-            $result = array_slice($array, 0, $keyPosition);
128
-            $result = array_merge($result, $insert);
129
-            return array_merge($result, array_slice($array, $keyPosition));
130
-        }
131
-        return array_merge($array, $insert);
132
-    }
115
+	/**
116
+	 * @param string $key
117
+	 * @param string $position
118
+	 * @return array
119
+	 */
120
+	public function insertInArray(array $array, array $insert, $key, $position = 'before')
121
+	{
122
+		$keyPosition = intval(array_search($key, array_keys($array)));
123
+		if ('after' == $position) {
124
+			++$keyPosition;
125
+		}
126
+		if (false !== $keyPosition) {
127
+			$result = array_slice($array, 0, $keyPosition);
128
+			$result = array_merge($result, $insert);
129
+			return array_merge($result, array_slice($array, $keyPosition));
130
+		}
131
+		return array_merge($array, $insert);
132
+	}
133 133
 
134
-    /**
135
-     * @param mixed $array
136
-     * @return bool
137
-     */
138
-    public function isIndexedFlatArray($array)
139
-    {
140
-        if (!is_array($array) || array_filter($array, 'is_array')) {
141
-            return false;
142
-        }
143
-        return wp_is_numeric_array($array);
144
-    }
134
+	/**
135
+	 * @param mixed $array
136
+	 * @return bool
137
+	 */
138
+	public function isIndexedFlatArray($array)
139
+	{
140
+		if (!is_array($array) || array_filter($array, 'is_array')) {
141
+			return false;
142
+		}
143
+		return wp_is_numeric_array($array);
144
+	}
145 145
 
146
-    /**
147
-     * @param bool $prefixed
148
-     * @return array
149
-     */
150
-    public function prefixArrayKeys(array $values, $prefixed = true)
151
-    {
152
-        $trim = '_';
153
-        $prefix = $prefixed
154
-            ? $trim
155
-            : '';
156
-        $prefixed = [];
157
-        foreach ($values as $key => $value) {
158
-            $key = trim($key);
159
-            if (0 === strpos($key, $trim)) {
160
-                $key = substr($key, strlen($trim));
161
-            }
162
-            $prefixed[$prefix.$key] = $value;
163
-        }
164
-        return $prefixed;
165
-    }
146
+	/**
147
+	 * @param bool $prefixed
148
+	 * @return array
149
+	 */
150
+	public function prefixArrayKeys(array $values, $prefixed = true)
151
+	{
152
+		$trim = '_';
153
+		$prefix = $prefixed
154
+			? $trim
155
+			: '';
156
+		$prefixed = [];
157
+		foreach ($values as $key => $value) {
158
+			$key = trim($key);
159
+			if (0 === strpos($key, $trim)) {
160
+				$key = substr($key, strlen($trim));
161
+			}
162
+			$prefixed[$prefix.$key] = $value;
163
+		}
164
+		return $prefixed;
165
+	}
166 166
 
167
-    /**
168
-     * @return array
169
-     */
170
-    public function removeEmptyArrayValues(array $array)
171
-    {
172
-        $result = [];
173
-        foreach ($array as $key => $value) {
174
-            if (!$value) {
175
-                continue;
176
-            }
177
-            $result[$key] = is_array($value)
178
-                ? $this->removeEmptyArrayValues($value)
179
-                : $value;
180
-        }
181
-        return $result;
182
-    }
167
+	/**
168
+	 * @return array
169
+	 */
170
+	public function removeEmptyArrayValues(array $array)
171
+	{
172
+		$result = [];
173
+		foreach ($array as $key => $value) {
174
+			if (!$value) {
175
+				continue;
176
+			}
177
+			$result[$key] = is_array($value)
178
+				? $this->removeEmptyArrayValues($value)
179
+				: $value;
180
+		}
181
+		return $result;
182
+	}
183 183
 
184
-    /**
185
-     * @return array
186
-     */
187
-    public function unprefixArrayKeys(array $values)
188
-    {
189
-        return $this->prefixArrayKeys($values, false);
190
-    }
184
+	/**
185
+	 * @return array
186
+	 */
187
+	public function unprefixArrayKeys(array $values)
188
+	{
189
+		return $this->prefixArrayKeys($values, false);
190
+	}
191 191
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
     /**
8 8
      * @return bool
9 9
      */
10
-    public function compareArrays(array $arr1, array $arr2)
10
+    public function compareArrays( array $arr1, array $arr2 )
11 11
     {
12
-        sort($arr1);
13
-        sort($arr2);
12
+        sort( $arr1 );
13
+        sort( $arr2 );
14 14
         return $arr1 == $arr2;
15 15
     }
16 16
 
@@ -18,21 +18,21 @@  discard block
 block discarded – undo
18 18
      * @param mixed $array
19 19
      * @return array
20 20
      */
21
-    public function consolidateArray($array)
21
+    public function consolidateArray( $array )
22 22
     {
23
-        return is_array($array) || is_object($array)
24
-            ? (array) $array
23
+        return is_array( $array ) || is_object( $array )
24
+            ? (array)$array
25 25
             : [];
26 26
     }
27 27
 
28 28
     /**
29 29
      * @return array
30 30
      */
31
-    public function convertDotNotationArray(array $array)
31
+    public function convertDotNotationArray( array $array )
32 32
     {
33 33
         $results = [];
34
-        foreach ($array as $path => $value) {
35
-            $results = $this->dataSet($results, $path, $value);
34
+        foreach( $array as $path => $value ) {
35
+            $results = $this->dataSet( $results, $path, $value );
36 36
         }
37 37
         return $results;
38 38
     }
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
      * @param mixed $callback
43 43
      * @return array
44 44
      */
45
-    public function convertStringToArray($string, $callback = null)
45
+    public function convertStringToArray( $string, $callback = null )
46 46
     {
47
-        $array = array_map('trim', explode(',', $string));
47
+        $array = array_map( 'trim', explode( ',', $string ) );
48 48
         return $callback
49
-            ? array_filter($array, $callback)
50
-            : array_filter($array);
49
+            ? array_filter( $array, $callback )
50
+            : array_filter( $array );
51 51
     }
52 52
 
53 53
     /**
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
      * @param mixed $fallback
58 58
      * @return mixed
59 59
      */
60
-    public function dataGet($data, $path = '', $fallback = '')
60
+    public function dataGet( $data, $path = '', $fallback = '' )
61 61
     {
62
-        $data = $this->consolidateArray($data);
63
-        $keys = explode('.', $path);
64
-        foreach ($keys as $key) {
65
-            if (!isset($data[$key])) {
62
+        $data = $this->consolidateArray( $data );
63
+        $keys = explode( '.', $path );
64
+        foreach( $keys as $key ) {
65
+            if( !isset($data[$key]) ) {
66 66
                 return $fallback;
67 67
             }
68 68
             $data = $data[$key];
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
      * @param mixed $value
77 77
      * @return array
78 78
      */
79
-    public function dataSet(array $data, $path, $value)
79
+    public function dataSet( array $data, $path, $value )
80 80
     {
81
-        $token = strtok($path, '.');
81
+        $token = strtok( $path, '.' );
82 82
         $ref = &$data;
83
-        while (false !== $token) {
84
-            $ref = $this->consolidateArray($ref);
83
+        while( false !== $token ) {
84
+            $ref = $this->consolidateArray( $ref );
85 85
             $ref = &$ref[$token];
86
-            $token = strtok('.');
86
+            $token = strtok( '.' );
87 87
         }
88 88
         $ref = $value;
89 89
         return $data;
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
      * @param string $prefix
95 95
      * @return array
96 96
      */
97
-    public function flattenArray(array $array, $flattenValue = false, $prefix = '')
97
+    public function flattenArray( array $array, $flattenValue = false, $prefix = '' )
98 98
     {
99 99
         $result = [];
100
-        foreach ($array as $key => $value) {
101
-            $newKey = ltrim($prefix.'.'.$key, '.');
102
-            if ($this->isIndexedFlatArray($value)) {
103
-                if ($flattenValue) {
104
-                    $value = '['.implode(', ', $value).']';
100
+        foreach( $array as $key => $value ) {
101
+            $newKey = ltrim( $prefix.'.'.$key, '.' );
102
+            if( $this->isIndexedFlatArray( $value ) ) {
103
+                if( $flattenValue ) {
104
+                    $value = '['.implode( ', ', $value ).']';
105 105
                 }
106
-            } elseif (is_array($value)) {
107
-                $result = array_merge($result, $this->flattenArray($value, $flattenValue, $newKey));
106
+            } elseif( is_array( $value ) ) {
107
+                $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) );
108 108
                 continue;
109 109
             }
110 110
             $result[$newKey] = $value;
@@ -117,47 +117,47 @@  discard block
 block discarded – undo
117 117
      * @param string $position
118 118
      * @return array
119 119
      */
120
-    public function insertInArray(array $array, array $insert, $key, $position = 'before')
120
+    public function insertInArray( array $array, array $insert, $key, $position = 'before' )
121 121
     {
122
-        $keyPosition = intval(array_search($key, array_keys($array)));
123
-        if ('after' == $position) {
122
+        $keyPosition = intval( array_search( $key, array_keys( $array ) ) );
123
+        if( 'after' == $position ) {
124 124
             ++$keyPosition;
125 125
         }
126
-        if (false !== $keyPosition) {
127
-            $result = array_slice($array, 0, $keyPosition);
128
-            $result = array_merge($result, $insert);
129
-            return array_merge($result, array_slice($array, $keyPosition));
126
+        if( false !== $keyPosition ) {
127
+            $result = array_slice( $array, 0, $keyPosition );
128
+            $result = array_merge( $result, $insert );
129
+            return array_merge( $result, array_slice( $array, $keyPosition ) );
130 130
         }
131
-        return array_merge($array, $insert);
131
+        return array_merge( $array, $insert );
132 132
     }
133 133
 
134 134
     /**
135 135
      * @param mixed $array
136 136
      * @return bool
137 137
      */
138
-    public function isIndexedFlatArray($array)
138
+    public function isIndexedFlatArray( $array )
139 139
     {
140
-        if (!is_array($array) || array_filter($array, 'is_array')) {
140
+        if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) {
141 141
             return false;
142 142
         }
143
-        return wp_is_numeric_array($array);
143
+        return wp_is_numeric_array( $array );
144 144
     }
145 145
 
146 146
     /**
147 147
      * @param bool $prefixed
148 148
      * @return array
149 149
      */
150
-    public function prefixArrayKeys(array $values, $prefixed = true)
150
+    public function prefixArrayKeys( array $values, $prefixed = true )
151 151
     {
152 152
         $trim = '_';
153 153
         $prefix = $prefixed
154 154
             ? $trim
155 155
             : '';
156 156
         $prefixed = [];
157
-        foreach ($values as $key => $value) {
158
-            $key = trim($key);
159
-            if (0 === strpos($key, $trim)) {
160
-                $key = substr($key, strlen($trim));
157
+        foreach( $values as $key => $value ) {
158
+            $key = trim( $key );
159
+            if( 0 === strpos( $key, $trim ) ) {
160
+                $key = substr( $key, strlen( $trim ) );
161 161
             }
162 162
             $prefixed[$prefix.$key] = $value;
163 163
         }
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
     /**
168 168
      * @return array
169 169
      */
170
-    public function removeEmptyArrayValues(array $array)
170
+    public function removeEmptyArrayValues( array $array )
171 171
     {
172 172
         $result = [];
173
-        foreach ($array as $key => $value) {
174
-            if (!$value) {
173
+        foreach( $array as $key => $value ) {
174
+            if( !$value ) {
175 175
                 continue;
176 176
             }
177
-            $result[$key] = is_array($value)
178
-                ? $this->removeEmptyArrayValues($value)
177
+            $result[$key] = is_array( $value )
178
+                ? $this->removeEmptyArrayValues( $value )
179 179
                 : $value;
180 180
         }
181 181
         return $result;
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
     /**
185 185
      * @return array
186 186
      */
187
-    public function unprefixArrayKeys(array $values)
187
+    public function unprefixArrayKeys( array $values )
188 188
     {
189
-        return $this->prefixArrayKeys($values, false);
189
+        return $this->prefixArrayKeys( $values, false );
190 190
     }
191 191
 }
Please login to merge, or discard this patch.