Passed
Push — master ( ff717e...ba0f3b )
by Paul
08:41 queued 04:33
created
plugin/Controllers/PublicController.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -13,93 +13,93 @@
 block discarded – undo
13 13
 
14 14
 class PublicController extends Controller
15 15
 {
16
-    /**
17
-     * @return void
18
-     * @action wp_enqueue_scripts
19
-     */
20
-    public function enqueueAssets()
21
-    {
22
-        (new EnqueuePublicAssets())->handle();
23
-    }
16
+	/**
17
+	 * @return void
18
+	 * @action wp_enqueue_scripts
19
+	 */
20
+	public function enqueueAssets()
21
+	{
22
+		(new EnqueuePublicAssets())->handle();
23
+	}
24 24
 
25
-    /**
26
-     * @param string $tag
27
-     * @param string $handle
28
-     * @return string
29
-     * @filter script_loader_tag
30
-     */
31
-    public function filterEnqueuedScripts($tag, $handle)
32
-    {
33
-        $scripts = [Application::ID.'/google-recaptcha'];
34
-        if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) {
35
-            $tag = str_replace(' src=', ' async src=', $tag);
36
-        }
37
-        if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) {
38
-            $tag = str_replace(' src=', ' defer src=', $tag);
39
-        }
40
-        return $tag;
41
-    }
25
+	/**
26
+	 * @param string $tag
27
+	 * @param string $handle
28
+	 * @return string
29
+	 * @filter script_loader_tag
30
+	 */
31
+	public function filterEnqueuedScripts($tag, $handle)
32
+	{
33
+		$scripts = [Application::ID.'/google-recaptcha'];
34
+		if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) {
35
+			$tag = str_replace(' src=', ' async src=', $tag);
36
+		}
37
+		if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) {
38
+			$tag = str_replace(' src=', ' defer src=', $tag);
39
+		}
40
+		return $tag;
41
+	}
42 42
 
43
-    /**
44
-     * @return array
45
-     * @filter site-reviews/config/forms/submission-form
46
-     */
47
-    public function filterFieldOrder(array $config)
48
-    {
49
-        $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config));
50
-        return array_intersect_key(array_merge(array_flip($order), $config), $config);
51
-    }
43
+	/**
44
+	 * @return array
45
+	 * @filter site-reviews/config/forms/submission-form
46
+	 */
47
+	public function filterFieldOrder(array $config)
48
+	{
49
+		$order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config));
50
+		return array_intersect_key(array_merge(array_flip($order), $config), $config);
51
+	}
52 52
 
53
-    /**
54
-     * @param array $vars
55
-     * @return array
56
-     * @filter query_vars
57
-     */
58
-    public function filterQueryVars($vars)
59
-    {
60
-        $vars = Arr::consolidateArray($vars);
61
-        $vars[] = glsr()->constant('PAGED_QUERY_VAR');
62
-        return $vars;
63
-    }
53
+	/**
54
+	 * @param array $vars
55
+	 * @return array
56
+	 * @filter query_vars
57
+	 */
58
+	public function filterQueryVars($vars)
59
+	{
60
+		$vars = Arr::consolidateArray($vars);
61
+		$vars[] = glsr()->constant('PAGED_QUERY_VAR');
62
+		return $vars;
63
+	}
64 64
 
65
-    /**
66
-     * @param string $view
67
-     * @return string
68
-     * @filter site-reviews/render/view
69
-     */
70
-    public function filterRenderView($view)
71
-    {
72
-        return glsr(Style::class)->filterView($view);
73
-    }
65
+	/**
66
+	 * @param string $view
67
+	 * @return string
68
+	 * @filter site-reviews/render/view
69
+	 */
70
+	public function filterRenderView($view)
71
+	{
72
+		return glsr(Style::class)->filterView($view);
73
+	}
74 74
 
75
-    /**
76
-     * @return void
77
-     * @action site-reviews/builder
78
-     */
79
-    public function modifyBuilder(Builder $instance)
80
-    {
81
-        call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
82
-    }
75
+	/**
76
+	 * @return void
77
+	 * @action site-reviews/builder
78
+	 */
79
+	public function modifyBuilder(Builder $instance)
80
+	{
81
+		call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]);
82
+	}
83 83
 
84
-    /**
85
-     * @return void
86
-     * @action wp_footer
87
-     */
88
-    public function renderSchema()
89
-    {
90
-        glsr(Schema::class)->render();
91
-    }
84
+	/**
85
+	 * @return void
86
+	 * @action wp_footer
87
+	 */
88
+	public function renderSchema()
89
+	{
90
+		glsr(Schema::class)->render();
91
+	}
92 92
 
93
-    /**
94
-     * @return CreateReview
95
-     */
96
-    public function routerSubmitReview(array $request)
97
-    {
98
-        $validated = glsr(ValidateReview::class)->validate($request);
99
-        $command = new CreateReview($validated->request);
100
-        if (empty($validated->error) && !$validated->recaptchaIsUnset) {
101
-            $this->execute($command);
102
-        }
103
-        return $command;
104
-    }
93
+	/**
94
+	 * @return CreateReview
95
+	 */
96
+	public function routerSubmitReview(array $request)
97
+	{
98
+		$validated = glsr(ValidateReview::class)->validate($request);
99
+		$command = new CreateReview($validated->request);
100
+		if (empty($validated->error) && !$validated->recaptchaIsUnset) {
101
+			$this->execute($command);
102
+		}
103
+		return $command;
104
+	}
105 105
 }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 1 patch
Indentation   +403 added lines, -403 removed lines patch added patch discarded remove patch
@@ -19,434 +19,434 @@
 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
-            Arr::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
+			Arr::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 = Arr::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 = Arr::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
-            Arr::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
+			Arr::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
-     * @param \WP_Post $post
305
-     * @param bool $isUpdate
306
-     * @return void
307
-     * @action save_post_.Application::POST_TYPE
308
-     */
309
-    public function saveMetaboxes($postId, $post, $isUpdating)
310
-    {
311
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
312
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
313
-        if ($isUpdating) {
314
-            do_action('site-reviews/review/saved', glsr_get_review($postId));
315
-        }
316
-    }
302
+	/**
303
+	 * @param int $postId
304
+	 * @param \WP_Post $post
305
+	 * @param bool $isUpdate
306
+	 * @return void
307
+	 * @action save_post_.Application::POST_TYPE
308
+	 */
309
+	public function saveMetaboxes($postId, $post, $isUpdating)
310
+	{
311
+		glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
312
+		glsr(Metaboxes::class)->saveResponseMetabox($postId);
313
+		if ($isUpdating) {
314
+			do_action('site-reviews/review/saved', glsr_get_review($postId));
315
+		}
316
+	}
317 317
 
318
-    /**
319
-     * @param string $assignedTo
320
-     * @return string
321
-     */
322
-    protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
323
-    {
324
-        $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
325
-        if (!($assignedPost instanceof WP_Post)) {
326
-            return;
327
-        }
328
-        return glsr(Template::class)->build('partials/editor/assigned-post', [
329
-            'context' => [
330
-                'data.url' => (string) get_permalink($assignedPost),
331
-                'data.title' => get_the_title($assignedPost),
332
-            ],
333
-        ]);
334
-    }
318
+	/**
319
+	 * @param string $assignedTo
320
+	 * @return string
321
+	 */
322
+	protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
323
+	{
324
+		$assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
325
+		if (!($assignedPost instanceof WP_Post)) {
326
+			return;
327
+		}
328
+		return glsr(Template::class)->build('partials/editor/assigned-post', [
329
+			'context' => [
330
+				'data.url' => (string) get_permalink($assignedPost),
331
+				'data.title' => get_the_title($assignedPost),
332
+			],
333
+		]);
334
+	}
335 335
 
336
-    /**
337
-     * @return string
338
-     */
339
-    protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
340
-    {
341
-        $isModified = !Arr::compareArrays(
342
-            [$review->title, $review->content, $review->date],
343
-            [
344
-                glsr(Database::class)->get($post->ID, 'title'),
345
-                glsr(Database::class)->get($post->ID, 'content'),
346
-                glsr(Database::class)->get($post->ID, 'date'),
347
-            ]
348
-        );
349
-        if ($isModified) {
350
-            $revertUrl = wp_nonce_url(
351
-                admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
352
-                'revert-review_'.$post->ID
353
-            );
354
-            return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
355
-                'class' => 'button button-large',
356
-                'href' => $revertUrl,
357
-                'id' => 'revert',
358
-            ]);
359
-        }
360
-        return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
361
-            'class' => 'button-large',
362
-            'disabled' => true,
363
-            'id' => 'revert',
364
-        ]);
365
-    }
336
+	/**
337
+	 * @return string
338
+	 */
339
+	protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
340
+	{
341
+		$isModified = !Arr::compareArrays(
342
+			[$review->title, $review->content, $review->date],
343
+			[
344
+				glsr(Database::class)->get($post->ID, 'title'),
345
+				glsr(Database::class)->get($post->ID, 'content'),
346
+				glsr(Database::class)->get($post->ID, 'date'),
347
+			]
348
+		);
349
+		if ($isModified) {
350
+			$revertUrl = wp_nonce_url(
351
+				admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
352
+				'revert-review_'.$post->ID
353
+			);
354
+			return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
355
+				'class' => 'button button-large',
356
+				'href' => $revertUrl,
357
+				'id' => 'revert',
358
+			]);
359
+		}
360
+		return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
361
+			'class' => 'button-large',
362
+			'disabled' => true,
363
+			'id' => 'revert',
364
+		]);
365
+	}
366 366
 
367
-    /**
368
-     * @param object $review
369
-     * @return string|void
370
-     */
371
-    protected function getReviewType($review)
372
-    {
373
-        if (count(glsr()->reviewTypes) < 2) {
374
-            return;
375
-        }
376
-        $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
377
-            ? glsr()->reviewTypes[$review->review_type]
378
-            : __('Unknown', 'site-reviews');
379
-        if (!empty($review->url)) {
380
-            $reviewType = glsr(Builder::class)->a($reviewType, [
381
-                'href' => $review->url,
382
-                'target' => '_blank',
383
-            ]);
384
-        }
385
-        return $reviewType;
386
-    }
367
+	/**
368
+	 * @param object $review
369
+	 * @return string|void
370
+	 */
371
+	protected function getReviewType($review)
372
+	{
373
+		if (count(glsr()->reviewTypes) < 2) {
374
+			return;
375
+		}
376
+		$reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
377
+			? glsr()->reviewTypes[$review->review_type]
378
+			: __('Unknown', 'site-reviews');
379
+		if (!empty($review->url)) {
380
+			$reviewType = glsr(Builder::class)->a($reviewType, [
381
+				'href' => $review->url,
382
+				'target' => '_blank',
383
+			]);
384
+		}
385
+		return $reviewType;
386
+	}
387 387
 
388
-    /**
389
-     * @return bool
390
-     */
391
-    protected function isReviewEditable($post)
392
-    {
393
-        return $this->isReviewPostType($post)
394
-            && post_type_supports(Application::POST_TYPE, 'title')
395
-            && 'local' == glsr(Database::class)->get($post->ID, 'review_type');
396
-    }
388
+	/**
389
+	 * @return bool
390
+	 */
391
+	protected function isReviewEditable($post)
392
+	{
393
+		return $this->isReviewPostType($post)
394
+			&& post_type_supports(Application::POST_TYPE, 'title')
395
+			&& 'local' == glsr(Database::class)->get($post->ID, 'review_type');
396
+	}
397 397
 
398
-    /**
399
-     * @param mixed $post
400
-     * @return bool
401
-     */
402
-    protected function isReviewPostType($post)
403
-    {
404
-        return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
405
-    }
398
+	/**
399
+	 * @param mixed $post
400
+	 * @return bool
401
+	 */
402
+	protected function isReviewPostType($post)
403
+	{
404
+		return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
405
+	}
406 406
 
407
-    /**
408
-     * @return array
409
-     */
410
-    protected function normalizeDetailsMetaBox(Review $review)
411
-    {
412
-        $user = empty($review->user_id)
413
-            ? __('Unregistered user', 'site-reviews')
414
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
415
-                'href' => get_author_posts_url($review->user_id),
416
-            ]);
417
-        $email = empty($review->email)
418
-            ? '&mdash;'
419
-            : glsr(Builder::class)->a($review->email, [
420
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
421
-            ]);
422
-        $metabox = [
423
-            __('Rating', 'site-reviews') => glsr_star_rating($review->rating),
424
-            __('Type', 'site-reviews') => $this->getReviewType($review),
425
-            __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
426
-            __('Name', 'site-reviews') => $review->author,
427
-            __('Email', 'site-reviews') => $email,
428
-            __('User', 'site-reviews') => $user,
429
-            __('IP Address', 'site-reviews') => $review->ip_address,
430
-            __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
431
-        ];
432
-        return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
433
-    }
407
+	/**
408
+	 * @return array
409
+	 */
410
+	protected function normalizeDetailsMetaBox(Review $review)
411
+	{
412
+		$user = empty($review->user_id)
413
+			? __('Unregistered user', 'site-reviews')
414
+			: glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
415
+				'href' => get_author_posts_url($review->user_id),
416
+			]);
417
+		$email = empty($review->email)
418
+			? '&mdash;'
419
+			: glsr(Builder::class)->a($review->email, [
420
+				'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
421
+			]);
422
+		$metabox = [
423
+			__('Rating', 'site-reviews') => glsr_star_rating($review->rating),
424
+			__('Type', 'site-reviews') => $this->getReviewType($review),
425
+			__('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
426
+			__('Name', 'site-reviews') => $review->author,
427
+			__('Email', 'site-reviews') => $email,
428
+			__('User', 'site-reviews') => $user,
429
+			__('IP Address', 'site-reviews') => $review->ip_address,
430
+			__('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
431
+		];
432
+		return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
433
+	}
434 434
 
435
-    /**
436
-     * @param int $postId
437
-     * @param int $messageIndex
438
-     * @return void
439
-     */
440
-    protected function redirect($postId, $messageIndex)
441
-    {
442
-        $referer = wp_get_referer();
443
-        $hasReferer = !$referer
444
-            || false !== strpos($referer, 'post.php')
445
-            || false !== strpos($referer, 'post-new.php');
446
-        $redirectUri = $hasReferer
447
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
448
-            : get_edit_post_link($postId);
449
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
450
-        exit;
451
-    }
435
+	/**
436
+	 * @param int $postId
437
+	 * @param int $messageIndex
438
+	 * @return void
439
+	 */
440
+	protected function redirect($postId, $messageIndex)
441
+	{
442
+		$referer = wp_get_referer();
443
+		$hasReferer = !$referer
444
+			|| false !== strpos($referer, 'post.php')
445
+			|| false !== strpos($referer, 'post-new.php');
446
+		$redirectUri = $hasReferer
447
+			? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
448
+			: get_edit_post_link($postId);
449
+		wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
450
+		exit;
451
+	}
452 452
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController/Columns.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -10,141 +10,141 @@
 block discarded – undo
10 10
 
11 11
 class Columns
12 12
 {
13
-    /**
14
-     * @param int $postId
15
-     * @return string
16
-     */
17
-    public function buildColumnAssignedTo($postId)
18
-    {
19
-        $assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
-        $column = '&mdash;';
21
-        if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
22
-            $column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
23
-                'href' => (string) get_the_permalink($assignedPost->ID),
24
-            ]);
25
-        }
26
-        return $column;
27
-    }
13
+	/**
14
+	 * @param int $postId
15
+	 * @return string
16
+	 */
17
+	public function buildColumnAssignedTo($postId)
18
+	{
19
+		$assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
+		$column = '&mdash;';
21
+		if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
22
+			$column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
23
+				'href' => (string) get_the_permalink($assignedPost->ID),
24
+			]);
25
+		}
26
+		return $column;
27
+	}
28 28
 
29
-    /**
30
-     * @param int $postId
31
-     * @return string
32
-     */
33
-    public function buildColumnPinned($postId)
34
-    {
35
-        $pinned = glsr(Database::class)->get($postId, 'pinned')
36
-            ? 'pinned '
37
-            : '';
38
-        return glsr(Builder::class)->i([
39
-            'class' => $pinned.'dashicons dashicons-sticky',
40
-            'data-id' => $postId,
41
-        ]);
42
-    }
29
+	/**
30
+	 * @param int $postId
31
+	 * @return string
32
+	 */
33
+	public function buildColumnPinned($postId)
34
+	{
35
+		$pinned = glsr(Database::class)->get($postId, 'pinned')
36
+			? 'pinned '
37
+			: '';
38
+		return glsr(Builder::class)->i([
39
+			'class' => $pinned.'dashicons dashicons-sticky',
40
+			'data-id' => $postId,
41
+		]);
42
+	}
43 43
 
44
-    /**
45
-     * @param int $postId
46
-     * @return string
47
-     */
48
-    public function buildColumnReviewer($postId)
49
-    {
50
-        return strval(glsr(Database::class)->get($postId, 'author'));
51
-    }
44
+	/**
45
+	 * @param int $postId
46
+	 * @return string
47
+	 */
48
+	public function buildColumnReviewer($postId)
49
+	{
50
+		return strval(glsr(Database::class)->get($postId, 'author'));
51
+	}
52 52
 
53
-    /**
54
-     * @param int $postId
55
-     * @param int|null $rating
56
-     * @return string
57
-     */
58
-    public function buildColumnRating($postId)
59
-    {
60
-        return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
61
-    }
53
+	/**
54
+	 * @param int $postId
55
+	 * @param int|null $rating
56
+	 * @return string
57
+	 */
58
+	public function buildColumnRating($postId)
59
+	{
60
+		return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
61
+	}
62 62
 
63
-    /**
64
-     * @param int $postId
65
-     * @return string
66
-     */
67
-    public function buildColumnReviewType($postId)
68
-    {
69
-        $type = glsr(Database::class)->get($postId, 'review_type');
70
-        return array_key_exists($type, glsr()->reviewTypes)
71
-            ? glsr()->reviewTypes[$type]
72
-            : __('Unsupported Type', 'site-reviews');
73
-    }
63
+	/**
64
+	 * @param int $postId
65
+	 * @return string
66
+	 */
67
+	public function buildColumnReviewType($postId)
68
+	{
69
+		$type = glsr(Database::class)->get($postId, 'review_type');
70
+		return array_key_exists($type, glsr()->reviewTypes)
71
+			? glsr()->reviewTypes[$type]
72
+			: __('Unsupported Type', 'site-reviews');
73
+	}
74 74
 
75
-    /**
76
-     * @param string $postType
77
-     * @return void
78
-     */
79
-    public function renderFilters($postType)
80
-    {
81
-        if (Application::POST_TYPE !== $postType) {
82
-            return;
83
-        }
84
-        if (!($status = filter_input(INPUT_GET, 'post_status'))) {
85
-            $status = 'publish';
86
-        }
87
-        $ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
88
-        $types = glsr(Database::class)->getReviewsMeta('review_type', $status);
89
-        $this->renderFilterRatings($ratings);
90
-        $this->renderFilterTypes($types);
91
-    }
75
+	/**
76
+	 * @param string $postType
77
+	 * @return void
78
+	 */
79
+	public function renderFilters($postType)
80
+	{
81
+		if (Application::POST_TYPE !== $postType) {
82
+			return;
83
+		}
84
+		if (!($status = filter_input(INPUT_GET, 'post_status'))) {
85
+			$status = 'publish';
86
+		}
87
+		$ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
88
+		$types = glsr(Database::class)->getReviewsMeta('review_type', $status);
89
+		$this->renderFilterRatings($ratings);
90
+		$this->renderFilterTypes($types);
91
+	}
92 92
 
93
-    /**
94
-     * @param string $column
95
-     * @param int $postId
96
-     * @return void
97
-     */
98
-    public function renderValues($column, $postId)
99
-    {
100
-        $method = Helper::buildMethodName($column, 'buildColumn');
101
-        echo method_exists($this, $method)
102
-            ? call_user_func([$this, $method], $postId)
103
-            : apply_filters('site-reviews/columns/'.$column, '', $postId);
104
-    }
93
+	/**
94
+	 * @param string $column
95
+	 * @param int $postId
96
+	 * @return void
97
+	 */
98
+	public function renderValues($column, $postId)
99
+	{
100
+		$method = Helper::buildMethodName($column, 'buildColumn');
101
+		echo method_exists($this, $method)
102
+			? call_user_func([$this, $method], $postId)
103
+			: apply_filters('site-reviews/columns/'.$column, '', $postId);
104
+	}
105 105
 
106
-    /**
107
-     * @param array $ratings
108
-     * @return void
109
-     */
110
-    protected function renderFilterRatings($ratings)
111
-    {
112
-        if (empty($ratings)) {
113
-            return;
114
-        }
115
-        $ratings = array_flip(array_reverse($ratings));
116
-        array_walk($ratings, function (&$value, $key) {
117
-            $label = _n('%s star', '%s stars', $key, 'site-reviews');
118
-            $value = sprintf($label, $key);
119
-        });
120
-        echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
121
-            'class' => 'screen-reader-text',
122
-            'for' => 'rating',
123
-        ]);
124
-        echo glsr(Builder::class)->select([
125
-            'name' => 'rating',
126
-            'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
127
-            'value' => filter_input(INPUT_GET, 'rating'),
128
-        ]);
129
-    }
106
+	/**
107
+	 * @param array $ratings
108
+	 * @return void
109
+	 */
110
+	protected function renderFilterRatings($ratings)
111
+	{
112
+		if (empty($ratings)) {
113
+			return;
114
+		}
115
+		$ratings = array_flip(array_reverse($ratings));
116
+		array_walk($ratings, function (&$value, $key) {
117
+			$label = _n('%s star', '%s stars', $key, 'site-reviews');
118
+			$value = sprintf($label, $key);
119
+		});
120
+		echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
121
+			'class' => 'screen-reader-text',
122
+			'for' => 'rating',
123
+		]);
124
+		echo glsr(Builder::class)->select([
125
+			'name' => 'rating',
126
+			'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
127
+			'value' => filter_input(INPUT_GET, 'rating'),
128
+		]);
129
+	}
130 130
 
131
-    /**
132
-     * @param array $types
133
-     * @return void
134
-     */
135
-    protected function renderFilterTypes($types)
136
-    {
137
-        if (count(glsr()->reviewTypes) < 2) {
138
-            return;
139
-        }
140
-        echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
141
-            'class' => 'screen-reader-text',
142
-            'for' => 'review_type',
143
-        ]);
144
-        echo glsr(Builder::class)->select([
145
-            'name' => 'review_type',
146
-            'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
147
-            'value' => filter_input(INPUT_GET, 'review_type'),
148
-        ]);
149
-    }
131
+	/**
132
+	 * @param array $types
133
+	 * @return void
134
+	 */
135
+	protected function renderFilterTypes($types)
136
+	{
137
+		if (count(glsr()->reviewTypes) < 2) {
138
+			return;
139
+		}
140
+		echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
141
+			'class' => 'screen-reader-text',
142
+			'for' => 'review_type',
143
+		]);
144
+		echo glsr(Builder::class)->select([
145
+			'name' => 'review_type',
146
+			'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
147
+			'value' => filter_input(INPUT_GET, 'review_type'),
148
+		]);
149
+	}
150 150
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterShortcodes.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,18 +7,18 @@
 block discarded – undo
7 7
 
8 8
 class RegisterShortcodes
9 9
 {
10
-    /**
11
-     * @return void
12
-     */
13
-    public function handle(Command $command)
14
-    {
15
-        foreach ($command->shortcodes as $shortcode) {
16
-            $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes');
17
-            if (!class_exists($shortcodeClass)) {
18
-                glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass));
19
-                continue;
20
-            }
21
-            add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']);
22
-        }
23
-    }
10
+	/**
11
+	 * @return void
12
+	 */
13
+	public function handle(Command $command)
14
+	{
15
+		foreach ($command->shortcodes as $shortcode) {
16
+			$shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes');
17
+			if (!class_exists($shortcodeClass)) {
18
+				glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass));
19
+				continue;
20
+			}
21
+			add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']);
22
+		}
23
+	}
24 24
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterTinymcePopups.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
 
8 8
 class RegisterTinymcePopups
9 9
 {
10
-    /**
11
-     * @return void
12
-     */
13
-    public function handle(Command $command)
14
-    {
15
-        foreach ($command->popups as $slug => $label) {
16
-            $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes');
17
-            if (!class_exists($buttonClass)) {
18
-                glsr_log()->error(sprintf('Class missing (%s)', $buttonClass));
19
-                continue;
20
-            }
21
-            $shortcode = glsr($buttonClass)->register($slug, [
22
-                'label' => $label,
23
-                'title' => $label,
24
-            ]);
25
-            glsr()->mceShortcodes[$slug] = $shortcode->properties;
26
-        }
27
-    }
10
+	/**
11
+	 * @return void
12
+	 */
13
+	public function handle(Command $command)
14
+	{
15
+		foreach ($command->popups as $slug => $label) {
16
+			$buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes');
17
+			if (!class_exists($buttonClass)) {
18
+				glsr_log()->error(sprintf('Class missing (%s)', $buttonClass));
19
+				continue;
20
+			}
21
+			$shortcode = glsr($buttonClass)->register($slug, [
22
+				'label' => $label,
23
+				'title' => $label,
24
+			]);
25
+			glsr()->mceShortcodes[$slug] = $shortcode->properties;
26
+		}
27
+	}
28 28
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterWidgets.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -8,21 +8,21 @@
 block discarded – undo
8 8
 
9 9
 class RegisterWidgets
10 10
 {
11
-    /**
12
-     * @return void
13
-     */
14
-    public function handle(Command $command)
15
-    {
16
-        global $wp_widget_factory;
17
-        foreach ($command->widgets as $key => $values) {
18
-            $widgetClass = Helper::buildClassName($key.'-widget', 'Widgets');
19
-            if (!class_exists($widgetClass)) {
20
-                glsr_log()->error(sprintf('Class missing (%s)', $widgetClass));
21
-                continue;
22
-            }
23
-            // Here we bypass register_widget() in order to pass our custom values to the widget
24
-            $widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values);
25
-            $wp_widget_factory->widgets[$widgetClass] = $widget;
26
-        }
27
-    }
11
+	/**
12
+	 * @return void
13
+	 */
14
+	public function handle(Command $command)
15
+	{
16
+		global $wp_widget_factory;
17
+		foreach ($command->widgets as $key => $values) {
18
+			$widgetClass = Helper::buildClassName($key.'-widget', 'Widgets');
19
+			if (!class_exists($widgetClass)) {
20
+				glsr_log()->error(sprintf('Class missing (%s)', $widgetClass));
21
+				continue;
22
+			}
23
+			// Here we bypass register_widget() in order to pass our custom values to the widget
24
+			$widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values);
25
+			$wp_widget_factory->widgets[$widgetClass] = $widget;
26
+		}
27
+	}
28 28
 }
Please login to merge, or discard this patch.
plugin/Helper.php 1 patch
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -8,121 +8,121 @@
 block discarded – undo
8 8
 
9 9
 class Helper
10 10
 {
11
-    /**
12
-     * @param string $name
13
-     * @param string $path
14
-     * @return string
15
-     */
16
-    public static function buildClassName($name, $path = '')
17
-    {
18
-        $className = Str::camelCase($name);
19
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
20
-        return !empty($path)
21
-            ? __NAMESPACE__.'\\'.$path.'\\'.$className
22
-            : $className;
23
-    }
11
+	/**
12
+	 * @param string $name
13
+	 * @param string $path
14
+	 * @return string
15
+	 */
16
+	public static function buildClassName($name, $path = '')
17
+	{
18
+		$className = Str::camelCase($name);
19
+		$path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
20
+		return !empty($path)
21
+			? __NAMESPACE__.'\\'.$path.'\\'.$className
22
+			: $className;
23
+	}
24 24
 
25
-    /**
26
-     * @param string $name
27
-     * @param string $prefix
28
-     * @return string
29
-     */
30
-    public static function buildMethodName($name, $prefix = '')
31
-    {
32
-        return lcfirst($prefix.static::buildClassName($name));
33
-    }
25
+	/**
26
+	 * @param string $name
27
+	 * @param string $prefix
28
+	 * @return string
29
+	 */
30
+	public static function buildMethodName($name, $prefix = '')
31
+	{
32
+		return lcfirst($prefix.static::buildClassName($name));
33
+	}
34 34
 
35
-    /**
36
-     * @param string $name
37
-     * @return string
38
-     */
39
-    public static function buildPropertyName($name)
40
-    {
41
-        return lcfirst(static::buildClassName($name));
42
-    }
35
+	/**
36
+	 * @param string $name
37
+	 * @return string
38
+	 */
39
+	public static function buildPropertyName($name)
40
+	{
41
+		return lcfirst(static::buildClassName($name));
42
+	}
43 43
 
44
-    /**
45
-     * @param string $cast
46
-     * @param mixed $value
47
-     * @return mixed
48
-     */
49
-    public static function castTo($cast = '', $value)
50
-    {
51
-        switch ($cast) {
52
-            case 'array':
53
-                return (array) $value;
54
-            case 'bool':
55
-            case 'boolean':
56
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
57
-            case 'float':
58
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
59
-            case 'int':
60
-            case 'integer':
61
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
62
-            case 'object':
63
-                return (object) (array) $value;
64
-            case 'str':
65
-            case 'string':
66
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
67
-                    return (string) $value->__toString();
68
-                }
69
-                if (is_array($value) || is_object($value)) {
70
-                    return serialize($value);
71
-                }
72
-                return (string) $value;
73
-            default:
74
-                return $value;
75
-        }
76
-    }
44
+	/**
45
+	 * @param string $cast
46
+	 * @param mixed $value
47
+	 * @return mixed
48
+	 */
49
+	public static function castTo($cast = '', $value)
50
+	{
51
+		switch ($cast) {
52
+			case 'array':
53
+				return (array) $value;
54
+			case 'bool':
55
+			case 'boolean':
56
+				return filter_var($value, FILTER_VALIDATE_BOOLEAN);
57
+			case 'float':
58
+				return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
59
+			case 'int':
60
+			case 'integer':
61
+				return (int) filter_var($value, FILTER_VALIDATE_INT);
62
+			case 'object':
63
+				return (object) (array) $value;
64
+			case 'str':
65
+			case 'string':
66
+				if (is_object($value) && in_array('__toString', get_class_methods($value))) {
67
+					return (string) $value->__toString();
68
+				}
69
+				if (is_array($value) || is_object($value)) {
70
+					return serialize($value);
71
+				}
72
+				return (string) $value;
73
+			default:
74
+				return $value;
75
+		}
76
+	}
77 77
 
78
-    /**
79
-     * @param string $key
80
-     * @return mixed
81
-     */
82
-    public static function filterInput($key, array $request = [])
83
-    {
84
-        if (isset($request[$key])) {
85
-            return $request[$key];
86
-        }
87
-        $variable = filter_input(INPUT_POST, $key);
88
-        if (is_null($variable) && isset($_POST[$key])) {
89
-            $variable = $_POST[$key];
90
-        }
91
-        return $variable;
92
-    }
78
+	/**
79
+	 * @param string $key
80
+	 * @return mixed
81
+	 */
82
+	public static function filterInput($key, array $request = [])
83
+	{
84
+		if (isset($request[$key])) {
85
+			return $request[$key];
86
+		}
87
+		$variable = filter_input(INPUT_POST, $key);
88
+		if (is_null($variable) && isset($_POST[$key])) {
89
+			$variable = $_POST[$key];
90
+		}
91
+		return $variable;
92
+	}
93 93
 
94
-    /**
95
-     * @param string $key
96
-     * @return array
97
-     */
98
-    public static function filterInputArray($key)
99
-    {
100
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
101
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
102
-            $variable = $_POST[$key];
103
-        }
104
-        return (array) $variable;
105
-    }
94
+	/**
95
+	 * @param string $key
96
+	 * @return array
97
+	 */
98
+	public static function filterInputArray($key)
99
+	{
100
+		$variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
101
+		if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
102
+			$variable = $_POST[$key];
103
+		}
104
+		return (array) $variable;
105
+	}
106 106
 
107
-    /**
108
-     * @return string
109
-     */
110
-    public static function getIpAddress()
111
-    {
112
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
113
-        $whitelist = [
114
-            Whip::CLOUDFLARE_HEADERS => [Whip::IPV4 => $cloudflareIps['v4']],
115
-            // Whip::CUSTOM_HEADERS => [Whip::IPV4 => ['127.0.0.1']],
116
-        ];
117
-        if (defined('AF_INET6')) {
118
-            $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6'];
119
-            // $whitelist[Whip::CUSTOM_HEADERS][Whip::IPV6] = ['::1'];
120
-        }
121
-        $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist);
122
-        $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
123
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
124
-        $whip = new Whip($methods, $whitelist);
125
-        do_action_ref_array('site-reviews/whip', [$whip]);
126
-        return (string) $whip->getValidIpAddress();
127
-    }
107
+	/**
108
+	 * @return string
109
+	 */
110
+	public static function getIpAddress()
111
+	{
112
+		$cloudflareIps = glsr(Cache::class)->getCloudflareIps();
113
+		$whitelist = [
114
+			Whip::CLOUDFLARE_HEADERS => [Whip::IPV4 => $cloudflareIps['v4']],
115
+			// Whip::CUSTOM_HEADERS => [Whip::IPV4 => ['127.0.0.1']],
116
+		];
117
+		if (defined('AF_INET6')) {
118
+			$whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6'];
119
+			// $whitelist[Whip::CUSTOM_HEADERS][Whip::IPV6] = ['::1'];
120
+		}
121
+		$whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist);
122
+		$methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
123
+		$methods = apply_filters('site-reviews/whip/methods', $methods);
124
+		$whip = new Whip($methods, $whitelist);
125
+		do_action_ref_array('site-reviews/whip', [$whip]);
126
+		return (string) $whip->getValidIpAddress();
127
+	}
128 128
 }
Please login to merge, or discard this patch.
plugin/Defaults/ValidateReviewDefaults.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
 
8 8
 class ValidateReviewDefaults extends Defaults
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    protected function defaults()
14
-    {
15
-        return [
16
-            'assign_to' => '',
17
-            'category' => '',
18
-            'content' => '',
19
-            'email' => '',
20
-            'form_id' => '',
21
-            'ip_address' => Helper::getIpAddress(), // required for Akismet and Blacklist validation
22
-            'name' => '',
23
-            'rating' => '0',
24
-            'terms' => '',
25
-            'title' => '',
26
-        ];
27
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	protected function defaults()
14
+	{
15
+		return [
16
+			'assign_to' => '',
17
+			'category' => '',
18
+			'content' => '',
19
+			'email' => '',
20
+			'form_id' => '',
21
+			'ip_address' => Helper::getIpAddress(), // required for Akismet and Blacklist validation
22
+			'name' => '',
23
+			'rating' => '0',
24
+			'terms' => '',
25
+			'title' => '',
26
+		];
27
+	}
28 28
 }
Please login to merge, or discard this patch.
plugin/Defaults/DefaultsAbstract.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -7,117 +7,117 @@
 block discarded – undo
7 7
 
8 8
 abstract class DefaultsAbstract
9 9
 {
10
-    /**
11
-     * @var array
12
-     */
13
-    protected $callable = [
14
-        'defaults', 'filter', 'merge', 'restrict', 'unguarded',
15
-    ];
10
+	/**
11
+	 * @var array
12
+	 */
13
+	protected $callable = [
14
+		'defaults', 'filter', 'merge', 'restrict', 'unguarded',
15
+	];
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $guarded = [];
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $guarded = [];
21 21
 
22
-    /**
23
-     * @param string $name
24
-     * @return void|array
25
-     */
26
-    public function __call($name, array $args = [])
27
-    {
28
-        if (!method_exists($this, $name) || !in_array($name, $this->callable)) {
29
-            return;
30
-        }
31
-        $defaults = call_user_func_array([$this, $name], $args);
32
-        $hookName = (new ReflectionClass($this))->getShortName();
33
-        $hookName = str_replace('Defaults', '', $hookName);
34
-        $hookName = Str::dashCase($hookName);
35
-        return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name);
36
-    }
22
+	/**
23
+	 * @param string $name
24
+	 * @return void|array
25
+	 */
26
+	public function __call($name, array $args = [])
27
+	{
28
+		if (!method_exists($this, $name) || !in_array($name, $this->callable)) {
29
+			return;
30
+		}
31
+		$defaults = call_user_func_array([$this, $name], $args);
32
+		$hookName = (new ReflectionClass($this))->getShortName();
33
+		$hookName = str_replace('Defaults', '', $hookName);
34
+		$hookName = Str::dashCase($hookName);
35
+		return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name);
36
+	}
37 37
 
38
-    /**
39
-     * @return array
40
-     */
41
-    abstract protected function defaults();
38
+	/**
39
+	 * @return array
40
+	 */
41
+	abstract protected function defaults();
42 42
 
43
-    /**
44
-     * @return array
45
-     */
46
-    protected function filter(array $values = [])
47
-    {
48
-        return $this->normalize($this->merge(array_filter($values)), $values);
49
-    }
43
+	/**
44
+	 * @return array
45
+	 */
46
+	protected function filter(array $values = [])
47
+	{
48
+		return $this->normalize($this->merge(array_filter($values)), $values);
49
+	}
50 50
 
51
-    /**
52
-     * @return string
53
-     */
54
-    protected function filteredJson(array $values = [])
55
-    {
56
-        $defaults = $this->flattenArray(
57
-            array_diff_key($this->defaults(), array_flip($this->guarded))
58
-        );
59
-        $values = $this->flattenArray(
60
-            shortcode_atts($defaults, $values)
61
-        );
62
-        $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) {
63
-            return !$this->isEmpty($value);
64
-        });
65
-        return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
66
-    }
51
+	/**
52
+	 * @return string
53
+	 */
54
+	protected function filteredJson(array $values = [])
55
+	{
56
+		$defaults = $this->flattenArray(
57
+			array_diff_key($this->defaults(), array_flip($this->guarded))
58
+		);
59
+		$values = $this->flattenArray(
60
+			shortcode_atts($defaults, $values)
61
+		);
62
+		$filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) {
63
+			return !$this->isEmpty($value);
64
+		});
65
+		return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
66
+	}
67 67
 
68
-    /**
69
-     * @return array
70
-     */
71
-    protected function flattenArray(array $values)
72
-    {
73
-        array_walk($values, function (&$value) {
74
-            if (!is_array($value)) {
75
-                return;
76
-            }
77
-            $value = implode(',', $value);
78
-        });
79
-        return $values;
80
-    }
68
+	/**
69
+	 * @return array
70
+	 */
71
+	protected function flattenArray(array $values)
72
+	{
73
+		array_walk($values, function (&$value) {
74
+			if (!is_array($value)) {
75
+				return;
76
+			}
77
+			$value = implode(',', $value);
78
+		});
79
+		return $values;
80
+	}
81 81
 
82
-    /**
83
-     * @param mixed $var
84
-     * @return bool
85
-     */
86
-    protected function isEmpty($var)
87
-    {
88
-        return !is_numeric($var) && !is_bool($var) && empty($var);
89
-    }
82
+	/**
83
+	 * @param mixed $var
84
+	 * @return bool
85
+	 */
86
+	protected function isEmpty($var)
87
+	{
88
+		return !is_numeric($var) && !is_bool($var) && empty($var);
89
+	}
90 90
 
91
-    /**
92
-     * @return array
93
-     */
94
-    protected function merge(array $values = [])
95
-    {
96
-        return $this->normalize(wp_parse_args($values, $this->defaults()), $values);
97
-    }
91
+	/**
92
+	 * @return array
93
+	 */
94
+	protected function merge(array $values = [])
95
+	{
96
+		return $this->normalize(wp_parse_args($values, $this->defaults()), $values);
97
+	}
98 98
 
99
-    /**
100
-     * @return array
101
-     */
102
-    protected function normalize(array $values, array $originalValues)
103
-    {
104
-        $values['json'] = $this->filteredJson($originalValues);
105
-        return $values;
106
-    }
99
+	/**
100
+	 * @return array
101
+	 */
102
+	protected function normalize(array $values, array $originalValues)
103
+	{
104
+		$values['json'] = $this->filteredJson($originalValues);
105
+		return $values;
106
+	}
107 107
 
108
-    /**
109
-     * @return array
110
-     */
111
-    protected function restrict(array $values = [])
112
-    {
113
-        return $this->normalize(shortcode_atts($this->defaults(), $values), $values);
114
-    }
108
+	/**
109
+	 * @return array
110
+	 */
111
+	protected function restrict(array $values = [])
112
+	{
113
+		return $this->normalize(shortcode_atts($this->defaults(), $values), $values);
114
+	}
115 115
 
116
-    /**
117
-     * @return array
118
-     */
119
-    protected function unguarded()
120
-    {
121
-        return array_diff_key($this->defaults(), array_flip($this->guarded));
122
-    }
116
+	/**
117
+	 * @return array
118
+	 */
119
+	protected function unguarded()
120
+	{
121
+		return array_diff_key($this->defaults(), array_flip($this->guarded));
122
+	}
123 123
 }
Please login to merge, or discard this patch.