PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.4.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.4.1
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
← All changes | includes/Campaign/Elements/ProElementSchemas.php +13 -447 2.4.0 → 2.4.1 View file →
@@ -1,45 +1,33 @@
1 1 <?php
2 2
3 3 namespace Better_Payment\Lite\Campaign\Elements;
4 4
5 -use Better_Payment\Lite\Classes\ProCompatibility;
6 -
7 5 if ( ! defined( 'ABSPATH' ) ) {
8 6 exit;
9 7 }
10 8
11 9 /**
12 - * Transitional copy for Better Payment Pro <= 1.4.3; delete when
13 - * ProCompatibility::MIN_PRO_VERSION >= 1.4.4.
14 - * Pro copy: better-payment-pro/includes/Campaign/ProElementSchemas.php.
15 - * Slug: campaign_pro_element_schemas.
10 + * Fatal guard for Better Payment Pro 1.4.3 and older. Holds no schema.
16 11 *
17 - * Control schemas and default settings for the three Pro-only campaign elements
18 - * — Donors Wall, FAQ and Video. Pro 1.4.3 and earlier register renderers only and
19 - * rely on Lite for these, so Lite still serves them to an active Pro that does not
20 - * declare {@see self::FEATURE}, through {@see self::apply_lite_copy()}. A free
21 - * install never receives them: it gets {@see ProElementStubs}, and a current Pro
22 - * registers its own copy.
12 + * The Donors Wall, FAQ and Video schemas and default settings ship with Pro
13 + * (better-payment-pro/includes/Campaign/ProElementSchemas.php); a free install gets
14 + * {@see ProElementStubs}. Lite's transitional copy of the schemas was deleted when
15 + * ProCompatibility::MIN_PRO_VERSION reached 1.4.4.
23 16 *
24 - * Deleting this file at step 3 also means deleting the `add_filter()` line in
25 - * {@see CampaignElements::register_pro_elements()} and the three contract symbols
26 - * below from tests/Unit/ProCouplingContractTest.php (Pro 1.4.4 no longer calls them).
17 + * What stays is only what Pro 1.4.3 reads directly: its `BuilderElements` aliases
18 + * these constants at class-constant time and calls {@see self::default_video_url()},
19 + * so removing them would fatal every campaign render on a site that updated Lite
20 + * before Pro. Pro 1.4.4+ reads its own class. Pinned by
21 + * tests/Unit/ProCouplingContractTest.php; delete this file once no supported site
22 + * can run Pro 1.4.3.
27 23 *
28 - * The public constants and {@see self::default_video_url()} are part of the Pro
29 - * coupling contract: Pro 1.4.3's `BuilderElements` aliases them.
24 + * @deprecated Kept only so Better Payment Pro <= 1.4.3 does not fatal.
30 25 */
31 26 class ProElementSchemas {
32 27
33 28 /**
34 - * Feature slug Pro declares on `better_payment/pro_provides` once it ships
35 - * these schemas itself.
36 - */
37 - const FEATURE = 'campaign_pro_element_schemas';
38 -
39 - /**
40 - * The video a newly added Video element starts with, so a freshly dropped
41 - * element isn't a blank box.
29 + * The video a newly added Video element starts with.
42 30 *
43 31 * Pro 1.4.3's `BuilderElements::DEFAULT_VIDEO_URL` aliases this constant.
44 32 */
45 33 const DEFAULT_VIDEO_URL = 'https://www.youtube.com/watch?v=jeXG-4SOlZE';
@@ -55,428 +43,6 @@
55 43 * @return string
56 44 */
57 45 public static function default_video_url(): string {
58 46 return (string) apply_filters( 'better_payment/campaign/default_video_url', self::DEFAULT_VIDEO_URL );
59 - }
60 -
61 - /**
62 - * Callback for `better_payment/campaign_elements` (priority 5): replace the lock
63 - * stubs with the full definitions, for an older active Pro only.
64 - *
65 - * @param mixed $elements Registered elements, keyed by type.
66 - * @return mixed
67 - */
68 - public static function apply_lite_copy( $elements ) {
69 - if ( ! is_array( $elements ) || ! ProCompatibility::lite_copy_applies( self::FEATURE ) ) {
70 - return $elements;
71 - }
72 -
73 - foreach ( self::get_all() as $type => $schema ) {
74 - $elements[ $type ] = array_merge( $schema, [ 'type' => $type, 'pro' => true ] );
75 - }
76 -
77 - return $elements;
78 - }
79 -
80 - /**
81 - * All three schemas, keyed by element type.
82 - *
83 - * @return array<string, array>
84 - */
85 - public static function get_all(): array {
86 - return [
87 - 'donors_wall' => self::donors_wall(),
88 - 'faq' => self::faq(),
89 - 'video' => self::video(),
90 - ];
91 - }
92 -
93 - /**
94 - * @return array
95 - */
96 - public static function donors_wall(): array {
97 - return [
98 - 'label' => __( 'Donors Wall', 'better-payment' ),
99 - 'icon' => 'groups',
100 - 'defaultSettings' => [
101 - 'headline' => __( 'Recent Donors', 'better-payment' ),
102 - 'layout' => 'list',
103 - 'columns' => 2,
104 - 'number_to_show' => 10,
105 - 'order_by' => 'date',
106 - 'order' => 'desc',
107 - 'hide_if_empty' => false,
108 - 'show_summary' => true,
109 - 'show_name' => true,
110 - 'show_amount' => true,
111 - 'show_avatar' => true,
112 - 'show_date' => true,
113 - 'accent_color' => '',
114 - 'width' => 100,
115 - 'align' => 'left',
116 - ],
117 - 'settingsSchema' => [
118 - [
119 - 'key' => 'headline',
120 - 'label' => __( 'Headline', 'better-payment' ),
121 - 'type' => 'text',
122 - 'placeholder' => __( 'Recent Donors', 'better-payment' ),
123 - ],
124 - [
125 - 'key' => 'layout',
126 - 'label' => __( 'Layout', 'better-payment' ),
127 - 'type' => 'select',
128 - 'options' => [
129 - [ 'value' => 'list', 'label' => __( 'List (vertical)', 'better-payment' ) ],
130 - [ 'value' => 'grid', 'label' => __( 'Grid', 'better-payment' ) ],
131 - [ 'value' => 'ticker', 'label' => __( 'Ticker (auto-scroll)', 'better-payment' ) ],
132 - ],
133 - ],
134 - // A select, not a range: three discrete values are chosen, not
135 - // dialled. It was a slider whose value read "4%" — the builder's
136 - // range control used to assume every range was a percentage.
137 - // Shown only for the grid, where columns mean anything at all.
138 - [
139 - 'key' => 'columns',
140 - 'label' => __( 'Grid Columns', 'better-payment' ),
141 - 'type' => 'select',
142 - 'defaultValue' => 2,
143 - 'condition' => [ 'layout' => 'grid' ],
144 - 'options' => [
145 - [ 'value' => 2, 'label' => __( '2 columns', 'better-payment' ) ],
146 - [ 'value' => 3, 'label' => __( '3 columns', 'better-payment' ) ],
147 - [ 'value' => 4, 'label' => __( '4 columns', 'better-payment' ) ],
148 - ],
149 - ],
150 - [
151 - 'key' => 'number_to_show',
152 - 'label' => __( 'Number of Donors To Show', 'better-payment' ),
153 - 'type' => 'number',
154 - 'min' => 0,
155 - 'max' => 100,
156 - 'defaultValue' => 10,
157 - 'info' => __( 'Set to 0 to hide the donor list.', 'better-payment' ),
158 - ],
159 - [
160 - 'key' => 'order_by',
161 - 'label' => __( 'Order By', 'better-payment' ),
162 - 'type' => 'select',
163 - 'options' => [
164 - [ 'value' => 'date', 'label' => __( 'Date', 'better-payment' ) ],
165 - [ 'value' => 'amount', 'label' => __( 'Amount', 'better-payment' ) ],
166 - ],
167 - ],
168 - // Two variants of the same `order` control, gated on `order_by`,
169 - // so the direction labels read naturally for what's being sorted.
170 - // Both write the same `order` key with the same `desc`/`asc`
171 - // values — the renderer is unchanged and the chosen value survives
172 - // switching Order By. Only one is ever visible (isControlVisible).
173 - [
174 - 'key' => 'order',
175 - 'label' => __( 'Order', 'better-payment' ),
176 - 'type' => 'select',
177 - 'condition' => [ 'order_by' => 'amount' ],
178 - 'options' => [
179 - [ 'value' => 'desc', 'label' => __( 'High to Low', 'better-payment' ) ],
180 - [ 'value' => 'asc', 'label' => __( 'Low to High', 'better-payment' ) ],
181 - ],
182 - ],
183 - [
184 - 'key' => 'order',
185 - 'label' => __( 'Order', 'better-payment' ),
186 - 'type' => 'select',
187 - 'condition' => [ 'order_by' => 'date' ],
188 - 'options' => [
189 - [ 'value' => 'desc', 'label' => __( 'Newest First', 'better-payment' ) ],
190 - [ 'value' => 'asc', 'label' => __( 'Oldest First', 'better-payment' ) ],
191 - ],
192 - ],
193 - [
194 - 'key' => 'hide_if_empty',
195 - 'label' => __( 'Hide If No Donors', 'better-payment' ),
196 - 'type' => 'switch',
197 - ],
198 - [
199 - 'key' => '_donor_info_label',
200 - 'label' => __( 'Donor Information', 'better-payment' ),
201 - 'type' => 'section_label',
202 - ],
203 - [
204 - 'key' => 'show_summary',
205 - 'label' => __( 'Show Totals Summary', 'better-payment' ),
206 - 'type' => 'switch',
207 - ],
208 - [
209 - 'key' => 'show_name',
210 - 'label' => __( 'Show Name', 'better-payment' ),
211 - 'type' => 'switch',
212 - ],
213 - [
214 - 'key' => 'show_amount',
215 - 'label' => __( 'Show Amount', 'better-payment' ),
216 - 'type' => 'switch',
217 - ],
218 - [
219 - 'key' => 'show_avatar',
220 - 'label' => __( 'Show Avatar', 'better-payment' ),
221 - 'type' => 'switch',
222 - ],
223 - [
224 - 'key' => 'show_date',
225 - 'label' => __( 'Show Time', 'better-payment' ),
226 - 'type' => 'switch',
227 - ],
228 - [
229 - 'key' => '_style_label',
230 - 'label' => __( 'Style', 'better-payment' ),
231 - 'type' => 'section_label',
232 - ],
233 - [
234 - 'key' => 'accent_color',
235 - 'label' => __( 'Accent Color', 'better-payment' ),
236 - 'type' => 'color',
237 - 'info' => __( 'Leave empty to inherit the campaign color.', 'better-payment' ),
238 - ],
239 - [
240 - 'key' => 'width',
241 - 'label' => __( 'Width', 'better-payment' ),
242 - 'type' => 'range',
243 - 'min' => 10,
244 - 'max' => 100,
245 - 'step' => 1,
246 - 'unit' => '%',
247 - 'defaultValue' => 100,
248 - ],
249 - [
250 - 'key' => 'align',
251 - 'label' => __( 'Align', 'better-payment' ),
252 - 'type' => 'align',
253 - ],
254 - ],
255 - ];
256 - }
257 -
258 - /**
259 - * @return array
260 - */
261 - public static function faq(): array {
262 - return [
263 - 'label' => __( 'FAQ', 'better-payment' ),
264 - 'icon' => 'editor-help',
265 - 'defaultSettings' => [
266 - 'heading' => __( 'Frequently Asked Questions', 'better-payment' ),
267 - 'items' => [
268 - [
269 - 'question' => __( 'How will my donation help?', 'better-payment' ),
270 - 'answer' => __( 'Your donation will directly support the goals of this campaign and help make a meaningful difference for the people or cause it aims to support.', 'better-payment' ),
271 - ],
272 - [
273 - 'question' => __( 'Is my donation secure?', 'better-payment' ),
274 - 'answer' => __( 'Yes. Donations are processed through a secure payment system to help keep your payment information safe.', 'better-payment' ),
275 - ],
276 - [
277 - 'question' => __( 'Can I donate any amount?', 'better-payment' ),
278 - 'answer' => __( 'Yes. Every contribution matters, regardless of the amount. You can donate an amount that feels comfortable for you.', 'better-payment' ),
279 - ],
280 - [
281 - 'question' => __( 'Can I share this campaign with others?', 'better-payment' ),
282 - 'answer' => __( 'Absolutely! Sharing the campaign with your friends, family, and social network is a great way to help spread awareness and support the cause.', 'better-payment' ),
283 - ],
284 - ],
285 - 'style' => 'accordion',
286 - 'icon_style' => 'chevron',
287 - 'single_open' => true,
288 - 'first_open' => true,
289 - 'accent_color' => '',
290 - 'width' => 100,
291 - 'align' => 'left',
292 - ],
293 - 'settingsSchema' => [
294 - [
295 - 'key' => 'heading',
296 - 'label' => __( 'Heading', 'better-payment' ),
297 - 'type' => 'text',
298 - 'placeholder' => __( 'Frequently Asked Questions', 'better-payment' ),
299 - ],
300 - [
301 - 'key' => 'items',
302 - 'label' => __( 'FAQ Items', 'better-payment' ),
303 - 'type' => 'repeater',
304 - 'itemLabel' => __( 'Question', 'better-payment' ),
305 - 'titleField' => 'question',
306 - 'addLabel' => __( 'Add Question', 'better-payment' ),
307 - 'max' => 30,
308 - 'fields' => [
309 - [
310 - 'key' => 'question',
311 - 'label' => __( 'Question', 'better-payment' ),
312 - 'type' => 'text',
313 - 'placeholder' => __( 'Enter a question', 'better-payment' ),
314 - ],
315 - [
316 - 'key' => 'answer',
317 - 'label' => __( 'Answer', 'better-payment' ),
318 - 'type' => 'textarea',
319 - 'rows' => 3,
320 - 'placeholder' => __( 'Enter the answer', 'better-payment' ),
321 - ],
322 - [
323 - 'key' => 'open',
324 - 'label' => __( 'Open by default?', 'better-payment' ),
325 - 'type' => 'switch',
326 - ],
327 - ],
328 - ],
329 - [
330 - 'key' => 'style',
331 - 'label' => __( 'Style', 'better-payment' ),
332 - 'type' => 'select',
333 - 'options' => [
334 - [ 'value' => 'accordion', 'label' => __( 'Accordion (collapsible)', 'better-payment' ) ],
335 - [ 'value' => 'list', 'label' => __( 'Open list', 'better-payment' ) ],
336 - ],
337 - ],
338 - [
339 - 'key' => 'icon_style',
340 - 'label' => __( 'Toggle Icon', 'better-payment' ),
341 - 'type' => 'select',
342 - // Accordion-only: the open-list style shows every answer, so
343 - // there is no collapse toggle to put an icon on.
344 - 'condition' => [ 'style' => 'accordion' ],
345 - 'options' => [
346 - [ 'value' => 'chevron', 'label' => __( 'Chevron', 'better-payment' ) ],
347 - [ 'value' => 'plus', 'label' => __( 'Plus / Minus', 'better-payment' ) ],
348 - [ 'value' => 'none', 'label' => __( 'No icon', 'better-payment' ) ],
349 - ],
350 - ],
351 - [
352 - 'key' => 'single_open',
353 - 'label' => __( 'Open One At A Time', 'better-payment' ),
354 - 'type' => 'switch',
355 - // Accordion-only: an open list has nothing to close.
356 - 'condition' => [ 'style' => 'accordion' ],
357 - 'info' => __( 'Opening a question closes the others (accordion only).', 'better-payment' ),
358 - ],
359 - [
360 - 'key' => 'first_open',
361 - 'label' => __( 'Open First Item By Default', 'better-payment' ),
362 - 'type' => 'switch',
363 - // Accordion-only: open-list items are all expanded already.
364 - 'condition' => [ 'style' => 'accordion' ],
365 - ],
366 - [
367 - 'key' => 'accent_color',
368 - 'label' => __( 'Accent Color', 'better-payment' ),
369 - 'type' => 'color',
370 - 'info' => __( 'Leave empty to inherit the campaign color.', 'better-payment' ),
371 - ],
372 - [
373 - 'key' => 'width',
374 - 'label' => __( 'Width', 'better-payment' ),
375 - 'type' => 'range',
376 - 'min' => 10,
377 - 'max' => 100,
378 - 'step' => 1,
379 - 'unit' => '%',
380 - 'defaultValue' => 100,
381 - ],
382 - [
383 - 'key' => 'align',
384 - 'label' => __( 'Align', 'better-payment' ),
385 - 'type' => 'align',
386 - ],
387 - ],
388 - ];
389 - }
390 -
391 - /**
392 - * @return array
393 - */
394 - public static function video(): array {
395 - return [
396 - 'label' => __( 'Video', 'better-payment' ),
397 - 'icon' => 'format-video',
398 - 'defaultSettings' => [
399 - 'url' => self::default_video_url(),
400 - 'aspect_ratio' => '16-9',
401 - 'autoplay' => false,
402 - 'muted' => false,
403 - 'loop' => false,
404 - 'controls' => true,
405 - 'start_time' => self::DEFAULT_VIDEO_START,
406 - 'width' => 100,
407 - 'align' => 'center',
408 - ],
409 - 'settingsSchema' => [
410 - [
411 - 'key' => 'url',
412 - 'label' => __( 'Video URL', 'better-payment' ),
413 - 'type' => 'url',
414 - // Renders a Media Library button beside the field (Lite's
415 - // `url` control), so an uploaded video can be chosen without
416 - // leaving the builder to copy its URL.
417 - 'mediaType' => 'video',
418 - 'placeholder' => 'https://www.youtube.com/watch?v=…',
419 - 'info' => __( 'Paste a YouTube or Vimeo link, or choose an uploaded video from your Media Library.', 'better-payment' ),
420 - ],
421 - [
422 - 'key' => 'aspect_ratio',
423 - 'label' => __( 'Aspect Ratio', 'better-payment' ),
424 - 'type' => 'select',
425 - 'options' => [
426 - [ 'value' => '16-9', 'label' => '16:9' ],
427 - [ 'value' => '4-3', 'label' => '4:3' ],
428 - [ 'value' => '1-1', 'label' => '1:1' ],
429 - [ 'value' => '21-9', 'label' => '21:9' ],
430 - ],
431 - ],
432 - [
433 - 'key' => '_playback_label',
434 - 'label' => __( 'Playback', 'better-payment' ),
435 - 'type' => 'section_label',
436 - ],
437 - [
438 - 'key' => 'autoplay',
439 - 'label' => __( 'Autoplay', 'better-payment' ),
440 - 'type' => 'switch',
441 - ],
442 - [
443 - 'key' => 'muted',
444 - 'label' => __( 'Muted', 'better-payment' ),
445 - 'type' => 'switch',
446 - ],
447 - [
448 - 'key' => 'loop',
449 - 'label' => __( 'Loop', 'better-payment' ),
450 - 'type' => 'switch',
451 - ],
452 - [
453 - 'key' => 'controls',
454 - 'label' => __( 'Show Controls', 'better-payment' ),
455 - 'type' => 'switch',
456 - ],
457 - [
458 - 'key' => 'start_time',
459 - 'label' => __( 'Start Time (seconds)', 'better-payment' ),
460 - 'type' => 'number',
461 - 'min' => 0,
462 - 'defaultValue' => 0,
463 - ],
464 - [
465 - 'key' => 'width',
466 - 'label' => __( 'Width', 'better-payment' ),
467 - 'type' => 'range',
468 - 'min' => 10,
469 - 'max' => 100,
470 - 'step' => 1,
471 - 'unit' => '%',
472 - 'defaultValue' => 100,
473 - ],
474 - [
475 - 'key' => 'align',
476 - 'label' => __( 'Align', 'better-payment' ),
477 - 'type' => 'align',
478 - ],
479 - ],
480 - ];
481 47 }
482 48 }