@@ -1,473 +1,473 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'settings.general.style' => [ |
|
5 | - 'default' => 'default', |
|
6 | - 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | - 'label' => __('Plugin Style', 'site-reviews'), |
|
8 | - 'options' => [ |
|
9 | - 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
|
10 | - 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
|
11 | - 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
|
12 | - 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
|
13 | - 'wpforms' => 'Plugin: WPForms Lite (v1)', |
|
14 | - 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | - 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
16 | - 'divi' => 'Theme: Divi (v3)', |
|
17 | - 'materialize' => 'Theme: Materialize', |
|
18 | - 'twentyfifteen' => 'Theme: Twenty Fifteen', |
|
19 | - 'twentyseventeen' => 'Theme: Twenty Seventeen', |
|
20 | - 'twentynineteen' => 'Theme: Twenty Nineteen', |
|
21 | - ], |
|
22 | - 'type' => 'select', |
|
23 | - ], |
|
24 | - 'settings.general.require.approval' => [ |
|
25 | - 'default' => 'no', |
|
26 | - 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | - 'label' => __('Require Approval', 'site-reviews'), |
|
28 | - 'type' => 'yes_no', |
|
29 | - ], |
|
30 | - 'settings.general.require.login' => [ |
|
31 | - 'default' => 'no', |
|
32 | - 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | - 'label' => __('Require Login', 'site-reviews'), |
|
34 | - 'type' => 'yes_no', |
|
35 | - ], |
|
36 | - 'settings.general.require.login_register' => [ |
|
37 | - 'default' => 'no', |
|
38 | - 'depends_on' => [ |
|
39 | - 'settings.general.require.login' => 'yes', |
|
40 | - ], |
|
41 | - 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | - '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
43 | - ), |
|
44 | - 'label' => __('Show Registration Link', 'site-reviews'), |
|
45 | - 'type' => 'yes_no', |
|
46 | - ], |
|
47 | - 'settings.general.support.polylang' => [ |
|
48 | - 'default' => 'no', |
|
49 | - 'description' => sprintf(__('Integrate with the %s plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
50 | - '<a href="https://wordpress.org/plugins/polylang/">Polylang</a>' |
|
51 | - ), |
|
52 | - 'label' => __('Integrate with Polylang', 'site-reviews'), |
|
53 | - 'type' => 'yes_no', |
|
54 | - ], |
|
55 | - 'settings.general.support.rebusify' => [ |
|
56 | - 'default' => 'no', |
|
57 | - 'description' => sprintf(__('Integrate with the %s and sync your reviews to the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
58 | - '<a href="https://rebusify.com">Rebusify Confidence System</a>' |
|
59 | - ), |
|
60 | - 'label' => __('Integrate with Rebusify', 'site-reviews'), |
|
61 | - 'type' => 'yes_no', |
|
62 | - ], |
|
63 | - 'settings.general.support.rebusify_api_key' => [ |
|
64 | - 'default' => '', |
|
65 | - 'depends_on' => [ |
|
66 | - 'settings.general.support.rebusify' => ['yes'], |
|
67 | - ], |
|
68 | - 'description' => sprintf(__('Get a free Rebusify API key from %s.', 'site-reviews'), |
|
69 | - '<a href="https://rebusify.com">rebusify.com</a>' |
|
70 | - ), |
|
71 | - 'label' => __('Rebusify API key', 'site-reviews'), |
|
72 | - 'type' => 'text', |
|
73 | - ], |
|
74 | - 'settings.general.notifications' => [ |
|
75 | - 'default' => [], |
|
76 | - 'label' => __('Notifications', 'site-reviews'), |
|
77 | - 'options' => [ |
|
78 | - 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
79 | - 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
80 | - 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
81 | - 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
82 | - ], |
|
83 | - 'type' => 'checkbox', |
|
84 | - ], |
|
85 | - 'settings.general.notification_email' => [ |
|
86 | - 'default' => '', |
|
87 | - 'depends_on' => [ |
|
88 | - 'settings.general.notifications' => ['custom'], |
|
89 | - ], |
|
90 | - 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
91 | - 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
92 | - 'type' => 'text', |
|
93 | - ], |
|
94 | - 'settings.general.notification_slack' => [ |
|
95 | - 'default' => '', |
|
96 | - 'depends_on' => [ |
|
97 | - 'settings.general.notifications' => ['slack'], |
|
98 | - ], |
|
99 | - 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
100 | - '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
101 | - ), |
|
102 | - 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
103 | - 'type' => 'text', |
|
104 | - ], |
|
105 | - 'settings.general.notification_message' => [ |
|
106 | - 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
107 | - 'depends_on' => [ |
|
108 | - 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
109 | - ], |
|
110 | - 'description' => __( |
|
111 | - 'To restore the default text, save an empty template. '. |
|
112 | - 'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'. |
|
113 | - '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
114 | - '<br><code>{review_title}</code> The review title'. |
|
115 | - '<br><code>{review_content}</code> The review content'. |
|
116 | - '<br><code>{review_author}</code> The review author'. |
|
117 | - '<br><code>{review_email}</code> The email of the review author'. |
|
118 | - '<br><code>{review_ip}</code> The IP address of the review author'. |
|
119 | - '<br><code>{review_link}</code> The link to edit/view a review', |
|
120 | - 'site-reviews' |
|
121 | - ), |
|
122 | - 'label' => __('Notification Template', 'site-reviews'), |
|
123 | - 'rows' => 10, |
|
124 | - 'type' => 'code', |
|
125 | - ], |
|
126 | - 'settings.reviews.date.format' => [ |
|
127 | - 'default' => '', |
|
128 | - 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
129 | - '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
130 | - ), |
|
131 | - 'label' => __('Date Format', 'site-reviews'), |
|
132 | - 'options' => [ |
|
133 | - '' => __('Use the default date format', 'site-reviews'), |
|
134 | - 'relative' => __('Use a relative date format', 'site-reviews'), |
|
135 | - 'custom' => __('Use a custom date format', 'site-reviews'), |
|
136 | - ], |
|
137 | - 'type' => 'select', |
|
138 | - ], |
|
139 | - 'settings.reviews.date.custom' => [ |
|
140 | - 'default' => get_option('date_format'), |
|
141 | - 'depends_on' => [ |
|
142 | - 'settings.reviews.date.format' => 'custom', |
|
143 | - ], |
|
144 | - 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
145 | - 'label' => __('Custom Date Format', 'site-reviews'), |
|
146 | - 'type' => 'text', |
|
147 | - ], |
|
148 | - 'settings.reviews.assigned_links' => [ |
|
149 | - 'default' => 'no', |
|
150 | - 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
151 | - 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
152 | - 'type' => 'yes_no', |
|
153 | - ], |
|
154 | - 'settings.reviews.avatars' => [ |
|
155 | - 'default' => 'no', |
|
156 | - 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
157 | - 'label' => __('Enable Avatars', 'site-reviews'), |
|
158 | - 'type' => 'yes_no', |
|
159 | - ], |
|
160 | - 'settings.reviews.avatars_regenerate' => [ |
|
161 | - 'default' => 'no', |
|
162 | - 'depends_on' => [ |
|
163 | - 'settings.reviews.avatars' => 'yes', |
|
164 | - ], |
|
165 | - 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
166 | - 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
167 | - 'type' => 'yes_no', |
|
168 | - ], |
|
169 | - 'settings.reviews.avatars_size' => [ |
|
170 | - 'default' => 40, |
|
171 | - 'depends_on' => [ |
|
172 | - 'settings.reviews.avatars' => 'yes', |
|
173 | - ], |
|
174 | - 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
175 | - 'label' => __('Avatar Size', 'site-reviews'), |
|
176 | - 'type' => 'number', |
|
177 | - ], |
|
178 | - 'settings.reviews.excerpts' => [ |
|
179 | - 'default' => 'yes', |
|
180 | - 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
181 | - 'label' => __('Enable Excerpts', 'site-reviews'), |
|
182 | - 'type' => 'yes_no', |
|
183 | - ], |
|
184 | - 'settings.reviews.excerpts_length' => [ |
|
185 | - 'default' => 55, |
|
186 | - 'depends_on' => [ |
|
187 | - 'settings.reviews.excerpts' => 'yes', |
|
188 | - ], |
|
189 | - 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
190 | - 'label' => __('Excerpt Length', 'site-reviews'), |
|
191 | - 'type' => 'number', |
|
192 | - ], |
|
193 | - 'settings.reviews.fallback' => [ |
|
194 | - 'default' => 'no', |
|
195 | - 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
196 | - '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
197 | - '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
198 | - ), |
|
199 | - 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
200 | - 'type' => 'yes_no', |
|
201 | - ], |
|
202 | - 'settings.schema.type.default' => [ |
|
203 | - 'default' => 'LocalBusiness', |
|
204 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
205 | - 'label' => __('Default Schema Type', 'site-reviews'), |
|
206 | - 'options' => [ |
|
207 | - 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
208 | - 'Product' => __('Product', 'site-reviews'), |
|
209 | - 'custom' => __('Custom', 'site-reviews'), |
|
210 | - ], |
|
211 | - 'type' => 'select', |
|
212 | - ], |
|
213 | - 'settings.schema.type.custom' => [ |
|
214 | - 'default' => '', |
|
215 | - 'depends_on' => [ |
|
216 | - 'settings.schema.type.default' => 'custom', |
|
217 | - ], |
|
218 | - 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
219 | - 'label' => __('Custom Schema Type', 'site-reviews'), |
|
220 | - 'type' => 'text', |
|
221 | - ], |
|
222 | - 'settings.schema.name.default' => [ |
|
223 | - 'default' => 'post', |
|
224 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
225 | - 'label' => __('Default Name', 'site-reviews'), |
|
226 | - 'options' => [ |
|
227 | - 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
228 | - 'custom' => __('Enter a custom title', 'site-reviews'), |
|
229 | - ], |
|
230 | - 'type' => 'select', |
|
231 | - ], |
|
232 | - 'settings.schema.name.custom' => [ |
|
233 | - 'default' => '', |
|
234 | - 'depends_on' => [ |
|
235 | - 'settings.schema.name.default' => 'custom', |
|
236 | - ], |
|
237 | - 'label' => __('Custom Name', 'site-reviews'), |
|
238 | - 'type' => 'text', |
|
239 | - ], |
|
240 | - 'settings.schema.description.default' => [ |
|
241 | - 'default' => 'post', |
|
242 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
243 | - 'label' => __('Default Description', 'site-reviews'), |
|
244 | - 'options' => [ |
|
245 | - 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
246 | - 'custom' => __('Enter a custom description', 'site-reviews'), |
|
247 | - ], |
|
248 | - 'type' => 'select', |
|
249 | - ], |
|
250 | - 'settings.schema.description.custom' => [ |
|
251 | - 'default' => '', |
|
252 | - 'depends_on' => [ |
|
253 | - 'settings.schema.description.default' => 'custom', |
|
254 | - ], |
|
255 | - 'label' => __('Custom Description', 'site-reviews'), |
|
256 | - 'type' => 'text', |
|
257 | - ], |
|
258 | - 'settings.schema.url.default' => [ |
|
259 | - 'default' => 'post', |
|
260 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
261 | - 'label' => __('Default URL', 'site-reviews'), |
|
262 | - 'options' => [ |
|
263 | - 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
264 | - 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
265 | - ], |
|
266 | - 'type' => 'select', |
|
267 | - ], |
|
268 | - 'settings.schema.url.custom' => [ |
|
269 | - 'default' => '', |
|
270 | - 'depends_on' => [ |
|
271 | - 'settings.schema.url.default' => 'custom', |
|
272 | - ], |
|
273 | - 'label' => __('Custom URL', 'site-reviews'), |
|
274 | - 'type' => 'text', |
|
275 | - ], |
|
276 | - 'settings.schema.image.default' => [ |
|
277 | - 'default' => 'post', |
|
278 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
279 | - 'label' => __('Default Image', 'site-reviews'), |
|
280 | - 'options' => [ |
|
281 | - 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
282 | - 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
283 | - ], |
|
284 | - 'type' => 'select', |
|
285 | - ], |
|
286 | - 'settings.schema.image.custom' => [ |
|
287 | - 'default' => '', |
|
288 | - 'depends_on' => [ |
|
289 | - 'settings.schema.image.default' => 'custom', |
|
290 | - ], |
|
291 | - 'label' => __('Custom Image URL', 'site-reviews'), |
|
292 | - 'type' => 'text', |
|
293 | - ], |
|
294 | - 'settings.schema.address' => [ |
|
295 | - 'default' => '', |
|
296 | - 'depends_on' => [ |
|
297 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
298 | - ], |
|
299 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
300 | - 'label' => __('Address', 'site-reviews'), |
|
301 | - 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
302 | - 'type' => 'text', |
|
303 | - ], |
|
304 | - 'settings.schema.telephone' => [ |
|
305 | - 'default' => '', |
|
306 | - 'depends_on' => [ |
|
307 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
308 | - ], |
|
309 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
310 | - 'label' => __('Telephone Number', 'site-reviews'), |
|
311 | - 'placeholder' => '+1 (877) 273-3049', |
|
312 | - 'type' => 'text', |
|
313 | - ], |
|
314 | - 'settings.schema.pricerange' => [ |
|
315 | - 'default' => '', |
|
316 | - 'depends_on' => [ |
|
317 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
318 | - ], |
|
319 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
320 | - 'label' => __('Price Range', 'site-reviews'), |
|
321 | - 'placeholder' => '$$-$$$', |
|
322 | - 'type' => 'text', |
|
323 | - ], |
|
324 | - 'settings.schema.offertype' => [ |
|
325 | - 'default' => 'AggregateOffer', |
|
326 | - 'depends_on' => [ |
|
327 | - 'settings.schema.type.default' => 'Product', |
|
328 | - ], |
|
329 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
330 | - 'label' => __('Offer Type', 'site-reviews'), |
|
331 | - 'options' => [ |
|
332 | - 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
333 | - 'Offer' => __('Offer', 'site-reviews'), |
|
334 | - ], |
|
335 | - 'type' => 'select', |
|
336 | - ], |
|
337 | - 'settings.schema.price' => [ |
|
338 | - 'default' => '', |
|
339 | - 'depends_on' => [ |
|
340 | - 'settings.schema.type.default' => 'Product', |
|
341 | - 'settings.schema.offertype' => 'Offer', |
|
342 | - ], |
|
343 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
344 | - 'label' => __('Price', 'site-reviews'), |
|
345 | - 'placeholder' => '50.00', |
|
346 | - 'type' => 'text', |
|
347 | - ], |
|
348 | - 'settings.schema.lowprice' => [ |
|
349 | - 'default' => '', |
|
350 | - 'depends_on' => [ |
|
351 | - 'settings.schema.type.default' => 'Product', |
|
352 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
353 | - ], |
|
354 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
355 | - 'label' => __('Low Price', 'site-reviews'), |
|
356 | - 'placeholder' => '10.00', |
|
357 | - 'type' => 'text', |
|
358 | - ], |
|
359 | - 'settings.schema.highprice' => [ |
|
360 | - 'default' => '', |
|
361 | - 'depends_on' => [ |
|
362 | - 'settings.schema.type.default' => 'Product', |
|
363 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
364 | - ], |
|
365 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
366 | - 'label' => __('High Price', 'site-reviews'), |
|
367 | - 'placeholder' => '100.00', |
|
368 | - 'type' => 'text', |
|
369 | - ], |
|
370 | - 'settings.schema.pricecurrency' => [ |
|
371 | - 'default' => '', |
|
372 | - 'depends_on' => [ |
|
373 | - 'settings.schema.type.default' => 'Product', |
|
374 | - ], |
|
375 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
376 | - 'label' => __('Price Currency', 'site-reviews'), |
|
377 | - 'placeholder' => 'USD', |
|
378 | - 'type' => 'text', |
|
379 | - ], |
|
380 | - 'settings.submissions.required' => [ |
|
381 | - 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
382 | - 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
383 | - 'label' => __('Required Fields', 'site-reviews'), |
|
384 | - 'options' => [ |
|
385 | - 'rating' => __('Rating', 'site-reviews'), |
|
386 | - 'title' => __('Title', 'site-reviews'), |
|
387 | - 'content' => __('Review', 'site-reviews'), |
|
388 | - 'name' => __('Name', 'site-reviews'), |
|
389 | - 'email' => __('Email', 'site-reviews'), |
|
390 | - 'terms' => __('Terms', 'site-reviews'), |
|
391 | - ], |
|
392 | - 'type' => 'checkbox', |
|
393 | - ], |
|
394 | - 'settings.submissions.recaptcha.integration' => [ |
|
395 | - 'default' => '', |
|
396 | - 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
397 | - 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
398 | - 'options' => [ |
|
399 | - '' => 'Do not use reCAPTCHA', |
|
400 | - 'all' => 'Use reCAPTCHA', |
|
401 | - 'guest' => 'Use reCAPTCHA only for guest users', |
|
402 | - ], |
|
403 | - 'type' => 'select', |
|
404 | - ], |
|
405 | - 'settings.submissions.recaptcha.key' => [ |
|
406 | - 'default' => '', |
|
407 | - 'depends_on' => [ |
|
408 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
409 | - ], |
|
410 | - 'label' => __('Site Key', 'site-reviews'), |
|
411 | - 'type' => 'text', |
|
412 | - ], |
|
413 | - 'settings.submissions.recaptcha.secret' => [ |
|
414 | - 'default' => '', |
|
415 | - 'depends_on' => [ |
|
416 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
417 | - ], |
|
418 | - 'label' => __('Site Secret', 'site-reviews'), |
|
419 | - 'type' => 'text', |
|
420 | - ], |
|
421 | - 'settings.submissions.recaptcha.position' => [ |
|
422 | - 'default' => 'bottomleft', |
|
423 | - 'depends_on' => [ |
|
424 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
425 | - ], |
|
426 | - 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
427 | - 'label' => __('Badge Position', 'site-reviews'), |
|
428 | - 'options' => [ |
|
429 | - 'bottomleft' => 'Bottom Left', |
|
430 | - 'bottomright' => 'Bottom Right', |
|
431 | - 'inline' => 'Inline', |
|
432 | - ], |
|
433 | - 'type' => 'select', |
|
434 | - ], |
|
435 | - 'settings.submissions.akismet' => [ |
|
436 | - 'default' => 'no', |
|
437 | - 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
438 | - 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
439 | - 'type' => 'yes_no', |
|
440 | - ], |
|
441 | - 'settings.submissions.blacklist.integration' => [ |
|
442 | - 'default' => '', |
|
443 | - 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
444 | - '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
445 | - ), |
|
446 | - 'label' => __('Blacklist', 'site-reviews'), |
|
447 | - 'options' => [ |
|
448 | - '' => 'Use the Site Reviews Blacklist', |
|
449 | - 'comments' => 'Use the WordPress Comment Blacklist', |
|
450 | - ], |
|
451 | - 'type' => 'select', |
|
452 | - ], |
|
453 | - 'settings.submissions.blacklist.entries' => [ |
|
454 | - 'default' => '', |
|
455 | - 'depends_on' => [ |
|
456 | - 'settings.submissions.blacklist.integration' => [''], |
|
457 | - ], |
|
458 | - 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
459 | - 'label' => __('Review Blacklist', 'site-reviews'), |
|
460 | - 'rows' => 10, |
|
461 | - 'type' => 'code', |
|
462 | - ], |
|
463 | - 'settings.submissions.blacklist.action' => [ |
|
464 | - 'default' => 'unapprove', |
|
465 | - 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
466 | - 'label' => __('Blacklist Action', 'site-reviews'), |
|
467 | - 'options' => [ |
|
468 | - 'unapprove' => __('Require approval', 'site-reviews'), |
|
469 | - 'reject' => __('Reject submission', 'site-reviews'), |
|
470 | - ], |
|
471 | - 'type' => 'select', |
|
472 | - ], |
|
4 | + 'settings.general.style' => [ |
|
5 | + 'default' => 'default', |
|
6 | + 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | + 'label' => __('Plugin Style', 'site-reviews'), |
|
8 | + 'options' => [ |
|
9 | + 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
|
10 | + 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
|
11 | + 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
|
12 | + 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
|
13 | + 'wpforms' => 'Plugin: WPForms Lite (v1)', |
|
14 | + 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | + 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
16 | + 'divi' => 'Theme: Divi (v3)', |
|
17 | + 'materialize' => 'Theme: Materialize', |
|
18 | + 'twentyfifteen' => 'Theme: Twenty Fifteen', |
|
19 | + 'twentyseventeen' => 'Theme: Twenty Seventeen', |
|
20 | + 'twentynineteen' => 'Theme: Twenty Nineteen', |
|
21 | + ], |
|
22 | + 'type' => 'select', |
|
23 | + ], |
|
24 | + 'settings.general.require.approval' => [ |
|
25 | + 'default' => 'no', |
|
26 | + 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | + 'label' => __('Require Approval', 'site-reviews'), |
|
28 | + 'type' => 'yes_no', |
|
29 | + ], |
|
30 | + 'settings.general.require.login' => [ |
|
31 | + 'default' => 'no', |
|
32 | + 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | + 'label' => __('Require Login', 'site-reviews'), |
|
34 | + 'type' => 'yes_no', |
|
35 | + ], |
|
36 | + 'settings.general.require.login_register' => [ |
|
37 | + 'default' => 'no', |
|
38 | + 'depends_on' => [ |
|
39 | + 'settings.general.require.login' => 'yes', |
|
40 | + ], |
|
41 | + 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | + '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
43 | + ), |
|
44 | + 'label' => __('Show Registration Link', 'site-reviews'), |
|
45 | + 'type' => 'yes_no', |
|
46 | + ], |
|
47 | + 'settings.general.support.polylang' => [ |
|
48 | + 'default' => 'no', |
|
49 | + 'description' => sprintf(__('Integrate with the %s plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
50 | + '<a href="https://wordpress.org/plugins/polylang/">Polylang</a>' |
|
51 | + ), |
|
52 | + 'label' => __('Integrate with Polylang', 'site-reviews'), |
|
53 | + 'type' => 'yes_no', |
|
54 | + ], |
|
55 | + 'settings.general.support.rebusify' => [ |
|
56 | + 'default' => 'no', |
|
57 | + 'description' => sprintf(__('Integrate with the %s and sync your reviews to the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
58 | + '<a href="https://rebusify.com">Rebusify Confidence System</a>' |
|
59 | + ), |
|
60 | + 'label' => __('Integrate with Rebusify', 'site-reviews'), |
|
61 | + 'type' => 'yes_no', |
|
62 | + ], |
|
63 | + 'settings.general.support.rebusify_api_key' => [ |
|
64 | + 'default' => '', |
|
65 | + 'depends_on' => [ |
|
66 | + 'settings.general.support.rebusify' => ['yes'], |
|
67 | + ], |
|
68 | + 'description' => sprintf(__('Get a free Rebusify API key from %s.', 'site-reviews'), |
|
69 | + '<a href="https://rebusify.com">rebusify.com</a>' |
|
70 | + ), |
|
71 | + 'label' => __('Rebusify API key', 'site-reviews'), |
|
72 | + 'type' => 'text', |
|
73 | + ], |
|
74 | + 'settings.general.notifications' => [ |
|
75 | + 'default' => [], |
|
76 | + 'label' => __('Notifications', 'site-reviews'), |
|
77 | + 'options' => [ |
|
78 | + 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
79 | + 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
80 | + 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
81 | + 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
82 | + ], |
|
83 | + 'type' => 'checkbox', |
|
84 | + ], |
|
85 | + 'settings.general.notification_email' => [ |
|
86 | + 'default' => '', |
|
87 | + 'depends_on' => [ |
|
88 | + 'settings.general.notifications' => ['custom'], |
|
89 | + ], |
|
90 | + 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
91 | + 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
92 | + 'type' => 'text', |
|
93 | + ], |
|
94 | + 'settings.general.notification_slack' => [ |
|
95 | + 'default' => '', |
|
96 | + 'depends_on' => [ |
|
97 | + 'settings.general.notifications' => ['slack'], |
|
98 | + ], |
|
99 | + 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
100 | + '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
101 | + ), |
|
102 | + 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
103 | + 'type' => 'text', |
|
104 | + ], |
|
105 | + 'settings.general.notification_message' => [ |
|
106 | + 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
107 | + 'depends_on' => [ |
|
108 | + 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
109 | + ], |
|
110 | + 'description' => __( |
|
111 | + 'To restore the default text, save an empty template. '. |
|
112 | + 'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'. |
|
113 | + '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
114 | + '<br><code>{review_title}</code> The review title'. |
|
115 | + '<br><code>{review_content}</code> The review content'. |
|
116 | + '<br><code>{review_author}</code> The review author'. |
|
117 | + '<br><code>{review_email}</code> The email of the review author'. |
|
118 | + '<br><code>{review_ip}</code> The IP address of the review author'. |
|
119 | + '<br><code>{review_link}</code> The link to edit/view a review', |
|
120 | + 'site-reviews' |
|
121 | + ), |
|
122 | + 'label' => __('Notification Template', 'site-reviews'), |
|
123 | + 'rows' => 10, |
|
124 | + 'type' => 'code', |
|
125 | + ], |
|
126 | + 'settings.reviews.date.format' => [ |
|
127 | + 'default' => '', |
|
128 | + 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
129 | + '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
130 | + ), |
|
131 | + 'label' => __('Date Format', 'site-reviews'), |
|
132 | + 'options' => [ |
|
133 | + '' => __('Use the default date format', 'site-reviews'), |
|
134 | + 'relative' => __('Use a relative date format', 'site-reviews'), |
|
135 | + 'custom' => __('Use a custom date format', 'site-reviews'), |
|
136 | + ], |
|
137 | + 'type' => 'select', |
|
138 | + ], |
|
139 | + 'settings.reviews.date.custom' => [ |
|
140 | + 'default' => get_option('date_format'), |
|
141 | + 'depends_on' => [ |
|
142 | + 'settings.reviews.date.format' => 'custom', |
|
143 | + ], |
|
144 | + 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
145 | + 'label' => __('Custom Date Format', 'site-reviews'), |
|
146 | + 'type' => 'text', |
|
147 | + ], |
|
148 | + 'settings.reviews.assigned_links' => [ |
|
149 | + 'default' => 'no', |
|
150 | + 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
151 | + 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
152 | + 'type' => 'yes_no', |
|
153 | + ], |
|
154 | + 'settings.reviews.avatars' => [ |
|
155 | + 'default' => 'no', |
|
156 | + 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
157 | + 'label' => __('Enable Avatars', 'site-reviews'), |
|
158 | + 'type' => 'yes_no', |
|
159 | + ], |
|
160 | + 'settings.reviews.avatars_regenerate' => [ |
|
161 | + 'default' => 'no', |
|
162 | + 'depends_on' => [ |
|
163 | + 'settings.reviews.avatars' => 'yes', |
|
164 | + ], |
|
165 | + 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
166 | + 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
167 | + 'type' => 'yes_no', |
|
168 | + ], |
|
169 | + 'settings.reviews.avatars_size' => [ |
|
170 | + 'default' => 40, |
|
171 | + 'depends_on' => [ |
|
172 | + 'settings.reviews.avatars' => 'yes', |
|
173 | + ], |
|
174 | + 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
175 | + 'label' => __('Avatar Size', 'site-reviews'), |
|
176 | + 'type' => 'number', |
|
177 | + ], |
|
178 | + 'settings.reviews.excerpts' => [ |
|
179 | + 'default' => 'yes', |
|
180 | + 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
181 | + 'label' => __('Enable Excerpts', 'site-reviews'), |
|
182 | + 'type' => 'yes_no', |
|
183 | + ], |
|
184 | + 'settings.reviews.excerpts_length' => [ |
|
185 | + 'default' => 55, |
|
186 | + 'depends_on' => [ |
|
187 | + 'settings.reviews.excerpts' => 'yes', |
|
188 | + ], |
|
189 | + 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
190 | + 'label' => __('Excerpt Length', 'site-reviews'), |
|
191 | + 'type' => 'number', |
|
192 | + ], |
|
193 | + 'settings.reviews.fallback' => [ |
|
194 | + 'default' => 'no', |
|
195 | + 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
196 | + '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
197 | + '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
198 | + ), |
|
199 | + 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
200 | + 'type' => 'yes_no', |
|
201 | + ], |
|
202 | + 'settings.schema.type.default' => [ |
|
203 | + 'default' => 'LocalBusiness', |
|
204 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
205 | + 'label' => __('Default Schema Type', 'site-reviews'), |
|
206 | + 'options' => [ |
|
207 | + 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
208 | + 'Product' => __('Product', 'site-reviews'), |
|
209 | + 'custom' => __('Custom', 'site-reviews'), |
|
210 | + ], |
|
211 | + 'type' => 'select', |
|
212 | + ], |
|
213 | + 'settings.schema.type.custom' => [ |
|
214 | + 'default' => '', |
|
215 | + 'depends_on' => [ |
|
216 | + 'settings.schema.type.default' => 'custom', |
|
217 | + ], |
|
218 | + 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
219 | + 'label' => __('Custom Schema Type', 'site-reviews'), |
|
220 | + 'type' => 'text', |
|
221 | + ], |
|
222 | + 'settings.schema.name.default' => [ |
|
223 | + 'default' => 'post', |
|
224 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
225 | + 'label' => __('Default Name', 'site-reviews'), |
|
226 | + 'options' => [ |
|
227 | + 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
228 | + 'custom' => __('Enter a custom title', 'site-reviews'), |
|
229 | + ], |
|
230 | + 'type' => 'select', |
|
231 | + ], |
|
232 | + 'settings.schema.name.custom' => [ |
|
233 | + 'default' => '', |
|
234 | + 'depends_on' => [ |
|
235 | + 'settings.schema.name.default' => 'custom', |
|
236 | + ], |
|
237 | + 'label' => __('Custom Name', 'site-reviews'), |
|
238 | + 'type' => 'text', |
|
239 | + ], |
|
240 | + 'settings.schema.description.default' => [ |
|
241 | + 'default' => 'post', |
|
242 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
243 | + 'label' => __('Default Description', 'site-reviews'), |
|
244 | + 'options' => [ |
|
245 | + 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
246 | + 'custom' => __('Enter a custom description', 'site-reviews'), |
|
247 | + ], |
|
248 | + 'type' => 'select', |
|
249 | + ], |
|
250 | + 'settings.schema.description.custom' => [ |
|
251 | + 'default' => '', |
|
252 | + 'depends_on' => [ |
|
253 | + 'settings.schema.description.default' => 'custom', |
|
254 | + ], |
|
255 | + 'label' => __('Custom Description', 'site-reviews'), |
|
256 | + 'type' => 'text', |
|
257 | + ], |
|
258 | + 'settings.schema.url.default' => [ |
|
259 | + 'default' => 'post', |
|
260 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
261 | + 'label' => __('Default URL', 'site-reviews'), |
|
262 | + 'options' => [ |
|
263 | + 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
264 | + 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
265 | + ], |
|
266 | + 'type' => 'select', |
|
267 | + ], |
|
268 | + 'settings.schema.url.custom' => [ |
|
269 | + 'default' => '', |
|
270 | + 'depends_on' => [ |
|
271 | + 'settings.schema.url.default' => 'custom', |
|
272 | + ], |
|
273 | + 'label' => __('Custom URL', 'site-reviews'), |
|
274 | + 'type' => 'text', |
|
275 | + ], |
|
276 | + 'settings.schema.image.default' => [ |
|
277 | + 'default' => 'post', |
|
278 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
279 | + 'label' => __('Default Image', 'site-reviews'), |
|
280 | + 'options' => [ |
|
281 | + 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
282 | + 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
283 | + ], |
|
284 | + 'type' => 'select', |
|
285 | + ], |
|
286 | + 'settings.schema.image.custom' => [ |
|
287 | + 'default' => '', |
|
288 | + 'depends_on' => [ |
|
289 | + 'settings.schema.image.default' => 'custom', |
|
290 | + ], |
|
291 | + 'label' => __('Custom Image URL', 'site-reviews'), |
|
292 | + 'type' => 'text', |
|
293 | + ], |
|
294 | + 'settings.schema.address' => [ |
|
295 | + 'default' => '', |
|
296 | + 'depends_on' => [ |
|
297 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
298 | + ], |
|
299 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
300 | + 'label' => __('Address', 'site-reviews'), |
|
301 | + 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
302 | + 'type' => 'text', |
|
303 | + ], |
|
304 | + 'settings.schema.telephone' => [ |
|
305 | + 'default' => '', |
|
306 | + 'depends_on' => [ |
|
307 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
308 | + ], |
|
309 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
310 | + 'label' => __('Telephone Number', 'site-reviews'), |
|
311 | + 'placeholder' => '+1 (877) 273-3049', |
|
312 | + 'type' => 'text', |
|
313 | + ], |
|
314 | + 'settings.schema.pricerange' => [ |
|
315 | + 'default' => '', |
|
316 | + 'depends_on' => [ |
|
317 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
318 | + ], |
|
319 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
320 | + 'label' => __('Price Range', 'site-reviews'), |
|
321 | + 'placeholder' => '$$-$$$', |
|
322 | + 'type' => 'text', |
|
323 | + ], |
|
324 | + 'settings.schema.offertype' => [ |
|
325 | + 'default' => 'AggregateOffer', |
|
326 | + 'depends_on' => [ |
|
327 | + 'settings.schema.type.default' => 'Product', |
|
328 | + ], |
|
329 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
330 | + 'label' => __('Offer Type', 'site-reviews'), |
|
331 | + 'options' => [ |
|
332 | + 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
333 | + 'Offer' => __('Offer', 'site-reviews'), |
|
334 | + ], |
|
335 | + 'type' => 'select', |
|
336 | + ], |
|
337 | + 'settings.schema.price' => [ |
|
338 | + 'default' => '', |
|
339 | + 'depends_on' => [ |
|
340 | + 'settings.schema.type.default' => 'Product', |
|
341 | + 'settings.schema.offertype' => 'Offer', |
|
342 | + ], |
|
343 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
344 | + 'label' => __('Price', 'site-reviews'), |
|
345 | + 'placeholder' => '50.00', |
|
346 | + 'type' => 'text', |
|
347 | + ], |
|
348 | + 'settings.schema.lowprice' => [ |
|
349 | + 'default' => '', |
|
350 | + 'depends_on' => [ |
|
351 | + 'settings.schema.type.default' => 'Product', |
|
352 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
353 | + ], |
|
354 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
355 | + 'label' => __('Low Price', 'site-reviews'), |
|
356 | + 'placeholder' => '10.00', |
|
357 | + 'type' => 'text', |
|
358 | + ], |
|
359 | + 'settings.schema.highprice' => [ |
|
360 | + 'default' => '', |
|
361 | + 'depends_on' => [ |
|
362 | + 'settings.schema.type.default' => 'Product', |
|
363 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
364 | + ], |
|
365 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
366 | + 'label' => __('High Price', 'site-reviews'), |
|
367 | + 'placeholder' => '100.00', |
|
368 | + 'type' => 'text', |
|
369 | + ], |
|
370 | + 'settings.schema.pricecurrency' => [ |
|
371 | + 'default' => '', |
|
372 | + 'depends_on' => [ |
|
373 | + 'settings.schema.type.default' => 'Product', |
|
374 | + ], |
|
375 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
376 | + 'label' => __('Price Currency', 'site-reviews'), |
|
377 | + 'placeholder' => 'USD', |
|
378 | + 'type' => 'text', |
|
379 | + ], |
|
380 | + 'settings.submissions.required' => [ |
|
381 | + 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
382 | + 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
383 | + 'label' => __('Required Fields', 'site-reviews'), |
|
384 | + 'options' => [ |
|
385 | + 'rating' => __('Rating', 'site-reviews'), |
|
386 | + 'title' => __('Title', 'site-reviews'), |
|
387 | + 'content' => __('Review', 'site-reviews'), |
|
388 | + 'name' => __('Name', 'site-reviews'), |
|
389 | + 'email' => __('Email', 'site-reviews'), |
|
390 | + 'terms' => __('Terms', 'site-reviews'), |
|
391 | + ], |
|
392 | + 'type' => 'checkbox', |
|
393 | + ], |
|
394 | + 'settings.submissions.recaptcha.integration' => [ |
|
395 | + 'default' => '', |
|
396 | + 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
397 | + 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
398 | + 'options' => [ |
|
399 | + '' => 'Do not use reCAPTCHA', |
|
400 | + 'all' => 'Use reCAPTCHA', |
|
401 | + 'guest' => 'Use reCAPTCHA only for guest users', |
|
402 | + ], |
|
403 | + 'type' => 'select', |
|
404 | + ], |
|
405 | + 'settings.submissions.recaptcha.key' => [ |
|
406 | + 'default' => '', |
|
407 | + 'depends_on' => [ |
|
408 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
409 | + ], |
|
410 | + 'label' => __('Site Key', 'site-reviews'), |
|
411 | + 'type' => 'text', |
|
412 | + ], |
|
413 | + 'settings.submissions.recaptcha.secret' => [ |
|
414 | + 'default' => '', |
|
415 | + 'depends_on' => [ |
|
416 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
417 | + ], |
|
418 | + 'label' => __('Site Secret', 'site-reviews'), |
|
419 | + 'type' => 'text', |
|
420 | + ], |
|
421 | + 'settings.submissions.recaptcha.position' => [ |
|
422 | + 'default' => 'bottomleft', |
|
423 | + 'depends_on' => [ |
|
424 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
425 | + ], |
|
426 | + 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
427 | + 'label' => __('Badge Position', 'site-reviews'), |
|
428 | + 'options' => [ |
|
429 | + 'bottomleft' => 'Bottom Left', |
|
430 | + 'bottomright' => 'Bottom Right', |
|
431 | + 'inline' => 'Inline', |
|
432 | + ], |
|
433 | + 'type' => 'select', |
|
434 | + ], |
|
435 | + 'settings.submissions.akismet' => [ |
|
436 | + 'default' => 'no', |
|
437 | + 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
438 | + 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
439 | + 'type' => 'yes_no', |
|
440 | + ], |
|
441 | + 'settings.submissions.blacklist.integration' => [ |
|
442 | + 'default' => '', |
|
443 | + 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
444 | + '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
445 | + ), |
|
446 | + 'label' => __('Blacklist', 'site-reviews'), |
|
447 | + 'options' => [ |
|
448 | + '' => 'Use the Site Reviews Blacklist', |
|
449 | + 'comments' => 'Use the WordPress Comment Blacklist', |
|
450 | + ], |
|
451 | + 'type' => 'select', |
|
452 | + ], |
|
453 | + 'settings.submissions.blacklist.entries' => [ |
|
454 | + 'default' => '', |
|
455 | + 'depends_on' => [ |
|
456 | + 'settings.submissions.blacklist.integration' => [''], |
|
457 | + ], |
|
458 | + 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
459 | + 'label' => __('Review Blacklist', 'site-reviews'), |
|
460 | + 'rows' => 10, |
|
461 | + 'type' => 'code', |
|
462 | + ], |
|
463 | + 'settings.submissions.blacklist.action' => [ |
|
464 | + 'default' => 'unapprove', |
|
465 | + 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
466 | + 'label' => __('Blacklist Action', 'site-reviews'), |
|
467 | + 'options' => [ |
|
468 | + 'unapprove' => __('Require approval', 'site-reviews'), |
|
469 | + 'reject' => __('Reject submission', 'site-reviews'), |
|
470 | + ], |
|
471 | + 'type' => 'select', |
|
472 | + ], |
|
473 | 473 | ]; |
@@ -3,16 +3,16 @@ discard block |
||
3 | 3 | return [ |
4 | 4 | 'settings.general.style' => [ |
5 | 5 | 'default' => 'default', |
6 | - 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | - 'label' => __('Plugin Style', 'site-reviews'), |
|
6 | + 'description' => __( 'Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews' ), |
|
7 | + 'label' => __( 'Plugin Style', 'site-reviews' ), |
|
8 | 8 | 'options' => [ |
9 | 9 | 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
10 | 10 | 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
11 | 11 | 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
12 | 12 | 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
13 | 13 | 'wpforms' => 'Plugin: WPForms Lite (v1)', |
14 | - 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | - 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
14 | + 'default' => __( 'Site Reviews (default)', 'site-reviews' ), |
|
15 | + 'minimal' => __( 'Site Reviews (minimal)', 'site-reviews' ), |
|
16 | 16 | 'divi' => 'Theme: Divi (v3)', |
17 | 17 | 'materialize' => 'Theme: Materialize', |
18 | 18 | 'twentyfifteen' => 'Theme: Twenty Fifteen', |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | ], |
24 | 24 | 'settings.general.require.approval' => [ |
25 | 25 | 'default' => 'no', |
26 | - 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | - 'label' => __('Require Approval', 'site-reviews'), |
|
26 | + 'description' => __( 'Set the status of new review submissions to "unapproved".', 'site-reviews' ), |
|
27 | + 'label' => __( 'Require Approval', 'site-reviews' ), |
|
28 | 28 | 'type' => 'yes_no', |
29 | 29 | ], |
30 | 30 | 'settings.general.require.login' => [ |
31 | 31 | 'default' => 'no', |
32 | - 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | - 'label' => __('Require Login', 'site-reviews'), |
|
32 | + 'description' => __( 'Only allow review submissions from registered users.', 'site-reviews' ), |
|
33 | + 'label' => __( 'Require Login', 'site-reviews' ), |
|
34 | 34 | 'type' => 'yes_no', |
35 | 35 | ], |
36 | 36 | 'settings.general.require.login_register' => [ |
@@ -38,26 +38,26 @@ discard block |
||
38 | 38 | 'depends_on' => [ |
39 | 39 | 'settings.general.require.login' => 'yes', |
40 | 40 | ], |
41 | - 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | - '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
41 | + 'description' => sprintf( __( 'Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews' ), |
|
42 | + '<a href="'.admin_url( 'options-general.php#users_can_register' ).'">'.__( 'Anyone can register', 'site-reviews' ).'</a>' |
|
43 | 43 | ), |
44 | - 'label' => __('Show Registration Link', 'site-reviews'), |
|
44 | + 'label' => __( 'Show Registration Link', 'site-reviews' ), |
|
45 | 45 | 'type' => 'yes_no', |
46 | 46 | ], |
47 | 47 | 'settings.general.support.polylang' => [ |
48 | 48 | 'default' => 'no', |
49 | - 'description' => sprintf(__('Integrate with the %s plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
49 | + 'description' => sprintf( __( 'Integrate with the %s plugin to calculate ratings for all languages of a post.', 'site-reviews' ), |
|
50 | 50 | '<a href="https://wordpress.org/plugins/polylang/">Polylang</a>' |
51 | 51 | ), |
52 | - 'label' => __('Integrate with Polylang', 'site-reviews'), |
|
52 | + 'label' => __( 'Integrate with Polylang', 'site-reviews' ), |
|
53 | 53 | 'type' => 'yes_no', |
54 | 54 | ], |
55 | 55 | 'settings.general.support.rebusify' => [ |
56 | 56 | 'default' => 'no', |
57 | - 'description' => sprintf(__('Integrate with the %s and sync your reviews to the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
57 | + 'description' => sprintf( __( 'Integrate with the %s and sync your reviews to the blockchain to increase online reputation, trust, and transparency.', 'site-reviews' ), |
|
58 | 58 | '<a href="https://rebusify.com">Rebusify Confidence System</a>' |
59 | 59 | ), |
60 | - 'label' => __('Integrate with Rebusify', 'site-reviews'), |
|
60 | + 'label' => __( 'Integrate with Rebusify', 'site-reviews' ), |
|
61 | 61 | 'type' => 'yes_no', |
62 | 62 | ], |
63 | 63 | 'settings.general.support.rebusify_api_key' => [ |
@@ -65,20 +65,20 @@ discard block |
||
65 | 65 | 'depends_on' => [ |
66 | 66 | 'settings.general.support.rebusify' => ['yes'], |
67 | 67 | ], |
68 | - 'description' => sprintf(__('Get a free Rebusify API key from %s.', 'site-reviews'), |
|
68 | + 'description' => sprintf( __( 'Get a free Rebusify API key from %s.', 'site-reviews' ), |
|
69 | 69 | '<a href="https://rebusify.com">rebusify.com</a>' |
70 | 70 | ), |
71 | - 'label' => __('Rebusify API key', 'site-reviews'), |
|
71 | + 'label' => __( 'Rebusify API key', 'site-reviews' ), |
|
72 | 72 | 'type' => 'text', |
73 | 73 | ], |
74 | 74 | 'settings.general.notifications' => [ |
75 | 75 | 'default' => [], |
76 | - 'label' => __('Notifications', 'site-reviews'), |
|
76 | + 'label' => __( 'Notifications', 'site-reviews' ), |
|
77 | 77 | 'options' => [ |
78 | - 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
79 | - 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
80 | - 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
81 | - 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
78 | + 'admin' => __( 'Send to administrator', 'site-reviews' ).' <code>'.(string)get_option( 'admin_email' ).'</code>', |
|
79 | + 'author' => __( 'Send to author of the page that the review is assigned to', 'site-reviews' ), |
|
80 | + 'custom' => __( 'Send to one or more email addresses', 'site-reviews' ), |
|
81 | + 'slack' => __( 'Send to <a href="https://slack.com/">Slack</a>', 'site-reviews' ), |
|
82 | 82 | ], |
83 | 83 | 'type' => 'checkbox', |
84 | 84 | ], |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'depends_on' => [ |
88 | 88 | 'settings.general.notifications' => ['custom'], |
89 | 89 | ], |
90 | - 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
91 | - 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
90 | + 'label' => __( 'Send Notification Emails To', 'site-reviews' ), |
|
91 | + 'placeholder' => __( 'Separate multiple emails with a comma', 'site-reviews' ), |
|
92 | 92 | 'type' => 'text', |
93 | 93 | ], |
94 | 94 | 'settings.general.notification_slack' => [ |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | 'depends_on' => [ |
97 | 97 | 'settings.general.notifications' => ['slack'], |
98 | 98 | ], |
99 | - 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
100 | - '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
99 | + 'description' => sprintf( __( 'To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews' ), |
|
100 | + '<a href="https://api.slack.com/incoming-webhooks">'.__( 'Incoming WebHook', 'site-reviews' ).'</a>' |
|
101 | 101 | ), |
102 | - 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
102 | + 'label' => __( 'Slack Webhook URL', 'site-reviews' ), |
|
103 | 103 | 'type' => 'text', |
104 | 104 | ], |
105 | 105 | 'settings.general.notification_message' => [ |
106 | - 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
106 | + 'default' => glsr( 'Modules\Html\Template' )->build( 'templates/email-notification' ), |
|
107 | 107 | 'depends_on' => [ |
108 | 108 | 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
109 | 109 | ], |
@@ -119,42 +119,42 @@ discard block |
||
119 | 119 | '<br><code>{review_link}</code> The link to edit/view a review', |
120 | 120 | 'site-reviews' |
121 | 121 | ), |
122 | - 'label' => __('Notification Template', 'site-reviews'), |
|
122 | + 'label' => __( 'Notification Template', 'site-reviews' ), |
|
123 | 123 | 'rows' => 10, |
124 | 124 | 'type' => 'code', |
125 | 125 | ], |
126 | 126 | 'settings.reviews.date.format' => [ |
127 | 127 | 'default' => '', |
128 | - 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
129 | - '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
128 | + 'description' => sprintf( __( 'The default date format is the one set in your %s.', 'site-reviews' ), |
|
129 | + '<a href="'.admin_url( 'options-general.php#date_format_custom' ).'">'.__( 'WordPress settings', 'site-reviews' ).'</a>' |
|
130 | 130 | ), |
131 | - 'label' => __('Date Format', 'site-reviews'), |
|
131 | + 'label' => __( 'Date Format', 'site-reviews' ), |
|
132 | 132 | 'options' => [ |
133 | - '' => __('Use the default date format', 'site-reviews'), |
|
134 | - 'relative' => __('Use a relative date format', 'site-reviews'), |
|
135 | - 'custom' => __('Use a custom date format', 'site-reviews'), |
|
133 | + '' => __( 'Use the default date format', 'site-reviews' ), |
|
134 | + 'relative' => __( 'Use a relative date format', 'site-reviews' ), |
|
135 | + 'custom' => __( 'Use a custom date format', 'site-reviews' ), |
|
136 | 136 | ], |
137 | 137 | 'type' => 'select', |
138 | 138 | ], |
139 | 139 | 'settings.reviews.date.custom' => [ |
140 | - 'default' => get_option('date_format'), |
|
140 | + 'default' => get_option( 'date_format' ), |
|
141 | 141 | 'depends_on' => [ |
142 | 142 | 'settings.reviews.date.format' => 'custom', |
143 | 143 | ], |
144 | - 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
145 | - 'label' => __('Custom Date Format', 'site-reviews'), |
|
144 | + 'description' => __( 'Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews' ), |
|
145 | + 'label' => __( 'Custom Date Format', 'site-reviews' ), |
|
146 | 146 | 'type' => 'text', |
147 | 147 | ], |
148 | 148 | 'settings.reviews.assigned_links' => [ |
149 | 149 | 'default' => 'no', |
150 | - 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
151 | - 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
150 | + 'description' => __( 'Display a link to the assigned post of a review.', 'site-reviews' ), |
|
151 | + 'label' => __( 'Enable Assigned Links', 'site-reviews' ), |
|
152 | 152 | 'type' => 'yes_no', |
153 | 153 | ], |
154 | 154 | 'settings.reviews.avatars' => [ |
155 | 155 | 'default' => 'no', |
156 | - 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
157 | - 'label' => __('Enable Avatars', 'site-reviews'), |
|
156 | + 'description' => __( 'Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews' ), |
|
157 | + 'label' => __( 'Enable Avatars', 'site-reviews' ), |
|
158 | 158 | 'type' => 'yes_no', |
159 | 159 | ], |
160 | 160 | 'settings.reviews.avatars_regenerate' => [ |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | 'depends_on' => [ |
163 | 163 | 'settings.reviews.avatars' => 'yes', |
164 | 164 | ], |
165 | - 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
166 | - 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
165 | + 'description' => __( 'Regenerate the avatar whenever a local review is shown?', 'site-reviews' ), |
|
166 | + 'label' => __( 'Regenerate Avatars', 'site-reviews' ), |
|
167 | 167 | 'type' => 'yes_no', |
168 | 168 | ], |
169 | 169 | 'settings.reviews.avatars_size' => [ |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | 'depends_on' => [ |
172 | 172 | 'settings.reviews.avatars' => 'yes', |
173 | 173 | ], |
174 | - 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
175 | - 'label' => __('Avatar Size', 'site-reviews'), |
|
174 | + 'description' => __( 'Set the avatar size in pixels.', 'site-reviews' ), |
|
175 | + 'label' => __( 'Avatar Size', 'site-reviews' ), |
|
176 | 176 | 'type' => 'number', |
177 | 177 | ], |
178 | 178 | 'settings.reviews.excerpts' => [ |
179 | 179 | 'default' => 'yes', |
180 | - 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
181 | - 'label' => __('Enable Excerpts', 'site-reviews'), |
|
180 | + 'description' => __( 'Display an excerpt instead of the full review.', 'site-reviews' ), |
|
181 | + 'label' => __( 'Enable Excerpts', 'site-reviews' ), |
|
182 | 182 | 'type' => 'yes_no', |
183 | 183 | ], |
184 | 184 | 'settings.reviews.excerpts_length' => [ |
@@ -186,27 +186,27 @@ discard block |
||
186 | 186 | 'depends_on' => [ |
187 | 187 | 'settings.reviews.excerpts' => 'yes', |
188 | 188 | ], |
189 | - 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
190 | - 'label' => __('Excerpt Length', 'site-reviews'), |
|
189 | + 'description' => __( 'Set the excerpt word length.', 'site-reviews' ), |
|
190 | + 'label' => __( 'Excerpt Length', 'site-reviews' ), |
|
191 | 191 | 'type' => 'number', |
192 | 192 | ], |
193 | 193 | 'settings.reviews.fallback' => [ |
194 | 194 | 'default' => 'no', |
195 | - 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
196 | - '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
197 | - '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
195 | + 'description' => sprintf( __( 'Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews' ), |
|
196 | + '<a href="'.admin_url( 'edit.php?post_type=site-review&page=settings#!translations' ).'">'.__( 'Translations', 'site-reviews' ).'</a>', |
|
197 | + '<code>'.__( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' ).'</code>' |
|
198 | 198 | ), |
199 | - 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
199 | + 'label' => __( 'Enable Fallback Text', 'site-reviews' ), |
|
200 | 200 | 'type' => 'yes_no', |
201 | 201 | ], |
202 | 202 | 'settings.schema.type.default' => [ |
203 | 203 | 'default' => 'LocalBusiness', |
204 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
205 | - 'label' => __('Default Schema Type', 'site-reviews'), |
|
204 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_type</code>', |
|
205 | + 'label' => __( 'Default Schema Type', 'site-reviews' ), |
|
206 | 206 | 'options' => [ |
207 | - 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
208 | - 'Product' => __('Product', 'site-reviews'), |
|
209 | - 'custom' => __('Custom', 'site-reviews'), |
|
207 | + 'LocalBusiness' => __( 'Local Business', 'site-reviews' ), |
|
208 | + 'Product' => __( 'Product', 'site-reviews' ), |
|
209 | + 'custom' => __( 'Custom', 'site-reviews' ), |
|
210 | 210 | ], |
211 | 211 | 'type' => 'select', |
212 | 212 | ], |
@@ -215,17 +215,17 @@ discard block |
||
215 | 215 | 'depends_on' => [ |
216 | 216 | 'settings.schema.type.default' => 'custom', |
217 | 217 | ], |
218 | - 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
219 | - 'label' => __('Custom Schema Type', 'site-reviews'), |
|
218 | + 'description' => '<a href="https://schema.org/docs/schemas.html">'.__( 'View more information on schema types here', 'site-reviews' ).'</a>', |
|
219 | + 'label' => __( 'Custom Schema Type', 'site-reviews' ), |
|
220 | 220 | 'type' => 'text', |
221 | 221 | ], |
222 | 222 | 'settings.schema.name.default' => [ |
223 | 223 | 'default' => 'post', |
224 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
225 | - 'label' => __('Default Name', 'site-reviews'), |
|
224 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_name</code>', |
|
225 | + 'label' => __( 'Default Name', 'site-reviews' ), |
|
226 | 226 | 'options' => [ |
227 | - 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
228 | - 'custom' => __('Enter a custom title', 'site-reviews'), |
|
227 | + 'post' => __( 'Use the assigned or current page title', 'site-reviews' ), |
|
228 | + 'custom' => __( 'Enter a custom title', 'site-reviews' ), |
|
229 | 229 | ], |
230 | 230 | 'type' => 'select', |
231 | 231 | ], |
@@ -234,16 +234,16 @@ discard block |
||
234 | 234 | 'depends_on' => [ |
235 | 235 | 'settings.schema.name.default' => 'custom', |
236 | 236 | ], |
237 | - 'label' => __('Custom Name', 'site-reviews'), |
|
237 | + 'label' => __( 'Custom Name', 'site-reviews' ), |
|
238 | 238 | 'type' => 'text', |
239 | 239 | ], |
240 | 240 | 'settings.schema.description.default' => [ |
241 | 241 | 'default' => 'post', |
242 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
243 | - 'label' => __('Default Description', 'site-reviews'), |
|
242 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_description</code>', |
|
243 | + 'label' => __( 'Default Description', 'site-reviews' ), |
|
244 | 244 | 'options' => [ |
245 | - 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
246 | - 'custom' => __('Enter a custom description', 'site-reviews'), |
|
245 | + 'post' => __( 'Use the assigned or current page excerpt', 'site-reviews' ), |
|
246 | + 'custom' => __( 'Enter a custom description', 'site-reviews' ), |
|
247 | 247 | ], |
248 | 248 | 'type' => 'select', |
249 | 249 | ], |
@@ -252,16 +252,16 @@ discard block |
||
252 | 252 | 'depends_on' => [ |
253 | 253 | 'settings.schema.description.default' => 'custom', |
254 | 254 | ], |
255 | - 'label' => __('Custom Description', 'site-reviews'), |
|
255 | + 'label' => __( 'Custom Description', 'site-reviews' ), |
|
256 | 256 | 'type' => 'text', |
257 | 257 | ], |
258 | 258 | 'settings.schema.url.default' => [ |
259 | 259 | 'default' => 'post', |
260 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
261 | - 'label' => __('Default URL', 'site-reviews'), |
|
260 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_url</code>', |
|
261 | + 'label' => __( 'Default URL', 'site-reviews' ), |
|
262 | 262 | 'options' => [ |
263 | - 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
264 | - 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
263 | + 'post' => __( 'Use the assigned or current page URL', 'site-reviews' ), |
|
264 | + 'custom' => __( 'Enter a custom URL', 'site-reviews' ), |
|
265 | 265 | ], |
266 | 266 | 'type' => 'select', |
267 | 267 | ], |
@@ -270,16 +270,16 @@ discard block |
||
270 | 270 | 'depends_on' => [ |
271 | 271 | 'settings.schema.url.default' => 'custom', |
272 | 272 | ], |
273 | - 'label' => __('Custom URL', 'site-reviews'), |
|
273 | + 'label' => __( 'Custom URL', 'site-reviews' ), |
|
274 | 274 | 'type' => 'text', |
275 | 275 | ], |
276 | 276 | 'settings.schema.image.default' => [ |
277 | 277 | 'default' => 'post', |
278 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
279 | - 'label' => __('Default Image', 'site-reviews'), |
|
278 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_image</code>', |
|
279 | + 'label' => __( 'Default Image', 'site-reviews' ), |
|
280 | 280 | 'options' => [ |
281 | - 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
282 | - 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
281 | + 'post' => __( 'Use the featured image of the assigned or current page', 'site-reviews' ), |
|
282 | + 'custom' => __( 'Enter a custom image URL', 'site-reviews' ), |
|
283 | 283 | ], |
284 | 284 | 'type' => 'select', |
285 | 285 | ], |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | 'depends_on' => [ |
289 | 289 | 'settings.schema.image.default' => 'custom', |
290 | 290 | ], |
291 | - 'label' => __('Custom Image URL', 'site-reviews'), |
|
291 | + 'label' => __( 'Custom Image URL', 'site-reviews' ), |
|
292 | 292 | 'type' => 'text', |
293 | 293 | ], |
294 | 294 | 'settings.schema.address' => [ |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | 'depends_on' => [ |
297 | 297 | 'settings.schema.type.default' => 'LocalBusiness', |
298 | 298 | ], |
299 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
300 | - 'label' => __('Address', 'site-reviews'), |
|
299 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_address</code>', |
|
300 | + 'label' => __( 'Address', 'site-reviews' ), |
|
301 | 301 | 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
302 | 302 | 'type' => 'text', |
303 | 303 | ], |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | 'depends_on' => [ |
307 | 307 | 'settings.schema.type.default' => 'LocalBusiness', |
308 | 308 | ], |
309 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
310 | - 'label' => __('Telephone Number', 'site-reviews'), |
|
309 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_telephone</code>', |
|
310 | + 'label' => __( 'Telephone Number', 'site-reviews' ), |
|
311 | 311 | 'placeholder' => '+1 (877) 273-3049', |
312 | 312 | 'type' => 'text', |
313 | 313 | ], |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | 'depends_on' => [ |
317 | 317 | 'settings.schema.type.default' => 'LocalBusiness', |
318 | 318 | ], |
319 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
320 | - 'label' => __('Price Range', 'site-reviews'), |
|
319 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_pricerange</code>', |
|
320 | + 'label' => __( 'Price Range', 'site-reviews' ), |
|
321 | 321 | 'placeholder' => '$$-$$$', |
322 | 322 | 'type' => 'text', |
323 | 323 | ], |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | 'depends_on' => [ |
327 | 327 | 'settings.schema.type.default' => 'Product', |
328 | 328 | ], |
329 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
330 | - 'label' => __('Offer Type', 'site-reviews'), |
|
329 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_offertype</code>', |
|
330 | + 'label' => __( 'Offer Type', 'site-reviews' ), |
|
331 | 331 | 'options' => [ |
332 | - 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
333 | - 'Offer' => __('Offer', 'site-reviews'), |
|
332 | + 'AggregateOffer' => __( 'AggregateOffer', 'site-reviews' ), |
|
333 | + 'Offer' => __( 'Offer', 'site-reviews' ), |
|
334 | 334 | ], |
335 | 335 | 'type' => 'select', |
336 | 336 | ], |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | 'settings.schema.type.default' => 'Product', |
341 | 341 | 'settings.schema.offertype' => 'Offer', |
342 | 342 | ], |
343 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
344 | - 'label' => __('Price', 'site-reviews'), |
|
343 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_price</code>', |
|
344 | + 'label' => __( 'Price', 'site-reviews' ), |
|
345 | 345 | 'placeholder' => '50.00', |
346 | 346 | 'type' => 'text', |
347 | 347 | ], |
@@ -351,8 +351,8 @@ discard block |
||
351 | 351 | 'settings.schema.type.default' => 'Product', |
352 | 352 | 'settings.schema.offertype' => 'AggregateOffer', |
353 | 353 | ], |
354 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
355 | - 'label' => __('Low Price', 'site-reviews'), |
|
354 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_lowprice</code>', |
|
355 | + 'label' => __( 'Low Price', 'site-reviews' ), |
|
356 | 356 | 'placeholder' => '10.00', |
357 | 357 | 'type' => 'text', |
358 | 358 | ], |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | 'settings.schema.type.default' => 'Product', |
363 | 363 | 'settings.schema.offertype' => 'AggregateOffer', |
364 | 364 | ], |
365 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
366 | - 'label' => __('High Price', 'site-reviews'), |
|
365 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_highprice</code>', |
|
366 | + 'label' => __( 'High Price', 'site-reviews' ), |
|
367 | 367 | 'placeholder' => '100.00', |
368 | 368 | 'type' => 'text', |
369 | 369 | ], |
@@ -372,29 +372,29 @@ discard block |
||
372 | 372 | 'depends_on' => [ |
373 | 373 | 'settings.schema.type.default' => 'Product', |
374 | 374 | ], |
375 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
376 | - 'label' => __('Price Currency', 'site-reviews'), |
|
375 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_pricecurrency</code>', |
|
376 | + 'label' => __( 'Price Currency', 'site-reviews' ), |
|
377 | 377 | 'placeholder' => 'USD', |
378 | 378 | 'type' => 'text', |
379 | 379 | ], |
380 | 380 | 'settings.submissions.required' => [ |
381 | 381 | 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
382 | - 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
383 | - 'label' => __('Required Fields', 'site-reviews'), |
|
382 | + 'description' => __( 'Choose which fields should be required in the submission form.', 'site-reviews' ), |
|
383 | + 'label' => __( 'Required Fields', 'site-reviews' ), |
|
384 | 384 | 'options' => [ |
385 | - 'rating' => __('Rating', 'site-reviews'), |
|
386 | - 'title' => __('Title', 'site-reviews'), |
|
387 | - 'content' => __('Review', 'site-reviews'), |
|
388 | - 'name' => __('Name', 'site-reviews'), |
|
389 | - 'email' => __('Email', 'site-reviews'), |
|
390 | - 'terms' => __('Terms', 'site-reviews'), |
|
385 | + 'rating' => __( 'Rating', 'site-reviews' ), |
|
386 | + 'title' => __( 'Title', 'site-reviews' ), |
|
387 | + 'content' => __( 'Review', 'site-reviews' ), |
|
388 | + 'name' => __( 'Name', 'site-reviews' ), |
|
389 | + 'email' => __( 'Email', 'site-reviews' ), |
|
390 | + 'terms' => __( 'Terms', 'site-reviews' ), |
|
391 | 391 | ], |
392 | 392 | 'type' => 'checkbox', |
393 | 393 | ], |
394 | 394 | 'settings.submissions.recaptcha.integration' => [ |
395 | 395 | 'default' => '', |
396 | - 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
397 | - 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
396 | + 'description' => __( 'Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews' ), |
|
397 | + 'label' => __( 'Invisible reCAPTCHA', 'site-reviews' ), |
|
398 | 398 | 'options' => [ |
399 | 399 | '' => 'Do not use reCAPTCHA', |
400 | 400 | 'all' => 'Use reCAPTCHA', |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | 'depends_on' => [ |
408 | 408 | 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
409 | 409 | ], |
410 | - 'label' => __('Site Key', 'site-reviews'), |
|
410 | + 'label' => __( 'Site Key', 'site-reviews' ), |
|
411 | 411 | 'type' => 'text', |
412 | 412 | ], |
413 | 413 | 'settings.submissions.recaptcha.secret' => [ |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | 'depends_on' => [ |
416 | 416 | 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
417 | 417 | ], |
418 | - 'label' => __('Site Secret', 'site-reviews'), |
|
418 | + 'label' => __( 'Site Secret', 'site-reviews' ), |
|
419 | 419 | 'type' => 'text', |
420 | 420 | ], |
421 | 421 | 'settings.submissions.recaptcha.position' => [ |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | 'depends_on' => [ |
424 | 424 | 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
425 | 425 | ], |
426 | - 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
427 | - 'label' => __('Badge Position', 'site-reviews'), |
|
426 | + 'description' => __( 'This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews' ), |
|
427 | + 'label' => __( 'Badge Position', 'site-reviews' ), |
|
428 | 428 | 'options' => [ |
429 | 429 | 'bottomleft' => 'Bottom Left', |
430 | 430 | 'bottomright' => 'Bottom Right', |
@@ -434,16 +434,16 @@ discard block |
||
434 | 434 | ], |
435 | 435 | 'settings.submissions.akismet' => [ |
436 | 436 | 'default' => 'no', |
437 | - 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
438 | - 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
437 | + 'description' => __( 'The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews' ), |
|
438 | + 'label' => __( 'Enable Akismet Integration', 'site-reviews' ), |
|
439 | 439 | 'type' => 'yes_no', |
440 | 440 | ], |
441 | 441 | 'settings.submissions.blacklist.integration' => [ |
442 | 442 | 'default' => '', |
443 | - 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
444 | - '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
443 | + 'description' => sprintf( __( 'Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews' ), |
|
444 | + '<a href="'.admin_url( 'options-discussion.php#users_can_register' ).'">'.__( 'Comment Blacklist', 'site-reviews' ).'</a>' |
|
445 | 445 | ), |
446 | - 'label' => __('Blacklist', 'site-reviews'), |
|
446 | + 'label' => __( 'Blacklist', 'site-reviews' ), |
|
447 | 447 | 'options' => [ |
448 | 448 | '' => 'Use the Site Reviews Blacklist', |
449 | 449 | 'comments' => 'Use the WordPress Comment Blacklist', |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | 'depends_on' => [ |
456 | 456 | 'settings.submissions.blacklist.integration' => [''], |
457 | 457 | ], |
458 | - 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
459 | - 'label' => __('Review Blacklist', 'site-reviews'), |
|
458 | + 'description' => __( 'One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews' ), |
|
459 | + 'label' => __( 'Review Blacklist', 'site-reviews' ), |
|
460 | 460 | 'rows' => 10, |
461 | 461 | 'type' => 'code', |
462 | 462 | ], |
463 | 463 | 'settings.submissions.blacklist.action' => [ |
464 | 464 | 'default' => 'unapprove', |
465 | - 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
466 | - 'label' => __('Blacklist Action', 'site-reviews'), |
|
465 | + 'description' => __( 'Choose the action that should be taken when a review is blacklisted.', 'site-reviews' ), |
|
466 | + 'label' => __( 'Blacklist Action', 'site-reviews' ), |
|
467 | 467 | 'options' => [ |
468 | - 'unapprove' => __('Require approval', 'site-reviews'), |
|
469 | - 'reject' => __('Reject submission', 'site-reviews'), |
|
468 | + 'unapprove' => __( 'Require approval', 'site-reviews' ), |
|
469 | + 'reject' => __( 'Reject submission', 'site-reviews' ), |
|
470 | 470 | ], |
471 | 471 | 'type' => 'select', |
472 | 472 | ], |
@@ -19,430 +19,430 @@ |
||
19 | 19 | |
20 | 20 | class EditorController extends Controller |
21 | 21 | { |
22 | - /** |
|
23 | - * @return void |
|
24 | - * @action admin_enqueue_scripts |
|
25 | - */ |
|
26 | - public function customizePostStatusLabels() |
|
27 | - { |
|
28 | - glsr(Labels::class)->customizePostStatusLabels(); |
|
29 | - } |
|
22 | + /** |
|
23 | + * @return void |
|
24 | + * @action admin_enqueue_scripts |
|
25 | + */ |
|
26 | + public function customizePostStatusLabels() |
|
27 | + { |
|
28 | + glsr(Labels::class)->customizePostStatusLabels(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param array $settings |
|
33 | - * @return array |
|
34 | - * @filter wp_editor_settings |
|
35 | - */ |
|
36 | - public function filterEditorSettings($settings) |
|
37 | - { |
|
38 | - return glsr(Customization::class)->filterEditorSettings( |
|
39 | - glsr(Helper::class)->consolidateArray($settings) |
|
40 | - ); |
|
41 | - } |
|
31 | + /** |
|
32 | + * @param array $settings |
|
33 | + * @return array |
|
34 | + * @filter wp_editor_settings |
|
35 | + */ |
|
36 | + public function filterEditorSettings($settings) |
|
37 | + { |
|
38 | + return glsr(Customization::class)->filterEditorSettings( |
|
39 | + glsr(Helper::class)->consolidateArray($settings) |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script. |
|
45 | - * @param string $html |
|
46 | - * @return string |
|
47 | - * @filter the_editor |
|
48 | - */ |
|
49 | - public function filterEditorTextarea($html) |
|
50 | - { |
|
51 | - return glsr(Customization::class)->filterEditorTextarea($html); |
|
52 | - } |
|
43 | + /** |
|
44 | + * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script. |
|
45 | + * @param string $html |
|
46 | + * @return string |
|
47 | + * @filter the_editor |
|
48 | + */ |
|
49 | + public function filterEditorTextarea($html) |
|
50 | + { |
|
51 | + return glsr(Customization::class)->filterEditorTextarea($html); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param bool $protected |
|
56 | - * @param string $metaKey |
|
57 | - * @param string $metaType |
|
58 | - * @return bool |
|
59 | - * @filter is_protected_meta |
|
60 | - */ |
|
61 | - public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
62 | - { |
|
63 | - if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
64 | - $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
65 | - $values = glsr(Helper::class)->prefixArrayKeys($values); |
|
66 | - if (array_key_exists($metaKey, $values)) { |
|
67 | - $protected = false; |
|
68 | - } |
|
69 | - } |
|
70 | - return $protected; |
|
71 | - } |
|
54 | + /** |
|
55 | + * @param bool $protected |
|
56 | + * @param string $metaKey |
|
57 | + * @param string $metaType |
|
58 | + * @return bool |
|
59 | + * @filter is_protected_meta |
|
60 | + */ |
|
61 | + public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
62 | + { |
|
63 | + if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
64 | + $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
65 | + $values = glsr(Helper::class)->prefixArrayKeys($values); |
|
66 | + if (array_key_exists($metaKey, $values)) { |
|
67 | + $protected = false; |
|
68 | + } |
|
69 | + } |
|
70 | + return $protected; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param string $translation |
|
75 | - * @param string $test |
|
76 | - * @param string $domain |
|
77 | - * @return string |
|
78 | - * @filter gettext |
|
79 | - */ |
|
80 | - public function filterPostStatusLabels($translation, $text, $domain) |
|
81 | - { |
|
82 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
83 | - } |
|
73 | + /** |
|
74 | + * @param string $translation |
|
75 | + * @param string $test |
|
76 | + * @param string $domain |
|
77 | + * @return string |
|
78 | + * @filter gettext |
|
79 | + */ |
|
80 | + public function filterPostStatusLabels($translation, $text, $domain) |
|
81 | + { |
|
82 | + return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $translation |
|
87 | - * @param string $test |
|
88 | - * @param string $domain |
|
89 | - * @return string |
|
90 | - * @filter gettext_with_context |
|
91 | - */ |
|
92 | - public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain) |
|
93 | - { |
|
94 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
95 | - } |
|
85 | + /** |
|
86 | + * @param string $translation |
|
87 | + * @param string $test |
|
88 | + * @param string $domain |
|
89 | + * @return string |
|
90 | + * @filter gettext_with_context |
|
91 | + */ |
|
92 | + public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain) |
|
93 | + { |
|
94 | + return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * @param array $messages |
|
99 | - * @return array |
|
100 | - * @filter post_updated_messages |
|
101 | - */ |
|
102 | - public function filterUpdateMessages($messages) |
|
103 | - { |
|
104 | - return glsr(Labels::class)->filterUpdateMessages( |
|
105 | - glsr(Helper::class)->consolidateArray($messages) |
|
106 | - ); |
|
107 | - } |
|
97 | + /** |
|
98 | + * @param array $messages |
|
99 | + * @return array |
|
100 | + * @filter post_updated_messages |
|
101 | + */ |
|
102 | + public function filterUpdateMessages($messages) |
|
103 | + { |
|
104 | + return glsr(Labels::class)->filterUpdateMessages( |
|
105 | + glsr(Helper::class)->consolidateArray($messages) |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @return void |
|
111 | - * @action add_meta_boxes_{Application::POST_TYPE} |
|
112 | - */ |
|
113 | - public function registerMetaBoxes($post) |
|
114 | - { |
|
115 | - add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
116 | - add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
117 | - if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
118 | - return; |
|
119 | - } |
|
120 | - add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
121 | - } |
|
109 | + /** |
|
110 | + * @return void |
|
111 | + * @action add_meta_boxes_{Application::POST_TYPE} |
|
112 | + */ |
|
113 | + public function registerMetaBoxes($post) |
|
114 | + { |
|
115 | + add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
116 | + add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
117 | + if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
118 | + return; |
|
119 | + } |
|
120 | + add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @return void |
|
125 | - * @action admin_print_scripts |
|
126 | - */ |
|
127 | - public function removeAutosave() |
|
128 | - { |
|
129 | - glsr(Customization::class)->removeAutosave(); |
|
130 | - } |
|
123 | + /** |
|
124 | + * @return void |
|
125 | + * @action admin_print_scripts |
|
126 | + */ |
|
127 | + public function removeAutosave() |
|
128 | + { |
|
129 | + glsr(Customization::class)->removeAutosave(); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @return void |
|
134 | - * @action admin_menu |
|
135 | - */ |
|
136 | - public function removeMetaBoxes() |
|
137 | - { |
|
138 | - glsr(Customization::class)->removeMetaBoxes(); |
|
139 | - } |
|
132 | + /** |
|
133 | + * @return void |
|
134 | + * @action admin_menu |
|
135 | + */ |
|
136 | + public function removeMetaBoxes() |
|
137 | + { |
|
138 | + glsr(Customization::class)->removeMetaBoxes(); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * @return void |
|
143 | - */ |
|
144 | - public function removePostTypeSupport() |
|
145 | - { |
|
146 | - glsr(Customization::class)->removePostTypeSupport(); |
|
147 | - } |
|
141 | + /** |
|
142 | + * @return void |
|
143 | + */ |
|
144 | + public function removePostTypeSupport() |
|
145 | + { |
|
146 | + glsr(Customization::class)->removePostTypeSupport(); |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @param WP_Post $post |
|
151 | - * @return void |
|
152 | - * @callback add_meta_box |
|
153 | - */ |
|
154 | - public function renderAssignedToMetabox($post) |
|
155 | - { |
|
156 | - if (!$this->isReviewPostType($post)) { |
|
157 | - return; |
|
158 | - } |
|
159 | - $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
160 | - wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
161 | - glsr()->render('partials/editor/metabox-assigned-to', [ |
|
162 | - 'id' => $assignedTo, |
|
163 | - 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
164 | - ]); |
|
165 | - } |
|
149 | + /** |
|
150 | + * @param WP_Post $post |
|
151 | + * @return void |
|
152 | + * @callback add_meta_box |
|
153 | + */ |
|
154 | + public function renderAssignedToMetabox($post) |
|
155 | + { |
|
156 | + if (!$this->isReviewPostType($post)) { |
|
157 | + return; |
|
158 | + } |
|
159 | + $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
160 | + wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
161 | + glsr()->render('partials/editor/metabox-assigned-to', [ |
|
162 | + 'id' => $assignedTo, |
|
163 | + 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
164 | + ]); |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @param WP_Post $post |
|
169 | - * @return void |
|
170 | - * @callback add_meta_box |
|
171 | - */ |
|
172 | - public function renderDetailsMetaBox($post) |
|
173 | - { |
|
174 | - if (!$this->isReviewPostType($post)) { |
|
175 | - return; |
|
176 | - } |
|
177 | - $review = glsr_get_review($post); |
|
178 | - glsr()->render('partials/editor/metabox-details', [ |
|
179 | - 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
180 | - 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
181 | - ]); |
|
182 | - } |
|
167 | + /** |
|
168 | + * @param WP_Post $post |
|
169 | + * @return void |
|
170 | + * @callback add_meta_box |
|
171 | + */ |
|
172 | + public function renderDetailsMetaBox($post) |
|
173 | + { |
|
174 | + if (!$this->isReviewPostType($post)) { |
|
175 | + return; |
|
176 | + } |
|
177 | + $review = glsr_get_review($post); |
|
178 | + glsr()->render('partials/editor/metabox-details', [ |
|
179 | + 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
180 | + 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
181 | + ]); |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * @return void |
|
186 | - * @action post_submitbox_misc_actions |
|
187 | - */ |
|
188 | - public function renderPinnedInPublishMetaBox() |
|
189 | - { |
|
190 | - if (!$this->isReviewPostType(get_post())) { |
|
191 | - return; |
|
192 | - } |
|
193 | - glsr(Template::class)->render('partials/editor/pinned', [ |
|
194 | - 'context' => [ |
|
195 | - 'no' => __('No', 'site-reviews'), |
|
196 | - 'yes' => __('Yes', 'site-reviews'), |
|
197 | - ], |
|
198 | - 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
199 | - ]); |
|
200 | - } |
|
184 | + /** |
|
185 | + * @return void |
|
186 | + * @action post_submitbox_misc_actions |
|
187 | + */ |
|
188 | + public function renderPinnedInPublishMetaBox() |
|
189 | + { |
|
190 | + if (!$this->isReviewPostType(get_post())) { |
|
191 | + return; |
|
192 | + } |
|
193 | + glsr(Template::class)->render('partials/editor/pinned', [ |
|
194 | + 'context' => [ |
|
195 | + 'no' => __('No', 'site-reviews'), |
|
196 | + 'yes' => __('Yes', 'site-reviews'), |
|
197 | + ], |
|
198 | + 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
199 | + ]); |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * @param WP_Post $post |
|
204 | - * @return void |
|
205 | - * @callback add_meta_box |
|
206 | - */ |
|
207 | - public function renderResponseMetaBox($post) |
|
208 | - { |
|
209 | - if (!$this->isReviewPostType($post)) { |
|
210 | - return; |
|
211 | - } |
|
212 | - wp_nonce_field('response', '_nonce-response', false); |
|
213 | - glsr()->render('partials/editor/metabox-response', [ |
|
214 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
215 | - ]); |
|
216 | - } |
|
202 | + /** |
|
203 | + * @param WP_Post $post |
|
204 | + * @return void |
|
205 | + * @callback add_meta_box |
|
206 | + */ |
|
207 | + public function renderResponseMetaBox($post) |
|
208 | + { |
|
209 | + if (!$this->isReviewPostType($post)) { |
|
210 | + return; |
|
211 | + } |
|
212 | + wp_nonce_field('response', '_nonce-response', false); |
|
213 | + glsr()->render('partials/editor/metabox-response', [ |
|
214 | + 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
215 | + ]); |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * @param WP_Post $post |
|
220 | - * @return void |
|
221 | - * @action edit_form_after_title |
|
222 | - */ |
|
223 | - public function renderReviewEditor($post) |
|
224 | - { |
|
225 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
226 | - return; |
|
227 | - } |
|
228 | - glsr()->render('partials/editor/review', [ |
|
229 | - 'post' => $post, |
|
230 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
231 | - ]); |
|
232 | - } |
|
218 | + /** |
|
219 | + * @param WP_Post $post |
|
220 | + * @return void |
|
221 | + * @action edit_form_after_title |
|
222 | + */ |
|
223 | + public function renderReviewEditor($post) |
|
224 | + { |
|
225 | + if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
226 | + return; |
|
227 | + } |
|
228 | + glsr()->render('partials/editor/review', [ |
|
229 | + 'post' => $post, |
|
230 | + 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
231 | + ]); |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * @return void |
|
236 | - * @action admin_head |
|
237 | - */ |
|
238 | - public function renderReviewFields() |
|
239 | - { |
|
240 | - $screen = glsr_current_screen(); |
|
241 | - if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
242 | - return; |
|
243 | - } |
|
244 | - add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
245 | - add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
246 | - } |
|
234 | + /** |
|
235 | + * @return void |
|
236 | + * @action admin_head |
|
237 | + */ |
|
238 | + public function renderReviewFields() |
|
239 | + { |
|
240 | + $screen = glsr_current_screen(); |
|
241 | + if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
242 | + return; |
|
243 | + } |
|
244 | + add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
245 | + add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * @param WP_Post $post |
|
250 | - * @return void |
|
251 | - * @action edit_form_top |
|
252 | - */ |
|
253 | - public function renderReviewNotice($post) |
|
254 | - { |
|
255 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
256 | - return; |
|
257 | - } |
|
258 | - glsr(Notice::class)->addWarning(sprintf( |
|
259 | - __('%s reviews are read-only.', 'site-reviews'), |
|
260 | - glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
261 | - )); |
|
262 | - glsr(Template::class)->render('partials/editor/notice', [ |
|
263 | - 'context' => [ |
|
264 | - 'notices' => glsr(Notice::class)->get(), |
|
265 | - ], |
|
266 | - ]); |
|
267 | - } |
|
248 | + /** |
|
249 | + * @param WP_Post $post |
|
250 | + * @return void |
|
251 | + * @action edit_form_top |
|
252 | + */ |
|
253 | + public function renderReviewNotice($post) |
|
254 | + { |
|
255 | + if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
256 | + return; |
|
257 | + } |
|
258 | + glsr(Notice::class)->addWarning(sprintf( |
|
259 | + __('%s reviews are read-only.', 'site-reviews'), |
|
260 | + glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
261 | + )); |
|
262 | + glsr(Template::class)->render('partials/editor/notice', [ |
|
263 | + 'context' => [ |
|
264 | + 'notices' => glsr(Notice::class)->get(), |
|
265 | + ], |
|
266 | + ]); |
|
267 | + } |
|
268 | 268 | |
269 | - /** |
|
270 | - * @param WP_Post $post |
|
271 | - * @return void |
|
272 | - * @see glsr_categories_meta_box() |
|
273 | - * @callback register_taxonomy |
|
274 | - */ |
|
275 | - public function renderTaxonomyMetabox($post) |
|
276 | - { |
|
277 | - if (!$this->isReviewPostType($post)) { |
|
278 | - return; |
|
279 | - } |
|
280 | - glsr()->render('partials/editor/metabox-categories', [ |
|
281 | - 'post' => $post, |
|
282 | - 'tax_name' => Application::TAXONOMY, |
|
283 | - 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
284 | - ]); |
|
285 | - } |
|
269 | + /** |
|
270 | + * @param WP_Post $post |
|
271 | + * @return void |
|
272 | + * @see glsr_categories_meta_box() |
|
273 | + * @callback register_taxonomy |
|
274 | + */ |
|
275 | + public function renderTaxonomyMetabox($post) |
|
276 | + { |
|
277 | + if (!$this->isReviewPostType($post)) { |
|
278 | + return; |
|
279 | + } |
|
280 | + glsr()->render('partials/editor/metabox-categories', [ |
|
281 | + 'post' => $post, |
|
282 | + 'tax_name' => Application::TAXONOMY, |
|
283 | + 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
284 | + ]); |
|
285 | + } |
|
286 | 286 | |
287 | - /** |
|
288 | - * @return void |
|
289 | - * @see $this->filterUpdateMessages() |
|
290 | - * @action admin_action_revert |
|
291 | - */ |
|
292 | - public function revertReview() |
|
293 | - { |
|
294 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
295 | - return; |
|
296 | - } |
|
297 | - check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
298 | - glsr(ReviewManager::class)->revert($postId); |
|
299 | - $this->redirect($postId, 52); |
|
300 | - } |
|
287 | + /** |
|
288 | + * @return void |
|
289 | + * @see $this->filterUpdateMessages() |
|
290 | + * @action admin_action_revert |
|
291 | + */ |
|
292 | + public function revertReview() |
|
293 | + { |
|
294 | + if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
295 | + return; |
|
296 | + } |
|
297 | + check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
298 | + glsr(ReviewManager::class)->revert($postId); |
|
299 | + $this->redirect($postId, 52); |
|
300 | + } |
|
301 | 301 | |
302 | - /** |
|
303 | - * @param int $postId |
|
304 | - * @return void |
|
305 | - * @action save_post_.Application::POST_TYPE |
|
306 | - */ |
|
307 | - public function saveMetaboxes($postId) |
|
308 | - { |
|
309 | - glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
310 | - glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
311 | - do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
312 | - } |
|
302 | + /** |
|
303 | + * @param int $postId |
|
304 | + * @return void |
|
305 | + * @action save_post_.Application::POST_TYPE |
|
306 | + */ |
|
307 | + public function saveMetaboxes($postId) |
|
308 | + { |
|
309 | + glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
310 | + glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
311 | + do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
315 | - * @param string $assignedTo |
|
316 | - * @return string |
|
317 | - */ |
|
318 | - protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
319 | - { |
|
320 | - $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
321 | - if (!($assignedPost instanceof WP_Post)) { |
|
322 | - return; |
|
323 | - } |
|
324 | - return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
325 | - 'context' => [ |
|
326 | - 'data.url' => (string) get_permalink($assignedPost), |
|
327 | - 'data.title' => get_the_title($assignedPost), |
|
328 | - ], |
|
329 | - ]); |
|
330 | - } |
|
314 | + /** |
|
315 | + * @param string $assignedTo |
|
316 | + * @return string |
|
317 | + */ |
|
318 | + protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
319 | + { |
|
320 | + $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
321 | + if (!($assignedPost instanceof WP_Post)) { |
|
322 | + return; |
|
323 | + } |
|
324 | + return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
325 | + 'context' => [ |
|
326 | + 'data.url' => (string) get_permalink($assignedPost), |
|
327 | + 'data.title' => get_the_title($assignedPost), |
|
328 | + ], |
|
329 | + ]); |
|
330 | + } |
|
331 | 331 | |
332 | - /** |
|
333 | - * @return string |
|
334 | - */ |
|
335 | - protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
336 | - { |
|
337 | - $isModified = !glsr(Helper::class)->compareArrays( |
|
338 | - [$review->title, $review->content, $review->date], |
|
339 | - [ |
|
340 | - glsr(Database::class)->get($post->ID, 'title'), |
|
341 | - glsr(Database::class)->get($post->ID, 'content'), |
|
342 | - glsr(Database::class)->get($post->ID, 'date'), |
|
343 | - ] |
|
344 | - ); |
|
345 | - if ($isModified) { |
|
346 | - $revertUrl = wp_nonce_url( |
|
347 | - admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
348 | - 'revert-review_'.$post->ID |
|
349 | - ); |
|
350 | - return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
351 | - 'class' => 'button button-large', |
|
352 | - 'href' => $revertUrl, |
|
353 | - 'id' => 'revert', |
|
354 | - ]); |
|
355 | - } |
|
356 | - return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
357 | - 'class' => 'button-large', |
|
358 | - 'disabled' => true, |
|
359 | - 'id' => 'revert', |
|
360 | - ]); |
|
361 | - } |
|
332 | + /** |
|
333 | + * @return string |
|
334 | + */ |
|
335 | + protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
336 | + { |
|
337 | + $isModified = !glsr(Helper::class)->compareArrays( |
|
338 | + [$review->title, $review->content, $review->date], |
|
339 | + [ |
|
340 | + glsr(Database::class)->get($post->ID, 'title'), |
|
341 | + glsr(Database::class)->get($post->ID, 'content'), |
|
342 | + glsr(Database::class)->get($post->ID, 'date'), |
|
343 | + ] |
|
344 | + ); |
|
345 | + if ($isModified) { |
|
346 | + $revertUrl = wp_nonce_url( |
|
347 | + admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
348 | + 'revert-review_'.$post->ID |
|
349 | + ); |
|
350 | + return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
351 | + 'class' => 'button button-large', |
|
352 | + 'href' => $revertUrl, |
|
353 | + 'id' => 'revert', |
|
354 | + ]); |
|
355 | + } |
|
356 | + return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
357 | + 'class' => 'button-large', |
|
358 | + 'disabled' => true, |
|
359 | + 'id' => 'revert', |
|
360 | + ]); |
|
361 | + } |
|
362 | 362 | |
363 | - /** |
|
364 | - * @param object $review |
|
365 | - * @return string|void |
|
366 | - */ |
|
367 | - protected function getReviewType($review) |
|
368 | - { |
|
369 | - if (count(glsr()->reviewTypes) < 2) { |
|
370 | - return; |
|
371 | - } |
|
372 | - $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
373 | - ? glsr()->reviewTypes[$review->review_type] |
|
374 | - : __('Unknown', 'site-reviews'); |
|
375 | - if (!empty($review->url)) { |
|
376 | - $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
377 | - 'href' => $review->url, |
|
378 | - 'target' => '_blank', |
|
379 | - ]); |
|
380 | - } |
|
381 | - return $reviewType; |
|
382 | - } |
|
363 | + /** |
|
364 | + * @param object $review |
|
365 | + * @return string|void |
|
366 | + */ |
|
367 | + protected function getReviewType($review) |
|
368 | + { |
|
369 | + if (count(glsr()->reviewTypes) < 2) { |
|
370 | + return; |
|
371 | + } |
|
372 | + $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
373 | + ? glsr()->reviewTypes[$review->review_type] |
|
374 | + : __('Unknown', 'site-reviews'); |
|
375 | + if (!empty($review->url)) { |
|
376 | + $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
377 | + 'href' => $review->url, |
|
378 | + 'target' => '_blank', |
|
379 | + ]); |
|
380 | + } |
|
381 | + return $reviewType; |
|
382 | + } |
|
383 | 383 | |
384 | - /** |
|
385 | - * @return bool |
|
386 | - */ |
|
387 | - protected function isReviewEditable($post) |
|
388 | - { |
|
389 | - return $this->isReviewPostType($post) |
|
390 | - && post_type_supports(Application::POST_TYPE, 'title') |
|
391 | - && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
392 | - } |
|
384 | + /** |
|
385 | + * @return bool |
|
386 | + */ |
|
387 | + protected function isReviewEditable($post) |
|
388 | + { |
|
389 | + return $this->isReviewPostType($post) |
|
390 | + && post_type_supports(Application::POST_TYPE, 'title') |
|
391 | + && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
392 | + } |
|
393 | 393 | |
394 | - /** |
|
395 | - * @param mixed $post |
|
396 | - * @return bool |
|
397 | - */ |
|
398 | - protected function isReviewPostType($post) |
|
399 | - { |
|
400 | - return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
|
401 | - } |
|
394 | + /** |
|
395 | + * @param mixed $post |
|
396 | + * @return bool |
|
397 | + */ |
|
398 | + protected function isReviewPostType($post) |
|
399 | + { |
|
400 | + return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
|
401 | + } |
|
402 | 402 | |
403 | - /** |
|
404 | - * @return array |
|
405 | - */ |
|
406 | - protected function normalizeDetailsMetaBox(Review $review) |
|
407 | - { |
|
408 | - $user = empty($review->user_id) |
|
409 | - ? __('Unregistered user', 'site-reviews') |
|
410 | - : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
411 | - 'href' => get_author_posts_url($review->user_id), |
|
412 | - ]); |
|
413 | - $email = empty($review->email) |
|
414 | - ? '—' |
|
415 | - : glsr(Builder::class)->a($review->email, [ |
|
416 | - 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
417 | - ]); |
|
418 | - $metabox = [ |
|
419 | - __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
420 | - __('Type', 'site-reviews') => $this->getReviewType($review), |
|
421 | - __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
422 | - __('Name', 'site-reviews') => $review->author, |
|
423 | - __('Email', 'site-reviews') => $email, |
|
424 | - __('User', 'site-reviews') => $user, |
|
425 | - __('IP Address', 'site-reviews') => $review->ip_address, |
|
426 | - __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
427 | - ]; |
|
428 | - return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
429 | - } |
|
403 | + /** |
|
404 | + * @return array |
|
405 | + */ |
|
406 | + protected function normalizeDetailsMetaBox(Review $review) |
|
407 | + { |
|
408 | + $user = empty($review->user_id) |
|
409 | + ? __('Unregistered user', 'site-reviews') |
|
410 | + : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
411 | + 'href' => get_author_posts_url($review->user_id), |
|
412 | + ]); |
|
413 | + $email = empty($review->email) |
|
414 | + ? '—' |
|
415 | + : glsr(Builder::class)->a($review->email, [ |
|
416 | + 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
417 | + ]); |
|
418 | + $metabox = [ |
|
419 | + __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
420 | + __('Type', 'site-reviews') => $this->getReviewType($review), |
|
421 | + __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
422 | + __('Name', 'site-reviews') => $review->author, |
|
423 | + __('Email', 'site-reviews') => $email, |
|
424 | + __('User', 'site-reviews') => $user, |
|
425 | + __('IP Address', 'site-reviews') => $review->ip_address, |
|
426 | + __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
427 | + ]; |
|
428 | + return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
429 | + } |
|
430 | 430 | |
431 | - /** |
|
432 | - * @param int $postId |
|
433 | - * @param int $messageIndex |
|
434 | - * @return void |
|
435 | - */ |
|
436 | - protected function redirect($postId, $messageIndex) |
|
437 | - { |
|
438 | - $referer = wp_get_referer(); |
|
439 | - $hasReferer = !$referer |
|
440 | - || false !== strpos($referer, 'post.php') |
|
441 | - || false !== strpos($referer, 'post-new.php'); |
|
442 | - $redirectUri = $hasReferer |
|
443 | - ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
444 | - : get_edit_post_link($postId); |
|
445 | - wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
446 | - exit; |
|
447 | - } |
|
431 | + /** |
|
432 | + * @param int $postId |
|
433 | + * @param int $messageIndex |
|
434 | + * @return void |
|
435 | + */ |
|
436 | + protected function redirect($postId, $messageIndex) |
|
437 | + { |
|
438 | + $referer = wp_get_referer(); |
|
439 | + $hasReferer = !$referer |
|
440 | + || false !== strpos($referer, 'post.php') |
|
441 | + || false !== strpos($referer, 'post-new.php'); |
|
442 | + $redirectUri = $hasReferer |
|
443 | + ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
444 | + : get_edit_post_link($postId); |
|
445 | + wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
446 | + exit; |
|
447 | + } |
|
448 | 448 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function customizePostStatusLabels() |
27 | 27 | { |
28 | - glsr(Labels::class)->customizePostStatusLabels(); |
|
28 | + glsr( Labels::class )->customizePostStatusLabels(); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | * @return array |
34 | 34 | * @filter wp_editor_settings |
35 | 35 | */ |
36 | - public function filterEditorSettings($settings) |
|
36 | + public function filterEditorSettings( $settings ) |
|
37 | 37 | { |
38 | - return glsr(Customization::class)->filterEditorSettings( |
|
39 | - glsr(Helper::class)->consolidateArray($settings) |
|
38 | + return glsr( Customization::class )->filterEditorSettings( |
|
39 | + glsr( Helper::class )->consolidateArray( $settings ) |
|
40 | 40 | ); |
41 | 41 | } |
42 | 42 | |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @return string |
47 | 47 | * @filter the_editor |
48 | 48 | */ |
49 | - public function filterEditorTextarea($html) |
|
49 | + public function filterEditorTextarea( $html ) |
|
50 | 50 | { |
51 | - return glsr(Customization::class)->filterEditorTextarea($html); |
|
51 | + return glsr( Customization::class )->filterEditorTextarea( $html ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * @return bool |
59 | 59 | * @filter is_protected_meta |
60 | 60 | */ |
61 | - public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
61 | + public function filterIsProtectedMeta( $protected, $metaKey, $metaType ) |
|
62 | 62 | { |
63 | - if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
64 | - $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
65 | - $values = glsr(Helper::class)->prefixArrayKeys($values); |
|
66 | - if (array_key_exists($metaKey, $values)) { |
|
63 | + if( 'post' == $metaType && Application::POST_TYPE == get_post_type() ) { |
|
64 | + $values = glsr( CreateReviewDefaults::class )->unguarded(); |
|
65 | + $values = glsr( Helper::class )->prefixArrayKeys( $values ); |
|
66 | + if( array_key_exists( $metaKey, $values ) ) { |
|
67 | 67 | $protected = false; |
68 | 68 | } |
69 | 69 | } |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * @return string |
78 | 78 | * @filter gettext |
79 | 79 | */ |
80 | - public function filterPostStatusLabels($translation, $text, $domain) |
|
80 | + public function filterPostStatusLabels( $translation, $text, $domain ) |
|
81 | 81 | { |
82 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
82 | + return glsr( Labels::class )->filterPostStatusLabels( $translation, $text, $domain ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * @return string |
90 | 90 | * @filter gettext_with_context |
91 | 91 | */ |
92 | - public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain) |
|
92 | + public function filterPostStatusLabelsWithContext( $translation, $text, $context, $domain ) |
|
93 | 93 | { |
94 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
94 | + return glsr( Labels::class )->filterPostStatusLabels( $translation, $text, $domain ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * @return array |
100 | 100 | * @filter post_updated_messages |
101 | 101 | */ |
102 | - public function filterUpdateMessages($messages) |
|
102 | + public function filterUpdateMessages( $messages ) |
|
103 | 103 | { |
104 | - return glsr(Labels::class)->filterUpdateMessages( |
|
105 | - glsr(Helper::class)->consolidateArray($messages) |
|
104 | + return glsr( Labels::class )->filterUpdateMessages( |
|
105 | + glsr( Helper::class )->consolidateArray( $messages ) |
|
106 | 106 | ); |
107 | 107 | } |
108 | 108 | |
@@ -110,14 +110,14 @@ discard block |
||
110 | 110 | * @return void |
111 | 111 | * @action add_meta_boxes_{Application::POST_TYPE} |
112 | 112 | */ |
113 | - public function registerMetaBoxes($post) |
|
113 | + public function registerMetaBoxes( $post ) |
|
114 | 114 | { |
115 | - add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
116 | - add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
117 | - if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
115 | + add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
|
116 | + add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
|
117 | + if( 'local' != glsr( Database::class )->get( $post->ID, 'review_type' ) ) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | - add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
120 | + add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function removeAutosave() |
128 | 128 | { |
129 | - glsr(Customization::class)->removeAutosave(); |
|
129 | + glsr( Customization::class )->removeAutosave(); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function removeMetaBoxes() |
137 | 137 | { |
138 | - glsr(Customization::class)->removeMetaBoxes(); |
|
138 | + glsr( Customization::class )->removeMetaBoxes(); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function removePostTypeSupport() |
145 | 145 | { |
146 | - glsr(Customization::class)->removePostTypeSupport(); |
|
146 | + glsr( Customization::class )->removePostTypeSupport(); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | * @return void |
152 | 152 | * @callback add_meta_box |
153 | 153 | */ |
154 | - public function renderAssignedToMetabox($post) |
|
154 | + public function renderAssignedToMetabox( $post ) |
|
155 | 155 | { |
156 | - if (!$this->isReviewPostType($post)) { |
|
156 | + if( !$this->isReviewPostType( $post ) ) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | - $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
160 | - wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
161 | - glsr()->render('partials/editor/metabox-assigned-to', [ |
|
159 | + $assignedTo = (string)glsr( Database::class )->get( $post->ID, 'assigned_to' ); |
|
160 | + wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
|
161 | + glsr()->render( 'partials/editor/metabox-assigned-to', [ |
|
162 | 162 | 'id' => $assignedTo, |
163 | - 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
164 | - ]); |
|
163 | + 'template' => $this->buildAssignedToTemplate( $assignedTo, $post ), |
|
164 | + ] ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | * @return void |
170 | 170 | * @callback add_meta_box |
171 | 171 | */ |
172 | - public function renderDetailsMetaBox($post) |
|
172 | + public function renderDetailsMetaBox( $post ) |
|
173 | 173 | { |
174 | - if (!$this->isReviewPostType($post)) { |
|
174 | + if( !$this->isReviewPostType( $post ) ) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | - $review = glsr_get_review($post); |
|
178 | - glsr()->render('partials/editor/metabox-details', [ |
|
179 | - 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
180 | - 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
181 | - ]); |
|
177 | + $review = glsr_get_review( $post ); |
|
178 | + glsr()->render( 'partials/editor/metabox-details', [ |
|
179 | + 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
|
180 | + 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
|
181 | + ] ); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function renderPinnedInPublishMetaBox() |
189 | 189 | { |
190 | - if (!$this->isReviewPostType(get_post())) { |
|
190 | + if( !$this->isReviewPostType( get_post() ) ) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | - glsr(Template::class)->render('partials/editor/pinned', [ |
|
193 | + glsr( Template::class )->render( 'partials/editor/pinned', [ |
|
194 | 194 | 'context' => [ |
195 | - 'no' => __('No', 'site-reviews'), |
|
196 | - 'yes' => __('Yes', 'site-reviews'), |
|
195 | + 'no' => __( 'No', 'site-reviews' ), |
|
196 | + 'yes' => __( 'Yes', 'site-reviews' ), |
|
197 | 197 | ], |
198 | - 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
199 | - ]); |
|
198 | + 'pinned' => wp_validate_boolean( glsr( Database::class )->get( get_the_ID(), 'pinned' ) ), |
|
199 | + ] ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -204,15 +204,15 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | * @callback add_meta_box |
206 | 206 | */ |
207 | - public function renderResponseMetaBox($post) |
|
207 | + public function renderResponseMetaBox( $post ) |
|
208 | 208 | { |
209 | - if (!$this->isReviewPostType($post)) { |
|
209 | + if( !$this->isReviewPostType( $post ) ) { |
|
210 | 210 | return; |
211 | 211 | } |
212 | - wp_nonce_field('response', '_nonce-response', false); |
|
213 | - glsr()->render('partials/editor/metabox-response', [ |
|
214 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
215 | - ]); |
|
212 | + wp_nonce_field( 'response', '_nonce-response', false ); |
|
213 | + glsr()->render( 'partials/editor/metabox-response', [ |
|
214 | + 'response' => glsr( Database::class )->get( $post->ID, 'response' ), |
|
215 | + ] ); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | * @return void |
221 | 221 | * @action edit_form_after_title |
222 | 222 | */ |
223 | - public function renderReviewEditor($post) |
|
223 | + public function renderReviewEditor( $post ) |
|
224 | 224 | { |
225 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
225 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | - glsr()->render('partials/editor/review', [ |
|
228 | + glsr()->render( 'partials/editor/review', [ |
|
229 | 229 | 'post' => $post, |
230 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
231 | - ]); |
|
230 | + 'response' => glsr( Database::class )->get( $post->ID, 'response' ), |
|
231 | + ] ); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | public function renderReviewFields() |
239 | 239 | { |
240 | 240 | $screen = glsr_current_screen(); |
241 | - if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
241 | + if( 'post' != $screen->base || Application::POST_TYPE != $screen->post_type ) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | - add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
245 | - add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
244 | + add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
|
245 | + add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -250,20 +250,20 @@ discard block |
||
250 | 250 | * @return void |
251 | 251 | * @action edit_form_top |
252 | 252 | */ |
253 | - public function renderReviewNotice($post) |
|
253 | + public function renderReviewNotice( $post ) |
|
254 | 254 | { |
255 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
255 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | - glsr(Notice::class)->addWarning(sprintf( |
|
259 | - __('%s reviews are read-only.', 'site-reviews'), |
|
260 | - glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
261 | - )); |
|
262 | - glsr(Template::class)->render('partials/editor/notice', [ |
|
258 | + glsr( Notice::class )->addWarning( sprintf( |
|
259 | + __( '%s reviews are read-only.', 'site-reviews' ), |
|
260 | + glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
|
261 | + ) ); |
|
262 | + glsr( Template::class )->render( 'partials/editor/notice', [ |
|
263 | 263 | 'context' => [ |
264 | - 'notices' => glsr(Notice::class)->get(), |
|
264 | + 'notices' => glsr( Notice::class )->get(), |
|
265 | 265 | ], |
266 | - ]); |
|
266 | + ] ); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | * @see glsr_categories_meta_box() |
273 | 273 | * @callback register_taxonomy |
274 | 274 | */ |
275 | - public function renderTaxonomyMetabox($post) |
|
275 | + public function renderTaxonomyMetabox( $post ) |
|
276 | 276 | { |
277 | - if (!$this->isReviewPostType($post)) { |
|
277 | + if( !$this->isReviewPostType( $post ) ) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | - glsr()->render('partials/editor/metabox-categories', [ |
|
280 | + glsr()->render( 'partials/editor/metabox-categories', [ |
|
281 | 281 | 'post' => $post, |
282 | 282 | 'tax_name' => Application::TAXONOMY, |
283 | - 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
284 | - ]); |
|
283 | + 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
|
284 | + ] ); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function revertReview() |
293 | 293 | { |
294 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
294 | + if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) { |
|
295 | 295 | return; |
296 | 296 | } |
297 | - check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
298 | - glsr(ReviewManager::class)->revert($postId); |
|
299 | - $this->redirect($postId, 52); |
|
297 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
298 | + glsr( ReviewManager::class )->revert( $postId ); |
|
299 | + $this->redirect( $postId, 52 ); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -304,79 +304,79 @@ discard block |
||
304 | 304 | * @return void |
305 | 305 | * @action save_post_.Application::POST_TYPE |
306 | 306 | */ |
307 | - public function saveMetaboxes($postId) |
|
307 | + public function saveMetaboxes( $postId ) |
|
308 | 308 | { |
309 | - glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
310 | - glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
311 | - do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
309 | + glsr( Metaboxes::class )->saveAssignedToMetabox( $postId ); |
|
310 | + glsr( Metaboxes::class )->saveResponseMetabox( $postId ); |
|
311 | + do_action( 'site-reviews/review/saved', glsr_get_review( $postId ) ); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
315 | 315 | * @param string $assignedTo |
316 | 316 | * @return string |
317 | 317 | */ |
318 | - protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
318 | + protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
|
319 | 319 | { |
320 | - $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
321 | - if (!($assignedPost instanceof WP_Post)) { |
|
320 | + $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
|
321 | + if( !($assignedPost instanceof WP_Post) ) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | - return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
324 | + return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
|
325 | 325 | 'context' => [ |
326 | - 'data.url' => (string) get_permalink($assignedPost), |
|
327 | - 'data.title' => get_the_title($assignedPost), |
|
326 | + 'data.url' => (string)get_permalink( $assignedPost ), |
|
327 | + 'data.title' => get_the_title( $assignedPost ), |
|
328 | 328 | ], |
329 | - ]); |
|
329 | + ] ); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
333 | 333 | * @return string |
334 | 334 | */ |
335 | - protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
335 | + protected function buildDetailsMetaBoxRevertButton( Review $review, WP_Post $post ) |
|
336 | 336 | { |
337 | - $isModified = !glsr(Helper::class)->compareArrays( |
|
337 | + $isModified = !glsr( Helper::class )->compareArrays( |
|
338 | 338 | [$review->title, $review->content, $review->date], |
339 | 339 | [ |
340 | - glsr(Database::class)->get($post->ID, 'title'), |
|
341 | - glsr(Database::class)->get($post->ID, 'content'), |
|
342 | - glsr(Database::class)->get($post->ID, 'date'), |
|
340 | + glsr( Database::class )->get( $post->ID, 'title' ), |
|
341 | + glsr( Database::class )->get( $post->ID, 'content' ), |
|
342 | + glsr( Database::class )->get( $post->ID, 'date' ), |
|
343 | 343 | ] |
344 | 344 | ); |
345 | - if ($isModified) { |
|
345 | + if( $isModified ) { |
|
346 | 346 | $revertUrl = wp_nonce_url( |
347 | - admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
347 | + admin_url( 'post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID ), |
|
348 | 348 | 'revert-review_'.$post->ID |
349 | 349 | ); |
350 | - return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
350 | + return glsr( Builder::class )->a( __( 'Revert Changes', 'site-reviews' ), [ |
|
351 | 351 | 'class' => 'button button-large', |
352 | 352 | 'href' => $revertUrl, |
353 | 353 | 'id' => 'revert', |
354 | - ]); |
|
354 | + ] ); |
|
355 | 355 | } |
356 | - return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
356 | + return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
|
357 | 357 | 'class' => 'button-large', |
358 | 358 | 'disabled' => true, |
359 | 359 | 'id' => 'revert', |
360 | - ]); |
|
360 | + ] ); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
364 | 364 | * @param object $review |
365 | 365 | * @return string|void |
366 | 366 | */ |
367 | - protected function getReviewType($review) |
|
367 | + protected function getReviewType( $review ) |
|
368 | 368 | { |
369 | - if (count(glsr()->reviewTypes) < 2) { |
|
369 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | - $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
372 | + $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
|
373 | 373 | ? glsr()->reviewTypes[$review->review_type] |
374 | - : __('Unknown', 'site-reviews'); |
|
375 | - if (!empty($review->url)) { |
|
376 | - $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
374 | + : __( 'Unknown', 'site-reviews' ); |
|
375 | + if( !empty($review->url) ) { |
|
376 | + $reviewType = glsr( Builder::class )->a( $reviewType, [ |
|
377 | 377 | 'href' => $review->url, |
378 | 378 | 'target' => '_blank', |
379 | - ]); |
|
379 | + ] ); |
|
380 | 380 | } |
381 | 381 | return $reviewType; |
382 | 382 | } |
@@ -384,18 +384,18 @@ discard block |
||
384 | 384 | /** |
385 | 385 | * @return bool |
386 | 386 | */ |
387 | - protected function isReviewEditable($post) |
|
387 | + protected function isReviewEditable( $post ) |
|
388 | 388 | { |
389 | - return $this->isReviewPostType($post) |
|
390 | - && post_type_supports(Application::POST_TYPE, 'title') |
|
391 | - && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
389 | + return $this->isReviewPostType( $post ) |
|
390 | + && post_type_supports( Application::POST_TYPE, 'title' ) |
|
391 | + && 'local' == glsr( Database::class )->get( $post->ID, 'review_type' ); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
395 | 395 | * @param mixed $post |
396 | 396 | * @return bool |
397 | 397 | */ |
398 | - protected function isReviewPostType($post) |
|
398 | + protected function isReviewPostType( $post ) |
|
399 | 399 | { |
400 | 400 | return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
401 | 401 | } |
@@ -403,29 +403,29 @@ discard block |
||
403 | 403 | /** |
404 | 404 | * @return array |
405 | 405 | */ |
406 | - protected function normalizeDetailsMetaBox(Review $review) |
|
406 | + protected function normalizeDetailsMetaBox( Review $review ) |
|
407 | 407 | { |
408 | 408 | $user = empty($review->user_id) |
409 | - ? __('Unregistered user', 'site-reviews') |
|
410 | - : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
411 | - 'href' => get_author_posts_url($review->user_id), |
|
412 | - ]); |
|
409 | + ? __( 'Unregistered user', 'site-reviews' ) |
|
410 | + : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
|
411 | + 'href' => get_author_posts_url( $review->user_id ), |
|
412 | + ] ); |
|
413 | 413 | $email = empty($review->email) |
414 | 414 | ? '—' |
415 | - : glsr(Builder::class)->a($review->email, [ |
|
416 | - 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
417 | - ]); |
|
415 | + : glsr( Builder::class )->a( $review->email, [ |
|
416 | + 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
|
417 | + ] ); |
|
418 | 418 | $metabox = [ |
419 | - __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
420 | - __('Type', 'site-reviews') => $this->getReviewType($review), |
|
421 | - __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
422 | - __('Name', 'site-reviews') => $review->author, |
|
423 | - __('Email', 'site-reviews') => $email, |
|
424 | - __('User', 'site-reviews') => $user, |
|
425 | - __('IP Address', 'site-reviews') => $review->ip_address, |
|
426 | - __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
419 | + __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ), |
|
420 | + __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
|
421 | + __( 'Date', 'site-reviews' ) => get_date_from_gmt( $review->date, 'F j, Y' ), |
|
422 | + __( 'Name', 'site-reviews' ) => $review->author, |
|
423 | + __( 'Email', 'site-reviews' ) => $email, |
|
424 | + __( 'User', 'site-reviews' ) => $user, |
|
425 | + __( 'IP Address', 'site-reviews' ) => $review->ip_address, |
|
426 | + __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ), |
|
427 | 427 | ]; |
428 | - return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
428 | + return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) ); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -433,16 +433,16 @@ discard block |
||
433 | 433 | * @param int $messageIndex |
434 | 434 | * @return void |
435 | 435 | */ |
436 | - protected function redirect($postId, $messageIndex) |
|
436 | + protected function redirect( $postId, $messageIndex ) |
|
437 | 437 | { |
438 | 438 | $referer = wp_get_referer(); |
439 | 439 | $hasReferer = !$referer |
440 | - || false !== strpos($referer, 'post.php') |
|
441 | - || false !== strpos($referer, 'post-new.php'); |
|
440 | + || false !== strpos( $referer, 'post.php' ) |
|
441 | + || false !== strpos( $referer, 'post-new.php' ); |
|
442 | 442 | $redirectUri = $hasReferer |
443 | - ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
444 | - : get_edit_post_link($postId); |
|
445 | - wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
443 | + ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
|
444 | + : get_edit_post_link( $postId ); |
|
445 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
446 | 446 | exit; |
447 | 447 | } |
448 | 448 | } |
@@ -8,71 +8,71 @@ |
||
8 | 8 | |
9 | 9 | class RebusifyController extends Controller |
10 | 10 | { |
11 | - /** |
|
12 | - * Triggered when a review is created |
|
13 | - * @return void |
|
14 | - * @action site-reviews/review/created |
|
15 | - */ |
|
16 | - public function onCreated(Review $review) |
|
17 | - { |
|
18 | - if ($this->canProceed($review) && 'publish' === $review->status) { |
|
19 | - $result = glsr(Rebusify::class)->sendReview($review); |
|
20 | - // @todo |
|
21 | - } |
|
22 | - } |
|
11 | + /** |
|
12 | + * Triggered when a review is created |
|
13 | + * @return void |
|
14 | + * @action site-reviews/review/created |
|
15 | + */ |
|
16 | + public function onCreated(Review $review) |
|
17 | + { |
|
18 | + if ($this->canProceed($review) && 'publish' === $review->status) { |
|
19 | + $result = glsr(Rebusify::class)->sendReview($review); |
|
20 | + // @todo |
|
21 | + } |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * Triggered when a review is reverted to its original title/content/date_timestamp |
|
26 | - * @return void |
|
27 | - * @action site-reviews/review/reverted |
|
28 | - */ |
|
29 | - public function onReverted(Review $review) |
|
30 | - { |
|
31 | - if ($this->canProceed($review) && 'publish' === $review->status) { |
|
32 | - $result = glsr(Rebusify::class)->sendReview($review); |
|
33 | - // @todo |
|
34 | - } |
|
35 | - } |
|
24 | + /** |
|
25 | + * Triggered when a review is reverted to its original title/content/date_timestamp |
|
26 | + * @return void |
|
27 | + * @action site-reviews/review/reverted |
|
28 | + */ |
|
29 | + public function onReverted(Review $review) |
|
30 | + { |
|
31 | + if ($this->canProceed($review) && 'publish' === $review->status) { |
|
32 | + $result = glsr(Rebusify::class)->sendReview($review); |
|
33 | + // @todo |
|
34 | + } |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Triggered when an existing review is updated |
|
39 | - * @return void |
|
40 | - * @action site-reviews/review/saved |
|
41 | - */ |
|
42 | - public function onSaved(Review $review) |
|
43 | - { |
|
44 | - if ($this->canProceed($review) && 'publish' === $review->status) { |
|
45 | - $result = glsr(Rebusify::class)->sendReview($review); |
|
46 | - // @todo |
|
47 | - } |
|
48 | - } |
|
37 | + /** |
|
38 | + * Triggered when an existing review is updated |
|
39 | + * @return void |
|
40 | + * @action site-reviews/review/saved |
|
41 | + */ |
|
42 | + public function onSaved(Review $review) |
|
43 | + { |
|
44 | + if ($this->canProceed($review) && 'publish' === $review->status) { |
|
45 | + $result = glsr(Rebusify::class)->sendReview($review); |
|
46 | + // @todo |
|
47 | + } |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Triggered when a review's response is added or updated |
|
52 | - * @param int $metaId |
|
53 | - * @param int $postId |
|
54 | - * @param string $metaKey |
|
55 | - * @param mixed $metaValue |
|
56 | - * @return void |
|
57 | - * @action updated_postmeta |
|
58 | - */ |
|
59 | - public function onUpdatedMeta($metaId, $postId, $metaKey, $metaValue) |
|
60 | - { |
|
61 | - if (!$this->isReviewPostId($postId) |
|
62 | - || $this->canProceed($review) |
|
63 | - || '_response' !== $metaKey) { |
|
64 | - return; |
|
65 | - } |
|
66 | - $review = glsr_get_review($postId); |
|
67 | - $result = glsr(Rebusify::class)->sendReviewResponse($review); |
|
68 | - // @todo |
|
69 | - } |
|
50 | + /** |
|
51 | + * Triggered when a review's response is added or updated |
|
52 | + * @param int $metaId |
|
53 | + * @param int $postId |
|
54 | + * @param string $metaKey |
|
55 | + * @param mixed $metaValue |
|
56 | + * @return void |
|
57 | + * @action updated_postmeta |
|
58 | + */ |
|
59 | + public function onUpdatedMeta($metaId, $postId, $metaKey, $metaValue) |
|
60 | + { |
|
61 | + if (!$this->isReviewPostId($postId) |
|
62 | + || $this->canProceed($review) |
|
63 | + || '_response' !== $metaKey) { |
|
64 | + return; |
|
65 | + } |
|
66 | + $review = glsr_get_review($postId); |
|
67 | + $result = glsr(Rebusify::class)->sendReviewResponse($review); |
|
68 | + // @todo |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return bool |
|
73 | - */ |
|
74 | - protected function canProceed(Review $review) |
|
75 | - { |
|
76 | - return glsr(OptionManager::class)->getBool('settings.general.support.rebusify'); |
|
77 | - } |
|
71 | + /** |
|
72 | + * @return bool |
|
73 | + */ |
|
74 | + protected function canProceed(Review $review) |
|
75 | + { |
|
76 | + return glsr(OptionManager::class)->getBool('settings.general.support.rebusify'); |
|
77 | + } |
|
78 | 78 | } |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | * @return void |
14 | 14 | * @action site-reviews/review/created |
15 | 15 | */ |
16 | - public function onCreated(Review $review) |
|
16 | + public function onCreated( Review $review ) |
|
17 | 17 | { |
18 | - if ($this->canProceed($review) && 'publish' === $review->status) { |
|
19 | - $result = glsr(Rebusify::class)->sendReview($review); |
|
18 | + if( $this->canProceed( $review ) && 'publish' === $review->status ) { |
|
19 | + $result = glsr( Rebusify::class )->sendReview( $review ); |
|
20 | 20 | // @todo |
21 | 21 | } |
22 | 22 | } |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | * @return void |
27 | 27 | * @action site-reviews/review/reverted |
28 | 28 | */ |
29 | - public function onReverted(Review $review) |
|
29 | + public function onReverted( Review $review ) |
|
30 | 30 | { |
31 | - if ($this->canProceed($review) && 'publish' === $review->status) { |
|
32 | - $result = glsr(Rebusify::class)->sendReview($review); |
|
31 | + if( $this->canProceed( $review ) && 'publish' === $review->status ) { |
|
32 | + $result = glsr( Rebusify::class )->sendReview( $review ); |
|
33 | 33 | // @todo |
34 | 34 | } |
35 | 35 | } |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | * @return void |
40 | 40 | * @action site-reviews/review/saved |
41 | 41 | */ |
42 | - public function onSaved(Review $review) |
|
42 | + public function onSaved( Review $review ) |
|
43 | 43 | { |
44 | - if ($this->canProceed($review) && 'publish' === $review->status) { |
|
45 | - $result = glsr(Rebusify::class)->sendReview($review); |
|
44 | + if( $this->canProceed( $review ) && 'publish' === $review->status ) { |
|
45 | + $result = glsr( Rebusify::class )->sendReview( $review ); |
|
46 | 46 | // @todo |
47 | 47 | } |
48 | 48 | } |
@@ -56,23 +56,23 @@ discard block |
||
56 | 56 | * @return void |
57 | 57 | * @action updated_postmeta |
58 | 58 | */ |
59 | - public function onUpdatedMeta($metaId, $postId, $metaKey, $metaValue) |
|
59 | + public function onUpdatedMeta( $metaId, $postId, $metaKey, $metaValue ) |
|
60 | 60 | { |
61 | - if (!$this->isReviewPostId($postId) |
|
62 | - || $this->canProceed($review) |
|
63 | - || '_response' !== $metaKey) { |
|
61 | + if( !$this->isReviewPostId( $postId ) |
|
62 | + || $this->canProceed( $review ) |
|
63 | + || '_response' !== $metaKey ) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | - $review = glsr_get_review($postId); |
|
67 | - $result = glsr(Rebusify::class)->sendReviewResponse($review); |
|
66 | + $review = glsr_get_review( $postId ); |
|
67 | + $result = glsr( Rebusify::class )->sendReviewResponse( $review ); |
|
68 | 68 | // @todo |
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @return bool |
73 | 73 | */ |
74 | - protected function canProceed(Review $review) |
|
74 | + protected function canProceed( Review $review ) |
|
75 | 75 | { |
76 | - return glsr(OptionManager::class)->getBool('settings.general.support.rebusify'); |
|
76 | + return glsr( OptionManager::class )->getBool( 'settings.general.support.rebusify' ); |
|
77 | 77 | } |
78 | 78 | } |
@@ -16,204 +16,204 @@ |
||
16 | 16 | |
17 | 17 | class ReviewManager |
18 | 18 | { |
19 | - /** |
|
20 | - * @return false|Review |
|
21 | - */ |
|
22 | - public function create(CreateReview $command) |
|
23 | - { |
|
24 | - $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command); |
|
25 | - $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command); |
|
26 | - $reviewValues = glsr(Helper::class)->prefixArrayKeys($reviewValues); |
|
27 | - unset($reviewValues['json']); // @todo remove the need for this |
|
28 | - $postValues = [ |
|
29 | - 'comment_status' => 'closed', |
|
30 | - 'meta_input' => $reviewValues, |
|
31 | - 'ping_status' => 'closed', |
|
32 | - 'post_content' => $reviewValues['_content'], |
|
33 | - 'post_date' => $reviewValues['_date'], |
|
34 | - 'post_date_gmt' => get_gmt_from_date($reviewValues['_date']), |
|
35 | - 'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'], |
|
36 | - 'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted), |
|
37 | - 'post_title' => $reviewValues['_title'], |
|
38 | - 'post_type' => Application::POST_TYPE, |
|
39 | - ]; |
|
40 | - $postId = wp_insert_post($postValues, true); |
|
41 | - if (is_wp_error($postId)) { |
|
42 | - glsr_log()->error($postId->get_error_message())->debug($postValues); |
|
43 | - return false; |
|
44 | - } |
|
45 | - $this->setTerms($postId, $command->category); |
|
46 | - $review = $this->single(get_post($postId)); |
|
47 | - do_action('site-reviews/review/created', $review, $command); |
|
48 | - return $review; |
|
49 | - } |
|
19 | + /** |
|
20 | + * @return false|Review |
|
21 | + */ |
|
22 | + public function create(CreateReview $command) |
|
23 | + { |
|
24 | + $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command); |
|
25 | + $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command); |
|
26 | + $reviewValues = glsr(Helper::class)->prefixArrayKeys($reviewValues); |
|
27 | + unset($reviewValues['json']); // @todo remove the need for this |
|
28 | + $postValues = [ |
|
29 | + 'comment_status' => 'closed', |
|
30 | + 'meta_input' => $reviewValues, |
|
31 | + 'ping_status' => 'closed', |
|
32 | + 'post_content' => $reviewValues['_content'], |
|
33 | + 'post_date' => $reviewValues['_date'], |
|
34 | + 'post_date_gmt' => get_gmt_from_date($reviewValues['_date']), |
|
35 | + 'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'], |
|
36 | + 'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted), |
|
37 | + 'post_title' => $reviewValues['_title'], |
|
38 | + 'post_type' => Application::POST_TYPE, |
|
39 | + ]; |
|
40 | + $postId = wp_insert_post($postValues, true); |
|
41 | + if (is_wp_error($postId)) { |
|
42 | + glsr_log()->error($postId->get_error_message())->debug($postValues); |
|
43 | + return false; |
|
44 | + } |
|
45 | + $this->setTerms($postId, $command->category); |
|
46 | + $review = $this->single(get_post($postId)); |
|
47 | + do_action('site-reviews/review/created', $review, $command); |
|
48 | + return $review; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param string $metaReviewId |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function delete($metaReviewId) |
|
56 | - { |
|
57 | - if ($postId = $this->getPostId($metaReviewId)) { |
|
58 | - wp_delete_post($postId, true); |
|
59 | - } |
|
60 | - } |
|
51 | + /** |
|
52 | + * @param string $metaReviewId |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function delete($metaReviewId) |
|
56 | + { |
|
57 | + if ($postId = $this->getPostId($metaReviewId)) { |
|
58 | + wp_delete_post($postId, true); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return object |
|
64 | - */ |
|
65 | - public function get(array $args = []) |
|
66 | - { |
|
67 | - $args = glsr(ReviewsDefaults::class)->merge($args); |
|
68 | - $metaQuery = glsr(QueryBuilder::class)->buildQuery( |
|
69 | - ['assigned_to', 'type', 'rating'], |
|
70 | - $args |
|
71 | - ); |
|
72 | - $taxQuery = glsr(QueryBuilder::class)->buildQuery( |
|
73 | - ['category'], |
|
74 | - ['category' => $this->normalizeTermIds($args['category'])] |
|
75 | - ); |
|
76 | - $paged = glsr(QueryBuilder::class)->getPaged( |
|
77 | - wp_validate_boolean($args['pagination']) |
|
78 | - ); |
|
79 | - $parameters = [ |
|
80 | - 'meta_key' => '_pinned', |
|
81 | - 'meta_query' => $metaQuery, |
|
82 | - 'offset' => $args['offset'], |
|
83 | - 'order' => $args['order'], |
|
84 | - 'orderby' => 'meta_value '.$args['orderby'], |
|
85 | - 'paged' => glsr_get($args, 'paged', $paged), |
|
86 | - 'post__in' => $args['post__in'], |
|
87 | - 'post__not_in' => $args['post__not_in'], |
|
88 | - 'post_status' => 'publish', |
|
89 | - 'post_type' => Application::POST_TYPE, |
|
90 | - 'posts_per_page' => $args['count'], |
|
91 | - 'tax_query' => $taxQuery, |
|
92 | - ]; |
|
93 | - $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args); |
|
94 | - $query = new WP_Query($parameters); |
|
95 | - $results = array_map([$this, 'single'], $query->posts); |
|
96 | - $reviews = new Reviews($results, $query->max_num_pages, $args); |
|
97 | - return apply_filters('site-reviews/get/reviews', $reviews, $query); |
|
98 | - } |
|
62 | + /** |
|
63 | + * @return object |
|
64 | + */ |
|
65 | + public function get(array $args = []) |
|
66 | + { |
|
67 | + $args = glsr(ReviewsDefaults::class)->merge($args); |
|
68 | + $metaQuery = glsr(QueryBuilder::class)->buildQuery( |
|
69 | + ['assigned_to', 'type', 'rating'], |
|
70 | + $args |
|
71 | + ); |
|
72 | + $taxQuery = glsr(QueryBuilder::class)->buildQuery( |
|
73 | + ['category'], |
|
74 | + ['category' => $this->normalizeTermIds($args['category'])] |
|
75 | + ); |
|
76 | + $paged = glsr(QueryBuilder::class)->getPaged( |
|
77 | + wp_validate_boolean($args['pagination']) |
|
78 | + ); |
|
79 | + $parameters = [ |
|
80 | + 'meta_key' => '_pinned', |
|
81 | + 'meta_query' => $metaQuery, |
|
82 | + 'offset' => $args['offset'], |
|
83 | + 'order' => $args['order'], |
|
84 | + 'orderby' => 'meta_value '.$args['orderby'], |
|
85 | + 'paged' => glsr_get($args, 'paged', $paged), |
|
86 | + 'post__in' => $args['post__in'], |
|
87 | + 'post__not_in' => $args['post__not_in'], |
|
88 | + 'post_status' => 'publish', |
|
89 | + 'post_type' => Application::POST_TYPE, |
|
90 | + 'posts_per_page' => $args['count'], |
|
91 | + 'tax_query' => $taxQuery, |
|
92 | + ]; |
|
93 | + $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args); |
|
94 | + $query = new WP_Query($parameters); |
|
95 | + $results = array_map([$this, 'single'], $query->posts); |
|
96 | + $reviews = new Reviews($results, $query->max_num_pages, $args); |
|
97 | + return apply_filters('site-reviews/get/reviews', $reviews, $query); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @param string $metaReviewId |
|
102 | - * @return int |
|
103 | - */ |
|
104 | - public function getPostId($metaReviewId) |
|
105 | - { |
|
106 | - return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId); |
|
107 | - } |
|
100 | + /** |
|
101 | + * @param string $metaReviewId |
|
102 | + * @return int |
|
103 | + */ |
|
104 | + public function getPostId($metaReviewId) |
|
105 | + { |
|
106 | + return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public function getRatingCounts(array $args = []) |
|
113 | - { |
|
114 | - $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args); |
|
115 | - $counts = glsr(CountsManager::class)->get([ |
|
116 | - 'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']), |
|
117 | - 'term_ids' => $this->normalizeTermIds($args['category']), |
|
118 | - 'type' => $args['type'], |
|
119 | - ]); |
|
120 | - return glsr(CountsManager::class)->flatten($counts, [ |
|
121 | - 'min' => $args['rating'], |
|
122 | - ]); |
|
123 | - } |
|
109 | + /** |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public function getRatingCounts(array $args = []) |
|
113 | + { |
|
114 | + $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args); |
|
115 | + $counts = glsr(CountsManager::class)->get([ |
|
116 | + 'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']), |
|
117 | + 'term_ids' => $this->normalizeTermIds($args['category']), |
|
118 | + 'type' => $args['type'], |
|
119 | + ]); |
|
120 | + return glsr(CountsManager::class)->flatten($counts, [ |
|
121 | + 'min' => $args['rating'], |
|
122 | + ]); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * @param string $commaSeparatedTermIds |
|
127 | - * @return array |
|
128 | - */ |
|
129 | - public function normalizeTermIds($commaSeparatedTermIds) |
|
130 | - { |
|
131 | - $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id'); |
|
132 | - return array_unique(array_map('intval', $termIds)); |
|
133 | - } |
|
125 | + /** |
|
126 | + * @param string $commaSeparatedTermIds |
|
127 | + * @return array |
|
128 | + */ |
|
129 | + public function normalizeTermIds($commaSeparatedTermIds) |
|
130 | + { |
|
131 | + $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id'); |
|
132 | + return array_unique(array_map('intval', $termIds)); |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * @param string $commaSeparatedTermIds |
|
137 | - * @return array |
|
138 | - */ |
|
139 | - public function normalizeTerms($commaSeparatedTermIds) |
|
140 | - { |
|
141 | - $terms = []; |
|
142 | - $termIds = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds); |
|
143 | - foreach ($termIds as $termId) { |
|
144 | - if (is_numeric($termId)) { |
|
145 | - $termId = intval($termId); |
|
146 | - } |
|
147 | - $term = term_exists($termId, Application::TAXONOMY); |
|
148 | - if (!isset($term['term_id'])) { |
|
149 | - continue; |
|
150 | - } |
|
151 | - $terms[] = $term; |
|
152 | - } |
|
153 | - return $terms; |
|
154 | - } |
|
135 | + /** |
|
136 | + * @param string $commaSeparatedTermIds |
|
137 | + * @return array |
|
138 | + */ |
|
139 | + public function normalizeTerms($commaSeparatedTermIds) |
|
140 | + { |
|
141 | + $terms = []; |
|
142 | + $termIds = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds); |
|
143 | + foreach ($termIds as $termId) { |
|
144 | + if (is_numeric($termId)) { |
|
145 | + $termId = intval($termId); |
|
146 | + } |
|
147 | + $term = term_exists($termId, Application::TAXONOMY); |
|
148 | + if (!isset($term['term_id'])) { |
|
149 | + continue; |
|
150 | + } |
|
151 | + $terms[] = $term; |
|
152 | + } |
|
153 | + return $terms; |
|
154 | + } |
|
155 | 155 | |
156 | - /** |
|
157 | - * @param int $postId |
|
158 | - * @return void |
|
159 | - */ |
|
160 | - public function revert($postId) |
|
161 | - { |
|
162 | - if (Application::POST_TYPE != get_post_field('post_type', $postId)) { |
|
163 | - return; |
|
164 | - } |
|
165 | - delete_post_meta($postId, '_edit_last'); |
|
166 | - $result = wp_update_post([ |
|
167 | - 'ID' => $postId, |
|
168 | - 'post_content' => glsr(Database::class)->get($postId, 'content'), |
|
169 | - 'post_date' => glsr(Database::class)->get($postId, 'date'), |
|
170 | - 'post_title' => glsr(Database::class)->get($postId, 'title'), |
|
171 | - ]); |
|
172 | - if (is_wp_error($result)) { |
|
173 | - glsr_log()->error($result->get_error_message()); |
|
174 | - } else { |
|
175 | - do_action('site-reviews/review/reverted', glsr_get_review($postId)); |
|
176 | - } |
|
177 | - } |
|
156 | + /** |
|
157 | + * @param int $postId |
|
158 | + * @return void |
|
159 | + */ |
|
160 | + public function revert($postId) |
|
161 | + { |
|
162 | + if (Application::POST_TYPE != get_post_field('post_type', $postId)) { |
|
163 | + return; |
|
164 | + } |
|
165 | + delete_post_meta($postId, '_edit_last'); |
|
166 | + $result = wp_update_post([ |
|
167 | + 'ID' => $postId, |
|
168 | + 'post_content' => glsr(Database::class)->get($postId, 'content'), |
|
169 | + 'post_date' => glsr(Database::class)->get($postId, 'date'), |
|
170 | + 'post_title' => glsr(Database::class)->get($postId, 'title'), |
|
171 | + ]); |
|
172 | + if (is_wp_error($result)) { |
|
173 | + glsr_log()->error($result->get_error_message()); |
|
174 | + } else { |
|
175 | + do_action('site-reviews/review/reverted', glsr_get_review($postId)); |
|
176 | + } |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * @return Review |
|
181 | - */ |
|
182 | - public function single(WP_Post $post) |
|
183 | - { |
|
184 | - if (Application::POST_TYPE != $post->post_type) { |
|
185 | - $post = new WP_Post((object) []); |
|
186 | - } |
|
187 | - $review = new Review($post); |
|
188 | - return apply_filters('site-reviews/get/review', $review, $post); |
|
189 | - } |
|
179 | + /** |
|
180 | + * @return Review |
|
181 | + */ |
|
182 | + public function single(WP_Post $post) |
|
183 | + { |
|
184 | + if (Application::POST_TYPE != $post->post_type) { |
|
185 | + $post = new WP_Post((object) []); |
|
186 | + } |
|
187 | + $review = new Review($post); |
|
188 | + return apply_filters('site-reviews/get/review', $review, $post); |
|
189 | + } |
|
190 | 190 | |
191 | - /** |
|
192 | - * @param bool $isBlacklisted |
|
193 | - * @return string |
|
194 | - */ |
|
195 | - protected function getNewPostStatus(array $reviewValues, $isBlacklisted) |
|
196 | - { |
|
197 | - $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval'); |
|
198 | - return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted) |
|
199 | - ? 'pending' |
|
200 | - : 'publish'; |
|
201 | - } |
|
191 | + /** |
|
192 | + * @param bool $isBlacklisted |
|
193 | + * @return string |
|
194 | + */ |
|
195 | + protected function getNewPostStatus(array $reviewValues, $isBlacklisted) |
|
196 | + { |
|
197 | + $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval'); |
|
198 | + return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted) |
|
199 | + ? 'pending' |
|
200 | + : 'publish'; |
|
201 | + } |
|
202 | 202 | |
203 | - /** |
|
204 | - * @param int $postId |
|
205 | - * @param string $termIds |
|
206 | - * @return void |
|
207 | - */ |
|
208 | - protected function setTerms($postId, $termIds) |
|
209 | - { |
|
210 | - $termIds = $this->normalizeTermIds($termIds); |
|
211 | - if (empty($termIds)) { |
|
212 | - return; |
|
213 | - } |
|
214 | - $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY); |
|
215 | - if (is_wp_error($termTaxonomyIds)) { |
|
216 | - glsr_log()->error($termTaxonomyIds->get_error_message()); |
|
217 | - } |
|
218 | - } |
|
203 | + /** |
|
204 | + * @param int $postId |
|
205 | + * @param string $termIds |
|
206 | + * @return void |
|
207 | + */ |
|
208 | + protected function setTerms($postId, $termIds) |
|
209 | + { |
|
210 | + $termIds = $this->normalizeTermIds($termIds); |
|
211 | + if (empty($termIds)) { |
|
212 | + return; |
|
213 | + } |
|
214 | + $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY); |
|
215 | + if (is_wp_error($termTaxonomyIds)) { |
|
216 | + glsr_log()->error($termTaxonomyIds->get_error_message()); |
|
217 | + } |
|
218 | + } |
|
219 | 219 | } |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @return false|Review |
21 | 21 | */ |
22 | - public function create(CreateReview $command) |
|
22 | + public function create( CreateReview $command ) |
|
23 | 23 | { |
24 | - $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command); |
|
25 | - $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command); |
|
26 | - $reviewValues = glsr(Helper::class)->prefixArrayKeys($reviewValues); |
|
24 | + $reviewValues = glsr( CreateReviewDefaults::class )->restrict( (array)$command ); |
|
25 | + $reviewValues = apply_filters( 'site-reviews/create/review-values', $reviewValues, $command ); |
|
26 | + $reviewValues = glsr( Helper::class )->prefixArrayKeys( $reviewValues ); |
|
27 | 27 | unset($reviewValues['json']); // @todo remove the need for this |
28 | 28 | $postValues = [ |
29 | 29 | 'comment_status' => 'closed', |
@@ -31,20 +31,20 @@ discard block |
||
31 | 31 | 'ping_status' => 'closed', |
32 | 32 | 'post_content' => $reviewValues['_content'], |
33 | 33 | 'post_date' => $reviewValues['_date'], |
34 | - 'post_date_gmt' => get_gmt_from_date($reviewValues['_date']), |
|
34 | + 'post_date_gmt' => get_gmt_from_date( $reviewValues['_date'] ), |
|
35 | 35 | 'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'], |
36 | - 'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted), |
|
36 | + 'post_status' => $this->getNewPostStatus( $reviewValues, $command->blacklisted ), |
|
37 | 37 | 'post_title' => $reviewValues['_title'], |
38 | 38 | 'post_type' => Application::POST_TYPE, |
39 | 39 | ]; |
40 | - $postId = wp_insert_post($postValues, true); |
|
41 | - if (is_wp_error($postId)) { |
|
42 | - glsr_log()->error($postId->get_error_message())->debug($postValues); |
|
40 | + $postId = wp_insert_post( $postValues, true ); |
|
41 | + if( is_wp_error( $postId ) ) { |
|
42 | + glsr_log()->error( $postId->get_error_message() )->debug( $postValues ); |
|
43 | 43 | return false; |
44 | 44 | } |
45 | - $this->setTerms($postId, $command->category); |
|
46 | - $review = $this->single(get_post($postId)); |
|
47 | - do_action('site-reviews/review/created', $review, $command); |
|
45 | + $this->setTerms( $postId, $command->category ); |
|
46 | + $review = $this->single( get_post( $postId ) ); |
|
47 | + do_action( 'site-reviews/review/created', $review, $command ); |
|
48 | 48 | return $review; |
49 | 49 | } |
50 | 50 | |
@@ -52,29 +52,29 @@ discard block |
||
52 | 52 | * @param string $metaReviewId |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function delete($metaReviewId) |
|
55 | + public function delete( $metaReviewId ) |
|
56 | 56 | { |
57 | - if ($postId = $this->getPostId($metaReviewId)) { |
|
58 | - wp_delete_post($postId, true); |
|
57 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
58 | + wp_delete_post( $postId, true ); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @return object |
64 | 64 | */ |
65 | - public function get(array $args = []) |
|
65 | + public function get( array $args = [] ) |
|
66 | 66 | { |
67 | - $args = glsr(ReviewsDefaults::class)->merge($args); |
|
68 | - $metaQuery = glsr(QueryBuilder::class)->buildQuery( |
|
67 | + $args = glsr( ReviewsDefaults::class )->merge( $args ); |
|
68 | + $metaQuery = glsr( QueryBuilder::class )->buildQuery( |
|
69 | 69 | ['assigned_to', 'type', 'rating'], |
70 | 70 | $args |
71 | 71 | ); |
72 | - $taxQuery = glsr(QueryBuilder::class)->buildQuery( |
|
72 | + $taxQuery = glsr( QueryBuilder::class )->buildQuery( |
|
73 | 73 | ['category'], |
74 | - ['category' => $this->normalizeTermIds($args['category'])] |
|
74 | + ['category' => $this->normalizeTermIds( $args['category'] )] |
|
75 | 75 | ); |
76 | - $paged = glsr(QueryBuilder::class)->getPaged( |
|
77 | - wp_validate_boolean($args['pagination']) |
|
76 | + $paged = glsr( QueryBuilder::class )->getPaged( |
|
77 | + wp_validate_boolean( $args['pagination'] ) |
|
78 | 78 | ); |
79 | 79 | $parameters = [ |
80 | 80 | 'meta_key' => '_pinned', |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'offset' => $args['offset'], |
83 | 83 | 'order' => $args['order'], |
84 | 84 | 'orderby' => 'meta_value '.$args['orderby'], |
85 | - 'paged' => glsr_get($args, 'paged', $paged), |
|
85 | + 'paged' => glsr_get( $args, 'paged', $paged ), |
|
86 | 86 | 'post__in' => $args['post__in'], |
87 | 87 | 'post__not_in' => $args['post__not_in'], |
88 | 88 | 'post_status' => 'publish', |
@@ -90,62 +90,62 @@ discard block |
||
90 | 90 | 'posts_per_page' => $args['count'], |
91 | 91 | 'tax_query' => $taxQuery, |
92 | 92 | ]; |
93 | - $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args); |
|
94 | - $query = new WP_Query($parameters); |
|
95 | - $results = array_map([$this, 'single'], $query->posts); |
|
96 | - $reviews = new Reviews($results, $query->max_num_pages, $args); |
|
97 | - return apply_filters('site-reviews/get/reviews', $reviews, $query); |
|
93 | + $parameters = apply_filters( 'site-reviews/get/reviews/query', $parameters, $args ); |
|
94 | + $query = new WP_Query( $parameters ); |
|
95 | + $results = array_map( [$this, 'single'], $query->posts ); |
|
96 | + $reviews = new Reviews( $results, $query->max_num_pages, $args ); |
|
97 | + return apply_filters( 'site-reviews/get/reviews', $reviews, $query ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @param string $metaReviewId |
102 | 102 | * @return int |
103 | 103 | */ |
104 | - public function getPostId($metaReviewId) |
|
104 | + public function getPostId( $metaReviewId ) |
|
105 | 105 | { |
106 | - return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId); |
|
106 | + return glsr( SqlQueries::class )->getPostIdFromReviewId( $metaReviewId ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @return array |
111 | 111 | */ |
112 | - public function getRatingCounts(array $args = []) |
|
112 | + public function getRatingCounts( array $args = [] ) |
|
113 | 113 | { |
114 | - $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args); |
|
115 | - $counts = glsr(CountsManager::class)->get([ |
|
116 | - 'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']), |
|
117 | - 'term_ids' => $this->normalizeTermIds($args['category']), |
|
114 | + $args = glsr( SiteReviewsSummaryDefaults::class )->filter( $args ); |
|
115 | + $counts = glsr( CountsManager::class )->get( [ |
|
116 | + 'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ), |
|
117 | + 'term_ids' => $this->normalizeTermIds( $args['category'] ), |
|
118 | 118 | 'type' => $args['type'], |
119 | - ]); |
|
120 | - return glsr(CountsManager::class)->flatten($counts, [ |
|
119 | + ] ); |
|
120 | + return glsr( CountsManager::class )->flatten( $counts, [ |
|
121 | 121 | 'min' => $args['rating'], |
122 | - ]); |
|
122 | + ] ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @param string $commaSeparatedTermIds |
127 | 127 | * @return array |
128 | 128 | */ |
129 | - public function normalizeTermIds($commaSeparatedTermIds) |
|
129 | + public function normalizeTermIds( $commaSeparatedTermIds ) |
|
130 | 130 | { |
131 | - $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id'); |
|
132 | - return array_unique(array_map('intval', $termIds)); |
|
131 | + $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' ); |
|
132 | + return array_unique( array_map( 'intval', $termIds ) ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | 136 | * @param string $commaSeparatedTermIds |
137 | 137 | * @return array |
138 | 138 | */ |
139 | - public function normalizeTerms($commaSeparatedTermIds) |
|
139 | + public function normalizeTerms( $commaSeparatedTermIds ) |
|
140 | 140 | { |
141 | 141 | $terms = []; |
142 | - $termIds = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds); |
|
143 | - foreach ($termIds as $termId) { |
|
144 | - if (is_numeric($termId)) { |
|
145 | - $termId = intval($termId); |
|
142 | + $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds ); |
|
143 | + foreach( $termIds as $termId ) { |
|
144 | + if( is_numeric( $termId ) ) { |
|
145 | + $termId = intval( $termId ); |
|
146 | 146 | } |
147 | - $term = term_exists($termId, Application::TAXONOMY); |
|
148 | - if (!isset($term['term_id'])) { |
|
147 | + $term = term_exists( $termId, Application::TAXONOMY ); |
|
148 | + if( !isset($term['term_id']) ) { |
|
149 | 149 | continue; |
150 | 150 | } |
151 | 151 | $terms[] = $term; |
@@ -157,44 +157,44 @@ discard block |
||
157 | 157 | * @param int $postId |
158 | 158 | * @return void |
159 | 159 | */ |
160 | - public function revert($postId) |
|
160 | + public function revert( $postId ) |
|
161 | 161 | { |
162 | - if (Application::POST_TYPE != get_post_field('post_type', $postId)) { |
|
162 | + if( Application::POST_TYPE != get_post_field( 'post_type', $postId ) ) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | - delete_post_meta($postId, '_edit_last'); |
|
166 | - $result = wp_update_post([ |
|
165 | + delete_post_meta( $postId, '_edit_last' ); |
|
166 | + $result = wp_update_post( [ |
|
167 | 167 | 'ID' => $postId, |
168 | - 'post_content' => glsr(Database::class)->get($postId, 'content'), |
|
169 | - 'post_date' => glsr(Database::class)->get($postId, 'date'), |
|
170 | - 'post_title' => glsr(Database::class)->get($postId, 'title'), |
|
171 | - ]); |
|
172 | - if (is_wp_error($result)) { |
|
173 | - glsr_log()->error($result->get_error_message()); |
|
168 | + 'post_content' => glsr( Database::class )->get( $postId, 'content' ), |
|
169 | + 'post_date' => glsr( Database::class )->get( $postId, 'date' ), |
|
170 | + 'post_title' => glsr( Database::class )->get( $postId, 'title' ), |
|
171 | + ] ); |
|
172 | + if( is_wp_error( $result ) ) { |
|
173 | + glsr_log()->error( $result->get_error_message() ); |
|
174 | 174 | } else { |
175 | - do_action('site-reviews/review/reverted', glsr_get_review($postId)); |
|
175 | + do_action( 'site-reviews/review/reverted', glsr_get_review( $postId ) ); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | 180 | * @return Review |
181 | 181 | */ |
182 | - public function single(WP_Post $post) |
|
182 | + public function single( WP_Post $post ) |
|
183 | 183 | { |
184 | - if (Application::POST_TYPE != $post->post_type) { |
|
185 | - $post = new WP_Post((object) []); |
|
184 | + if( Application::POST_TYPE != $post->post_type ) { |
|
185 | + $post = new WP_Post( (object)[] ); |
|
186 | 186 | } |
187 | - $review = new Review($post); |
|
188 | - return apply_filters('site-reviews/get/review', $review, $post); |
|
187 | + $review = new Review( $post ); |
|
188 | + return apply_filters( 'site-reviews/get/review', $review, $post ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | 192 | * @param bool $isBlacklisted |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - protected function getNewPostStatus(array $reviewValues, $isBlacklisted) |
|
195 | + protected function getNewPostStatus( array $reviewValues, $isBlacklisted ) |
|
196 | 196 | { |
197 | - $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval'); |
|
197 | + $requireApproval = glsr( OptionManager::class )->getBool( 'settings.general.require.approval' ); |
|
198 | 198 | return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted) |
199 | 199 | ? 'pending' |
200 | 200 | : 'publish'; |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * @param string $termIds |
206 | 206 | * @return void |
207 | 207 | */ |
208 | - protected function setTerms($postId, $termIds) |
|
208 | + protected function setTerms( $postId, $termIds ) |
|
209 | 209 | { |
210 | - $termIds = $this->normalizeTermIds($termIds); |
|
211 | - if (empty($termIds)) { |
|
210 | + $termIds = $this->normalizeTermIds( $termIds ); |
|
211 | + if( empty($termIds) ) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | - $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY); |
|
215 | - if (is_wp_error($termTaxonomyIds)) { |
|
216 | - glsr_log()->error($termTaxonomyIds->get_error_message()); |
|
214 | + $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
|
215 | + if( is_wp_error( $termTaxonomyIds ) ) { |
|
216 | + glsr_log()->error( $termTaxonomyIds->get_error_message() ); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | } |
@@ -171,7 +171,8 @@ |
||
171 | 171 | ]); |
172 | 172 | if (is_wp_error($result)) { |
173 | 173 | glsr_log()->error($result->get_error_message()); |
174 | - } else { |
|
174 | + } |
|
175 | + else { |
|
175 | 176 | do_action('site-reviews/review/reverted', glsr_get_review($postId)); |
176 | 177 | } |
177 | 178 | } |
@@ -18,100 +18,100 @@ |
||
18 | 18 | |
19 | 19 | class Actions implements HooksContract |
20 | 20 | { |
21 | - protected $admin; |
|
22 | - protected $app; |
|
23 | - protected $blocks; |
|
24 | - protected $console; |
|
25 | - protected $editor; |
|
26 | - protected $listtable; |
|
27 | - protected $menu; |
|
28 | - protected $main; |
|
29 | - protected $public; |
|
30 | - protected $rebusify; |
|
31 | - protected $review; |
|
32 | - protected $router; |
|
33 | - protected $settings; |
|
34 | - protected $taxonomy; |
|
21 | + protected $admin; |
|
22 | + protected $app; |
|
23 | + protected $blocks; |
|
24 | + protected $console; |
|
25 | + protected $editor; |
|
26 | + protected $listtable; |
|
27 | + protected $menu; |
|
28 | + protected $main; |
|
29 | + protected $public; |
|
30 | + protected $rebusify; |
|
31 | + protected $review; |
|
32 | + protected $router; |
|
33 | + protected $settings; |
|
34 | + protected $taxonomy; |
|
35 | 35 | |
36 | - public function __construct(Application $app ) { |
|
37 | - $this->app = $app; |
|
38 | - $this->admin = $app->make(AdminController::class); |
|
39 | - $this->blocks = $app->make(BlocksController::class); |
|
40 | - $this->console = $app->make(Console::class); |
|
41 | - $this->editor = $app->make(EditorController::class); |
|
42 | - $this->listtable = $app->make(ListTableController::class); |
|
43 | - $this->main = $app->make(MainController::class); |
|
44 | - $this->menu = $app->make(MenuController::class); |
|
45 | - $this->public = $app->make(PublicController::class); |
|
46 | - $this->rebusify = $app->make(RebusifyController::class); |
|
47 | - $this->review = $app->make(ReviewController::class); |
|
48 | - $this->router = $app->make(Router::class); |
|
49 | - $this->settings = $app->make(SettingsController::class); |
|
50 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
51 | - } |
|
36 | + public function __construct(Application $app ) { |
|
37 | + $this->app = $app; |
|
38 | + $this->admin = $app->make(AdminController::class); |
|
39 | + $this->blocks = $app->make(BlocksController::class); |
|
40 | + $this->console = $app->make(Console::class); |
|
41 | + $this->editor = $app->make(EditorController::class); |
|
42 | + $this->listtable = $app->make(ListTableController::class); |
|
43 | + $this->main = $app->make(MainController::class); |
|
44 | + $this->menu = $app->make(MenuController::class); |
|
45 | + $this->public = $app->make(PublicController::class); |
|
46 | + $this->rebusify = $app->make(RebusifyController::class); |
|
47 | + $this->review = $app->make(ReviewController::class); |
|
48 | + $this->router = $app->make(Router::class); |
|
49 | + $this->settings = $app->make(SettingsController::class); |
|
50 | + $this->taxonomy = $app->make(TaxonomyController::class); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function run() |
|
57 | - { |
|
58 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
59 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
60 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
61 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
62 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
63 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
64 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
65 | - add_action('upgrader_process_complete', [$this->app, 'upgraded'], 10, 2); |
|
66 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
67 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
68 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
69 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
70 | - add_action('admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels']); |
|
71 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
72 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
73 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
74 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
75 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
76 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
77 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
78 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes']); |
|
79 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
80 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
81 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
82 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
83 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
84 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
85 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
86 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
87 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
88 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
89 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
90 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
91 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
92 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
93 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
94 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
95 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
96 | - add_action('site-reviews/review/created', [$this->rebusify, 'onCreated']); |
|
97 | - add_action('site-reviews/review/reverted', [$this->rebusify, 'onReverted']); |
|
98 | - add_action('site-reviews/review/saved', [$this->rebusify, 'onSaved']); |
|
99 | - add_action('updated_postmeta', [$this->rebusify, 'onUpdatedMeta'], 10, 4); |
|
100 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
101 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
102 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
103 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
104 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
105 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
106 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
107 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
108 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
109 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
110 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
111 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
112 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
113 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
114 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
115 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
116 | - } |
|
53 | + /** |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function run() |
|
57 | + { |
|
58 | + add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
59 | + add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
60 | + add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
61 | + add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
62 | + add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
63 | + add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
64 | + add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
65 | + add_action('upgrader_process_complete', [$this->app, 'upgraded'], 10, 2); |
|
66 | + add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
67 | + add_action('init', [$this->blocks, 'registerBlocks']); |
|
68 | + add_action('admin_footer', [$this->console, 'logOnce']); |
|
69 | + add_action('wp_footer', [$this->console, 'logOnce']); |
|
70 | + add_action('admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels']); |
|
71 | + add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
72 | + add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
73 | + add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
74 | + add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
75 | + add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
76 | + add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
77 | + add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
78 | + add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes']); |
|
79 | + add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
80 | + add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
81 | + add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
82 | + add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
83 | + add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
84 | + add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
85 | + add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
86 | + add_action('init', [$this->main, 'registerPostType'], 8); |
|
87 | + add_action('init', [$this->main, 'registerShortcodes']); |
|
88 | + add_action('init', [$this->main, 'registerTaxonomy']); |
|
89 | + add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
90 | + add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
91 | + add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
92 | + add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
93 | + add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
94 | + add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
95 | + add_action('wp_footer', [$this->public, 'renderSchema']); |
|
96 | + add_action('site-reviews/review/created', [$this->rebusify, 'onCreated']); |
|
97 | + add_action('site-reviews/review/reverted', [$this->rebusify, 'onReverted']); |
|
98 | + add_action('site-reviews/review/saved', [$this->rebusify, 'onSaved']); |
|
99 | + add_action('updated_postmeta', [$this->rebusify, 'onUpdatedMeta'], 10, 4); |
|
100 | + add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
101 | + add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
102 | + add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
103 | + add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
104 | + add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
105 | + add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
106 | + add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
107 | + add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
108 | + add_action('init', [$this->router, 'routePublicPostRequest']); |
|
109 | + add_action('admin_init', [$this->settings, 'registerSettings']); |
|
110 | + add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
111 | + add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
112 | + add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
113 | + add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
114 | + add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
115 | + add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
116 | + } |
|
117 | 117 | } |
@@ -33,21 +33,21 @@ discard block |
||
33 | 33 | protected $settings; |
34 | 34 | protected $taxonomy; |
35 | 35 | |
36 | - public function __construct(Application $app ) { |
|
36 | + public function __construct( Application $app ) { |
|
37 | 37 | $this->app = $app; |
38 | - $this->admin = $app->make(AdminController::class); |
|
39 | - $this->blocks = $app->make(BlocksController::class); |
|
40 | - $this->console = $app->make(Console::class); |
|
41 | - $this->editor = $app->make(EditorController::class); |
|
42 | - $this->listtable = $app->make(ListTableController::class); |
|
43 | - $this->main = $app->make(MainController::class); |
|
44 | - $this->menu = $app->make(MenuController::class); |
|
45 | - $this->public = $app->make(PublicController::class); |
|
46 | - $this->rebusify = $app->make(RebusifyController::class); |
|
47 | - $this->review = $app->make(ReviewController::class); |
|
48 | - $this->router = $app->make(Router::class); |
|
49 | - $this->settings = $app->make(SettingsController::class); |
|
50 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
38 | + $this->admin = $app->make( AdminController::class ); |
|
39 | + $this->blocks = $app->make( BlocksController::class ); |
|
40 | + $this->console = $app->make( Console::class ); |
|
41 | + $this->editor = $app->make( EditorController::class ); |
|
42 | + $this->listtable = $app->make( ListTableController::class ); |
|
43 | + $this->main = $app->make( MainController::class ); |
|
44 | + $this->menu = $app->make( MenuController::class ); |
|
45 | + $this->public = $app->make( PublicController::class ); |
|
46 | + $this->rebusify = $app->make( RebusifyController::class ); |
|
47 | + $this->review = $app->make( ReviewController::class ); |
|
48 | + $this->router = $app->make( Router::class ); |
|
49 | + $this->settings = $app->make( SettingsController::class ); |
|
50 | + $this->taxonomy = $app->make( TaxonomyController::class ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,63 +55,63 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function run() |
57 | 57 | { |
58 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
59 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
60 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
61 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
62 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
63 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
64 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
65 | - add_action('upgrader_process_complete', [$this->app, 'upgraded'], 10, 2); |
|
66 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
67 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
68 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
69 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
70 | - add_action('admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels']); |
|
71 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
72 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
73 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
74 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
75 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
76 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
77 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
78 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes']); |
|
79 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
80 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
81 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
82 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
83 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
84 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
85 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
86 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
87 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
88 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
89 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
90 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
91 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
92 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
93 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
94 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
95 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
96 | - add_action('site-reviews/review/created', [$this->rebusify, 'onCreated']); |
|
97 | - add_action('site-reviews/review/reverted', [$this->rebusify, 'onReverted']); |
|
98 | - add_action('site-reviews/review/saved', [$this->rebusify, 'onSaved']); |
|
99 | - add_action('updated_postmeta', [$this->rebusify, 'onUpdatedMeta'], 10, 4); |
|
100 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
101 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
102 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
103 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
104 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
105 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
106 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
107 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
108 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
109 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
110 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
111 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
112 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
113 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
114 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
115 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
58 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
59 | + add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
60 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
61 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
62 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
63 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
64 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
65 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
66 | + add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
67 | + add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
68 | + add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
69 | + add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
70 | + add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
71 | + add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
72 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
73 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
74 | + add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
75 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
76 | + add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
77 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
78 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
79 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
80 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
81 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
82 | + add_action( 'manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
83 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
84 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
85 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
86 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
87 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
88 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
89 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
90 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
91 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
92 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
93 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
94 | + add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
95 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
96 | + add_action( 'site-reviews/review/created', [$this->rebusify, 'onCreated'] ); |
|
97 | + add_action( 'site-reviews/review/reverted', [$this->rebusify, 'onReverted'] ); |
|
98 | + add_action( 'site-reviews/review/saved', [$this->rebusify, 'onSaved'] ); |
|
99 | + add_action( 'updated_postmeta', [$this->rebusify, 'onUpdatedMeta'], 10, 4 ); |
|
100 | + add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
101 | + add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
102 | + add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
103 | + add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
104 | + add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
105 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
106 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
107 | + add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
108 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
109 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
110 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
111 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
112 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
113 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
114 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
115 | + add_action( 'set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6 ); |
|
116 | 116 | } |
117 | 117 | } |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | defined('WPINC') || die; |
19 | 19 | |
20 | 20 | if (!class_exists('GL_Plugin_Check_v3')) { |
21 | - require_once __DIR__.'/activate.php'; |
|
21 | + require_once __DIR__.'/activate.php'; |
|
22 | 22 | } |
23 | 23 | $check = new GL_Plugin_Check_v3(__FILE__); |
24 | 24 | if (!$check->canProceed()) { |
25 | - return; |
|
25 | + return; |
|
26 | 26 | } |
27 | 27 | require_once __DIR__.'/autoload.php'; |
28 | 28 | require_once __DIR__.'/compatibility.php'; |
@@ -37,5 +37,5 @@ discard block |
||
37 | 37 | $app->init(); |
38 | 38 | |
39 | 39 | if (defined('WP_ENV') && WP_ENV == 'development') { |
40 | - add_filter('site-reviews/console/level', '__return_zero', 1); |
|
40 | + add_filter('site-reviews/console/level', '__return_zero', 1); |
|
41 | 41 | } |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | * Text Domain: site-reviews |
16 | 16 | * Domain Path: languages |
17 | 17 | */ |
18 | -defined('WPINC') || die; |
|
18 | +defined( 'WPINC' ) || die; |
|
19 | 19 | |
20 | -if (!class_exists('GL_Plugin_Check_v3')) { |
|
20 | +if( !class_exists( 'GL_Plugin_Check_v3' ) ) { |
|
21 | 21 | require_once __DIR__.'/activate.php'; |
22 | 22 | } |
23 | -$check = new GL_Plugin_Check_v3(__FILE__); |
|
24 | -if (!$check->canProceed()) { |
|
23 | +$check = new GL_Plugin_Check_v3( __FILE__ ); |
|
24 | +if( !$check->canProceed() ) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | require_once __DIR__.'/autoload.php'; |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | require_once __DIR__.'/helpers.php'; |
31 | 31 | |
32 | 32 | $app = new GeminiLabs\SiteReviews\Application(); |
33 | -$app->make('Provider')->register($app); |
|
34 | -register_activation_hook(__FILE__, array($app, 'activate')); |
|
35 | -register_deactivation_hook(__FILE__, array($app, 'deactivate')); |
|
36 | -register_shutdown_function(array($app, 'catchFatalError')); |
|
33 | +$app->make( 'Provider' )->register( $app ); |
|
34 | +register_activation_hook( __FILE__, array( $app, 'activate' ) ); |
|
35 | +register_deactivation_hook( __FILE__, array( $app, 'deactivate' ) ); |
|
36 | +register_shutdown_function( array( $app, 'catchFatalError' ) ); |
|
37 | 37 | $app->init(); |
38 | 38 | |
39 | -if (defined('WP_ENV') && WP_ENV == 'development') { |
|
40 | - add_filter('site-reviews/console/level', '__return_zero', 1); |
|
39 | +if( defined( 'WP_ENV' ) && WP_ENV == 'development' ) { |
|
40 | + add_filter( 'site-reviews/console/level', '__return_zero', 1 ); |
|
41 | 41 | } |
@@ -6,81 +6,81 @@ |
||
6 | 6 | |
7 | 7 | class Rebusify |
8 | 8 | { |
9 | - const API_URL = 'https://www.rebusify.com/api/rbs/'; |
|
9 | + const API_URL = 'https://www.rebusify.com/api/rbs/'; |
|
10 | 10 | |
11 | - /** |
|
12 | - * @return void|array |
|
13 | - */ |
|
14 | - public function sendReview(Review $review) |
|
15 | - { |
|
16 | - return $this->send('index.php', [ |
|
17 | - 'body' => $this->getBodyForReview($review), |
|
18 | - 'timeout' => 120, |
|
19 | - ]); |
|
20 | - } |
|
11 | + /** |
|
12 | + * @return void|array |
|
13 | + */ |
|
14 | + public function sendReview(Review $review) |
|
15 | + { |
|
16 | + return $this->send('index.php', [ |
|
17 | + 'body' => $this->getBodyForReview($review), |
|
18 | + 'timeout' => 120, |
|
19 | + ]); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @return void|array |
|
24 | - */ |
|
25 | - public function sendReviewResponse(Review $review) |
|
26 | - { |
|
27 | - return $this->send('fetch_customer_reply.php', [ |
|
28 | - 'body' => $this->getBodyForResponse($review), |
|
29 | - ]); |
|
30 | - } |
|
22 | + /** |
|
23 | + * @return void|array |
|
24 | + */ |
|
25 | + public function sendReviewResponse(Review $review) |
|
26 | + { |
|
27 | + return $this->send('fetch_customer_reply.php', [ |
|
28 | + 'body' => $this->getBodyForResponse($review), |
|
29 | + ]); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - protected function getBodyForResponse(Review $review) |
|
36 | - { |
|
37 | - $rebusifyResponse = [ |
|
38 | - 'reply' => $review->response, // what is the 300 character limit for? |
|
39 | - 'review_id' => '', // @todo |
|
40 | - 'review_transaction_id' => '', // @todo |
|
41 | - 'type' => 'M', |
|
42 | - ]; |
|
43 | - return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review); |
|
44 | - } |
|
32 | + /** |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + protected function getBodyForResponse(Review $review) |
|
36 | + { |
|
37 | + $rebusifyResponse = [ |
|
38 | + 'reply' => $review->response, // what is the 300 character limit for? |
|
39 | + 'review_id' => '', // @todo |
|
40 | + 'review_transaction_id' => '', // @todo |
|
41 | + 'type' => 'M', |
|
42 | + ]; |
|
43 | + return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @return array |
|
48 | - */ |
|
49 | - protected function getBodyForReview(Review $review) |
|
50 | - { |
|
51 | - $rebusifyReview = [ |
|
52 | - 'domain' => get_site_url(), |
|
53 | - 'firstname' => $review->name, // what is the 25 character limit for? |
|
54 | - 'rate' => $review->rating, |
|
55 | - 'review_transaction_id' => '', // @todo |
|
56 | - 'reviews' => $review->content, // what is the 280 character limit for? |
|
57 | - 'title' => $review->title, // what is the 35 character limit for? |
|
58 | - 'transaction' => '', // @todo |
|
59 | - ]; |
|
60 | - return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review); |
|
61 | - } |
|
46 | + /** |
|
47 | + * @return array |
|
48 | + */ |
|
49 | + protected function getBodyForReview(Review $review) |
|
50 | + { |
|
51 | + $rebusifyReview = [ |
|
52 | + 'domain' => get_site_url(), |
|
53 | + 'firstname' => $review->name, // what is the 25 character limit for? |
|
54 | + 'rate' => $review->rating, |
|
55 | + 'review_transaction_id' => '', // @todo |
|
56 | + 'reviews' => $review->content, // what is the 280 character limit for? |
|
57 | + 'title' => $review->title, // what is the 35 character limit for? |
|
58 | + 'transaction' => '', // @todo |
|
59 | + ]; |
|
60 | + return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return void|array |
|
65 | - */ |
|
66 | - protected function send($endpoint, $args) |
|
67 | - { |
|
68 | - $args = wp_parse_args($args, [ |
|
69 | - 'blocking' => false, |
|
70 | - 'body' => [], |
|
71 | - 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
|
72 | - 'redirection' => 5, |
|
73 | - 'sslverify' => false, |
|
74 | - 'timeout' => 5, |
|
75 | - ]); |
|
76 | - $response = wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args); |
|
77 | - if (is_wp_error($response)) { |
|
78 | - glsr_log()->error('REBUSIFY: '.$response->get_error_message()); |
|
79 | - return; |
|
80 | - } |
|
81 | - if (200 === wp_remote_retrieve_response_code($response)) { |
|
82 | - $responsedata = wp_remote_retrieve_body($response); |
|
83 | - return json_decode($responsedata, true); |
|
84 | - } |
|
85 | - } |
|
63 | + /** |
|
64 | + * @return void|array |
|
65 | + */ |
|
66 | + protected function send($endpoint, $args) |
|
67 | + { |
|
68 | + $args = wp_parse_args($args, [ |
|
69 | + 'blocking' => false, |
|
70 | + 'body' => [], |
|
71 | + 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
|
72 | + 'redirection' => 5, |
|
73 | + 'sslverify' => false, |
|
74 | + 'timeout' => 5, |
|
75 | + ]); |
|
76 | + $response = wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args); |
|
77 | + if (is_wp_error($response)) { |
|
78 | + glsr_log()->error('REBUSIFY: '.$response->get_error_message()); |
|
79 | + return; |
|
80 | + } |
|
81 | + if (200 === wp_remote_retrieve_response_code($response)) { |
|
82 | + $responsedata = wp_remote_retrieve_body($response); |
|
83 | + return json_decode($responsedata, true); |
|
84 | + } |
|
85 | + } |
|
86 | 86 | } |
@@ -11,28 +11,28 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * @return void|array |
13 | 13 | */ |
14 | - public function sendReview(Review $review) |
|
14 | + public function sendReview( Review $review ) |
|
15 | 15 | { |
16 | - return $this->send('index.php', [ |
|
17 | - 'body' => $this->getBodyForReview($review), |
|
16 | + return $this->send( 'index.php', [ |
|
17 | + 'body' => $this->getBodyForReview( $review ), |
|
18 | 18 | 'timeout' => 120, |
19 | - ]); |
|
19 | + ] ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @return void|array |
24 | 24 | */ |
25 | - public function sendReviewResponse(Review $review) |
|
25 | + public function sendReviewResponse( Review $review ) |
|
26 | 26 | { |
27 | - return $this->send('fetch_customer_reply.php', [ |
|
28 | - 'body' => $this->getBodyForResponse($review), |
|
29 | - ]); |
|
27 | + return $this->send( 'fetch_customer_reply.php', [ |
|
28 | + 'body' => $this->getBodyForResponse( $review ), |
|
29 | + ] ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @return array |
34 | 34 | */ |
35 | - protected function getBodyForResponse(Review $review) |
|
35 | + protected function getBodyForResponse( Review $review ) |
|
36 | 36 | { |
37 | 37 | $rebusifyResponse = [ |
38 | 38 | 'reply' => $review->response, // what is the 300 character limit for? |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | 'review_transaction_id' => '', // @todo |
41 | 41 | 'type' => 'M', |
42 | 42 | ]; |
43 | - return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review); |
|
43 | + return apply_filters( 'site-reviews/rebusify/response', $rebusifyResponse, $review ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @return array |
48 | 48 | */ |
49 | - protected function getBodyForReview(Review $review) |
|
49 | + protected function getBodyForReview( Review $review ) |
|
50 | 50 | { |
51 | 51 | $rebusifyReview = [ |
52 | 52 | 'domain' => get_site_url(), |
@@ -57,30 +57,30 @@ discard block |
||
57 | 57 | 'title' => $review->title, // what is the 35 character limit for? |
58 | 58 | 'transaction' => '', // @todo |
59 | 59 | ]; |
60 | - return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review); |
|
60 | + return apply_filters( 'site-reviews/rebusify/review', $rebusifyReview, $review ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @return void|array |
65 | 65 | */ |
66 | - protected function send($endpoint, $args) |
|
66 | + protected function send( $endpoint, $args ) |
|
67 | 67 | { |
68 | - $args = wp_parse_args($args, [ |
|
68 | + $args = wp_parse_args( $args, [ |
|
69 | 69 | 'blocking' => false, |
70 | 70 | 'body' => [], |
71 | 71 | 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
72 | 72 | 'redirection' => 5, |
73 | 73 | 'sslverify' => false, |
74 | 74 | 'timeout' => 5, |
75 | - ]); |
|
76 | - $response = wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args); |
|
77 | - if (is_wp_error($response)) { |
|
78 | - glsr_log()->error('REBUSIFY: '.$response->get_error_message()); |
|
75 | + ] ); |
|
76 | + $response = wp_remote_post( trailingslashit( static::API_URL ).$endpoint, $args ); |
|
77 | + if( is_wp_error( $response ) ) { |
|
78 | + glsr_log()->error( 'REBUSIFY: '.$response->get_error_message() ); |
|
79 | 79 | return; |
80 | 80 | } |
81 | - if (200 === wp_remote_retrieve_response_code($response)) { |
|
82 | - $responsedata = wp_remote_retrieve_body($response); |
|
83 | - return json_decode($responsedata, true); |
|
81 | + if( 200 === wp_remote_retrieve_response_code( $response ) ) { |
|
82 | + $responsedata = wp_remote_retrieve_body( $response ); |
|
83 | + return json_decode( $responsedata, true ); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |