@@ -20,402 +20,402 @@ |
||
20 | 20 | |
21 | 21 | class EditorController extends Controller |
22 | 22 | { |
23 | - /** |
|
24 | - * @param array $settings |
|
25 | - * @return array |
|
26 | - * @filter wp_editor_settings |
|
27 | - */ |
|
28 | - public function filterEditorSettings($settings) |
|
29 | - { |
|
30 | - return glsr(Customization::class)->filterEditorSettings( |
|
31 | - Arr::consolidate($settings) |
|
32 | - ); |
|
33 | - } |
|
23 | + /** |
|
24 | + * @param array $settings |
|
25 | + * @return array |
|
26 | + * @filter wp_editor_settings |
|
27 | + */ |
|
28 | + public function filterEditorSettings($settings) |
|
29 | + { |
|
30 | + return glsr(Customization::class)->filterEditorSettings( |
|
31 | + Arr::consolidate($settings) |
|
32 | + ); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script. |
|
37 | - * @param string $html |
|
38 | - * @return string |
|
39 | - * @filter the_editor |
|
40 | - */ |
|
41 | - public function filterEditorTextarea($html) |
|
42 | - { |
|
43 | - return glsr(Customization::class)->filterEditorTextarea($html); |
|
44 | - } |
|
35 | + /** |
|
36 | + * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script. |
|
37 | + * @param string $html |
|
38 | + * @return string |
|
39 | + * @filter the_editor |
|
40 | + */ |
|
41 | + public function filterEditorTextarea($html) |
|
42 | + { |
|
43 | + return glsr(Customization::class)->filterEditorTextarea($html); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param bool $protected |
|
48 | - * @param string $metaKey |
|
49 | - * @param string $metaType |
|
50 | - * @return bool |
|
51 | - * @filter is_protected_meta |
|
52 | - */ |
|
53 | - public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
54 | - { |
|
55 | - if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
56 | - $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
57 | - $values = Arr::prefixKeys($values); |
|
58 | - if (array_key_exists($metaKey, $values)) { |
|
59 | - $protected = false; |
|
60 | - } |
|
61 | - } |
|
62 | - return $protected; |
|
63 | - } |
|
46 | + /** |
|
47 | + * @param bool $protected |
|
48 | + * @param string $metaKey |
|
49 | + * @param string $metaType |
|
50 | + * @return bool |
|
51 | + * @filter is_protected_meta |
|
52 | + */ |
|
53 | + public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
54 | + { |
|
55 | + if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
56 | + $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
57 | + $values = Arr::prefixKeys($values); |
|
58 | + if (array_key_exists($metaKey, $values)) { |
|
59 | + $protected = false; |
|
60 | + } |
|
61 | + } |
|
62 | + return $protected; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @param array $messages |
|
67 | - * @return array |
|
68 | - * @filter post_updated_messages |
|
69 | - */ |
|
70 | - public function filterUpdateMessages($messages) |
|
71 | - { |
|
72 | - return glsr(Labels::class)->filterUpdateMessages( |
|
73 | - Arr::consolidate($messages) |
|
74 | - ); |
|
75 | - } |
|
65 | + /** |
|
66 | + * @param array $messages |
|
67 | + * @return array |
|
68 | + * @filter post_updated_messages |
|
69 | + */ |
|
70 | + public function filterUpdateMessages($messages) |
|
71 | + { |
|
72 | + return glsr(Labels::class)->filterUpdateMessages( |
|
73 | + Arr::consolidate($messages) |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return void |
|
79 | - * @action add_meta_boxes_{Application::POST_TYPE} |
|
80 | - */ |
|
81 | - public function registerMetaBoxes($post) |
|
82 | - { |
|
83 | - add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
84 | - add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
85 | - if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
86 | - return; |
|
87 | - } |
|
88 | - add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
89 | - } |
|
77 | + /** |
|
78 | + * @return void |
|
79 | + * @action add_meta_boxes_{Application::POST_TYPE} |
|
80 | + */ |
|
81 | + public function registerMetaBoxes($post) |
|
82 | + { |
|
83 | + add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
84 | + add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
85 | + if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
86 | + return; |
|
87 | + } |
|
88 | + add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @return void |
|
93 | - * @action admin_print_scripts |
|
94 | - */ |
|
95 | - public function removeAutosave() |
|
96 | - { |
|
97 | - glsr(Customization::class)->removeAutosave(); |
|
98 | - } |
|
91 | + /** |
|
92 | + * @return void |
|
93 | + * @action admin_print_scripts |
|
94 | + */ |
|
95 | + public function removeAutosave() |
|
96 | + { |
|
97 | + glsr(Customization::class)->removeAutosave(); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return void |
|
102 | - * @action admin_menu |
|
103 | - */ |
|
104 | - public function removeMetaBoxes() |
|
105 | - { |
|
106 | - glsr(Customization::class)->removeMetaBoxes(); |
|
107 | - } |
|
100 | + /** |
|
101 | + * @return void |
|
102 | + * @action admin_menu |
|
103 | + */ |
|
104 | + public function removeMetaBoxes() |
|
105 | + { |
|
106 | + glsr(Customization::class)->removeMetaBoxes(); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @return void |
|
111 | - */ |
|
112 | - public function removePostTypeSupport() |
|
113 | - { |
|
114 | - glsr(Customization::class)->removePostTypeSupport(); |
|
115 | - } |
|
109 | + /** |
|
110 | + * @return void |
|
111 | + */ |
|
112 | + public function removePostTypeSupport() |
|
113 | + { |
|
114 | + glsr(Customization::class)->removePostTypeSupport(); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * @param WP_Post $post |
|
119 | - * @return void |
|
120 | - * @callback add_meta_box |
|
121 | - */ |
|
122 | - public function renderAssignedToMetabox($post) |
|
123 | - { |
|
124 | - if (!$this->isReviewPostType($post)) { |
|
125 | - return; |
|
126 | - } |
|
127 | - $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
128 | - wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
129 | - glsr()->render('partials/editor/metabox-assigned-to', [ |
|
130 | - 'id' => $assignedTo, |
|
131 | - 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
132 | - ]); |
|
133 | - } |
|
117 | + /** |
|
118 | + * @param WP_Post $post |
|
119 | + * @return void |
|
120 | + * @callback add_meta_box |
|
121 | + */ |
|
122 | + public function renderAssignedToMetabox($post) |
|
123 | + { |
|
124 | + if (!$this->isReviewPostType($post)) { |
|
125 | + return; |
|
126 | + } |
|
127 | + $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
128 | + wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
129 | + glsr()->render('partials/editor/metabox-assigned-to', [ |
|
130 | + 'id' => $assignedTo, |
|
131 | + 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
132 | + ]); |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * @param WP_Post $post |
|
137 | - * @return void |
|
138 | - * @callback add_meta_box |
|
139 | - */ |
|
140 | - public function renderDetailsMetaBox($post) |
|
141 | - { |
|
142 | - if (!$this->isReviewPostType($post)) { |
|
143 | - return; |
|
144 | - } |
|
145 | - $review = glsr_get_review($post); |
|
146 | - glsr()->render('partials/editor/metabox-details', [ |
|
147 | - 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
148 | - 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
149 | - ]); |
|
150 | - } |
|
135 | + /** |
|
136 | + * @param WP_Post $post |
|
137 | + * @return void |
|
138 | + * @callback add_meta_box |
|
139 | + */ |
|
140 | + public function renderDetailsMetaBox($post) |
|
141 | + { |
|
142 | + if (!$this->isReviewPostType($post)) { |
|
143 | + return; |
|
144 | + } |
|
145 | + $review = glsr_get_review($post); |
|
146 | + glsr()->render('partials/editor/metabox-details', [ |
|
147 | + 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
148 | + 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
149 | + ]); |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * @return void |
|
154 | - * @action post_submitbox_misc_actions |
|
155 | - */ |
|
156 | - public function renderPinnedInPublishMetaBox() |
|
157 | - { |
|
158 | - if (!$this->isReviewPostType(get_post()) |
|
159 | - || !glsr()->can('edit_others_posts')) { |
|
160 | - return; |
|
161 | - } |
|
162 | - glsr(Template::class)->render('partials/editor/pinned', [ |
|
163 | - 'context' => [ |
|
164 | - 'no' => __('No', 'site-reviews'), |
|
165 | - 'yes' => __('Yes', 'site-reviews'), |
|
166 | - ], |
|
167 | - 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
168 | - ]); |
|
169 | - } |
|
152 | + /** |
|
153 | + * @return void |
|
154 | + * @action post_submitbox_misc_actions |
|
155 | + */ |
|
156 | + public function renderPinnedInPublishMetaBox() |
|
157 | + { |
|
158 | + if (!$this->isReviewPostType(get_post()) |
|
159 | + || !glsr()->can('edit_others_posts')) { |
|
160 | + return; |
|
161 | + } |
|
162 | + glsr(Template::class)->render('partials/editor/pinned', [ |
|
163 | + 'context' => [ |
|
164 | + 'no' => __('No', 'site-reviews'), |
|
165 | + 'yes' => __('Yes', 'site-reviews'), |
|
166 | + ], |
|
167 | + 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
168 | + ]); |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * @param WP_Post $post |
|
173 | - * @return void |
|
174 | - * @callback add_meta_box |
|
175 | - */ |
|
176 | - public function renderResponseMetaBox($post) |
|
177 | - { |
|
178 | - if (!$this->isReviewPostType($post)) { |
|
179 | - return; |
|
180 | - } |
|
181 | - wp_nonce_field('response', '_nonce-response', false); |
|
182 | - glsr()->render('partials/editor/metabox-response', [ |
|
183 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
184 | - ]); |
|
185 | - } |
|
171 | + /** |
|
172 | + * @param WP_Post $post |
|
173 | + * @return void |
|
174 | + * @callback add_meta_box |
|
175 | + */ |
|
176 | + public function renderResponseMetaBox($post) |
|
177 | + { |
|
178 | + if (!$this->isReviewPostType($post)) { |
|
179 | + return; |
|
180 | + } |
|
181 | + wp_nonce_field('response', '_nonce-response', false); |
|
182 | + glsr()->render('partials/editor/metabox-response', [ |
|
183 | + 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
184 | + ]); |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * @param WP_Post $post |
|
189 | - * @return void |
|
190 | - * @action edit_form_after_title |
|
191 | - */ |
|
192 | - public function renderReviewEditor($post) |
|
193 | - { |
|
194 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
195 | - return; |
|
196 | - } |
|
197 | - glsr()->render('partials/editor/review', [ |
|
198 | - 'post' => $post, |
|
199 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
200 | - ]); |
|
201 | - } |
|
187 | + /** |
|
188 | + * @param WP_Post $post |
|
189 | + * @return void |
|
190 | + * @action edit_form_after_title |
|
191 | + */ |
|
192 | + public function renderReviewEditor($post) |
|
193 | + { |
|
194 | + if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
195 | + return; |
|
196 | + } |
|
197 | + glsr()->render('partials/editor/review', [ |
|
198 | + 'post' => $post, |
|
199 | + 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
200 | + ]); |
|
201 | + } |
|
202 | 202 | |
203 | - /** |
|
204 | - * @return void |
|
205 | - * @action admin_head |
|
206 | - */ |
|
207 | - public function renderReviewFields() |
|
208 | - { |
|
209 | - $screen = glsr_current_screen(); |
|
210 | - if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
211 | - return; |
|
212 | - } |
|
213 | - add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
214 | - add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
215 | - } |
|
203 | + /** |
|
204 | + * @return void |
|
205 | + * @action admin_head |
|
206 | + */ |
|
207 | + public function renderReviewFields() |
|
208 | + { |
|
209 | + $screen = glsr_current_screen(); |
|
210 | + if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
211 | + return; |
|
212 | + } |
|
213 | + add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
214 | + add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
215 | + } |
|
216 | 216 | |
217 | - /** |
|
218 | - * @param WP_Post $post |
|
219 | - * @return void |
|
220 | - * @action edit_form_top |
|
221 | - */ |
|
222 | - public function renderReviewNotice($post) |
|
223 | - { |
|
224 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
225 | - return; |
|
226 | - } |
|
227 | - glsr(Notice::class)->addWarning(sprintf( |
|
228 | - __('%s reviews are read-only.', 'site-reviews'), |
|
229 | - glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
230 | - )); |
|
231 | - glsr(Template::class)->render('partials/editor/notice', [ |
|
232 | - 'context' => [ |
|
233 | - 'notices' => glsr(Notice::class)->get(), |
|
234 | - ], |
|
235 | - ]); |
|
236 | - } |
|
217 | + /** |
|
218 | + * @param WP_Post $post |
|
219 | + * @return void |
|
220 | + * @action edit_form_top |
|
221 | + */ |
|
222 | + public function renderReviewNotice($post) |
|
223 | + { |
|
224 | + if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
225 | + return; |
|
226 | + } |
|
227 | + glsr(Notice::class)->addWarning(sprintf( |
|
228 | + __('%s reviews are read-only.', 'site-reviews'), |
|
229 | + glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
230 | + )); |
|
231 | + glsr(Template::class)->render('partials/editor/notice', [ |
|
232 | + 'context' => [ |
|
233 | + 'notices' => glsr(Notice::class)->get(), |
|
234 | + ], |
|
235 | + ]); |
|
236 | + } |
|
237 | 237 | |
238 | - /** |
|
239 | - * @param WP_Post $post |
|
240 | - * @return void |
|
241 | - * @see glsr_categories_meta_box() |
|
242 | - * @callback register_taxonomy |
|
243 | - */ |
|
244 | - public function renderTaxonomyMetabox($post) |
|
245 | - { |
|
246 | - if (!$this->isReviewPostType($post)) { |
|
247 | - return; |
|
248 | - } |
|
249 | - glsr()->render('partials/editor/metabox-categories', [ |
|
250 | - 'post' => $post, |
|
251 | - 'tax_name' => Application::TAXONOMY, |
|
252 | - 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
253 | - ]); |
|
254 | - } |
|
238 | + /** |
|
239 | + * @param WP_Post $post |
|
240 | + * @return void |
|
241 | + * @see glsr_categories_meta_box() |
|
242 | + * @callback register_taxonomy |
|
243 | + */ |
|
244 | + public function renderTaxonomyMetabox($post) |
|
245 | + { |
|
246 | + if (!$this->isReviewPostType($post)) { |
|
247 | + return; |
|
248 | + } |
|
249 | + glsr()->render('partials/editor/metabox-categories', [ |
|
250 | + 'post' => $post, |
|
251 | + 'tax_name' => Application::TAXONOMY, |
|
252 | + 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
253 | + ]); |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * @return void |
|
258 | - * @see $this->filterUpdateMessages() |
|
259 | - * @action admin_action_revert |
|
260 | - */ |
|
261 | - public function revertReview() |
|
262 | - { |
|
263 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
264 | - return; |
|
265 | - } |
|
266 | - check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
267 | - glsr(ReviewManager::class)->revert($postId); |
|
268 | - $this->redirect($postId, 52); |
|
269 | - } |
|
256 | + /** |
|
257 | + * @return void |
|
258 | + * @see $this->filterUpdateMessages() |
|
259 | + * @action admin_action_revert |
|
260 | + */ |
|
261 | + public function revertReview() |
|
262 | + { |
|
263 | + if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
264 | + return; |
|
265 | + } |
|
266 | + check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
267 | + glsr(ReviewManager::class)->revert($postId); |
|
268 | + $this->redirect($postId, 52); |
|
269 | + } |
|
270 | 270 | |
271 | - /** |
|
272 | - * @param int $postId |
|
273 | - * @param \WP_Post $post |
|
274 | - * @param bool $isUpdate |
|
275 | - * @return void |
|
276 | - * @action save_post_.Application::POST_TYPE |
|
277 | - */ |
|
278 | - public function saveMetaboxes($postId, $post, $isUpdating) |
|
279 | - { |
|
280 | - glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
281 | - glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
282 | - if ($isUpdating) { |
|
283 | - do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
284 | - } |
|
285 | - } |
|
271 | + /** |
|
272 | + * @param int $postId |
|
273 | + * @param \WP_Post $post |
|
274 | + * @param bool $isUpdate |
|
275 | + * @return void |
|
276 | + * @action save_post_.Application::POST_TYPE |
|
277 | + */ |
|
278 | + public function saveMetaboxes($postId, $post, $isUpdating) |
|
279 | + { |
|
280 | + glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
281 | + glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
282 | + if ($isUpdating) { |
|
283 | + do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
284 | + } |
|
285 | + } |
|
286 | 286 | |
287 | - /** |
|
288 | - * @param string $assignedTo |
|
289 | - * @return string |
|
290 | - */ |
|
291 | - protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
292 | - { |
|
293 | - $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
294 | - if (!($assignedPost instanceof WP_Post)) { |
|
295 | - return; |
|
296 | - } |
|
297 | - return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
298 | - 'context' => [ |
|
299 | - 'data.url' => (string) get_permalink($assignedPost), |
|
300 | - 'data.title' => get_the_title($assignedPost), |
|
301 | - ], |
|
302 | - ]); |
|
303 | - } |
|
287 | + /** |
|
288 | + * @param string $assignedTo |
|
289 | + * @return string |
|
290 | + */ |
|
291 | + protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
292 | + { |
|
293 | + $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
294 | + if (!($assignedPost instanceof WP_Post)) { |
|
295 | + return; |
|
296 | + } |
|
297 | + return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
298 | + 'context' => [ |
|
299 | + 'data.url' => (string) get_permalink($assignedPost), |
|
300 | + 'data.title' => get_the_title($assignedPost), |
|
301 | + ], |
|
302 | + ]); |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * @return string |
|
307 | - */ |
|
308 | - protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
309 | - { |
|
310 | - $isModified = !Arr::compare( |
|
311 | - [$review->title, $review->content, $review->date], |
|
312 | - [ |
|
313 | - glsr(Database::class)->get($post->ID, 'title'), |
|
314 | - glsr(Database::class)->get($post->ID, 'content'), |
|
315 | - glsr(Database::class)->get($post->ID, 'date'), |
|
316 | - ] |
|
317 | - ); |
|
318 | - if ($isModified) { |
|
319 | - $revertUrl = wp_nonce_url( |
|
320 | - admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
321 | - 'revert-review_'.$post->ID |
|
322 | - ); |
|
323 | - return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
324 | - 'class' => 'button button-large', |
|
325 | - 'href' => $revertUrl, |
|
326 | - 'id' => 'revert', |
|
327 | - ]); |
|
328 | - } |
|
329 | - return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
330 | - 'class' => 'button-large', |
|
331 | - 'disabled' => true, |
|
332 | - 'id' => 'revert', |
|
333 | - ]); |
|
334 | - } |
|
305 | + /** |
|
306 | + * @return string |
|
307 | + */ |
|
308 | + protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
309 | + { |
|
310 | + $isModified = !Arr::compare( |
|
311 | + [$review->title, $review->content, $review->date], |
|
312 | + [ |
|
313 | + glsr(Database::class)->get($post->ID, 'title'), |
|
314 | + glsr(Database::class)->get($post->ID, 'content'), |
|
315 | + glsr(Database::class)->get($post->ID, 'date'), |
|
316 | + ] |
|
317 | + ); |
|
318 | + if ($isModified) { |
|
319 | + $revertUrl = wp_nonce_url( |
|
320 | + admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
321 | + 'revert-review_'.$post->ID |
|
322 | + ); |
|
323 | + return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
324 | + 'class' => 'button button-large', |
|
325 | + 'href' => $revertUrl, |
|
326 | + 'id' => 'revert', |
|
327 | + ]); |
|
328 | + } |
|
329 | + return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
330 | + 'class' => 'button-large', |
|
331 | + 'disabled' => true, |
|
332 | + 'id' => 'revert', |
|
333 | + ]); |
|
334 | + } |
|
335 | 335 | |
336 | - /** |
|
337 | - * @param object $review |
|
338 | - * @return string|void |
|
339 | - */ |
|
340 | - protected function getReviewType($review) |
|
341 | - { |
|
342 | - if (count(glsr()->reviewTypes) < 2) { |
|
343 | - return; |
|
344 | - } |
|
345 | - $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
346 | - ? glsr()->reviewTypes[$review->review_type] |
|
347 | - : __('Unknown', 'site-reviews'); |
|
348 | - if (!empty($review->url)) { |
|
349 | - $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
350 | - 'href' => $review->url, |
|
351 | - 'target' => '_blank', |
|
352 | - ]); |
|
353 | - } |
|
354 | - return $reviewType; |
|
355 | - } |
|
336 | + /** |
|
337 | + * @param object $review |
|
338 | + * @return string|void |
|
339 | + */ |
|
340 | + protected function getReviewType($review) |
|
341 | + { |
|
342 | + if (count(glsr()->reviewTypes) < 2) { |
|
343 | + return; |
|
344 | + } |
|
345 | + $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
346 | + ? glsr()->reviewTypes[$review->review_type] |
|
347 | + : __('Unknown', 'site-reviews'); |
|
348 | + if (!empty($review->url)) { |
|
349 | + $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
350 | + 'href' => $review->url, |
|
351 | + 'target' => '_blank', |
|
352 | + ]); |
|
353 | + } |
|
354 | + return $reviewType; |
|
355 | + } |
|
356 | 356 | |
357 | - /** |
|
358 | - * @return bool |
|
359 | - */ |
|
360 | - protected function isReviewEditable($post) |
|
361 | - { |
|
362 | - return $this->isReviewPostType($post) |
|
363 | - && post_type_supports(Application::POST_TYPE, 'title') |
|
364 | - && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
365 | - } |
|
357 | + /** |
|
358 | + * @return bool |
|
359 | + */ |
|
360 | + protected function isReviewEditable($post) |
|
361 | + { |
|
362 | + return $this->isReviewPostType($post) |
|
363 | + && post_type_supports(Application::POST_TYPE, 'title') |
|
364 | + && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
365 | + } |
|
366 | 366 | |
367 | - /** |
|
368 | - * @param mixed $post |
|
369 | - * @return bool |
|
370 | - */ |
|
371 | - protected function isReviewPostType($post) |
|
372 | - { |
|
373 | - return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
|
374 | - } |
|
367 | + /** |
|
368 | + * @param mixed $post |
|
369 | + * @return bool |
|
370 | + */ |
|
371 | + protected function isReviewPostType($post) |
|
372 | + { |
|
373 | + return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
|
374 | + } |
|
375 | 375 | |
376 | - /** |
|
377 | - * @return array |
|
378 | - */ |
|
379 | - protected function normalizeDetailsMetaBox(Review $review) |
|
380 | - { |
|
381 | - $user = empty($review->user_id) |
|
382 | - ? __('Unregistered user', 'site-reviews') |
|
383 | - : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
384 | - 'href' => get_author_posts_url($review->user_id), |
|
385 | - ]); |
|
386 | - $email = empty($review->email) |
|
387 | - ? '—' |
|
388 | - : glsr(Builder::class)->a($review->email, [ |
|
389 | - 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
390 | - ]); |
|
391 | - $metabox = [ |
|
392 | - __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
393 | - __('Type', 'site-reviews') => $this->getReviewType($review), |
|
394 | - __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
395 | - __('Name', 'site-reviews') => $review->author, |
|
396 | - __('Email', 'site-reviews') => $email, |
|
397 | - __('User', 'site-reviews') => $user, |
|
398 | - __('IP Address', 'site-reviews') => $review->ip_address, |
|
399 | - __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
400 | - ]; |
|
401 | - return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
402 | - } |
|
376 | + /** |
|
377 | + * @return array |
|
378 | + */ |
|
379 | + protected function normalizeDetailsMetaBox(Review $review) |
|
380 | + { |
|
381 | + $user = empty($review->user_id) |
|
382 | + ? __('Unregistered user', 'site-reviews') |
|
383 | + : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
384 | + 'href' => get_author_posts_url($review->user_id), |
|
385 | + ]); |
|
386 | + $email = empty($review->email) |
|
387 | + ? '—' |
|
388 | + : glsr(Builder::class)->a($review->email, [ |
|
389 | + 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
390 | + ]); |
|
391 | + $metabox = [ |
|
392 | + __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
393 | + __('Type', 'site-reviews') => $this->getReviewType($review), |
|
394 | + __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
395 | + __('Name', 'site-reviews') => $review->author, |
|
396 | + __('Email', 'site-reviews') => $email, |
|
397 | + __('User', 'site-reviews') => $user, |
|
398 | + __('IP Address', 'site-reviews') => $review->ip_address, |
|
399 | + __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
400 | + ]; |
|
401 | + return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
402 | + } |
|
403 | 403 | |
404 | - /** |
|
405 | - * @param int $postId |
|
406 | - * @param int $messageIndex |
|
407 | - * @return void |
|
408 | - */ |
|
409 | - protected function redirect($postId, $messageIndex) |
|
410 | - { |
|
411 | - $referer = wp_get_referer(); |
|
412 | - $hasReferer = !$referer |
|
413 | - || Str::contains($referer, 'post.php') |
|
414 | - || Str::contains($referer, 'post-new.php'); |
|
415 | - $redirectUri = $hasReferer |
|
416 | - ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
417 | - : get_edit_post_link($postId); |
|
418 | - wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
419 | - exit; |
|
420 | - } |
|
404 | + /** |
|
405 | + * @param int $postId |
|
406 | + * @param int $messageIndex |
|
407 | + * @return void |
|
408 | + */ |
|
409 | + protected function redirect($postId, $messageIndex) |
|
410 | + { |
|
411 | + $referer = wp_get_referer(); |
|
412 | + $hasReferer = !$referer |
|
413 | + || Str::contains($referer, 'post.php') |
|
414 | + || Str::contains($referer, 'post-new.php'); |
|
415 | + $redirectUri = $hasReferer |
|
416 | + ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
417 | + : get_edit_post_link($postId); |
|
418 | + wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
419 | + exit; |
|
420 | + } |
|
421 | 421 | } |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * @return array |
26 | 26 | * @filter wp_editor_settings |
27 | 27 | */ |
28 | - public function filterEditorSettings($settings) |
|
28 | + public function filterEditorSettings( $settings ) |
|
29 | 29 | { |
30 | - return glsr(Customization::class)->filterEditorSettings( |
|
31 | - Arr::consolidate($settings) |
|
30 | + return glsr( Customization::class )->filterEditorSettings( |
|
31 | + Arr::consolidate( $settings ) |
|
32 | 32 | ); |
33 | 33 | } |
34 | 34 | |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * @return string |
39 | 39 | * @filter the_editor |
40 | 40 | */ |
41 | - public function filterEditorTextarea($html) |
|
41 | + public function filterEditorTextarea( $html ) |
|
42 | 42 | { |
43 | - return glsr(Customization::class)->filterEditorTextarea($html); |
|
43 | + return glsr( Customization::class )->filterEditorTextarea( $html ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | * @return bool |
51 | 51 | * @filter is_protected_meta |
52 | 52 | */ |
53 | - public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
53 | + public function filterIsProtectedMeta( $protected, $metaKey, $metaType ) |
|
54 | 54 | { |
55 | - if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
56 | - $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
57 | - $values = Arr::prefixKeys($values); |
|
58 | - if (array_key_exists($metaKey, $values)) { |
|
55 | + if( 'post' == $metaType && Application::POST_TYPE == get_post_type() ) { |
|
56 | + $values = glsr( CreateReviewDefaults::class )->unguarded(); |
|
57 | + $values = Arr::prefixKeys( $values ); |
|
58 | + if( array_key_exists( $metaKey, $values ) ) { |
|
59 | 59 | $protected = false; |
60 | 60 | } |
61 | 61 | } |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | * @return array |
68 | 68 | * @filter post_updated_messages |
69 | 69 | */ |
70 | - public function filterUpdateMessages($messages) |
|
70 | + public function filterUpdateMessages( $messages ) |
|
71 | 71 | { |
72 | - return glsr(Labels::class)->filterUpdateMessages( |
|
73 | - Arr::consolidate($messages) |
|
72 | + return glsr( Labels::class )->filterUpdateMessages( |
|
73 | + Arr::consolidate( $messages ) |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * @return void |
79 | 79 | * @action add_meta_boxes_{Application::POST_TYPE} |
80 | 80 | */ |
81 | - public function registerMetaBoxes($post) |
|
81 | + public function registerMetaBoxes( $post ) |
|
82 | 82 | { |
83 | - add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
84 | - add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
85 | - if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
83 | + add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
|
84 | + add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
|
85 | + if( 'local' != glsr( Database::class )->get( $post->ID, 'review_type' ) ) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | - add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
88 | + add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function removeAutosave() |
96 | 96 | { |
97 | - glsr(Customization::class)->removeAutosave(); |
|
97 | + glsr( Customization::class )->removeAutosave(); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function removeMetaBoxes() |
105 | 105 | { |
106 | - glsr(Customization::class)->removeMetaBoxes(); |
|
106 | + glsr( Customization::class )->removeMetaBoxes(); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function removePostTypeSupport() |
113 | 113 | { |
114 | - glsr(Customization::class)->removePostTypeSupport(); |
|
114 | + glsr( Customization::class )->removePostTypeSupport(); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -119,17 +119,17 @@ discard block |
||
119 | 119 | * @return void |
120 | 120 | * @callback add_meta_box |
121 | 121 | */ |
122 | - public function renderAssignedToMetabox($post) |
|
122 | + public function renderAssignedToMetabox( $post ) |
|
123 | 123 | { |
124 | - if (!$this->isReviewPostType($post)) { |
|
124 | + if( !$this->isReviewPostType( $post ) ) { |
|
125 | 125 | return; |
126 | 126 | } |
127 | - $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
128 | - wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
129 | - glsr()->render('partials/editor/metabox-assigned-to', [ |
|
127 | + $assignedTo = (string)glsr( Database::class )->get( $post->ID, 'assigned_to' ); |
|
128 | + wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
|
129 | + glsr()->render( 'partials/editor/metabox-assigned-to', [ |
|
130 | 130 | 'id' => $assignedTo, |
131 | - 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
132 | - ]); |
|
131 | + 'template' => $this->buildAssignedToTemplate( $assignedTo, $post ), |
|
132 | + ] ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -137,16 +137,16 @@ discard block |
||
137 | 137 | * @return void |
138 | 138 | * @callback add_meta_box |
139 | 139 | */ |
140 | - public function renderDetailsMetaBox($post) |
|
140 | + public function renderDetailsMetaBox( $post ) |
|
141 | 141 | { |
142 | - if (!$this->isReviewPostType($post)) { |
|
142 | + if( !$this->isReviewPostType( $post ) ) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | - $review = glsr_get_review($post); |
|
146 | - glsr()->render('partials/editor/metabox-details', [ |
|
147 | - 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
148 | - 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
149 | - ]); |
|
145 | + $review = glsr_get_review( $post ); |
|
146 | + glsr()->render( 'partials/editor/metabox-details', [ |
|
147 | + 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
|
148 | + 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
|
149 | + ] ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function renderPinnedInPublishMetaBox() |
157 | 157 | { |
158 | - if (!$this->isReviewPostType(get_post()) |
|
159 | - || !glsr()->can('edit_others_posts')) { |
|
158 | + if( !$this->isReviewPostType( get_post() ) |
|
159 | + || !glsr()->can( 'edit_others_posts' ) ) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | - glsr(Template::class)->render('partials/editor/pinned', [ |
|
162 | + glsr( Template::class )->render( 'partials/editor/pinned', [ |
|
163 | 163 | 'context' => [ |
164 | - 'no' => __('No', 'site-reviews'), |
|
165 | - 'yes' => __('Yes', 'site-reviews'), |
|
164 | + 'no' => __( 'No', 'site-reviews' ), |
|
165 | + 'yes' => __( 'Yes', 'site-reviews' ), |
|
166 | 166 | ], |
167 | - 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
168 | - ]); |
|
167 | + 'pinned' => wp_validate_boolean( glsr( Database::class )->get( get_the_ID(), 'pinned' ) ), |
|
168 | + ] ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | * @callback add_meta_box |
175 | 175 | */ |
176 | - public function renderResponseMetaBox($post) |
|
176 | + public function renderResponseMetaBox( $post ) |
|
177 | 177 | { |
178 | - if (!$this->isReviewPostType($post)) { |
|
178 | + if( !$this->isReviewPostType( $post ) ) { |
|
179 | 179 | return; |
180 | 180 | } |
181 | - wp_nonce_field('response', '_nonce-response', false); |
|
182 | - glsr()->render('partials/editor/metabox-response', [ |
|
183 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
184 | - ]); |
|
181 | + wp_nonce_field( 'response', '_nonce-response', false ); |
|
182 | + glsr()->render( 'partials/editor/metabox-response', [ |
|
183 | + 'response' => glsr( Database::class )->get( $post->ID, 'response' ), |
|
184 | + ] ); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -189,15 +189,15 @@ discard block |
||
189 | 189 | * @return void |
190 | 190 | * @action edit_form_after_title |
191 | 191 | */ |
192 | - public function renderReviewEditor($post) |
|
192 | + public function renderReviewEditor( $post ) |
|
193 | 193 | { |
194 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
194 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | - glsr()->render('partials/editor/review', [ |
|
197 | + glsr()->render( 'partials/editor/review', [ |
|
198 | 198 | 'post' => $post, |
199 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
200 | - ]); |
|
199 | + 'response' => glsr( Database::class )->get( $post->ID, 'response' ), |
|
200 | + ] ); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | public function renderReviewFields() |
208 | 208 | { |
209 | 209 | $screen = glsr_current_screen(); |
210 | - if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
210 | + if( 'post' != $screen->base || Application::POST_TYPE != $screen->post_type ) { |
|
211 | 211 | return; |
212 | 212 | } |
213 | - add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
214 | - add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
213 | + add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
|
214 | + add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -219,20 +219,20 @@ discard block |
||
219 | 219 | * @return void |
220 | 220 | * @action edit_form_top |
221 | 221 | */ |
222 | - public function renderReviewNotice($post) |
|
222 | + public function renderReviewNotice( $post ) |
|
223 | 223 | { |
224 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
224 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | - glsr(Notice::class)->addWarning(sprintf( |
|
228 | - __('%s reviews are read-only.', 'site-reviews'), |
|
229 | - glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
230 | - )); |
|
231 | - glsr(Template::class)->render('partials/editor/notice', [ |
|
227 | + glsr( Notice::class )->addWarning( sprintf( |
|
228 | + __( '%s reviews are read-only.', 'site-reviews' ), |
|
229 | + glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
|
230 | + ) ); |
|
231 | + glsr( Template::class )->render( 'partials/editor/notice', [ |
|
232 | 232 | 'context' => [ |
233 | - 'notices' => glsr(Notice::class)->get(), |
|
233 | + 'notices' => glsr( Notice::class )->get(), |
|
234 | 234 | ], |
235 | - ]); |
|
235 | + ] ); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -241,16 +241,16 @@ discard block |
||
241 | 241 | * @see glsr_categories_meta_box() |
242 | 242 | * @callback register_taxonomy |
243 | 243 | */ |
244 | - public function renderTaxonomyMetabox($post) |
|
244 | + public function renderTaxonomyMetabox( $post ) |
|
245 | 245 | { |
246 | - if (!$this->isReviewPostType($post)) { |
|
246 | + if( !$this->isReviewPostType( $post ) ) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | - glsr()->render('partials/editor/metabox-categories', [ |
|
249 | + glsr()->render( 'partials/editor/metabox-categories', [ |
|
250 | 250 | 'post' => $post, |
251 | 251 | 'tax_name' => Application::TAXONOMY, |
252 | - 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
253 | - ]); |
|
252 | + 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
|
253 | + ] ); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -260,12 +260,12 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function revertReview() |
262 | 262 | { |
263 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
263 | + if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | - check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
267 | - glsr(ReviewManager::class)->revert($postId); |
|
268 | - $this->redirect($postId, 52); |
|
266 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
267 | + glsr( ReviewManager::class )->revert( $postId ); |
|
268 | + $this->redirect( $postId, 52 ); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | * @return void |
276 | 276 | * @action save_post_.Application::POST_TYPE |
277 | 277 | */ |
278 | - public function saveMetaboxes($postId, $post, $isUpdating) |
|
278 | + public function saveMetaboxes( $postId, $post, $isUpdating ) |
|
279 | 279 | { |
280 | - glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
281 | - glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
282 | - if ($isUpdating) { |
|
283 | - do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
280 | + glsr( Metaboxes::class )->saveAssignedToMetabox( $postId ); |
|
281 | + glsr( Metaboxes::class )->saveResponseMetabox( $postId ); |
|
282 | + if( $isUpdating ) { |
|
283 | + do_action( 'site-reviews/review/saved', glsr_get_review( $postId ) ); |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
@@ -288,68 +288,68 @@ discard block |
||
288 | 288 | * @param string $assignedTo |
289 | 289 | * @return string |
290 | 290 | */ |
291 | - protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
291 | + protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
|
292 | 292 | { |
293 | - $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
294 | - if (!($assignedPost instanceof WP_Post)) { |
|
293 | + $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
|
294 | + if( !($assignedPost instanceof WP_Post) ) { |
|
295 | 295 | return; |
296 | 296 | } |
297 | - return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
297 | + return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
|
298 | 298 | 'context' => [ |
299 | - 'data.url' => (string) get_permalink($assignedPost), |
|
300 | - 'data.title' => get_the_title($assignedPost), |
|
299 | + 'data.url' => (string)get_permalink( $assignedPost ), |
|
300 | + 'data.title' => get_the_title( $assignedPost ), |
|
301 | 301 | ], |
302 | - ]); |
|
302 | + ] ); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
306 | 306 | * @return string |
307 | 307 | */ |
308 | - protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
308 | + protected function buildDetailsMetaBoxRevertButton( Review $review, WP_Post $post ) |
|
309 | 309 | { |
310 | 310 | $isModified = !Arr::compare( |
311 | 311 | [$review->title, $review->content, $review->date], |
312 | 312 | [ |
313 | - glsr(Database::class)->get($post->ID, 'title'), |
|
314 | - glsr(Database::class)->get($post->ID, 'content'), |
|
315 | - glsr(Database::class)->get($post->ID, 'date'), |
|
313 | + glsr( Database::class )->get( $post->ID, 'title' ), |
|
314 | + glsr( Database::class )->get( $post->ID, 'content' ), |
|
315 | + glsr( Database::class )->get( $post->ID, 'date' ), |
|
316 | 316 | ] |
317 | 317 | ); |
318 | - if ($isModified) { |
|
318 | + if( $isModified ) { |
|
319 | 319 | $revertUrl = wp_nonce_url( |
320 | - admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
320 | + admin_url( 'post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID ), |
|
321 | 321 | 'revert-review_'.$post->ID |
322 | 322 | ); |
323 | - return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
323 | + return glsr( Builder::class )->a( __( 'Revert Changes', 'site-reviews' ), [ |
|
324 | 324 | 'class' => 'button button-large', |
325 | 325 | 'href' => $revertUrl, |
326 | 326 | 'id' => 'revert', |
327 | - ]); |
|
327 | + ] ); |
|
328 | 328 | } |
329 | - return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
329 | + return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
|
330 | 330 | 'class' => 'button-large', |
331 | 331 | 'disabled' => true, |
332 | 332 | 'id' => 'revert', |
333 | - ]); |
|
333 | + ] ); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
337 | 337 | * @param object $review |
338 | 338 | * @return string|void |
339 | 339 | */ |
340 | - protected function getReviewType($review) |
|
340 | + protected function getReviewType( $review ) |
|
341 | 341 | { |
342 | - if (count(glsr()->reviewTypes) < 2) { |
|
342 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
343 | 343 | return; |
344 | 344 | } |
345 | - $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
345 | + $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
|
346 | 346 | ? glsr()->reviewTypes[$review->review_type] |
347 | - : __('Unknown', 'site-reviews'); |
|
348 | - if (!empty($review->url)) { |
|
349 | - $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
347 | + : __( 'Unknown', 'site-reviews' ); |
|
348 | + if( !empty($review->url) ) { |
|
349 | + $reviewType = glsr( Builder::class )->a( $reviewType, [ |
|
350 | 350 | 'href' => $review->url, |
351 | 351 | 'target' => '_blank', |
352 | - ]); |
|
352 | + ] ); |
|
353 | 353 | } |
354 | 354 | return $reviewType; |
355 | 355 | } |
@@ -357,18 +357,18 @@ discard block |
||
357 | 357 | /** |
358 | 358 | * @return bool |
359 | 359 | */ |
360 | - protected function isReviewEditable($post) |
|
360 | + protected function isReviewEditable( $post ) |
|
361 | 361 | { |
362 | - return $this->isReviewPostType($post) |
|
363 | - && post_type_supports(Application::POST_TYPE, 'title') |
|
364 | - && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
362 | + return $this->isReviewPostType( $post ) |
|
363 | + && post_type_supports( Application::POST_TYPE, 'title' ) |
|
364 | + && 'local' == glsr( Database::class )->get( $post->ID, 'review_type' ); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
368 | 368 | * @param mixed $post |
369 | 369 | * @return bool |
370 | 370 | */ |
371 | - protected function isReviewPostType($post) |
|
371 | + protected function isReviewPostType( $post ) |
|
372 | 372 | { |
373 | 373 | return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
374 | 374 | } |
@@ -376,29 +376,29 @@ discard block |
||
376 | 376 | /** |
377 | 377 | * @return array |
378 | 378 | */ |
379 | - protected function normalizeDetailsMetaBox(Review $review) |
|
379 | + protected function normalizeDetailsMetaBox( Review $review ) |
|
380 | 380 | { |
381 | 381 | $user = empty($review->user_id) |
382 | - ? __('Unregistered user', 'site-reviews') |
|
383 | - : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
384 | - 'href' => get_author_posts_url($review->user_id), |
|
385 | - ]); |
|
382 | + ? __( 'Unregistered user', 'site-reviews' ) |
|
383 | + : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
|
384 | + 'href' => get_author_posts_url( $review->user_id ), |
|
385 | + ] ); |
|
386 | 386 | $email = empty($review->email) |
387 | 387 | ? '—' |
388 | - : glsr(Builder::class)->a($review->email, [ |
|
389 | - 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
390 | - ]); |
|
388 | + : glsr( Builder::class )->a( $review->email, [ |
|
389 | + 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
|
390 | + ] ); |
|
391 | 391 | $metabox = [ |
392 | - __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
393 | - __('Type', 'site-reviews') => $this->getReviewType($review), |
|
394 | - __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
395 | - __('Name', 'site-reviews') => $review->author, |
|
396 | - __('Email', 'site-reviews') => $email, |
|
397 | - __('User', 'site-reviews') => $user, |
|
398 | - __('IP Address', 'site-reviews') => $review->ip_address, |
|
399 | - __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
392 | + __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ), |
|
393 | + __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
|
394 | + __( 'Date', 'site-reviews' ) => get_date_from_gmt( $review->date, 'F j, Y' ), |
|
395 | + __( 'Name', 'site-reviews' ) => $review->author, |
|
396 | + __( 'Email', 'site-reviews' ) => $email, |
|
397 | + __( 'User', 'site-reviews' ) => $user, |
|
398 | + __( 'IP Address', 'site-reviews' ) => $review->ip_address, |
|
399 | + __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ), |
|
400 | 400 | ]; |
401 | - return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
401 | + return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) ); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -406,16 +406,16 @@ discard block |
||
406 | 406 | * @param int $messageIndex |
407 | 407 | * @return void |
408 | 408 | */ |
409 | - protected function redirect($postId, $messageIndex) |
|
409 | + protected function redirect( $postId, $messageIndex ) |
|
410 | 410 | { |
411 | 411 | $referer = wp_get_referer(); |
412 | 412 | $hasReferer = !$referer |
413 | - || Str::contains($referer, 'post.php') |
|
414 | - || Str::contains($referer, 'post-new.php'); |
|
413 | + || Str::contains( $referer, 'post.php' ) |
|
414 | + || Str::contains( $referer, 'post-new.php' ); |
|
415 | 415 | $redirectUri = $hasReferer |
416 | - ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
417 | - : get_edit_post_link($postId); |
|
418 | - wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
416 | + ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
|
417 | + : get_edit_post_link( $postId ); |
|
418 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
419 | 419 | exit; |
420 | 420 | } |
421 | 421 | } |
@@ -10,95 +10,95 @@ |
||
10 | 10 | |
11 | 11 | class MainController extends Controller |
12 | 12 | { |
13 | - /** |
|
14 | - * @return void |
|
15 | - * @action init |
|
16 | - */ |
|
17 | - public function registerPostType() |
|
18 | - { |
|
19 | - if (!glsr()->hasPermission()) { |
|
20 | - return; |
|
21 | - } |
|
22 | - $command = new RegisterPostType([ |
|
23 | - 'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
|
24 | - 'capability_type' => Application::POST_TYPE, |
|
25 | - 'columns' => [ |
|
26 | - 'title' => '', |
|
27 | - 'category' => '', |
|
28 | - 'assigned_to' => __('Assigned To', 'site-reviews'), |
|
29 | - 'reviewer' => __('Author', 'site-reviews'), |
|
30 | - 'email' => __('Email', 'site-reviews'), |
|
31 | - 'ip_address' => __('IP Address', 'site-reviews'), |
|
32 | - 'response' => __('Response', 'site-reviews'), |
|
33 | - 'review_type' => __('Type', 'site-reviews'), |
|
34 | - 'rating' => __('Rating', 'site-reviews'), |
|
35 | - 'pinned' => __('Pinned', 'site-reviews'), |
|
36 | - 'date' => '', |
|
37 | - ], |
|
38 | - 'menu_icon' => 'dashicons-star-half', |
|
39 | - 'menu_name' => glsr()->name, |
|
40 | - 'map_meta_cap' => true, |
|
41 | - 'plural' => __('Reviews', 'site-reviews'), |
|
42 | - 'post_type' => Application::POST_TYPE, |
|
43 | - 'rest_controller_class' => RestReviewController::class, |
|
44 | - 'show_in_rest' => true, |
|
45 | - 'single' => __('Review', 'site-reviews'), |
|
46 | - ]); |
|
47 | - $this->execute($command); |
|
48 | - } |
|
13 | + /** |
|
14 | + * @return void |
|
15 | + * @action init |
|
16 | + */ |
|
17 | + public function registerPostType() |
|
18 | + { |
|
19 | + if (!glsr()->hasPermission()) { |
|
20 | + return; |
|
21 | + } |
|
22 | + $command = new RegisterPostType([ |
|
23 | + 'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
|
24 | + 'capability_type' => Application::POST_TYPE, |
|
25 | + 'columns' => [ |
|
26 | + 'title' => '', |
|
27 | + 'category' => '', |
|
28 | + 'assigned_to' => __('Assigned To', 'site-reviews'), |
|
29 | + 'reviewer' => __('Author', 'site-reviews'), |
|
30 | + 'email' => __('Email', 'site-reviews'), |
|
31 | + 'ip_address' => __('IP Address', 'site-reviews'), |
|
32 | + 'response' => __('Response', 'site-reviews'), |
|
33 | + 'review_type' => __('Type', 'site-reviews'), |
|
34 | + 'rating' => __('Rating', 'site-reviews'), |
|
35 | + 'pinned' => __('Pinned', 'site-reviews'), |
|
36 | + 'date' => '', |
|
37 | + ], |
|
38 | + 'menu_icon' => 'dashicons-star-half', |
|
39 | + 'menu_name' => glsr()->name, |
|
40 | + 'map_meta_cap' => true, |
|
41 | + 'plural' => __('Reviews', 'site-reviews'), |
|
42 | + 'post_type' => Application::POST_TYPE, |
|
43 | + 'rest_controller_class' => RestReviewController::class, |
|
44 | + 'show_in_rest' => true, |
|
45 | + 'single' => __('Review', 'site-reviews'), |
|
46 | + ]); |
|
47 | + $this->execute($command); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return void |
|
52 | - * @action init |
|
53 | - */ |
|
54 | - public function registerShortcodes() |
|
55 | - { |
|
56 | - $command = new RegisterShortcodes([ |
|
57 | - 'site_reviews', |
|
58 | - 'site_reviews_form', |
|
59 | - 'site_reviews_summary', |
|
60 | - ]); |
|
61 | - $this->execute($command); |
|
62 | - } |
|
50 | + /** |
|
51 | + * @return void |
|
52 | + * @action init |
|
53 | + */ |
|
54 | + public function registerShortcodes() |
|
55 | + { |
|
56 | + $command = new RegisterShortcodes([ |
|
57 | + 'site_reviews', |
|
58 | + 'site_reviews_form', |
|
59 | + 'site_reviews_summary', |
|
60 | + ]); |
|
61 | + $this->execute($command); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return void |
|
66 | - * @action init |
|
67 | - */ |
|
68 | - public function registerTaxonomy() |
|
69 | - { |
|
70 | - $command = new RegisterTaxonomy([ |
|
71 | - 'hierarchical' => true, |
|
72 | - 'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
73 | - 'public' => false, |
|
74 | - 'rest_controller_class' => RestCategoryController::class, |
|
75 | - 'show_admin_column' => true, |
|
76 | - 'show_in_rest' => true, |
|
77 | - 'show_ui' => true, |
|
78 | - ]); |
|
79 | - $this->execute($command); |
|
80 | - } |
|
64 | + /** |
|
65 | + * @return void |
|
66 | + * @action init |
|
67 | + */ |
|
68 | + public function registerTaxonomy() |
|
69 | + { |
|
70 | + $command = new RegisterTaxonomy([ |
|
71 | + 'hierarchical' => true, |
|
72 | + 'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
73 | + 'public' => false, |
|
74 | + 'rest_controller_class' => RestCategoryController::class, |
|
75 | + 'show_admin_column' => true, |
|
76 | + 'show_in_rest' => true, |
|
77 | + 'show_ui' => true, |
|
78 | + ]); |
|
79 | + $this->execute($command); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return void |
|
84 | - * @action widgets_init |
|
85 | - */ |
|
86 | - public function registerWidgets() |
|
87 | - { |
|
88 | - $command = new RegisterWidgets([ |
|
89 | - 'site-reviews' => [ |
|
90 | - 'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'), |
|
91 | - 'name' => __('Recent Reviews', 'site-reviews'), |
|
92 | - ], |
|
93 | - 'site-reviews-form' => [ |
|
94 | - 'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'), |
|
95 | - 'name' => __('Submit a Review', 'site-reviews'), |
|
96 | - ], |
|
97 | - 'site-reviews-summary' => [ |
|
98 | - 'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'), |
|
99 | - 'name' => __('Summary of Reviews', 'site-reviews'), |
|
100 | - ], |
|
101 | - ]); |
|
102 | - $this->execute($command); |
|
103 | - } |
|
82 | + /** |
|
83 | + * @return void |
|
84 | + * @action widgets_init |
|
85 | + */ |
|
86 | + public function registerWidgets() |
|
87 | + { |
|
88 | + $command = new RegisterWidgets([ |
|
89 | + 'site-reviews' => [ |
|
90 | + 'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'), |
|
91 | + 'name' => __('Recent Reviews', 'site-reviews'), |
|
92 | + ], |
|
93 | + 'site-reviews-form' => [ |
|
94 | + 'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'), |
|
95 | + 'name' => __('Submit a Review', 'site-reviews'), |
|
96 | + ], |
|
97 | + 'site-reviews-summary' => [ |
|
98 | + 'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'), |
|
99 | + 'name' => __('Summary of Reviews', 'site-reviews'), |
|
100 | + ], |
|
101 | + ]); |
|
102 | + $this->execute($command); |
|
103 | + } |
|
104 | 104 | } |
@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function registerPostType() |
18 | 18 | { |
19 | - if (!glsr()->hasPermission()) { |
|
19 | + if( !glsr()->hasPermission() ) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | - $command = new RegisterPostType([ |
|
22 | + $command = new RegisterPostType( [ |
|
23 | 23 | 'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
24 | 24 | 'capability_type' => Application::POST_TYPE, |
25 | 25 | 'columns' => [ |
26 | 26 | 'title' => '', |
27 | 27 | 'category' => '', |
28 | - 'assigned_to' => __('Assigned To', 'site-reviews'), |
|
29 | - 'reviewer' => __('Author', 'site-reviews'), |
|
30 | - 'email' => __('Email', 'site-reviews'), |
|
31 | - 'ip_address' => __('IP Address', 'site-reviews'), |
|
32 | - 'response' => __('Response', 'site-reviews'), |
|
33 | - 'review_type' => __('Type', 'site-reviews'), |
|
34 | - 'rating' => __('Rating', 'site-reviews'), |
|
35 | - 'pinned' => __('Pinned', 'site-reviews'), |
|
28 | + 'assigned_to' => __( 'Assigned To', 'site-reviews' ), |
|
29 | + 'reviewer' => __( 'Author', 'site-reviews' ), |
|
30 | + 'email' => __( 'Email', 'site-reviews' ), |
|
31 | + 'ip_address' => __( 'IP Address', 'site-reviews' ), |
|
32 | + 'response' => __( 'Response', 'site-reviews' ), |
|
33 | + 'review_type' => __( 'Type', 'site-reviews' ), |
|
34 | + 'rating' => __( 'Rating', 'site-reviews' ), |
|
35 | + 'pinned' => __( 'Pinned', 'site-reviews' ), |
|
36 | 36 | 'date' => '', |
37 | 37 | ], |
38 | 38 | 'menu_icon' => 'dashicons-star-half', |
39 | 39 | 'menu_name' => glsr()->name, |
40 | 40 | 'map_meta_cap' => true, |
41 | - 'plural' => __('Reviews', 'site-reviews'), |
|
41 | + 'plural' => __( 'Reviews', 'site-reviews' ), |
|
42 | 42 | 'post_type' => Application::POST_TYPE, |
43 | 43 | 'rest_controller_class' => RestReviewController::class, |
44 | 44 | 'show_in_rest' => true, |
45 | - 'single' => __('Review', 'site-reviews'), |
|
46 | - ]); |
|
47 | - $this->execute($command); |
|
45 | + 'single' => __( 'Review', 'site-reviews' ), |
|
46 | + ] ); |
|
47 | + $this->execute( $command ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function registerShortcodes() |
55 | 55 | { |
56 | - $command = new RegisterShortcodes([ |
|
56 | + $command = new RegisterShortcodes( [ |
|
57 | 57 | 'site_reviews', |
58 | 58 | 'site_reviews_form', |
59 | 59 | 'site_reviews_summary', |
60 | - ]); |
|
61 | - $this->execute($command); |
|
60 | + ] ); |
|
61 | + $this->execute( $command ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function registerTaxonomy() |
69 | 69 | { |
70 | - $command = new RegisterTaxonomy([ |
|
70 | + $command = new RegisterTaxonomy( [ |
|
71 | 71 | 'hierarchical' => true, |
72 | - 'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
72 | + 'meta_box_cb' => [glsr( EditorController::class ), 'renderTaxonomyMetabox'], |
|
73 | 73 | 'public' => false, |
74 | 74 | 'rest_controller_class' => RestCategoryController::class, |
75 | 75 | 'show_admin_column' => true, |
76 | 76 | 'show_in_rest' => true, |
77 | 77 | 'show_ui' => true, |
78 | - ]); |
|
79 | - $this->execute($command); |
|
78 | + ] ); |
|
79 | + $this->execute( $command ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,20 +85,20 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function registerWidgets() |
87 | 87 | { |
88 | - $command = new RegisterWidgets([ |
|
88 | + $command = new RegisterWidgets( [ |
|
89 | 89 | 'site-reviews' => [ |
90 | - 'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'), |
|
91 | - 'name' => __('Recent Reviews', 'site-reviews'), |
|
90 | + 'description' => __( 'Site Reviews: Display your recent reviews.', 'site-reviews' ), |
|
91 | + 'name' => __( 'Recent Reviews', 'site-reviews' ), |
|
92 | 92 | ], |
93 | 93 | 'site-reviews-form' => [ |
94 | - 'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'), |
|
95 | - 'name' => __('Submit a Review', 'site-reviews'), |
|
94 | + 'description' => __( 'Site Reviews: Display a form to submit reviews.', 'site-reviews' ), |
|
95 | + 'name' => __( 'Submit a Review', 'site-reviews' ), |
|
96 | 96 | ], |
97 | 97 | 'site-reviews-summary' => [ |
98 | - 'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'), |
|
99 | - 'name' => __('Summary of Reviews', 'site-reviews'), |
|
98 | + 'description' => __( 'Site Reviews: Display a summary of your reviews.', 'site-reviews' ), |
|
99 | + 'name' => __( 'Summary of Reviews', 'site-reviews' ), |
|
100 | 100 | ], |
101 | - ]); |
|
102 | - $this->execute($command); |
|
101 | + ] ); |
|
102 | + $this->execute( $command ); |
|
103 | 103 | } |
104 | 104 | } |
@@ -8,86 +8,86 @@ |
||
8 | 8 | |
9 | 9 | class BlocksController extends Controller |
10 | 10 | { |
11 | - /** |
|
12 | - * @param array $categories |
|
13 | - * @return array |
|
14 | - * @filter block_categories |
|
15 | - */ |
|
16 | - public function filterBlockCategories($categories) |
|
17 | - { |
|
18 | - $categories = Arr::consolidate($categories); |
|
19 | - $categories[] = [ |
|
20 | - 'icon' => null, |
|
21 | - 'slug' => Application::ID, |
|
22 | - 'title' => glsr()->name, |
|
23 | - ]; |
|
24 | - return $categories; |
|
25 | - } |
|
11 | + /** |
|
12 | + * @param array $categories |
|
13 | + * @return array |
|
14 | + * @filter block_categories |
|
15 | + */ |
|
16 | + public function filterBlockCategories($categories) |
|
17 | + { |
|
18 | + $categories = Arr::consolidate($categories); |
|
19 | + $categories[] = [ |
|
20 | + 'icon' => null, |
|
21 | + 'slug' => Application::ID, |
|
22 | + 'title' => glsr()->name, |
|
23 | + ]; |
|
24 | + return $categories; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @param array $editors |
|
29 | - * @param string $postType |
|
30 | - * @return array |
|
31 | - * @filter classic_editor_enabled_editors_for_post_type |
|
32 | - * @plugin classic-editor/classic-editor.php |
|
33 | - */ |
|
34 | - public function filterEnabledEditors($editors, $postType) |
|
35 | - { |
|
36 | - return Application::POST_TYPE == $postType |
|
37 | - ? ['block_editor' => false, 'classic_editor' => false] |
|
38 | - : $editors; |
|
39 | - } |
|
27 | + /** |
|
28 | + * @param array $editors |
|
29 | + * @param string $postType |
|
30 | + * @return array |
|
31 | + * @filter classic_editor_enabled_editors_for_post_type |
|
32 | + * @plugin classic-editor/classic-editor.php |
|
33 | + */ |
|
34 | + public function filterEnabledEditors($editors, $postType) |
|
35 | + { |
|
36 | + return Application::POST_TYPE == $postType |
|
37 | + ? ['block_editor' => false, 'classic_editor' => false] |
|
38 | + : $editors; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param bool $bool |
|
43 | - * @param string $postType |
|
44 | - * @return bool |
|
45 | - * @filter use_block_editor_for_post_type |
|
46 | - */ |
|
47 | - public function filterUseBlockEditor($bool, $postType) |
|
48 | - { |
|
49 | - return Application::POST_TYPE == $postType |
|
50 | - ? false |
|
51 | - : $bool; |
|
52 | - } |
|
41 | + /** |
|
42 | + * @param bool $bool |
|
43 | + * @param string $postType |
|
44 | + * @return bool |
|
45 | + * @filter use_block_editor_for_post_type |
|
46 | + */ |
|
47 | + public function filterUseBlockEditor($bool, $postType) |
|
48 | + { |
|
49 | + return Application::POST_TYPE == $postType |
|
50 | + ? false |
|
51 | + : $bool; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return void |
|
56 | - * @action init |
|
57 | - */ |
|
58 | - public function registerAssets() |
|
59 | - { |
|
60 | - wp_register_style( |
|
61 | - Application::ID.'/blocks', |
|
62 | - glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
63 | - ['wp-edit-blocks'], |
|
64 | - glsr()->version |
|
65 | - ); |
|
66 | - wp_register_script( |
|
67 | - Application::ID.'/blocks', |
|
68 | - glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
69 | - ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID.'/admin'], |
|
70 | - glsr()->version |
|
71 | - ); |
|
72 | - } |
|
54 | + /** |
|
55 | + * @return void |
|
56 | + * @action init |
|
57 | + */ |
|
58 | + public function registerAssets() |
|
59 | + { |
|
60 | + wp_register_style( |
|
61 | + Application::ID.'/blocks', |
|
62 | + glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
63 | + ['wp-edit-blocks'], |
|
64 | + glsr()->version |
|
65 | + ); |
|
66 | + wp_register_script( |
|
67 | + Application::ID.'/blocks', |
|
68 | + glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
69 | + ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID.'/admin'], |
|
70 | + glsr()->version |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return void |
|
76 | - * @action init |
|
77 | - */ |
|
78 | - public function registerBlocks() |
|
79 | - { |
|
80 | - $blocks = [ |
|
81 | - 'form', 'reviews', 'summary', |
|
82 | - ]; |
|
83 | - foreach ($blocks as $block) { |
|
84 | - $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
85 | - $blockClass = Helper::buildClassName($id.'-block', 'Blocks'); |
|
86 | - if (!class_exists($blockClass)) { |
|
87 | - glsr_log()->error(sprintf('Block class missing (%s)', $blockClass)); |
|
88 | - continue; |
|
89 | - } |
|
90 | - glsr($blockClass)->register($block); |
|
91 | - } |
|
92 | - } |
|
74 | + /** |
|
75 | + * @return void |
|
76 | + * @action init |
|
77 | + */ |
|
78 | + public function registerBlocks() |
|
79 | + { |
|
80 | + $blocks = [ |
|
81 | + 'form', 'reviews', 'summary', |
|
82 | + ]; |
|
83 | + foreach ($blocks as $block) { |
|
84 | + $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
85 | + $blockClass = Helper::buildClassName($id.'-block', 'Blocks'); |
|
86 | + if (!class_exists($blockClass)) { |
|
87 | + glsr_log()->error(sprintf('Block class missing (%s)', $blockClass)); |
|
88 | + continue; |
|
89 | + } |
|
90 | + glsr($blockClass)->register($block); |
|
91 | + } |
|
92 | + } |
|
93 | 93 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | * @return array |
14 | 14 | * @filter block_categories |
15 | 15 | */ |
16 | - public function filterBlockCategories($categories) |
|
16 | + public function filterBlockCategories( $categories ) |
|
17 | 17 | { |
18 | - $categories = Arr::consolidate($categories); |
|
18 | + $categories = Arr::consolidate( $categories ); |
|
19 | 19 | $categories[] = [ |
20 | 20 | 'icon' => null, |
21 | 21 | 'slug' => Application::ID, |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @filter classic_editor_enabled_editors_for_post_type |
32 | 32 | * @plugin classic-editor/classic-editor.php |
33 | 33 | */ |
34 | - public function filterEnabledEditors($editors, $postType) |
|
34 | + public function filterEnabledEditors( $editors, $postType ) |
|
35 | 35 | { |
36 | 36 | return Application::POST_TYPE == $postType |
37 | 37 | ? ['block_editor' => false, 'classic_editor' => false] |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return bool |
45 | 45 | * @filter use_block_editor_for_post_type |
46 | 46 | */ |
47 | - public function filterUseBlockEditor($bool, $postType) |
|
47 | + public function filterUseBlockEditor( $bool, $postType ) |
|
48 | 48 | { |
49 | 49 | return Application::POST_TYPE == $postType |
50 | 50 | ? false |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | { |
60 | 60 | wp_register_style( |
61 | 61 | Application::ID.'/blocks', |
62 | - glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
62 | + glsr()->url( 'assets/styles/'.Application::ID.'-blocks.css' ), |
|
63 | 63 | ['wp-edit-blocks'], |
64 | 64 | glsr()->version |
65 | 65 | ); |
66 | 66 | wp_register_script( |
67 | 67 | Application::ID.'/blocks', |
68 | - glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
68 | + glsr()->url( 'assets/scripts/'.Application::ID.'-blocks.js' ), |
|
69 | 69 | ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID.'/admin'], |
70 | 70 | glsr()->version |
71 | 71 | ); |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | $blocks = [ |
81 | 81 | 'form', 'reviews', 'summary', |
82 | 82 | ]; |
83 | - foreach ($blocks as $block) { |
|
84 | - $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
85 | - $blockClass = Helper::buildClassName($id.'-block', 'Blocks'); |
|
86 | - if (!class_exists($blockClass)) { |
|
87 | - glsr_log()->error(sprintf('Block class missing (%s)', $blockClass)); |
|
83 | + foreach( $blocks as $block ) { |
|
84 | + $id = str_replace( '_reviews', '', Application::ID.'_'.$block ); |
|
85 | + $blockClass = Helper::buildClassName( $id.'-block', 'Blocks' ); |
|
86 | + if( !class_exists( $blockClass ) ) { |
|
87 | + glsr_log()->error( sprintf( 'Block class missing (%s)', $blockClass ) ); |
|
88 | 88 | continue; |
89 | 89 | } |
90 | - glsr($blockClass)->register($block); |
|
90 | + glsr( $blockClass )->register( $block ); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
@@ -10,228 +10,228 @@ |
||
10 | 10 | |
11 | 11 | class TranslationController |
12 | 12 | { |
13 | - /** |
|
14 | - * @var Translator |
|
15 | - */ |
|
16 | - public $translator; |
|
17 | - |
|
18 | - public function __construct(Translator $translator) |
|
19 | - { |
|
20 | - $this->translator = $translator; |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * @param array $messages |
|
25 | - * @return array |
|
26 | - * @filter bulk_post_updated_messages |
|
27 | - */ |
|
28 | - public function filterBulkUpdateMessages($messages, array $counts) |
|
29 | - { |
|
30 | - $messages = Arr::consolidate($messages); |
|
31 | - $messages[Application::POST_TYPE] = [ |
|
32 | - 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
33 | - 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
34 | - 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
35 | - 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
36 | - 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
37 | - ]; |
|
38 | - return $messages; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $translation |
|
43 | - * @param string $text |
|
44 | - * @param string $domain |
|
45 | - * @return string |
|
46 | - * @filter gettext |
|
47 | - */ |
|
48 | - public function filterGettext($translation, $text, $domain) |
|
49 | - { |
|
50 | - return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * @param string $translation |
|
55 | - * @param string $text |
|
56 | - * @return string |
|
57 | - * @filter site-reviews/gettext/site-reviews |
|
58 | - */ |
|
59 | - public function filterGettextSiteReviews($translation, $text) |
|
60 | - { |
|
61 | - return $this->translator->translate($translation, Application::ID, [ |
|
62 | - 'single' => $text, |
|
63 | - ]); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @param string $translation |
|
68 | - * @param string $text |
|
69 | - * @param string $context |
|
70 | - * @param string $domain |
|
71 | - * @return string |
|
72 | - * @filter gettext_with_context |
|
73 | - */ |
|
74 | - public function filterGettextWithContext($translation, $text, $context, $domain) |
|
75 | - { |
|
76 | - return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @param string $translation |
|
81 | - * @param string $text |
|
82 | - * @param string $context |
|
83 | - * @return string |
|
84 | - * @filter site-reviews/gettext_with_context/site-reviews |
|
85 | - */ |
|
86 | - public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
87 | - { |
|
88 | - return $this->translator->translate($translation, Application::ID, [ |
|
89 | - 'context' => $context, |
|
90 | - 'single' => $text, |
|
91 | - ]); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * @param string $translation |
|
96 | - * @param string $single |
|
97 | - * @param string $plural |
|
98 | - * @param int $number |
|
99 | - * @param string $domain |
|
100 | - * @return string |
|
101 | - * @filter ngettext |
|
102 | - */ |
|
103 | - public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
104 | - { |
|
105 | - return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $translation |
|
110 | - * @param string $single |
|
111 | - * @param string $plural |
|
112 | - * @param int $number |
|
113 | - * @return string |
|
114 | - * @filter site-reviews/ngettext/site-reviews |
|
115 | - */ |
|
116 | - public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
117 | - { |
|
118 | - return $this->translator->translate($translation, Application::ID, [ |
|
119 | - 'number' => $number, |
|
120 | - 'plural' => $plural, |
|
121 | - 'single' => $single, |
|
122 | - ]); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @param string $translation |
|
127 | - * @param string $single |
|
128 | - * @param string $plural |
|
129 | - * @param int $number |
|
130 | - * @param string $context |
|
131 | - * @param string $domain |
|
132 | - * @return string |
|
133 | - * @filter ngettext_with_context |
|
134 | - */ |
|
135 | - public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
136 | - { |
|
137 | - return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @param string $translation |
|
142 | - * @param string $single |
|
143 | - * @param string $plural |
|
144 | - * @param int $number |
|
145 | - * @param string $context |
|
146 | - * @return string |
|
147 | - * @filter site-reviews/ngettext_with_context/site-reviews |
|
148 | - */ |
|
149 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
150 | - { |
|
151 | - return $this->translator->translate($translation, Application::ID, [ |
|
152 | - 'context' => $context, |
|
153 | - 'number' => $number, |
|
154 | - 'plural' => $plural, |
|
155 | - 'single' => $single, |
|
156 | - ]); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * @param array $postStates |
|
161 | - * @param \WP_Post $post |
|
162 | - * @return array |
|
163 | - * @filter display_post_states |
|
164 | - */ |
|
165 | - public function filterPostStates($postStates, $post) |
|
166 | - { |
|
167 | - $postStates = Arr::consolidate($postStates); |
|
168 | - if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
169 | - $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
170 | - } |
|
171 | - return $postStates; |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * @param string $translation |
|
176 | - * @param string $text |
|
177 | - * @return string |
|
178 | - * @filter site-reviews/gettext/default |
|
179 | - * @filter site-reviews/gettext_with_context/default |
|
180 | - */ |
|
181 | - public function filterPostStatusLabels($translation, $text) |
|
182 | - { |
|
183 | - return $this->canModifyTranslation() |
|
184 | - ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
185 | - : $translation; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * @param string $translation |
|
190 | - * @param string $single |
|
191 | - * @param string $plural |
|
192 | - * @param int $number |
|
193 | - * @return string |
|
194 | - * @filter site-reviews/ngettext/default |
|
195 | - */ |
|
196 | - public function filterPostStatusText($translation, $single, $plural, $number) |
|
197 | - { |
|
198 | - if ($this->canModifyTranslation()) { |
|
199 | - $strings = [ |
|
200 | - 'Published' => __('Approved', 'site-reviews'), |
|
201 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
202 | - ]; |
|
203 | - foreach ($strings as $search => $replace) { |
|
204 | - if (!Str::contains($single, $search)) { |
|
205 | - continue; |
|
206 | - } |
|
207 | - return $this->translator->getTranslation([ |
|
208 | - 'number' => $number, |
|
209 | - 'plural' => str_replace($search, $replace, $plural), |
|
210 | - 'single' => str_replace($search, $replace, $single), |
|
211 | - ]); |
|
212 | - } |
|
213 | - } |
|
214 | - return $translation; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * @return void |
|
219 | - * @action admin_enqueue_scripts |
|
220 | - */ |
|
221 | - public function translatePostStatusLabels() |
|
222 | - { |
|
223 | - if ($this->canModifyTranslation()) { |
|
224 | - glsr(Labels::class)->translatePostStatusLabels(); |
|
225 | - } |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * @return bool |
|
230 | - */ |
|
231 | - protected function canModifyTranslation() |
|
232 | - { |
|
233 | - $screen = glsr_current_screen(); |
|
234 | - return Application::POST_TYPE == $screen->post_type |
|
235 | - && in_array($screen->base, ['edit', 'post']); |
|
236 | - } |
|
13 | + /** |
|
14 | + * @var Translator |
|
15 | + */ |
|
16 | + public $translator; |
|
17 | + |
|
18 | + public function __construct(Translator $translator) |
|
19 | + { |
|
20 | + $this->translator = $translator; |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * @param array $messages |
|
25 | + * @return array |
|
26 | + * @filter bulk_post_updated_messages |
|
27 | + */ |
|
28 | + public function filterBulkUpdateMessages($messages, array $counts) |
|
29 | + { |
|
30 | + $messages = Arr::consolidate($messages); |
|
31 | + $messages[Application::POST_TYPE] = [ |
|
32 | + 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
33 | + 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
34 | + 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
35 | + 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
36 | + 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
37 | + ]; |
|
38 | + return $messages; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $translation |
|
43 | + * @param string $text |
|
44 | + * @param string $domain |
|
45 | + * @return string |
|
46 | + * @filter gettext |
|
47 | + */ |
|
48 | + public function filterGettext($translation, $text, $domain) |
|
49 | + { |
|
50 | + return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * @param string $translation |
|
55 | + * @param string $text |
|
56 | + * @return string |
|
57 | + * @filter site-reviews/gettext/site-reviews |
|
58 | + */ |
|
59 | + public function filterGettextSiteReviews($translation, $text) |
|
60 | + { |
|
61 | + return $this->translator->translate($translation, Application::ID, [ |
|
62 | + 'single' => $text, |
|
63 | + ]); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @param string $translation |
|
68 | + * @param string $text |
|
69 | + * @param string $context |
|
70 | + * @param string $domain |
|
71 | + * @return string |
|
72 | + * @filter gettext_with_context |
|
73 | + */ |
|
74 | + public function filterGettextWithContext($translation, $text, $context, $domain) |
|
75 | + { |
|
76 | + return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @param string $translation |
|
81 | + * @param string $text |
|
82 | + * @param string $context |
|
83 | + * @return string |
|
84 | + * @filter site-reviews/gettext_with_context/site-reviews |
|
85 | + */ |
|
86 | + public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
87 | + { |
|
88 | + return $this->translator->translate($translation, Application::ID, [ |
|
89 | + 'context' => $context, |
|
90 | + 'single' => $text, |
|
91 | + ]); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * @param string $translation |
|
96 | + * @param string $single |
|
97 | + * @param string $plural |
|
98 | + * @param int $number |
|
99 | + * @param string $domain |
|
100 | + * @return string |
|
101 | + * @filter ngettext |
|
102 | + */ |
|
103 | + public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
104 | + { |
|
105 | + return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $translation |
|
110 | + * @param string $single |
|
111 | + * @param string $plural |
|
112 | + * @param int $number |
|
113 | + * @return string |
|
114 | + * @filter site-reviews/ngettext/site-reviews |
|
115 | + */ |
|
116 | + public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
117 | + { |
|
118 | + return $this->translator->translate($translation, Application::ID, [ |
|
119 | + 'number' => $number, |
|
120 | + 'plural' => $plural, |
|
121 | + 'single' => $single, |
|
122 | + ]); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @param string $translation |
|
127 | + * @param string $single |
|
128 | + * @param string $plural |
|
129 | + * @param int $number |
|
130 | + * @param string $context |
|
131 | + * @param string $domain |
|
132 | + * @return string |
|
133 | + * @filter ngettext_with_context |
|
134 | + */ |
|
135 | + public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
136 | + { |
|
137 | + return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @param string $translation |
|
142 | + * @param string $single |
|
143 | + * @param string $plural |
|
144 | + * @param int $number |
|
145 | + * @param string $context |
|
146 | + * @return string |
|
147 | + * @filter site-reviews/ngettext_with_context/site-reviews |
|
148 | + */ |
|
149 | + public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
150 | + { |
|
151 | + return $this->translator->translate($translation, Application::ID, [ |
|
152 | + 'context' => $context, |
|
153 | + 'number' => $number, |
|
154 | + 'plural' => $plural, |
|
155 | + 'single' => $single, |
|
156 | + ]); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * @param array $postStates |
|
161 | + * @param \WP_Post $post |
|
162 | + * @return array |
|
163 | + * @filter display_post_states |
|
164 | + */ |
|
165 | + public function filterPostStates($postStates, $post) |
|
166 | + { |
|
167 | + $postStates = Arr::consolidate($postStates); |
|
168 | + if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
169 | + $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
170 | + } |
|
171 | + return $postStates; |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * @param string $translation |
|
176 | + * @param string $text |
|
177 | + * @return string |
|
178 | + * @filter site-reviews/gettext/default |
|
179 | + * @filter site-reviews/gettext_with_context/default |
|
180 | + */ |
|
181 | + public function filterPostStatusLabels($translation, $text) |
|
182 | + { |
|
183 | + return $this->canModifyTranslation() |
|
184 | + ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
185 | + : $translation; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * @param string $translation |
|
190 | + * @param string $single |
|
191 | + * @param string $plural |
|
192 | + * @param int $number |
|
193 | + * @return string |
|
194 | + * @filter site-reviews/ngettext/default |
|
195 | + */ |
|
196 | + public function filterPostStatusText($translation, $single, $plural, $number) |
|
197 | + { |
|
198 | + if ($this->canModifyTranslation()) { |
|
199 | + $strings = [ |
|
200 | + 'Published' => __('Approved', 'site-reviews'), |
|
201 | + 'Pending' => __('Unapproved', 'site-reviews'), |
|
202 | + ]; |
|
203 | + foreach ($strings as $search => $replace) { |
|
204 | + if (!Str::contains($single, $search)) { |
|
205 | + continue; |
|
206 | + } |
|
207 | + return $this->translator->getTranslation([ |
|
208 | + 'number' => $number, |
|
209 | + 'plural' => str_replace($search, $replace, $plural), |
|
210 | + 'single' => str_replace($search, $replace, $single), |
|
211 | + ]); |
|
212 | + } |
|
213 | + } |
|
214 | + return $translation; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * @return void |
|
219 | + * @action admin_enqueue_scripts |
|
220 | + */ |
|
221 | + public function translatePostStatusLabels() |
|
222 | + { |
|
223 | + if ($this->canModifyTranslation()) { |
|
224 | + glsr(Labels::class)->translatePostStatusLabels(); |
|
225 | + } |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * @return bool |
|
230 | + */ |
|
231 | + protected function canModifyTranslation() |
|
232 | + { |
|
233 | + $screen = glsr_current_screen(); |
|
234 | + return Application::POST_TYPE == $screen->post_type |
|
235 | + && in_array($screen->base, ['edit', 'post']); |
|
236 | + } |
|
237 | 237 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public $translator; |
17 | 17 | |
18 | - public function __construct(Translator $translator) |
|
18 | + public function __construct( Translator $translator ) |
|
19 | 19 | { |
20 | 20 | $this->translator = $translator; |
21 | 21 | } |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | * @return array |
26 | 26 | * @filter bulk_post_updated_messages |
27 | 27 | */ |
28 | - public function filterBulkUpdateMessages($messages, array $counts) |
|
28 | + public function filterBulkUpdateMessages( $messages, array $counts ) |
|
29 | 29 | { |
30 | - $messages = Arr::consolidate($messages); |
|
30 | + $messages = Arr::consolidate( $messages ); |
|
31 | 31 | $messages[Application::POST_TYPE] = [ |
32 | - 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
33 | - 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
34 | - 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
35 | - 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
36 | - 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
32 | + 'updated' => _n( '%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews' ), |
|
33 | + 'locked' => _n( '%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews' ), |
|
34 | + 'deleted' => _n( '%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews' ), |
|
35 | + 'trashed' => _n( '%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews' ), |
|
36 | + 'untrashed' => _n( '%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews' ), |
|
37 | 37 | ]; |
38 | 38 | return $messages; |
39 | 39 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @return string |
46 | 46 | * @filter gettext |
47 | 47 | */ |
48 | - public function filterGettext($translation, $text, $domain) |
|
48 | + public function filterGettext( $translation, $text, $domain ) |
|
49 | 49 | { |
50 | - return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
50 | + return apply_filters( 'site-reviews/gettext/'.$domain, $translation, $text ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | * @return string |
57 | 57 | * @filter site-reviews/gettext/site-reviews |
58 | 58 | */ |
59 | - public function filterGettextSiteReviews($translation, $text) |
|
59 | + public function filterGettextSiteReviews( $translation, $text ) |
|
60 | 60 | { |
61 | - return $this->translator->translate($translation, Application::ID, [ |
|
61 | + return $this->translator->translate( $translation, Application::ID, [ |
|
62 | 62 | 'single' => $text, |
63 | - ]); |
|
63 | + ] ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * @return string |
72 | 72 | * @filter gettext_with_context |
73 | 73 | */ |
74 | - public function filterGettextWithContext($translation, $text, $context, $domain) |
|
74 | + public function filterGettextWithContext( $translation, $text, $context, $domain ) |
|
75 | 75 | { |
76 | - return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
76 | + return apply_filters( 'site-reviews/gettext_with_context/'.$domain, $translation, $text, $context ); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | * @return string |
84 | 84 | * @filter site-reviews/gettext_with_context/site-reviews |
85 | 85 | */ |
86 | - public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
86 | + public function filterGettextWithContextSiteReviews( $translation, $text, $context ) |
|
87 | 87 | { |
88 | - return $this->translator->translate($translation, Application::ID, [ |
|
88 | + return $this->translator->translate( $translation, Application::ID, [ |
|
89 | 89 | 'context' => $context, |
90 | 90 | 'single' => $text, |
91 | - ]); |
|
91 | + ] ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * @return string |
101 | 101 | * @filter ngettext |
102 | 102 | */ |
103 | - public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
103 | + public function filterNgettext( $translation, $single, $plural, $number, $domain ) |
|
104 | 104 | { |
105 | - return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
105 | + return apply_filters( 'site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | * @return string |
114 | 114 | * @filter site-reviews/ngettext/site-reviews |
115 | 115 | */ |
116 | - public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
116 | + public function filterNgettextSiteReviews( $translation, $single, $plural, $number ) |
|
117 | 117 | { |
118 | - return $this->translator->translate($translation, Application::ID, [ |
|
118 | + return $this->translator->translate( $translation, Application::ID, [ |
|
119 | 119 | 'number' => $number, |
120 | 120 | 'plural' => $plural, |
121 | 121 | 'single' => $single, |
122 | - ]); |
|
122 | + ] ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | * @return string |
133 | 133 | * @filter ngettext_with_context |
134 | 134 | */ |
135 | - public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
135 | + public function filterNgettextWithContext( $translation, $single, $plural, $number, $context, $domain ) |
|
136 | 136 | { |
137 | - return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
137 | + return apply_filters( 'site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | * @return string |
147 | 147 | * @filter site-reviews/ngettext_with_context/site-reviews |
148 | 148 | */ |
149 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
149 | + public function filterNgettextWithContextSiteReviews( $translation, $single, $plural, $number, $context ) |
|
150 | 150 | { |
151 | - return $this->translator->translate($translation, Application::ID, [ |
|
151 | + return $this->translator->translate( $translation, Application::ID, [ |
|
152 | 152 | 'context' => $context, |
153 | 153 | 'number' => $number, |
154 | 154 | 'plural' => $plural, |
155 | 155 | 'single' => $single, |
156 | - ]); |
|
156 | + ] ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | * @return array |
163 | 163 | * @filter display_post_states |
164 | 164 | */ |
165 | - public function filterPostStates($postStates, $post) |
|
165 | + public function filterPostStates( $postStates, $post ) |
|
166 | 166 | { |
167 | - $postStates = Arr::consolidate($postStates); |
|
168 | - if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
169 | - $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
167 | + $postStates = Arr::consolidate( $postStates ); |
|
168 | + if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) && array_key_exists( 'pending', $postStates ) ) { |
|
169 | + $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
|
170 | 170 | } |
171 | 171 | return $postStates; |
172 | 172 | } |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | * @filter site-reviews/gettext/default |
179 | 179 | * @filter site-reviews/gettext_with_context/default |
180 | 180 | */ |
181 | - public function filterPostStatusLabels($translation, $text) |
|
181 | + public function filterPostStatusLabels( $translation, $text ) |
|
182 | 182 | { |
183 | 183 | return $this->canModifyTranslation() |
184 | - ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
184 | + ? glsr( Labels::class )->filterPostStatusLabels( $translation, $text ) |
|
185 | 185 | : $translation; |
186 | 186 | } |
187 | 187 | |
@@ -193,22 +193,22 @@ discard block |
||
193 | 193 | * @return string |
194 | 194 | * @filter site-reviews/ngettext/default |
195 | 195 | */ |
196 | - public function filterPostStatusText($translation, $single, $plural, $number) |
|
196 | + public function filterPostStatusText( $translation, $single, $plural, $number ) |
|
197 | 197 | { |
198 | - if ($this->canModifyTranslation()) { |
|
198 | + if( $this->canModifyTranslation() ) { |
|
199 | 199 | $strings = [ |
200 | - 'Published' => __('Approved', 'site-reviews'), |
|
201 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
200 | + 'Published' => __( 'Approved', 'site-reviews' ), |
|
201 | + 'Pending' => __( 'Unapproved', 'site-reviews' ), |
|
202 | 202 | ]; |
203 | - foreach ($strings as $search => $replace) { |
|
204 | - if (!Str::contains($single, $search)) { |
|
203 | + foreach( $strings as $search => $replace ) { |
|
204 | + if( !Str::contains( $single, $search ) ) { |
|
205 | 205 | continue; |
206 | 206 | } |
207 | - return $this->translator->getTranslation([ |
|
207 | + return $this->translator->getTranslation( [ |
|
208 | 208 | 'number' => $number, |
209 | - 'plural' => str_replace($search, $replace, $plural), |
|
210 | - 'single' => str_replace($search, $replace, $single), |
|
211 | - ]); |
|
209 | + 'plural' => str_replace( $search, $replace, $plural ), |
|
210 | + 'single' => str_replace( $search, $replace, $single ), |
|
211 | + ] ); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | return $translation; |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function translatePostStatusLabels() |
222 | 222 | { |
223 | - if ($this->canModifyTranslation()) { |
|
224 | - glsr(Labels::class)->translatePostStatusLabels(); |
|
223 | + if( $this->canModifyTranslation() ) { |
|
224 | + glsr( Labels::class )->translatePostStatusLabels(); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
@@ -232,6 +232,6 @@ discard block |
||
232 | 232 | { |
233 | 233 | $screen = glsr_current_screen(); |
234 | 234 | return Application::POST_TYPE == $screen->post_type |
235 | - && in_array($screen->base, ['edit', 'post']); |
|
235 | + && in_array( $screen->base, ['edit', 'post'] ); |
|
236 | 236 | } |
237 | 237 | } |
@@ -14,268 +14,268 @@ |
||
14 | 14 | |
15 | 15 | class ListTableController extends Controller |
16 | 16 | { |
17 | - /** |
|
18 | - * @return void |
|
19 | - * @action admin_action_approve |
|
20 | - */ |
|
21 | - public function approve() |
|
22 | - { |
|
23 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
24 | - return; |
|
25 | - } |
|
26 | - check_admin_referer('approve-review_'.($postId = $this->getPostId())); |
|
27 | - wp_update_post([ |
|
28 | - 'ID' => $postId, |
|
29 | - 'post_status' => 'publish', |
|
30 | - ]); |
|
31 | - wp_safe_redirect(wp_get_referer()); |
|
32 | - exit; |
|
33 | - } |
|
17 | + /** |
|
18 | + * @return void |
|
19 | + * @action admin_action_approve |
|
20 | + */ |
|
21 | + public function approve() |
|
22 | + { |
|
23 | + if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
24 | + return; |
|
25 | + } |
|
26 | + check_admin_referer('approve-review_'.($postId = $this->getPostId())); |
|
27 | + wp_update_post([ |
|
28 | + 'ID' => $postId, |
|
29 | + 'post_status' => 'publish', |
|
30 | + ]); |
|
31 | + wp_safe_redirect(wp_get_referer()); |
|
32 | + exit; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param array $columns |
|
37 | - * @return array |
|
38 | - * @filter manage_.Application::POST_TYPE._posts_columns |
|
39 | - */ |
|
40 | - public function filterColumnsForPostType($columns) |
|
41 | - { |
|
42 | - $columns = Arr::consolidate($columns); |
|
43 | - $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
44 | - foreach ($postTypeColumns as $key => &$value) { |
|
45 | - if (!array_key_exists($key, $columns) || !empty($value)) { |
|
46 | - continue; |
|
47 | - } |
|
48 | - $value = $columns[$key]; |
|
49 | - } |
|
50 | - if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) { |
|
51 | - unset($postTypeColumns['review_type']); |
|
52 | - } |
|
53 | - return array_filter($postTypeColumns, 'strlen'); |
|
54 | - } |
|
35 | + /** |
|
36 | + * @param array $columns |
|
37 | + * @return array |
|
38 | + * @filter manage_.Application::POST_TYPE._posts_columns |
|
39 | + */ |
|
40 | + public function filterColumnsForPostType($columns) |
|
41 | + { |
|
42 | + $columns = Arr::consolidate($columns); |
|
43 | + $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
44 | + foreach ($postTypeColumns as $key => &$value) { |
|
45 | + if (!array_key_exists($key, $columns) || !empty($value)) { |
|
46 | + continue; |
|
47 | + } |
|
48 | + $value = $columns[$key]; |
|
49 | + } |
|
50 | + if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) { |
|
51 | + unset($postTypeColumns['review_type']); |
|
52 | + } |
|
53 | + return array_filter($postTypeColumns, 'strlen'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $status |
|
58 | - * @param WP_Post $post |
|
59 | - * @return string |
|
60 | - * @filter post_date_column_status |
|
61 | - */ |
|
62 | - public function filterDateColumnStatus($status, $post) |
|
63 | - { |
|
64 | - if (Application::POST_TYPE == Arr::get($post, 'post_type')) { |
|
65 | - $status = __('Submitted', 'site-reviews'); |
|
66 | - } |
|
67 | - return $status; |
|
68 | - } |
|
56 | + /** |
|
57 | + * @param string $status |
|
58 | + * @param WP_Post $post |
|
59 | + * @return string |
|
60 | + * @filter post_date_column_status |
|
61 | + */ |
|
62 | + public function filterDateColumnStatus($status, $post) |
|
63 | + { |
|
64 | + if (Application::POST_TYPE == Arr::get($post, 'post_type')) { |
|
65 | + $status = __('Submitted', 'site-reviews'); |
|
66 | + } |
|
67 | + return $status; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @param array $hidden |
|
72 | - * @param WP_Screen $post |
|
73 | - * @return array |
|
74 | - * @filter default_hidden_columns |
|
75 | - */ |
|
76 | - public function filterDefaultHiddenColumns($hidden, $screen) |
|
77 | - { |
|
78 | - if (Arr::get($screen, 'id') == 'edit-'.Application::POST_TYPE) { |
|
79 | - $hidden = Arr::consolidate($hidden); |
|
80 | - $hidden = array_unique(array_merge($hidden, [ |
|
81 | - 'email', 'ip_address', 'response', 'reviewer', |
|
82 | - ])); |
|
83 | - } |
|
84 | - return $hidden; |
|
85 | - } |
|
70 | + /** |
|
71 | + * @param array $hidden |
|
72 | + * @param WP_Screen $post |
|
73 | + * @return array |
|
74 | + * @filter default_hidden_columns |
|
75 | + */ |
|
76 | + public function filterDefaultHiddenColumns($hidden, $screen) |
|
77 | + { |
|
78 | + if (Arr::get($screen, 'id') == 'edit-'.Application::POST_TYPE) { |
|
79 | + $hidden = Arr::consolidate($hidden); |
|
80 | + $hidden = array_unique(array_merge($hidden, [ |
|
81 | + 'email', 'ip_address', 'response', 'reviewer', |
|
82 | + ])); |
|
83 | + } |
|
84 | + return $hidden; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param array $actions |
|
89 | - * @param WP_Post $post |
|
90 | - * @return array |
|
91 | - * @filter post_row_actions |
|
92 | - */ |
|
93 | - public function filterRowActions($actions, $post) |
|
94 | - { |
|
95 | - if (Application::POST_TYPE != Arr::get($post, 'post_type') |
|
96 | - || 'trash' == $post->post_status |
|
97 | - || !user_can(get_current_user_id(), 'edit_post', $post->ID)) { |
|
98 | - return $actions; |
|
99 | - } |
|
100 | - unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
101 | - $rowActions = [ |
|
102 | - 'approve' => esc_attr__('Approve', 'site-reviews'), |
|
103 | - 'unapprove' => esc_attr__('Unapprove', 'site-reviews'), |
|
104 | - ]; |
|
105 | - $newActions = []; |
|
106 | - foreach ($rowActions as $key => $text) { |
|
107 | - $newActions[$key] = glsr(Builder::class)->a($text, [ |
|
108 | - 'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text), |
|
109 | - 'class' => 'glsr-change-status', |
|
110 | - 'href' => wp_nonce_url( |
|
111 | - admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID), |
|
112 | - $key.'-review_'.$post->ID |
|
113 | - ), |
|
114 | - ]); |
|
115 | - } |
|
116 | - return $newActions + Arr::consolidate($actions); |
|
117 | - } |
|
87 | + /** |
|
88 | + * @param array $actions |
|
89 | + * @param WP_Post $post |
|
90 | + * @return array |
|
91 | + * @filter post_row_actions |
|
92 | + */ |
|
93 | + public function filterRowActions($actions, $post) |
|
94 | + { |
|
95 | + if (Application::POST_TYPE != Arr::get($post, 'post_type') |
|
96 | + || 'trash' == $post->post_status |
|
97 | + || !user_can(get_current_user_id(), 'edit_post', $post->ID)) { |
|
98 | + return $actions; |
|
99 | + } |
|
100 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
101 | + $rowActions = [ |
|
102 | + 'approve' => esc_attr__('Approve', 'site-reviews'), |
|
103 | + 'unapprove' => esc_attr__('Unapprove', 'site-reviews'), |
|
104 | + ]; |
|
105 | + $newActions = []; |
|
106 | + foreach ($rowActions as $key => $text) { |
|
107 | + $newActions[$key] = glsr(Builder::class)->a($text, [ |
|
108 | + 'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text), |
|
109 | + 'class' => 'glsr-change-status', |
|
110 | + 'href' => wp_nonce_url( |
|
111 | + admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID), |
|
112 | + $key.'-review_'.$post->ID |
|
113 | + ), |
|
114 | + ]); |
|
115 | + } |
|
116 | + return $newActions + Arr::consolidate($actions); |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * @param array $columns |
|
121 | - * @return array |
|
122 | - * @filter manage_edit-.Application::POST_TYPE._sortable_columns |
|
123 | - */ |
|
124 | - public function filterSortableColumns($columns) |
|
125 | - { |
|
126 | - $columns = Arr::consolidate($columns); |
|
127 | - $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
128 | - unset($postTypeColumns['cb']); |
|
129 | - foreach ($postTypeColumns as $key => $value) { |
|
130 | - if (Str::startsWith('taxonomy', $key)) { |
|
131 | - continue; |
|
132 | - } |
|
133 | - $columns[$key] = $key; |
|
134 | - } |
|
135 | - return $columns; |
|
136 | - } |
|
119 | + /** |
|
120 | + * @param array $columns |
|
121 | + * @return array |
|
122 | + * @filter manage_edit-.Application::POST_TYPE._sortable_columns |
|
123 | + */ |
|
124 | + public function filterSortableColumns($columns) |
|
125 | + { |
|
126 | + $columns = Arr::consolidate($columns); |
|
127 | + $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
128 | + unset($postTypeColumns['cb']); |
|
129 | + foreach ($postTypeColumns as $key => $value) { |
|
130 | + if (Str::startsWith('taxonomy', $key)) { |
|
131 | + continue; |
|
132 | + } |
|
133 | + $columns[$key] = $key; |
|
134 | + } |
|
135 | + return $columns; |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * @param string $columnName |
|
140 | - * @param string $postType |
|
141 | - * @return void |
|
142 | - * @action bulk_edit_custom_box |
|
143 | - */ |
|
144 | - public function renderBulkEditFields($columnName, $postType) |
|
145 | - { |
|
146 | - if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) { |
|
147 | - glsr()->render('partials/editor/bulk-edit-assigned-to'); |
|
148 | - } |
|
149 | - } |
|
138 | + /** |
|
139 | + * @param string $columnName |
|
140 | + * @param string $postType |
|
141 | + * @return void |
|
142 | + * @action bulk_edit_custom_box |
|
143 | + */ |
|
144 | + public function renderBulkEditFields($columnName, $postType) |
|
145 | + { |
|
146 | + if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) { |
|
147 | + glsr()->render('partials/editor/bulk-edit-assigned-to'); |
|
148 | + } |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @param string $postType |
|
153 | - * @return void |
|
154 | - * @action restrict_manage_posts |
|
155 | - */ |
|
156 | - public function renderColumnFilters($postType) |
|
157 | - { |
|
158 | - glsr(Columns::class)->renderFilters($postType); |
|
159 | - } |
|
151 | + /** |
|
152 | + * @param string $postType |
|
153 | + * @return void |
|
154 | + * @action restrict_manage_posts |
|
155 | + */ |
|
156 | + public function renderColumnFilters($postType) |
|
157 | + { |
|
158 | + glsr(Columns::class)->renderFilters($postType); |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * @param string $column |
|
163 | - * @param string $postId |
|
164 | - * @return void |
|
165 | - * @action manage_posts_custom_column |
|
166 | - */ |
|
167 | - public function renderColumnValues($column, $postId) |
|
168 | - { |
|
169 | - glsr(Columns::class)->renderValues($column, $postId); |
|
170 | - } |
|
161 | + /** |
|
162 | + * @param string $column |
|
163 | + * @param string $postId |
|
164 | + * @return void |
|
165 | + * @action manage_posts_custom_column |
|
166 | + */ |
|
167 | + public function renderColumnValues($column, $postId) |
|
168 | + { |
|
169 | + glsr(Columns::class)->renderValues($column, $postId); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * @param int $postId |
|
174 | - * @return void |
|
175 | - * @action save_post_.Application::POST_TYPE |
|
176 | - */ |
|
177 | - public function saveBulkEditFields($postId) |
|
178 | - { |
|
179 | - if (!glsr()->can('edit_posts')) { |
|
180 | - return; |
|
181 | - } |
|
182 | - $assignedTo = filter_input(INPUT_GET, 'assigned_to'); |
|
183 | - if ($assignedTo && get_post($assignedTo)) { |
|
184 | - glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
185 | - } |
|
186 | - } |
|
172 | + /** |
|
173 | + * @param int $postId |
|
174 | + * @return void |
|
175 | + * @action save_post_.Application::POST_TYPE |
|
176 | + */ |
|
177 | + public function saveBulkEditFields($postId) |
|
178 | + { |
|
179 | + if (!glsr()->can('edit_posts')) { |
|
180 | + return; |
|
181 | + } |
|
182 | + $assignedTo = filter_input(INPUT_GET, 'assigned_to'); |
|
183 | + if ($assignedTo && get_post($assignedTo)) { |
|
184 | + glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
185 | + } |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * @return void |
|
190 | - * @action pre_get_posts |
|
191 | - */ |
|
192 | - public function setQueryForColumn(WP_Query $query) |
|
193 | - { |
|
194 | - if (!$this->hasPermission($query)) { |
|
195 | - return; |
|
196 | - } |
|
197 | - $this->setMetaQuery($query, [ |
|
198 | - 'rating', 'review_type', |
|
199 | - ]); |
|
200 | - $this->setOrderby($query); |
|
201 | - } |
|
188 | + /** |
|
189 | + * @return void |
|
190 | + * @action pre_get_posts |
|
191 | + */ |
|
192 | + public function setQueryForColumn(WP_Query $query) |
|
193 | + { |
|
194 | + if (!$this->hasPermission($query)) { |
|
195 | + return; |
|
196 | + } |
|
197 | + $this->setMetaQuery($query, [ |
|
198 | + 'rating', 'review_type', |
|
199 | + ]); |
|
200 | + $this->setOrderby($query); |
|
201 | + } |
|
202 | 202 | |
203 | - /** |
|
204 | - * @return void |
|
205 | - * @action admin_action_unapprove |
|
206 | - */ |
|
207 | - public function unapprove() |
|
208 | - { |
|
209 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
210 | - return; |
|
211 | - } |
|
212 | - check_admin_referer('unapprove-review_'.($postId = $this->getPostId())); |
|
213 | - wp_update_post([ |
|
214 | - 'ID' => $postId, |
|
215 | - 'post_status' => 'pending', |
|
216 | - ]); |
|
217 | - wp_safe_redirect(wp_get_referer()); |
|
218 | - exit; |
|
219 | - } |
|
203 | + /** |
|
204 | + * @return void |
|
205 | + * @action admin_action_unapprove |
|
206 | + */ |
|
207 | + public function unapprove() |
|
208 | + { |
|
209 | + if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
210 | + return; |
|
211 | + } |
|
212 | + check_admin_referer('unapprove-review_'.($postId = $this->getPostId())); |
|
213 | + wp_update_post([ |
|
214 | + 'ID' => $postId, |
|
215 | + 'post_status' => 'pending', |
|
216 | + ]); |
|
217 | + wp_safe_redirect(wp_get_referer()); |
|
218 | + exit; |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * Check if the translation string can be modified. |
|
223 | - * @param string $domain |
|
224 | - * @return bool |
|
225 | - */ |
|
226 | - protected function canModifyTranslation($domain = 'default') |
|
227 | - { |
|
228 | - $screen = glsr_current_screen(); |
|
229 | - return 'default' == $domain |
|
230 | - && 'edit' == $screen->base |
|
231 | - && Application::POST_TYPE == $screen->post_type; |
|
232 | - } |
|
221 | + /** |
|
222 | + * Check if the translation string can be modified. |
|
223 | + * @param string $domain |
|
224 | + * @return bool |
|
225 | + */ |
|
226 | + protected function canModifyTranslation($domain = 'default') |
|
227 | + { |
|
228 | + $screen = glsr_current_screen(); |
|
229 | + return 'default' == $domain |
|
230 | + && 'edit' == $screen->base |
|
231 | + && Application::POST_TYPE == $screen->post_type; |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * @return bool |
|
236 | - */ |
|
237 | - protected function hasPermission(WP_Query $query) |
|
238 | - { |
|
239 | - global $pagenow; |
|
240 | - return is_admin() |
|
241 | - && $query->is_main_query() |
|
242 | - && Application::POST_TYPE == $query->get('post_type') |
|
243 | - && 'edit.php' == $pagenow; |
|
244 | - } |
|
234 | + /** |
|
235 | + * @return bool |
|
236 | + */ |
|
237 | + protected function hasPermission(WP_Query $query) |
|
238 | + { |
|
239 | + global $pagenow; |
|
240 | + return is_admin() |
|
241 | + && $query->is_main_query() |
|
242 | + && Application::POST_TYPE == $query->get('post_type') |
|
243 | + && 'edit.php' == $pagenow; |
|
244 | + } |
|
245 | 245 | |
246 | - /** |
|
247 | - * @return void |
|
248 | - */ |
|
249 | - protected function setMetaQuery(WP_Query $query, array $metaKeys) |
|
250 | - { |
|
251 | - foreach ($metaKeys as $key) { |
|
252 | - $value = (string) filter_input(INPUT_GET, $key); |
|
253 | - if ('' === $value) { |
|
254 | - continue; |
|
255 | - } |
|
256 | - $metaQuery = (array) $query->get('meta_query'); |
|
257 | - $metaQuery[] = [ |
|
258 | - 'key' => Str::prefix('_', $key, '_'), |
|
259 | - 'value' => $value, |
|
260 | - ]; |
|
261 | - $query->set('meta_query', array_filter($metaQuery)); |
|
262 | - } |
|
263 | - } |
|
246 | + /** |
|
247 | + * @return void |
|
248 | + */ |
|
249 | + protected function setMetaQuery(WP_Query $query, array $metaKeys) |
|
250 | + { |
|
251 | + foreach ($metaKeys as $key) { |
|
252 | + $value = (string) filter_input(INPUT_GET, $key); |
|
253 | + if ('' === $value) { |
|
254 | + continue; |
|
255 | + } |
|
256 | + $metaQuery = (array) $query->get('meta_query'); |
|
257 | + $metaQuery[] = [ |
|
258 | + 'key' => Str::prefix('_', $key, '_'), |
|
259 | + 'value' => $value, |
|
260 | + ]; |
|
261 | + $query->set('meta_query', array_filter($metaQuery)); |
|
262 | + } |
|
263 | + } |
|
264 | 264 | |
265 | - /** |
|
266 | - * @return void |
|
267 | - */ |
|
268 | - protected function setOrderby(WP_Query $query) |
|
269 | - { |
|
270 | - $orderby = $query->get('orderby'); |
|
271 | - $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
272 | - unset($columns['cb'], $columns['title'], $columns['date']); |
|
273 | - if (in_array($orderby, array_keys($columns))) { |
|
274 | - if ('reviewer' == $orderby) { |
|
275 | - $orderby = 'author'; |
|
276 | - } |
|
277 | - $query->set('meta_key', Str::prefix('_', $orderby, '_')); |
|
278 | - $query->set('orderby', 'meta_value'); |
|
279 | - } |
|
280 | - } |
|
265 | + /** |
|
266 | + * @return void |
|
267 | + */ |
|
268 | + protected function setOrderby(WP_Query $query) |
|
269 | + { |
|
270 | + $orderby = $query->get('orderby'); |
|
271 | + $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
|
272 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
273 | + if (in_array($orderby, array_keys($columns))) { |
|
274 | + if ('reviewer' == $orderby) { |
|
275 | + $orderby = 'author'; |
|
276 | + } |
|
277 | + $query->set('meta_key', Str::prefix('_', $orderby, '_')); |
|
278 | + $query->set('orderby', 'meta_value'); |
|
279 | + } |
|
280 | + } |
|
281 | 281 | } |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function approve() |
22 | 22 | { |
23 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
23 | + if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | - check_admin_referer('approve-review_'.($postId = $this->getPostId())); |
|
27 | - wp_update_post([ |
|
26 | + check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) ); |
|
27 | + wp_update_post( [ |
|
28 | 28 | 'ID' => $postId, |
29 | 29 | 'post_status' => 'publish', |
30 | - ]); |
|
31 | - wp_safe_redirect(wp_get_referer()); |
|
30 | + ] ); |
|
31 | + wp_safe_redirect( wp_get_referer() ); |
|
32 | 32 | exit; |
33 | 33 | } |
34 | 34 | |
@@ -37,20 +37,20 @@ discard block |
||
37 | 37 | * @return array |
38 | 38 | * @filter manage_.Application::POST_TYPE._posts_columns |
39 | 39 | */ |
40 | - public function filterColumnsForPostType($columns) |
|
40 | + public function filterColumnsForPostType( $columns ) |
|
41 | 41 | { |
42 | - $columns = Arr::consolidate($columns); |
|
42 | + $columns = Arr::consolidate( $columns ); |
|
43 | 43 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
44 | - foreach ($postTypeColumns as $key => &$value) { |
|
45 | - if (!array_key_exists($key, $columns) || !empty($value)) { |
|
44 | + foreach( $postTypeColumns as $key => &$value ) { |
|
45 | + if( !array_key_exists( $key, $columns ) || !empty($value) ) { |
|
46 | 46 | continue; |
47 | 47 | } |
48 | 48 | $value = $columns[$key]; |
49 | 49 | } |
50 | - if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) { |
|
50 | + if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) { |
|
51 | 51 | unset($postTypeColumns['review_type']); |
52 | 52 | } |
53 | - return array_filter($postTypeColumns, 'strlen'); |
|
53 | + return array_filter( $postTypeColumns, 'strlen' ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * @return string |
60 | 60 | * @filter post_date_column_status |
61 | 61 | */ |
62 | - public function filterDateColumnStatus($status, $post) |
|
62 | + public function filterDateColumnStatus( $status, $post ) |
|
63 | 63 | { |
64 | - if (Application::POST_TYPE == Arr::get($post, 'post_type')) { |
|
65 | - $status = __('Submitted', 'site-reviews'); |
|
64 | + if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) ) { |
|
65 | + $status = __( 'Submitted', 'site-reviews' ); |
|
66 | 66 | } |
67 | 67 | return $status; |
68 | 68 | } |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | * @return array |
74 | 74 | * @filter default_hidden_columns |
75 | 75 | */ |
76 | - public function filterDefaultHiddenColumns($hidden, $screen) |
|
76 | + public function filterDefaultHiddenColumns( $hidden, $screen ) |
|
77 | 77 | { |
78 | - if (Arr::get($screen, 'id') == 'edit-'.Application::POST_TYPE) { |
|
79 | - $hidden = Arr::consolidate($hidden); |
|
80 | - $hidden = array_unique(array_merge($hidden, [ |
|
78 | + if( Arr::get( $screen, 'id' ) == 'edit-'.Application::POST_TYPE ) { |
|
79 | + $hidden = Arr::consolidate( $hidden ); |
|
80 | + $hidden = array_unique( array_merge( $hidden, [ |
|
81 | 81 | 'email', 'ip_address', 'response', 'reviewer', |
82 | - ])); |
|
82 | + ] ) ); |
|
83 | 83 | } |
84 | 84 | return $hidden; |
85 | 85 | } |
@@ -90,30 +90,30 @@ discard block |
||
90 | 90 | * @return array |
91 | 91 | * @filter post_row_actions |
92 | 92 | */ |
93 | - public function filterRowActions($actions, $post) |
|
93 | + public function filterRowActions( $actions, $post ) |
|
94 | 94 | { |
95 | - if (Application::POST_TYPE != Arr::get($post, 'post_type') |
|
95 | + if( Application::POST_TYPE != Arr::get( $post, 'post_type' ) |
|
96 | 96 | || 'trash' == $post->post_status |
97 | - || !user_can(get_current_user_id(), 'edit_post', $post->ID)) { |
|
97 | + || !user_can( get_current_user_id(), 'edit_post', $post->ID ) ) { |
|
98 | 98 | return $actions; |
99 | 99 | } |
100 | 100 | unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
101 | 101 | $rowActions = [ |
102 | - 'approve' => esc_attr__('Approve', 'site-reviews'), |
|
103 | - 'unapprove' => esc_attr__('Unapprove', 'site-reviews'), |
|
102 | + 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
|
103 | + 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
|
104 | 104 | ]; |
105 | 105 | $newActions = []; |
106 | - foreach ($rowActions as $key => $text) { |
|
107 | - $newActions[$key] = glsr(Builder::class)->a($text, [ |
|
108 | - 'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text), |
|
106 | + foreach( $rowActions as $key => $text ) { |
|
107 | + $newActions[$key] = glsr( Builder::class )->a( $text, [ |
|
108 | + 'aria-label' => sprintf( esc_attr_x( '%s this review', 'Approve the review', 'site-reviews' ), $text ), |
|
109 | 109 | 'class' => 'glsr-change-status', |
110 | 110 | 'href' => wp_nonce_url( |
111 | - admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID), |
|
111 | + admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ), |
|
112 | 112 | $key.'-review_'.$post->ID |
113 | 113 | ), |
114 | - ]); |
|
114 | + ] ); |
|
115 | 115 | } |
116 | - return $newActions + Arr::consolidate($actions); |
|
116 | + return $newActions + Arr::consolidate( $actions ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | * @return array |
122 | 122 | * @filter manage_edit-.Application::POST_TYPE._sortable_columns |
123 | 123 | */ |
124 | - public function filterSortableColumns($columns) |
|
124 | + public function filterSortableColumns( $columns ) |
|
125 | 125 | { |
126 | - $columns = Arr::consolidate($columns); |
|
126 | + $columns = Arr::consolidate( $columns ); |
|
127 | 127 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
128 | 128 | unset($postTypeColumns['cb']); |
129 | - foreach ($postTypeColumns as $key => $value) { |
|
130 | - if (Str::startsWith('taxonomy', $key)) { |
|
129 | + foreach( $postTypeColumns as $key => $value ) { |
|
130 | + if( Str::startsWith( 'taxonomy', $key ) ) { |
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | $columns[$key] = $key; |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | * @return void |
142 | 142 | * @action bulk_edit_custom_box |
143 | 143 | */ |
144 | - public function renderBulkEditFields($columnName, $postType) |
|
144 | + public function renderBulkEditFields( $columnName, $postType ) |
|
145 | 145 | { |
146 | - if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) { |
|
147 | - glsr()->render('partials/editor/bulk-edit-assigned-to'); |
|
146 | + if( 'assigned_to' == $columnName && Application::POST_TYPE == $postType ) { |
|
147 | + glsr()->render( 'partials/editor/bulk-edit-assigned-to' ); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | * @return void |
154 | 154 | * @action restrict_manage_posts |
155 | 155 | */ |
156 | - public function renderColumnFilters($postType) |
|
156 | + public function renderColumnFilters( $postType ) |
|
157 | 157 | { |
158 | - glsr(Columns::class)->renderFilters($postType); |
|
158 | + glsr( Columns::class )->renderFilters( $postType ); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * @return void |
165 | 165 | * @action manage_posts_custom_column |
166 | 166 | */ |
167 | - public function renderColumnValues($column, $postId) |
|
167 | + public function renderColumnValues( $column, $postId ) |
|
168 | 168 | { |
169 | - glsr(Columns::class)->renderValues($column, $postId); |
|
169 | + glsr( Columns::class )->renderValues( $column, $postId ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | * @return void |
175 | 175 | * @action save_post_.Application::POST_TYPE |
176 | 176 | */ |
177 | - public function saveBulkEditFields($postId) |
|
177 | + public function saveBulkEditFields( $postId ) |
|
178 | 178 | { |
179 | - if (!glsr()->can('edit_posts')) { |
|
179 | + if( !glsr()->can( 'edit_posts' ) ) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | - $assignedTo = filter_input(INPUT_GET, 'assigned_to'); |
|
183 | - if ($assignedTo && get_post($assignedTo)) { |
|
184 | - glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
182 | + $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
|
183 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
184 | + glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo ); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
@@ -189,15 +189,15 @@ discard block |
||
189 | 189 | * @return void |
190 | 190 | * @action pre_get_posts |
191 | 191 | */ |
192 | - public function setQueryForColumn(WP_Query $query) |
|
192 | + public function setQueryForColumn( WP_Query $query ) |
|
193 | 193 | { |
194 | - if (!$this->hasPermission($query)) { |
|
194 | + if( !$this->hasPermission( $query ) ) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | - $this->setMetaQuery($query, [ |
|
197 | + $this->setMetaQuery( $query, [ |
|
198 | 198 | 'rating', 'review_type', |
199 | - ]); |
|
200 | - $this->setOrderby($query); |
|
199 | + ] ); |
|
200 | + $this->setOrderby( $query ); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function unapprove() |
208 | 208 | { |
209 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
209 | + if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) { |
|
210 | 210 | return; |
211 | 211 | } |
212 | - check_admin_referer('unapprove-review_'.($postId = $this->getPostId())); |
|
213 | - wp_update_post([ |
|
212 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
213 | + wp_update_post( [ |
|
214 | 214 | 'ID' => $postId, |
215 | 215 | 'post_status' => 'pending', |
216 | - ]); |
|
217 | - wp_safe_redirect(wp_get_referer()); |
|
216 | + ] ); |
|
217 | + wp_safe_redirect( wp_get_referer() ); |
|
218 | 218 | exit; |
219 | 219 | } |
220 | 220 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @param string $domain |
224 | 224 | * @return bool |
225 | 225 | */ |
226 | - protected function canModifyTranslation($domain = 'default') |
|
226 | + protected function canModifyTranslation( $domain = 'default' ) |
|
227 | 227 | { |
228 | 228 | $screen = glsr_current_screen(); |
229 | 229 | return 'default' == $domain |
@@ -234,48 +234,48 @@ discard block |
||
234 | 234 | /** |
235 | 235 | * @return bool |
236 | 236 | */ |
237 | - protected function hasPermission(WP_Query $query) |
|
237 | + protected function hasPermission( WP_Query $query ) |
|
238 | 238 | { |
239 | 239 | global $pagenow; |
240 | 240 | return is_admin() |
241 | 241 | && $query->is_main_query() |
242 | - && Application::POST_TYPE == $query->get('post_type') |
|
242 | + && Application::POST_TYPE == $query->get( 'post_type' ) |
|
243 | 243 | && 'edit.php' == $pagenow; |
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
247 | 247 | * @return void |
248 | 248 | */ |
249 | - protected function setMetaQuery(WP_Query $query, array $metaKeys) |
|
249 | + protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
|
250 | 250 | { |
251 | - foreach ($metaKeys as $key) { |
|
252 | - $value = (string) filter_input(INPUT_GET, $key); |
|
253 | - if ('' === $value) { |
|
251 | + foreach( $metaKeys as $key ) { |
|
252 | + $value = (string)filter_input( INPUT_GET, $key ); |
|
253 | + if( '' === $value ) { |
|
254 | 254 | continue; |
255 | 255 | } |
256 | - $metaQuery = (array) $query->get('meta_query'); |
|
256 | + $metaQuery = (array)$query->get( 'meta_query' ); |
|
257 | 257 | $metaQuery[] = [ |
258 | - 'key' => Str::prefix('_', $key, '_'), |
|
258 | + 'key' => Str::prefix( '_', $key, '_' ), |
|
259 | 259 | 'value' => $value, |
260 | 260 | ]; |
261 | - $query->set('meta_query', array_filter($metaQuery)); |
|
261 | + $query->set( 'meta_query', array_filter( $metaQuery ) ); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
266 | 266 | * @return void |
267 | 267 | */ |
268 | - protected function setOrderby(WP_Query $query) |
|
268 | + protected function setOrderby( WP_Query $query ) |
|
269 | 269 | { |
270 | - $orderby = $query->get('orderby'); |
|
270 | + $orderby = $query->get( 'orderby' ); |
|
271 | 271 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
272 | 272 | unset($columns['cb'], $columns['title'], $columns['date']); |
273 | - if (in_array($orderby, array_keys($columns))) { |
|
274 | - if ('reviewer' == $orderby) { |
|
273 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
274 | + if( 'reviewer' == $orderby ) { |
|
275 | 275 | $orderby = 'author'; |
276 | 276 | } |
277 | - $query->set('meta_key', Str::prefix('_', $orderby, '_')); |
|
278 | - $query->set('orderby', 'meta_value'); |
|
277 | + $query->set( 'meta_key', Str::prefix( '_', $orderby, '_' ) ); |
|
278 | + $query->set( 'orderby', 'meta_value' ); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | } |
@@ -8,137 +8,137 @@ |
||
8 | 8 | |
9 | 9 | abstract class DefaultsAbstract |
10 | 10 | { |
11 | - /** |
|
12 | - * @var array |
|
13 | - */ |
|
14 | - protected $callable = [ |
|
15 | - 'defaults', 'filter', 'merge', 'restrict', 'unguarded', |
|
16 | - ]; |
|
17 | - |
|
18 | - /** |
|
19 | - * @var array |
|
20 | - */ |
|
21 | - protected $guarded = []; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected $mapped = []; |
|
27 | - |
|
28 | - /** |
|
29 | - * @param string $name |
|
30 | - * @return void|array |
|
31 | - */ |
|
32 | - public function __call($name, array $args = []) |
|
33 | - { |
|
34 | - if (!method_exists($this, $name) || !in_array($name, $this->callable)) { |
|
35 | - return; |
|
36 | - } |
|
37 | - $args[0] = $this->mapKeys(Arr::get($args, 0, [])); |
|
38 | - $defaults = call_user_func_array([$this, $name], $args); |
|
39 | - $hookName = (new ReflectionClass($this))->getShortName(); |
|
40 | - $hookName = str_replace('Defaults', '', $hookName); |
|
41 | - $hookName = Str::dashCase($hookName); |
|
42 | - return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name); |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - abstract protected function defaults(); |
|
49 | - |
|
50 | - /** |
|
51 | - * @return array |
|
52 | - */ |
|
53 | - protected function filter(array $values = []) |
|
54 | - { |
|
55 | - return $this->normalize($this->merge(array_filter($values)), $values); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - protected function filteredJson(array $values = []) |
|
62 | - { |
|
63 | - $defaults = $this->flattenArrayValues( |
|
64 | - array_diff_key($this->defaults(), array_flip($this->guarded)) |
|
65 | - ); |
|
66 | - $values = $this->flattenArrayValues( |
|
67 | - shortcode_atts($defaults, $values) |
|
68 | - ); |
|
69 | - $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) { |
|
70 | - return !$this->isEmpty($value); |
|
71 | - }); |
|
72 | - return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @return array |
|
77 | - */ |
|
78 | - protected function flattenArrayValues(array $values) |
|
79 | - { |
|
80 | - array_walk($values, function (&$value) { |
|
81 | - if (!is_array($value)) { |
|
82 | - return; |
|
83 | - } |
|
84 | - $value = implode(',', $value); |
|
85 | - }); |
|
86 | - return $values; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @param mixed $var |
|
91 | - * @return bool |
|
92 | - */ |
|
93 | - protected function isEmpty($var) |
|
94 | - { |
|
95 | - return !is_numeric($var) && !is_bool($var) && empty($var); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - protected function mapKeys(array $args) |
|
102 | - { |
|
103 | - foreach ($this->mapped as $old => $new) { |
|
104 | - if (array_key_exists($old, $args)) { |
|
105 | - $args[$new] = $args[$old]; |
|
106 | - unset($args[$old]); |
|
107 | - } |
|
108 | - } |
|
109 | - return $args; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * @return array |
|
114 | - */ |
|
115 | - protected function merge(array $values = []) |
|
116 | - { |
|
117 | - return $this->normalize(wp_parse_args($values, $this->defaults()), $values); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @return array |
|
122 | - */ |
|
123 | - protected function normalize(array $values, array $originalValues) |
|
124 | - { |
|
125 | - $values['json'] = $this->filteredJson($originalValues); |
|
126 | - return $values; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - protected function restrict(array $values = []) |
|
133 | - { |
|
134 | - return $this->normalize(shortcode_atts($this->defaults(), $values), $values); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - protected function unguarded() |
|
141 | - { |
|
142 | - return array_diff_key($this->defaults(), array_flip($this->guarded)); |
|
143 | - } |
|
11 | + /** |
|
12 | + * @var array |
|
13 | + */ |
|
14 | + protected $callable = [ |
|
15 | + 'defaults', 'filter', 'merge', 'restrict', 'unguarded', |
|
16 | + ]; |
|
17 | + |
|
18 | + /** |
|
19 | + * @var array |
|
20 | + */ |
|
21 | + protected $guarded = []; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected $mapped = []; |
|
27 | + |
|
28 | + /** |
|
29 | + * @param string $name |
|
30 | + * @return void|array |
|
31 | + */ |
|
32 | + public function __call($name, array $args = []) |
|
33 | + { |
|
34 | + if (!method_exists($this, $name) || !in_array($name, $this->callable)) { |
|
35 | + return; |
|
36 | + } |
|
37 | + $args[0] = $this->mapKeys(Arr::get($args, 0, [])); |
|
38 | + $defaults = call_user_func_array([$this, $name], $args); |
|
39 | + $hookName = (new ReflectionClass($this))->getShortName(); |
|
40 | + $hookName = str_replace('Defaults', '', $hookName); |
|
41 | + $hookName = Str::dashCase($hookName); |
|
42 | + return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name); |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + abstract protected function defaults(); |
|
49 | + |
|
50 | + /** |
|
51 | + * @return array |
|
52 | + */ |
|
53 | + protected function filter(array $values = []) |
|
54 | + { |
|
55 | + return $this->normalize($this->merge(array_filter($values)), $values); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + protected function filteredJson(array $values = []) |
|
62 | + { |
|
63 | + $defaults = $this->flattenArrayValues( |
|
64 | + array_diff_key($this->defaults(), array_flip($this->guarded)) |
|
65 | + ); |
|
66 | + $values = $this->flattenArrayValues( |
|
67 | + shortcode_atts($defaults, $values) |
|
68 | + ); |
|
69 | + $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) { |
|
70 | + return !$this->isEmpty($value); |
|
71 | + }); |
|
72 | + return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @return array |
|
77 | + */ |
|
78 | + protected function flattenArrayValues(array $values) |
|
79 | + { |
|
80 | + array_walk($values, function (&$value) { |
|
81 | + if (!is_array($value)) { |
|
82 | + return; |
|
83 | + } |
|
84 | + $value = implode(',', $value); |
|
85 | + }); |
|
86 | + return $values; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @param mixed $var |
|
91 | + * @return bool |
|
92 | + */ |
|
93 | + protected function isEmpty($var) |
|
94 | + { |
|
95 | + return !is_numeric($var) && !is_bool($var) && empty($var); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + protected function mapKeys(array $args) |
|
102 | + { |
|
103 | + foreach ($this->mapped as $old => $new) { |
|
104 | + if (array_key_exists($old, $args)) { |
|
105 | + $args[$new] = $args[$old]; |
|
106 | + unset($args[$old]); |
|
107 | + } |
|
108 | + } |
|
109 | + return $args; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * @return array |
|
114 | + */ |
|
115 | + protected function merge(array $values = []) |
|
116 | + { |
|
117 | + return $this->normalize(wp_parse_args($values, $this->defaults()), $values); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @return array |
|
122 | + */ |
|
123 | + protected function normalize(array $values, array $originalValues) |
|
124 | + { |
|
125 | + $values['json'] = $this->filteredJson($originalValues); |
|
126 | + return $values; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + protected function restrict(array $values = []) |
|
133 | + { |
|
134 | + return $this->normalize(shortcode_atts($this->defaults(), $values), $values); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + protected function unguarded() |
|
141 | + { |
|
142 | + return array_diff_key($this->defaults(), array_flip($this->guarded)); |
|
143 | + } |
|
144 | 144 | } |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | * @param string $name |
30 | 30 | * @return void|array |
31 | 31 | */ |
32 | - public function __call($name, array $args = []) |
|
32 | + public function __call( $name, array $args = [] ) |
|
33 | 33 | { |
34 | - if (!method_exists($this, $name) || !in_array($name, $this->callable)) { |
|
34 | + if( !method_exists( $this, $name ) || !in_array( $name, $this->callable ) ) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | - $args[0] = $this->mapKeys(Arr::get($args, 0, [])); |
|
38 | - $defaults = call_user_func_array([$this, $name], $args); |
|
39 | - $hookName = (new ReflectionClass($this))->getShortName(); |
|
40 | - $hookName = str_replace('Defaults', '', $hookName); |
|
41 | - $hookName = Str::dashCase($hookName); |
|
42 | - return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name); |
|
37 | + $args[0] = $this->mapKeys( Arr::get( $args, 0, [] ) ); |
|
38 | + $defaults = call_user_func_array( [$this, $name], $args ); |
|
39 | + $hookName = (new ReflectionClass( $this ))->getShortName(); |
|
40 | + $hookName = str_replace( 'Defaults', '', $hookName ); |
|
41 | + $hookName = Str::dashCase( $hookName ); |
|
42 | + return apply_filters( 'site-reviews/defaults/'.$hookName, $defaults, $name ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -50,38 +50,38 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @return array |
52 | 52 | */ |
53 | - protected function filter(array $values = []) |
|
53 | + protected function filter( array $values = [] ) |
|
54 | 54 | { |
55 | - return $this->normalize($this->merge(array_filter($values)), $values); |
|
55 | + return $this->normalize( $this->merge( array_filter( $values ) ), $values ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - protected function filteredJson(array $values = []) |
|
61 | + protected function filteredJson( array $values = [] ) |
|
62 | 62 | { |
63 | 63 | $defaults = $this->flattenArrayValues( |
64 | - array_diff_key($this->defaults(), array_flip($this->guarded)) |
|
64 | + array_diff_key( $this->defaults(), array_flip( $this->guarded ) ) |
|
65 | 65 | ); |
66 | 66 | $values = $this->flattenArrayValues( |
67 | - shortcode_atts($defaults, $values) |
|
67 | + shortcode_atts( $defaults, $values ) |
|
68 | 68 | ); |
69 | - $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) { |
|
70 | - return !$this->isEmpty($value); |
|
69 | + $filtered = array_filter( array_diff_assoc( $values, $defaults ), function( $value ) { |
|
70 | + return !$this->isEmpty( $value ); |
|
71 | 71 | }); |
72 | - return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
72 | + return json_encode( $filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @return array |
77 | 77 | */ |
78 | - protected function flattenArrayValues(array $values) |
|
78 | + protected function flattenArrayValues( array $values ) |
|
79 | 79 | { |
80 | - array_walk($values, function (&$value) { |
|
81 | - if (!is_array($value)) { |
|
80 | + array_walk( $values, function( &$value ) { |
|
81 | + if( !is_array( $value ) ) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | - $value = implode(',', $value); |
|
84 | + $value = implode( ',', $value ); |
|
85 | 85 | }); |
86 | 86 | return $values; |
87 | 87 | } |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | * @param mixed $var |
91 | 91 | * @return bool |
92 | 92 | */ |
93 | - protected function isEmpty($var) |
|
93 | + protected function isEmpty( $var ) |
|
94 | 94 | { |
95 | - return !is_numeric($var) && !is_bool($var) && empty($var); |
|
95 | + return !is_numeric( $var ) && !is_bool( $var ) && empty($var); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @return array |
100 | 100 | */ |
101 | - protected function mapKeys(array $args) |
|
101 | + protected function mapKeys( array $args ) |
|
102 | 102 | { |
103 | - foreach ($this->mapped as $old => $new) { |
|
104 | - if (array_key_exists($old, $args)) { |
|
103 | + foreach( $this->mapped as $old => $new ) { |
|
104 | + if( array_key_exists( $old, $args ) ) { |
|
105 | 105 | $args[$new] = $args[$old]; |
106 | 106 | unset($args[$old]); |
107 | 107 | } |
@@ -112,26 +112,26 @@ discard block |
||
112 | 112 | /** |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - protected function merge(array $values = []) |
|
115 | + protected function merge( array $values = [] ) |
|
116 | 116 | { |
117 | - return $this->normalize(wp_parse_args($values, $this->defaults()), $values); |
|
117 | + return $this->normalize( wp_parse_args( $values, $this->defaults() ), $values ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | 121 | * @return array |
122 | 122 | */ |
123 | - protected function normalize(array $values, array $originalValues) |
|
123 | + protected function normalize( array $values, array $originalValues ) |
|
124 | 124 | { |
125 | - $values['json'] = $this->filteredJson($originalValues); |
|
125 | + $values['json'] = $this->filteredJson( $originalValues ); |
|
126 | 126 | return $values; |
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - protected function restrict(array $values = []) |
|
132 | + protected function restrict( array $values = [] ) |
|
133 | 133 | { |
134 | - return $this->normalize(shortcode_atts($this->defaults(), $values), $values); |
|
134 | + return $this->normalize( shortcode_atts( $this->defaults(), $values ), $values ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,6 +139,6 @@ discard block |
||
139 | 139 | */ |
140 | 140 | protected function unguarded() |
141 | 141 | { |
142 | - return array_diff_key($this->defaults(), array_flip($this->guarded)); |
|
142 | + return array_diff_key( $this->defaults(), array_flip( $this->guarded ) ); |
|
143 | 143 | } |
144 | 144 | } |