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/Admin/Elementor/Better_Payment_Widget.php +107 -744 2.3.1 → 2.4.1 View file →
@@ -113,395 +113,11 @@
113 113 'options' => $this->better_payment_free_layouts(),
114 114 ]
115 115 );
116 116
117 - $this->add_control(
118 - 'better_payment_form_payment_type',
119 - [
120 - 'label' => esc_html__( 'Payment Type', 'better-payment' ),
121 - 'description' => esc_html__( 'Recurring and Split Payment is available for Stripe only at the moment!', 'better-payment' ),
122 - 'type' => Controls_Manager::SELECT,
123 - 'default' => 'one-time',
124 - 'options' => [
125 - 'one-time' => 'One Time',
126 - 'recurring' => 'Recurring',
127 - 'mixed' => 'One Time + Recurring (Both)',
128 - 'split-payment' => 'Split Payment',
129 - ],
130 - 'condition' => [
131 - 'better_payment_form_layout!' => ['layout-1', 'layout-2', 'layout-3', 'layout-6-pro'],
132 - ],
133 - ]
134 - );
117 + do_action( 'better_payment/elementor/editor/pro_layout_payment_controls', $this );
135 118
136 119 $this->add_control(
137 - 'better_payment_form_recurring_price_id',
138 - [
139 - 'label' => esc_html__( 'Default Price ID', 'better-payment' ),
140 - 'type' => Controls_Manager::TEXT,
141 - 'description' => sprintf(
142 - __( '<p>Create a product from Stripe dashboard and <a href="%1$s" target="_blank">get the (default) price id.</a></p>', 'better-payment' ),
143 - esc_url('//betterpayment.co/docs/retrieve-price-id-for-recurring-payments/'),
144 - ),
145 - 'placeholder' => 'price_G0FvDp6vZvdwRZ',
146 - 'label_block' => true,
147 - 'ai' => [
148 - 'active' => false,
149 - ],
150 - 'condition' => [
151 - 'better_payment_form_payment_type' => [ 'recurring', 'split-payment' ],
152 - 'better_payment_form_layout!' => ['layout-1', 'layout-2', 'layout-3', 'layout-6-pro'],
153 - ],
154 - 'separator' => 'before',
155 - ]
156 - );
157 -
158 - $repeater_split_payment = new Repeater();
159 -
160 - $repeater_split_payment->add_control(
161 - 'better_payment_split_installment_name',
162 - [
163 - 'label' => esc_html__( 'Installment Name', 'better-payment' ),
164 - 'type' => Controls_Manager::TEXT,
165 - 'placeholder' => 'Installment Name',
166 - 'label_block' => true,
167 - 'ai' => [
168 - 'active' => false,
169 - ],
170 - ]
171 - );
172 -
173 - $repeater_split_payment->add_control(
174 - 'better_payment_split_installment_price_id',
175 - [
176 - 'label' => esc_html__( 'Price ID', 'better-payment' ),
177 - 'type' => Controls_Manager::TEXT,
178 - 'placeholder' => 'price_G0FvDp6vZvdwRZ',
179 - 'label_block' => true,
180 - 'ai' => [
181 - 'active' => false,
182 - ],
183 - ]
184 - );
185 -
186 - $repeater_split_payment->add_control(
187 - 'better_payment_split_installment_iteration',
188 - [
189 - 'label' => esc_html__( 'Iterations', 'better-payment' ),
190 - 'type' => Controls_Manager::NUMBER,
191 - 'min' => 1,
192 - 'max' => 36,
193 - ]
194 - );
195 -
196 - $this->add_control(
197 - 'better_payment_split_installment_price_ids_note',
198 - [
199 - 'type' => Controls_Manager::RAW_HTML,
200 - 'raw' => sprintf(
201 - __( '<p>Now add more prices to the product from Stripe dashboard and <a href="%1$s" target="_blank">get the price id for each installment.</a></p>', 'better-payment' ),
202 - esc_url('//betterpayment.co/docs/configure-split-payment-into-subscriptions/'),
203 - ),
204 - 'content_classes' => 'elementor-control-alert elementor-panel-alert elementor-panel-alert-info',
205 - 'ai' => [
206 - 'active' => false,
207 - ],
208 - 'condition' => [
209 - 'better_payment_form_payment_type' => 'split-payment',
210 - 'better_payment_form_layout!' => ['layout-1', 'layout-2', 'layout-3', 'layout-6-pro'],
211 - ],
212 - ]
213 - );
214 -
215 - $this->add_control(
216 - 'better_payment_split_installment_price_ids',
217 - [
218 - 'label' => esc_html__( 'Installments', 'better-payment' ),
219 - 'type' => Controls_Manager::REPEATER,
220 - 'separator' => 'after',
221 - 'default' => [
222 - [
223 - 'better_payment_split_installment_name' => '3 Months',
224 - 'better_payment_split_installment_price_id' => '',
225 - 'better_payment_split_installment_iteration' => 3,
226 - ],
227 - [
228 - 'better_payment_split_installment_name' => '6 Months',
229 - 'better_payment_split_installment_price_id' => '',
230 - 'better_payment_split_installment_iteration' => 6,
231 - ],
232 - [
233 - 'better_payment_split_installment_name' => '9 Months',
234 - 'better_payment_split_installment_price_id' => '',
235 - 'better_payment_split_installment_iteration' => 9,
236 - ],
237 - [
238 - 'better_payment_split_installment_name' => '12 Months',
239 - 'better_payment_split_installment_price_id' => '',
240 - 'better_payment_split_installment_iteration' => 12,
241 - ],
242 - ],
243 - 'fields' => $repeater_split_payment->get_controls(),
244 - 'title_field' => '<i class="{{ better_payment_split_installment_name }}" aria-hidden="true"></i> {{{ better_payment_split_installment_name }}}',
245 - 'condition' => [
246 - 'better_payment_form_payment_type' => 'split-payment',
247 - 'better_payment_form_layout!' => ['layout-1', 'layout-2', 'layout-3', 'layout-6-pro'],
248 - ],
249 - ]
250 - );
251 -
252 - $repeater_recurring_payment = new Repeater();
253 -
254 - $repeater_recurring_payment->add_control(
255 - 'better_payment_recurring_name',
256 - [
257 - 'label' => esc_html__( 'Interval Name', 'better-payment' ),
258 - 'type' => Controls_Manager::TEXT,
259 - 'placeholder' => 'Interval Name',
260 - 'label_block' => true,
261 - 'ai' => [
262 - 'active' => false,
263 - ],
264 - ]
265 - );
266 -
267 - $repeater_recurring_payment->add_control(
268 - 'better_payment_recurring_price_id',
269 - [
270 - 'label' => esc_html__( 'Price ID', 'better-payment' ),
271 - 'type' => Controls_Manager::TEXT,
272 - 'placeholder' => 'price_G0FvDp6vZvdwRZ',
273 - 'label_block' => true,
274 - 'ai' => [
275 - 'active' => false,
276 - ],
277 - ]
278 - );
279 -
280 - $this->add_control(
281 - 'better_payment_recurring_price_ids',
282 - [
283 - 'label' => esc_html__( 'Intervals', 'better-payment' ),
284 - 'type' => Controls_Manager::REPEATER,
285 - 'separator' => 'after',
286 - 'default' => [
287 - [
288 - 'better_payment_recurring_name' => 'Monthly',
289 - 'better_payment_recurring_price_id' => '',
290 - ],
291 - [
292 - 'better_payment_recurring_name' => 'Yearly',
293 - 'better_payment_recurring_price_id' => '',
294 - ],
295 - ],
296 - 'fields' => $repeater_recurring_payment->get_controls(),
297 - 'title_field' => '<i class="{{ better_payment_recurring_name }}" aria-hidden="true"></i> {{{ better_payment_recurring_name }}}',
298 - 'condition' => [
299 - 'better_payment_form_payment_type' => 'recurring',
300 - 'better_payment_form_layout' => 'layout-5-pro',
301 - ],
302 - ]
303 - );
304 -
305 - $this->add_control(
306 - 'better_payment_one_time_recurring_product_id',
307 - [
308 - 'label' => esc_html__( 'Product ID', 'better-payment' ),
309 - 'type' => Controls_Manager::TEXT,
310 - 'placeholder' => 'prod_G0FvDp6vZvdwRZ',
311 - 'label_block' => true,
312 - 'ai' => [
313 - 'active' => false,
314 - ],
315 - 'condition' => [
316 - 'better_payment_form_payment_type' => 'mixed',
317 - 'better_payment_form_layout' => ['layout-4-pro', 'layout-5-pro'],
318 - ]
319 - ]
320 - );
321 -
322 - $repeater_mixed_payment = new Repeater();
323 -
324 - $repeater_mixed_payment->add_control(
325 - 'better_payment_mixed_interval_type',
326 - [
327 - 'label' => esc_html__( 'Interval Type', 'better-payment' ),
328 - 'type' => Controls_Manager::SELECT,
329 - 'default' => 'day',
330 - 'options' => [
331 - 'day' => 'Day',
332 - 'week' => 'Week',
333 - 'month' => 'Month',
334 - 'year' => 'Year',
335 - ],
336 - ]
337 - );
338 -
339 - $repeater_mixed_payment->add_control(
340 - 'better_payment_mixed_name',
341 - [
342 - 'label' => esc_html__( 'Interval Name', 'better-payment' ),
343 - 'type' => Controls_Manager::TEXT,
344 - 'placeholder' => 'Interval Name',
345 - 'label_block' => true,
346 - 'ai' => [
347 - 'active' => false,
348 - ],
349 - ]
350 - );
351 -
352 - $repeater_mixed_payment->add_control(
353 - 'better_payment_mixed_interval_day',
354 - [
355 - 'label' => esc_html__( 'Interval', 'better-payment' ),
356 - 'type' => Controls_Manager::NUMBER,
357 - 'min' => 1,
358 - 'max' => 1095,
359 - 'condition' => [
360 - 'better_payment_mixed_interval_type' => ['day'],
361 - ],
362 - ]
363 - );
364 -
365 - $repeater_mixed_payment->add_control(
366 - 'better_payment_mixed_interval_month',
367 - [
368 - 'label' => esc_html__( 'Interval', 'better-payment' ),
369 - 'type' => Controls_Manager::NUMBER,
370 - 'min' => 1,
371 - 'max' => 36,
372 - 'condition' => [
373 - 'better_payment_mixed_interval_type' => ['month'],
374 - ],
375 - ]
376 - );
377 -
378 - $repeater_mixed_payment->add_control(
379 - 'better_payment_mixed_interval_week',
380 - [
381 - 'label' => esc_html__( 'Interval', 'better-payment' ),
382 - 'type' => Controls_Manager::NUMBER,
383 - 'min' => 1,
384 - 'max' => 156,
385 - 'condition' => [
386 - 'better_payment_mixed_interval_type' => ['week'],
387 - ],
388 - ]
389 - );
390 -
391 - $repeater_mixed_payment->add_control(
392 - 'better_payment_mixed_interval_year',
393 - [
394 - 'label' => esc_html__( 'Interval', 'better-payment' ),
395 - 'type' => Controls_Manager::NUMBER,
396 - 'min' => 1,
397 - 'max' => 3,
398 - 'condition' => [
399 - 'better_payment_mixed_interval_type' => ['year'],
400 - ],
401 - ]
402 - );
403 -
404 - $repeater_mixed_payment->add_control(
405 - 'better_payment_mixed_installment_options_note1',
406 - [
407 - 'type' => Controls_Manager::RAW_HTML,
408 - 'raw' => sprintf(
409 - __( '<p>Maximum interval: 3 years or equivalent.</p>', 'better-payment' ),
410 - ),
411 - 'content_classes' => 'elementor-control-alert elementor-panel-alert elementor-panel-alert-info',
412 - ]
413 - );
414 -
415 - $this->add_control(
416 - 'better_payment_mixed_installment_options',
417 - [
418 - 'label' => esc_html__( 'Mixed Intervals', 'better-payment' ),
419 - 'type' => Controls_Manager::REPEATER,
420 - 'separator' => 'after',
421 - 'default' => [
422 - [
423 - 'better_payment_mixed_name' => 'Monthly',
424 - 'better_payment_mixed_interval_month' => 1,
425 - 'better_payment_mixed_interval_type' => 'month',
426 - ],
427 - [
428 - 'better_payment_mixed_name' => 'Daily',
429 - 'better_payment_mixed_interval_day' => 1,
430 - 'better_payment_mixed_interval_type' => 'day',
431 - ],
432 - [
433 - 'better_payment_mixed_name' => 'Weekly',
434 - 'better_payment_mixed_interval_week' => 1,
435 - 'better_payment_mixed_interval_type' => 'week',
436 - ],
437 - [
438 - 'better_payment_mixed_name' => 'Yearly',
439 - 'better_payment_mixed_interval_year' => 1,
440 - 'better_payment_mixed_interval_type' => 'year',
441 - ],
442 - [
443 - 'better_payment_mixed_name' => 'Every 3 Months',
444 - 'better_payment_mixed_interval_month' => 3,
445 - 'better_payment_mixed_interval_type' => 'month',
446 - ],
447 - [
448 - 'better_payment_mixed_name' => 'Every 6 Months',
449 - 'better_payment_mixed_interval_month' => 6,
450 - 'better_payment_mixed_interval_type' => 'month',
451 - ],
452 - ],
453 - 'fields' => $repeater_mixed_payment->get_controls(),
454 - 'title_field' => '<i class="{{ better_payment_mixed_name }}" aria-hidden="true"></i> {{{ better_payment_mixed_name }}}',
455 - 'condition' => [
456 - 'better_payment_form_payment_type' => 'mixed',
457 - 'better_payment_form_layout' => ['layout-4-pro', 'layout-5-pro'],
458 - ],
459 - ]
460 - );
461 -
462 - $this->add_control(
463 - 'better_payment_form_recurring_webhook_stripe_secret',
464 - [
465 - 'label' => esc_html__( 'Webhook Secret', 'better-payment' ),
466 - 'type' => Controls_Manager::TEXT,
467 - 'description' => sprintf(
468 - __( '<p>Create a webhook endpoint from Stripe dashboard and <a href="%1$s" target="_blank">get the webhook secret.</a></p>', 'better-payment' ),
469 - esc_url('//betterpayment.co/docs/add-webhook-endpoint-recurring-better-payment/'),
470 - ),
471 - 'placeholder' => 'whsec_...',
472 - 'label_block' => true,
473 - 'ai' => [
474 - 'active' => false,
475 - ],
476 - 'condition' => [
477 - 'better_payment_form_payment_type' => [ 'recurring', 'split-payment' ],
478 - 'better_payment_form_layout!' => ['layout-1', 'layout-2', 'layout-3', 'layout-6-pro'],
479 - ],
480 - ]
481 - );
482 -
483 - $this->add_control(
484 - 'better_payment_form_recurring_webhook_stripe',
485 - [
486 - 'type' => Controls_Manager::RAW_HTML,
487 - 'raw' => sprintf(
488 - __( '<p><a href="%1$s" target="_blank">Your webhook endpoint url »</a><br>%2$s</p>', 'better-payment' ),
489 - esc_url('//wpdeveloper.com/docs-category/better-payment/'),
490 - esc_url_raw( get_permalink( get_the_ID() ) . '?webhook-stripe=1' )
491 - ),
492 - 'content_classes' => 'elementor-control-alert elementor-panel-alert elementor-panel-alert-info',
493 - 'ai' => [
494 - 'active' => false,
495 - ],
496 - 'condition' => [
497 - 'better_payment_form_payment_type' => [ 'recurring', 'split-payment' ],
498 - 'better_payment_form_layout!' => ['layout-1', 'layout-2', 'layout-3', 'layout-6-pro'],
499 - ],
500 - ]
501 - );
502 -
503 - $this->add_control(
504 120 'better_payment_form_payment_source',
505 121 [
506 122 'label' => esc_html__( 'Payment Source', 'better-payment' ),
507 123 'type' => Controls_Manager::SELECT,
@@ -520,11 +136,11 @@
520 136
521 137 $this->add_control( 'better_payment_form_payment_source_stripe_price_id', [
522 138 'label' => __( 'Default Price ID', 'better-payment' ),
523 139 'description' => sprintf(
524 - __( '<p>Create a product from Stripe dashboard and <a href="%1$s" target="_blank">get the (default) price id.</a></p> <p>For coupons, make sure they are <a href="%2$s" target="_blank">global or product independent.</a></p>', 'better-payment' ),
525 - esc_url('//betterpayment.co/docs/retrieve-price-id-for-recurring-payments/'),
526 - esc_url('//docs.stripe.com/api/coupons/')
140 + __( '<p>Create a product from Stripe dashboard and <a href="%1$s" target="_blank">get the (default) price id.</a></p> <p>For coupons, create a <a href="%2$s" target="_blank">promotion code</a> and share its code, or tag a coupon with the metadata <code>better_payment_public</code> = <code>yes</code> to accept its ID. Make sure they are global or product independent.</p>', 'better-payment' ),
141 + esc_url('//betterpayment.co/docs/retrieve-price-id-for-recurring-payments/'),
142 + esc_url('//docs.stripe.com/payments/checkout/discounts')
527 143 ),
528 144 'type' => Controls_Manager::TEXT,
529 145 'placeholder' => 'price_G0FvDp6vZvdwRZ',
530 146 'label_block' => true,
@@ -540,8 +156,9 @@
540 156 $this->add_control( 'better_payment_form_payment_source_notice', [
541 157 'type' => Controls_Manager::RAW_HTML,
542 158 'raw' => sprintf( __( '<a href="%1$s" target="_blank"><strong>WooCommerce</strong></a> is not installed/activated on your site. Please install and activate <a href="%1$s" target="_blank"><strong>WooCommerce</strong></a> first.', 'better-payment' ), esc_url('plugin-install.php?s=woocommerce&tab=search&type=term') ),
543 159 'content_classes' => 'better-payment-warning',
160 + // Layout 6 (Pro) has its own notice, registered with its product controls.
544 161 'conditions' => [
545 162 'relation' => 'and',
546 163 'terms' => [
547 164 [
@@ -554,38 +171,16 @@
554 171 'operator' => '!=',
555 172 'value' => 'layout-5-pro',
556 173 ],
557 174 [
558 - 'relation' => 'or',
559 - 'terms' => [
560 - [
561 - 'name' => 'better_payment_form_payment_source',
562 - 'value' => 'woocommerce' . ( ! class_exists('woocommerce') ? '' : 'exist' ),
563 - ],
564 - [
565 - 'relation' => 'and',
566 - 'terms' => [
567 - [
568 - 'name' => 'better_payment_form_layout',
569 - 'value' => 'layout-6-pro' . ( ! class_exists('woocommerce') ? '' : 'exist' ),
570 - ],
571 - [
572 - 'relation' => 'or',
573 - 'terms' => [
574 - [
575 - 'name' => 'better_payment_form_layout_6_ecommerce_platform',
576 - 'value' => '',
577 - ],
578 - [
579 - 'name' => 'better_payment_form_layout_6_ecommerce_platform',
580 - 'value' => 'woocommerce',
581 - ],
582 - ],
583 - ],
584 - ],
585 - ],
586 - ],
175 + 'name' => 'better_payment_form_layout',
176 + 'operator' => '!=',
177 + 'value' => 'layout-6-pro',
587 178 ],
179 + [
180 + 'name' => 'better_payment_form_payment_source',
181 + 'value' => 'woocommerce' . ( ! class_exists('woocommerce') ? '' : 'exist' ),
182 + ],
588 183 ],
589 184 ],
590 185 ] );
591 186
@@ -618,101 +213,37 @@
618 213 'better_payment_form_layout' => ['layout-1', 'layout-2', 'layout-3'],
619 214 ],
620 215 ] );
621 216
622 - $this->add_control(
623 - 'better_payment_form_layout_6_ecommerce_platform',
624 - [
625 - 'label' => esc_html__( 'eCommerce Platform', 'better-payment' ),
626 - 'type' => Controls_Manager::SELECT,
627 - 'default' => 'woocommerce',
628 - 'options' => [
629 - 'woocommerce' => 'WooCommerce',
630 - 'fluentcart' => 'FluentCart',
631 - ],
632 - 'condition' => [
633 - 'better_payment_form_layout' => ['layout-6-pro'],
634 - ],
635 - ]
636 - );
217 + do_action( 'better_payment/elementor/editor/pro_layout_product_controls', $this );
637 218
638 - $this->add_control('better_payment_form_woocommerce_product_ids', [
639 - 'label' => esc_html__('Select Products', 'better-payment'),
640 - 'type' => 'better-payment-select2',
641 - 'label_block' => true,
642 - 'multiple' => true,
643 - 'source_name' => 'post_type',
644 - 'source_type' => 'product',
645 - 'placeholder' => __( ' ', 'better-payment' ),
646 - 'condition' => [
647 - 'better_payment_form_layout' => ['layout-6-pro'],
648 - 'better_payment_form_layout_6_ecommerce_platform' => 'woocommerce',
649 - ],
650 - ]);
651 -
652 - $this->add_control('better_payment_form_fluentcart_product_ids', [
653 - 'label' => esc_html__('Select Products', 'better-payment'),
654 - 'type' => 'better-payment-select2',
655 - 'label_block' => true,
656 - 'multiple' => true,
657 - 'source_name' => 'post_type',
658 - 'source_type' => 'fluent-products',
659 - 'placeholder' => __( ' ', 'better-payment' ),
660 - 'condition' => [
661 - 'better_payment_form_layout' => ['layout-6-pro'],
662 - 'better_payment_form_layout_6_ecommerce_platform' => 'fluentcart',
663 - ],
664 - ]);
665 -
666 219 $this->add_control( 'better_payment_form_payment_source_fluentcart_notice', [
667 220 'type' => Controls_Manager::RAW_HTML,
668 221 'raw' => sprintf( __( '<a href="%1$s" target="_blank"><strong>FluentCart</strong></a> is not installed/activated on your site. Please install and activate <a href="%1$s" target="_blank"><strong>FluentCart</strong></a> first.', 'better-payment' ), esc_url('plugin-install.php?s=fluentcart&tab=search&type=term') ),
669 222 'content_classes' => 'better-payment-warning',
223 + // Layout 6 (Pro) has its own notice, registered with its product controls.
670 224 'conditions' => [
671 225 'relation' => 'and',
672 226 'terms' => [
673 227 [
674 - 'relation' => 'or',
675 - 'terms' => [
676 - [
677 - 'relation' => 'and',
678 - 'terms' => [
679 - [
680 - 'name' => 'better_payment_form_layout',
681 - 'operator' => '!=',
682 - 'value' => 'layout-4-pro',
683 - ],
684 - [
685 - 'name' => 'better_payment_form_layout',
686 - 'operator' => '!=',
687 - 'value' => 'layout-5-pro',
688 - ],
689 - [
690 - 'name' => 'better_payment_form_layout',
691 - 'operator' => '!=',
692 - 'value' => 'layout-6-pro',
693 - ],
694 - [
695 - 'name' => 'better_payment_form_payment_source',
696 - 'value' => 'fluentcart' . ( ! function_exists('fluentCart') ? '' : 'exist' ),
697 - ],
698 - ],
699 - ],
700 - [
701 - 'relation' => 'and',
702 - 'terms' => [
703 - [
704 - 'name' => 'better_payment_form_layout',
705 - 'value' => 'layout-6-pro',
706 - ],
707 - [
708 - 'name' => 'better_payment_form_layout_6_ecommerce_platform',
709 - 'value' => 'fluentcart' . ( ! function_exists('fluentCart') ? '' : 'exist' ),
710 - ],
711 - ],
712 - ],
713 - ],
228 + 'name' => 'better_payment_form_layout',
229 + 'operator' => '!=',
230 + 'value' => 'layout-4-pro',
714 231 ],
232 + [
233 + 'name' => 'better_payment_form_layout',
234 + 'operator' => '!=',
235 + 'value' => 'layout-5-pro',
236 + ],
237 + [
238 + 'name' => 'better_payment_form_layout',
239 + 'operator' => '!=',
240 + 'value' => 'layout-6-pro',
241 + ],
242 + [
243 + 'name' => 'better_payment_form_payment_source',
244 + 'value' => 'fluentcart' . ( ! function_exists('fluentCart') ? '' : 'exist' ),
245 + ],
715 246 ],
716 247 ],
717 248 ] );
718 249
@@ -742,11 +273,9 @@
742 273 'label_off' => __( 'No', 'better-payment' ),
743 274 'return_value' => 'yes',
744 275 'default' => esc_html($this->better_payment_global_settings['better_payment_settings_general_general_paypal']), //yes or no
745 276 'separator' => 'before',
746 - 'condition' => [
747 - 'better_payment_form_payment_type!' => [ 'recurring', 'split-payment' ],
748 - ],
277 + 'condition' => $this->pro_layout_control_condition( 'better_payment_form_paypal_enable' ),
749 278 ]
750 279 );
751 280
752 281 $this->add_control( 'better_payment_form_paypal_enable_notice', [
@@ -844,11 +373,9 @@
844 373 'label_on' => __( 'Yes', 'better-payment' ),
845 374 'label_off' => __( 'No', 'better-payment' ),
846 375 'return_value' => 'yes',
847 376 'default' => ! empty( $this->better_payment_global_settings['better_payment_settings_general_general_paystack'] ) ? esc_html($this->better_payment_global_settings['better_payment_settings_general_general_paystack']) : 'no', //yes or no
848 - 'condition' => [
849 - 'better_payment_form_payment_type!' => [ 'recurring', 'split-payment' ],
850 - ],
377 + 'condition' => $this->pro_layout_control_condition( 'better_payment_form_paystack_enable' ),
851 378 ]
852 379 );
853 380
854 381 $this->add_control( 'better_payment_form_paystack_enable_notice', [
@@ -1487,63 +1014,8 @@
1487 1014 'better_payment_field_name_show' => 'yes',
1488 1015 'better_payment_field_name_required' => 'yes',
1489 1016 ];
1490 1017
1491 - $form_fields_first_name_layout_4_5_6 = [
1492 - 'better_payment_field_name_heading' => esc_html__( 'First name', 'better-payment' ),
1493 - 'better_payment_field_name_placeholder' => esc_html__( 'First name', 'better-payment' ),
1494 - 'better_payment_field_type' => 'text',
1495 - 'better_payment_primary_field_type' => 'primary_first_name',
1496 - 'better_payment_field_name_show' => 'yes',
1497 - 'better_payment_field_name_required' => 'no',
1498 - 'better_payment_field_name_display_inline' => 'inline-block',
1499 - 'better_payment_field_name_display_inline_width' => [
1500 - 'size' => '48',
1501 - 'unit' => '%',
1502 - ],
1503 - ];
1504 -
1505 - $form_fields_last_name_layout_4_5_6 = [
1506 - 'better_payment_field_name_heading' => esc_html__( 'Last name', 'better-payment' ),
1507 - 'better_payment_field_name_placeholder' => esc_html__( 'Last name', 'better-payment' ),
1508 - 'better_payment_field_type' => 'text',
1509 - 'better_payment_primary_field_type' => 'primary_last_name',
1510 - 'better_payment_field_name_show' => 'yes',
1511 - 'better_payment_field_name_required' => 'no',
1512 - 'better_payment_field_name_display_inline' => 'inline-block',
1513 - 'better_payment_field_name_display_inline_width' => [
1514 - 'size' => '48',
1515 - 'unit' => '%',
1516 - ],
1517 - ];
1518 -
1519 - $form_field_email_layout_4_5_6 = [
1520 - 'better_payment_field_name_heading' => esc_html__( 'Email', 'better-payment' ),
1521 - 'better_payment_field_name_placeholder' => esc_html__( 'Enter your email', 'better-payment' ),
1522 - 'better_payment_field_type' => 'email',
1523 - 'better_payment_primary_field_type' => 'primary_email',
1524 - 'better_payment_field_name_show' => 'yes',
1525 - 'better_payment_field_name_required' => 'yes',
1526 - ];
1527 -
1528 - $form_field_payment_amount_layout_4_5_6 = [
1529 - 'better_payment_field_name_heading' => esc_html__( 'Amount', 'better-payment' ),
1530 - 'better_payment_field_name_placeholder' => esc_html__( 'Other amount', 'better-payment' ),
1531 - 'better_payment_field_type' => 'number',
1532 - 'better_payment_primary_field_type' => 'primary_payment_amount',
1533 - 'better_payment_field_name_show' => 'yes',
1534 - 'better_payment_field_name_required' => 'yes',
1535 - ];
1536 -
1537 - $form_field_payment_amount_layout_4_5_6_desc = [
1538 - 'better_payment_field_name_heading' => esc_html__( 'Amount to pay', 'better-payment' ),
1539 - 'better_payment_field_name_placeholder' => esc_html__( 'Other amount', 'better-payment' ),
1540 - 'better_payment_field_type' => 'number',
1541 - 'better_payment_primary_field_type' => 'primary_payment_amount',
1542 - 'better_payment_field_name_show' => 'yes',
1543 - 'better_payment_field_name_required' => 'yes',
1544 - ];
1545 -
1546 1018 $form_fields_defaults = [
1547 1019 $form_fields_first_name,
1548 1020 $form_fields_last_name,
1549 1021 $form_field_email,
@@ -1549,28 +1021,8 @@
1549 1021 $form_field_email,
1550 1022 $form_field_payment_amount,
1551 1023 ];
1552 1024
1553 - $form_fields_defaults_layout_4_5_6 = [
1554 - $form_fields_first_name_layout_4_5_6,
1555 - $form_fields_last_name_layout_4_5_6,
1556 - $form_field_email_layout_4_5_6,
1557 - $form_field_payment_amount_layout_4_5_6,
1558 - ];
1559 -
1560 - $form_fields_defaults_layout_4_5_6_desc = [
1561 - $form_field_payment_amount_layout_4_5_6_desc,
1562 - $form_fields_first_name_layout_4_5_6,
1563 - $form_fields_last_name_layout_4_5_6,
1564 - $form_field_email_layout_4_5_6,
1565 - ];
1566 -
1567 - $form_fields_defaults_layout_4_5_6_woo = [
1568 - $form_fields_first_name_layout_4_5_6,
1569 - $form_fields_last_name_layout_4_5_6,
1570 - $form_field_email_layout_4_5_6,
1571 - ];
1572 -
1573 1025 $this->add_control(
1574 1026 'better_payment_form_fields',
1575 1027 [
1576 1028 'label' => esc_html__( 'Form Fields', 'better-payment' ),
@@ -1583,49 +1035,9 @@
1583 1035 ],
1584 1036 ]
1585 1037 );
1586 1038
1587 - $this->add_control(
1588 - 'better_payment_form_fields_layout_4_5_6',
1589 - [
1590 - 'label' => esc_html__( 'Form Fields', 'better-payment' ),
1591 - 'type' => \Elementor\Controls_Manager::REPEATER,
1592 - 'fields' => $form_fields_repeater->get_controls(),
1593 - 'default' => $form_fields_defaults_layout_4_5_6,
1594 - 'title_field' => '{{{ better_payment_field_name_heading }}}',
1595 - 'condition' => [
1596 - 'better_payment_form_layout' => ['layout-4-pro'],
1597 - ],
1598 - ]
1599 - );
1600 -
1601 - $this->add_control(
1602 - 'better_payment_form_fields_layout_4_5_6_desc',
1603 - [
1604 - 'label' => esc_html__( 'Form Fields', 'better-payment' ),
1605 - 'type' => \Elementor\Controls_Manager::REPEATER,
1606 - 'fields' => $form_fields_repeater->get_controls(),
1607 - 'default' => $form_fields_defaults_layout_4_5_6_desc,
1608 - 'title_field' => '{{{ better_payment_field_name_heading }}}',
1609 - 'condition' => [
1610 - 'better_payment_form_layout' => ['layout-5-pro'],
1611 - ],
1612 - ]
1613 - );
1614 -
1615 - $this->add_control(
1616 - 'better_payment_form_fields_layout_4_5_6_woo',
1617 - [
1618 - 'label' => esc_html__( 'Form Fields', 'better-payment' ),
1619 - 'type' => \Elementor\Controls_Manager::REPEATER,
1620 - 'fields' => $form_fields_repeater->get_controls(),
1621 - 'default' => $form_fields_defaults_layout_4_5_6_woo,
1622 - 'title_field' => '{{{ better_payment_field_name_heading }}}',
1623 - 'condition' => [
1624 - 'better_payment_form_layout' => ['layout-6-pro'],
1625 - ],
1626 - ]
1627 - );
1039 + do_action( 'better_payment/elementor/editor/pro_layout_form_fields_controls', $this, $form_fields_repeater );
1628 1040
1629 1041 $repeater = new Repeater();
1630 1042
1631 1043
@@ -1653,23 +1065,9 @@
1653 1065 ],
1654 1066 ]
1655 1067 );
1656 1068
1657 - $this->add_control(
1658 - 'better_payment_show_amount_list_layout_4_5_6',
1659 - [
1660 - 'label' => __( 'Show Amount List', 'better-payment' ),
1661 - 'type' => Controls_Manager::SWITCHER,
1662 - 'label_on' => __( 'Yes', 'better-payment' ),
1663 - 'label_off' => __( 'No', 'better-payment' ),
1664 - 'return_value' => 'yes',
1665 - 'default' => 'yes',
1666 - 'condition' => [
1667 - 'better_payment_form_layout' => ['layout-4-pro', 'layout-5-pro', 'layout-6-pro'],
1668 - 'better_payment_form_payment_type!' => [ 'recurring', 'split-payment' ],
1669 - ],
1670 - ]
1671 - );
1069 + do_action( 'better_payment/elementor/editor/pro_layout_amount_list_toggle_control', $this );
1672 1070
1673 1071 $this->add_control(
1674 1072 'better_payment_amount',
1675 1073 [
@@ -1690,48 +1088,17 @@
1690 1088 ],
1691 1089 ],
1692 1090 'fields' => $repeater->get_controls(),
1693 1091 'title_field' => '<i class="{{ better_payment_amount_val }}" aria-hidden="true"></i> {{{ better_payment_amount_val }}}',
1694 - 'condition' => [
1092 + 'condition' => $this->pro_layout_control_condition( 'better_payment_amount', [
1695 1093 'better_payment_show_amount_list' => 'yes',
1696 1094 'better_payment_form_payment_source!' => ['woocommerce', 'fluentcart'],
1697 - 'better_payment_form_payment_type!' => [ 'recurring', 'split-payment' ],
1698 1095 'better_payment_form_layout!' => ['layout-4-pro', 'layout-5-pro', 'layout-6-pro'],
1699 - ],
1096 + ] ),
1700 1097 ]
1701 1098 );
1702 1099
1703 - $this->add_control(
1704 - 'better_payment_amount_layout_4_5_6',
1705 - [
1706 - 'label' => esc_html__( 'Amount List', 'better-payment' ),
1707 - 'type' => Controls_Manager::REPEATER,
1708 - 'default' => [
1709 - [
1710 - 'better_payment_amount_val' => 10
1711 - ],
1712 - [
1713 - 'better_payment_amount_val' => 30
1714 - ],
1715 - [
1716 - 'better_payment_amount_val' => 50
1717 - ],
1718 - [
1719 - 'better_payment_amount_val' => 100
1720 - ],
1721 - [
1722 - 'better_payment_amount_val' => 500
1723 - ],
1724 - ],
1725 - 'fields' => $repeater->get_controls(),
1726 - 'title_field' => '<i class="{{ better_payment_amount_val }}" aria-hidden="true"></i> {{{ better_payment_amount_val }}}',
1727 - 'condition' => [
1728 - 'better_payment_show_amount_list_layout_4_5_6' => 'yes',
1729 - 'better_payment_form_payment_type!' => [ 'recurring', 'split-payment' ],
1730 - 'better_payment_form_layout' => ['layout-4-pro', 'layout-5-pro', 'layout-6-pro'],
1731 - ],
1732 - ]
1733 - );
1100 + do_action( 'better_payment/elementor/editor/pro_layout_amount_list_control', $this, $repeater );
1734 1101
1735 1102 do_action('better_payment/elementor/editor/layouts_form_settings_amount_list_section', $this);
1736 1103
1737 1104 $this->add_control(
@@ -1811,39 +1178,11 @@
1811 1178 'separator' => 'before',
1812 1179 ]
1813 1180 );
1814 1181
1815 - $this->add_control(
1816 - 'better_payment_form_form_title_text',
1817 - [
1818 - 'label' => esc_html__( 'Form Title', 'better-payment' ),
1819 - 'type' => Controls_Manager::TEXT,
1820 - 'label_block' => true,
1821 - 'ai' => [
1822 - 'active' => false,
1823 - ],
1824 - 'condition' => [
1825 - 'better_payment_form_layout' => ['layout-4-pro', 'layout-5-pro', 'layout-6-pro'],
1826 - ],
1827 - ]
1828 - );
1182 + do_action( 'better_payment/elementor/editor/pro_layout_form_title_controls', $this );
1829 1183
1830 1184 $this->add_control(
1831 - 'better_payment_form_form_sub_title_text',
1832 - [
1833 - 'label' => esc_html__( 'Form Sub-Title', 'better-payment' ),
1834 - 'type' => Controls_Manager::TEXT,
1835 - 'label_block' => true,
1836 - 'ai' => [
1837 - 'active' => false,
1838 - ],
1839 - 'condition' => [
1840 - 'better_payment_form_layout' => ['layout-5-pro'],
1841 - ],
1842 - ]
1843 - );
1844 -
1845 - $this->add_control(
1846 1185 'better_payment_form_form_buttons_paypal_button_text',
1847 1186 [
1848 1187 'label' => esc_html__( 'PayPal Button Text', 'better-payment' ),
1849 1188 'type' => Controls_Manager::TEXT,
@@ -4290,13 +3629,8 @@
4290 3629 do_action('better_payment/elementor/editor/manage_response_webhook', $this, $settings );
4291 3630
4292 3631 wp_enqueue_script( 'better-payment' );
4293 3632
4294 - if( $this->pro_enabled ){
4295 - wp_enqueue_script( 'better-payment-pro-common-script' );
4296 - wp_enqueue_style( 'better-payment-pro-common-style' );
4297 - }
4298 -
4299 3633 $action = esc_url( admin_url( 'admin-post.php' ) );
4300 3634 $setting_meta = wp_json_encode( [
4301 3635 'page_id' => get_the_ID(),
4302 3636 'widget_id' => esc_attr( $this->get_id() ),
@@ -4320,16 +3654,11 @@
4320 3654 $better_payment_form_layout = sanitize_text_field($settings[ 'better_payment_form_layout' ]);
4321 3655 $better_payment_form_layout = in_array($better_payment_form_layout, array_keys( $this->better_payment_free_layouts() ) ) ? $better_payment_form_layout : 'layout-1';
4322 3656
4323 3657 $template_file = BETTER_PAYMENT_ADMIN_VIEWS_PATH . '/elementor/layouts/' . $better_payment_form_layout . '.php';
4324 - $is_pro_layout = false !== strpos( $better_payment_form_layout, '-pro' );
4325 -
4326 - if ( $this->pro_enabled && $is_pro_layout ){
4327 - $template_file = BETTER_PAYMENT_PRO_ADMIN_VIEWS_PATH . '/elementor/layouts/' . $better_payment_form_layout . '.php';
4328 - }
4329 3658
4330 - if ( ( ! $this->pro_enabled ) && $is_pro_layout ){
4331 - $template_file = BETTER_PAYMENT_ADMIN_VIEWS_PATH . '/partials/layout-pro-banners.php';
3659 + if ( false !== strpos( $better_payment_form_layout, '-pro' ) ) {
3660 + $template_file = $this->pro_layout_template_file( $better_payment_form_layout, $settings );
4332 3661 }
4333 3662
4334 3663 $better_payment_form_content = '';
4335 3664
@@ -4347,19 +3676,20 @@
4347 3676
4348 3677 /**
4349 3678 * Render amount element
4350 3679 *
3680 + * Lite's own layouts print their amount list with it. `'version' => 'v2'` is the
3681 + * amount list of Pro layouts 4 and 5, which Better Payment Pro prints itself
3682 + * (Admin\Elementor\LayoutRenderer), so Lite prints nothing for it. Public with this
3683 + * signature because Pro 1.4.3's templates called it; those templates no longer
3684 + * load (Pro 1.4.3 fills no `layout_template` filter), so the signature is kept as
3685 + * belt-and-braces (tests/Unit/ProCouplingContractTest.php).
3686 + *
4351 3687 * @since 0.0.1
4352 3688 */
4353 3689 public function render_amount_element( $settings, $args = [] ) {
4354 - $defauls = [
4355 - 'version' => 'v1',
4356 - 'items' => $settings['better_payment_amount'],
4357 - ];
4358 -
4359 3690 if ( ! empty( $args['version'] ) ) {
4360 - $defauls['version'] = 'v2';
4361 - $defauls['items'] = $settings['better_payment_amount_layout_4_5_6'];
3691 + return;
4362 3692 }
4363 3693
4364 3694 $layout_form_currency_symbol = $this->get_currency_symbol( esc_html($settings[ 'better_payment_form_currency' ]) );
4365 3695 $currency_alignment = ! empty ( $settings['better_payment_form_currency_alignment'] ) ? $settings['better_payment_form_currency_alignment'] : 'left';
@@ -4364,16 +3694,13 @@
4364 3694 $layout_form_currency_symbol = $this->get_currency_symbol( esc_html($settings[ 'better_payment_form_currency' ]) );
4365 3695 $currency_alignment = ! empty ( $settings['better_payment_form_currency_alignment'] ) ? $settings['better_payment_form_currency_alignment'] : 'left';
4366 3696 $layout_form_currency_left = 'left' === $currency_alignment ? $layout_form_currency_symbol : '';
4367 3697 $layout_form_currency_right = 'right' === $currency_alignment ? $layout_form_currency_symbol : '' ;
4368 -
4369 - $id = esc_attr( $this->get_id() );
4370 3698 ?>
4371 3699 <!-- <div class="pt-5"> -->
4372 3700 <?php
4373 - foreach ( $defauls['items'] as $item ) {
3701 + foreach ( $settings['better_payment_amount'] as $item ) {
4374 3702 $uid = uniqid();
4375 - if ( 'v1' === $defauls['version'] ) :
4376 3703 ?>
4377 3704 <div class="bp-form__group pt-5">
4378 3705 <input type="radio" value="<?php echo floatval( $item[ 'better_payment_amount_val' ] ); ?>"
4379 3706 id="bp_payment_amount-<?php echo esc_attr($uid); ?>" class="bp-form__control bp-form_pay-radio "
@@ -4381,19 +3708,8 @@
4381 3708 <label for="bp_payment_amount-<?php echo esc_attr($uid); ?>"><?php printf( "%s%s%s", esc_html( $layout_form_currency_left ), floatval( $item[ 'better_payment_amount_val' ] ), esc_html( $layout_form_currency_right ) ); ?></label>
4382 3709 </div>
4383 3710
4384 3711 <?php
4385 - elseif ( 'v2' === $defauls['version'] ) :
4386 - ?>
4387 - <label class="payment-amount">
4388 - <input type="radio" value="<?php echo floatval( $item[ 'better_payment_amount_val' ] ); ?>"
4389 - id="bp_payment_amount-<?php echo esc_attr($uid); ?>" class="bp-form__control bp-form_pay-radio "
4390 - name="primary_payment_amount_radio">
4391 - <span class="text"><?php printf( "%s%s%s", esc_html( $layout_form_currency_left ), floatval( $item[ 'better_payment_amount_val' ] ), esc_html( $layout_form_currency_right ) ); ?></span>
4392 - </label>
4393 -
4394 - <?php
4395 - endif;
4396 3712 }
4397 3713 ?>
4398 3714 <!-- </div> -->
4399 3715 <?php
@@ -4398,8 +3714,20 @@
4398 3714 <!-- </div> -->
4399 3715 <?php
4400 3716 }
4401 3717
3718 + /**
3719 + * The dynamic default amount of a free layout's payment amount field.
3720 + *
3721 + * Pro layouts 4, 5 and 6 read their own repeater in Better Payment Pro
3722 + * (Admin\Elementor\LayoutRenderer::attribute_default_text()), so they get ''
3723 + * here. Public with this signature because Pro 1.4.3's templates called it; they
3724 + * no longer load, so it is kept as belt-and-braces
3725 + * (tests/Unit/ProCouplingContractTest.php).
3726 + *
3727 + * @param array $settings Widget settings.
3728 + * @return float|string
3729 + */
4402 3730 public function render_attribute_default_text( $settings ) {
4403 3731 $render_attribute_default_text = '';
4404 3732
4405 3733 $items = [];
@@ -4411,18 +3739,8 @@
4411 3739 case 'layout-3':
4412 3740 $items = ! empty( $settings['better_payment_form_fields'] ) ? $settings['better_payment_form_fields'] : [];
4413 3741 break;
4414 3742
4415 - case 'layout-4-pro':
4416 - $items = ! empty( $settings['better_payment_form_fields_layout_4_5_6'] ) ? $settings['better_payment_form_fields_layout_4_5_6'] : [];
4417 - break;
4418 - case 'layout-5-pro':
4419 - $items = ! empty( $settings['better_payment_form_fields_layout_4_5_6_desc'] ) ? $settings['better_payment_form_fields_layout_4_5_6_desc'] : [];
4420 - break;
4421 - case 'layout-6-pro':
4422 - $items = ! empty( $settings['better_payment_form_fields_layout_4_5_6_woo'] ) ? $settings['better_payment_form_fields_layout_4_5_6_woo'] : [];
4423 - break;
4424 -
4425 3743 default:
4426 3744 break;
4427 3745 }
4428 3746
@@ -4486,6 +3804,51 @@
4486 3804 'value' => $currency,
4487 3805 ];
4488 3806 }
4489 3807 return $conditions;
3808 + }
3809 +
3810 + /**
3811 + * A free control's condition, plus what Pro's payment types add to it.
3812 + *
3813 + * PayPal, Paystack and the amount list hide for a recurring or split payment. That
3814 + * condition names `better_payment_form_payment_type`, a Pro-layout control, and
3815 + * Elementor hides — and nulls when rendering — a control whose condition names a
3816 + * control that is not registered. So a free install gets the bare condition, and
3817 + * Better Payment Pro, which registers the Pro-layout controls on the
3818 + * `better_payment/elementor/editor/pro_layout_*` actions, adds the payment type on
3819 + * `better_payment/elementor/editor/pro_layout_control_condition`. Control ids must
3820 + * never change: saved Elementor data, PaymentRequestGuard and the payment handlers
3821 + * read them.
3822 + *
3823 + * @param string $control_id The control id.
3824 + * @param array $condition The control's own condition.
3825 + * @return array
3826 + */
3827 + protected function pro_layout_control_condition( $control_id, array $condition = [] ) {
3828 + $filtered = apply_filters( 'better_payment/elementor/editor/pro_layout_control_condition', $condition, $control_id, $this );
3829 +
3830 + return is_array( $filtered ) ? $filtered : $condition;
3831 + }
3832 +
3833 + /**
3834 + * The template that renders a Pro layout (`layout-4-pro`, `layout-5-pro`, `layout-6-pro`).
3835 + *
3836 + * Without Pro it is the upgrade banner. With Pro it is whatever
3837 + * `better_payment/elementor/widget/layout_template` returns, which is where Better
3838 + * Payment Pro supplies its template. An active Pro never gets the banner; with no
3839 + * template nothing renders.
3840 + *
3841 + * @param string $layout Whitelisted `-pro` layout key.
3842 + * @param array $settings Widget settings.
3843 + * @return string Template path, or '' for none.
3844 + */
3845 + protected function pro_layout_template_file( $layout, $settings ) {
3846 + if ( ! $this->pro_enabled ) {
3847 + return BETTER_PAYMENT_ADMIN_VIEWS_PATH . '/partials/layout-pro-banners.php';
3848 + }
3849 +
3850 + $template = apply_filters( 'better_payment/elementor/widget/layout_template', '', $layout, $settings, $this );
3851 +
3852 + return is_string( $template ) ? $template : '';
4490 3853 }
4491 3854 }