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 +27 -68 2.4.0 → 2.4.1 View file →
@@ -4,11 +4,8 @@
4 4
5 5 use Better_Payment\Lite\Admin\DB;
6 6 use Better_Payment\Lite\Classes\Handler;
7 7 use Better_Payment\Lite\Classes\Helper as ClassesHelper;
8 -use Better_Payment\Lite\Classes\ProCompatibility;
9 -use Better_Payment\Lite\Classes\ProPaymentFormControls;
10 -use Better_Payment\Lite\Classes\ProPaymentFormLayouts;
11 8 use Better_Payment\Lite\Traits\Helper as TraitsHelper;
12 9 use \Elementor\Controls_Manager as Controls_Manager;
13 10 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
14 11 use Elementor\Group_Control_Background;
@@ -116,11 +113,8 @@
116 113 'options' => $this->better_payment_free_layouts(),
117 114 ]
118 115 );
119 116
120 - if ( $this->lite_registers_pro_layout_controls() ) {
121 - ProPaymentFormControls::payment_controls( $this );
122 - }
123 117 do_action( 'better_payment/elementor/editor/pro_layout_payment_controls', $this );
124 118
125 119 $this->add_control(
126 120 'better_payment_form_payment_source',
@@ -219,11 +213,8 @@
219 213 'better_payment_form_layout' => ['layout-1', 'layout-2', 'layout-3'],
220 214 ],
221 215 ] );
222 216
223 - if ( $this->lite_registers_pro_layout_controls() ) {
224 - ProPaymentFormControls::product_controls( $this );
225 - }
226 217 do_action( 'better_payment/elementor/editor/pro_layout_product_controls', $this );
227 218
228 219 $this->add_control( 'better_payment_form_payment_source_fluentcart_notice', [
229 220 'type' => Controls_Manager::RAW_HTML,
@@ -1044,11 +1035,8 @@
1044 1035 ],
1045 1036 ]
1046 1037 );
1047 1038
1048 - if ( $this->lite_registers_pro_layout_controls() ) {
1049 - ProPaymentFormControls::form_fields_controls( $this, $form_fields_repeater );
1050 - }
1051 1039 do_action( 'better_payment/elementor/editor/pro_layout_form_fields_controls', $this, $form_fields_repeater );
1052 1040
1053 1041 $repeater = new Repeater();
1054 1042
@@ -1077,11 +1065,8 @@
1077 1065 ],
1078 1066 ]
1079 1067 );
1080 1068
1081 - if ( $this->lite_registers_pro_layout_controls() ) {
1082 - ProPaymentFormControls::amount_list_toggle_control( $this );
1083 - }
1084 1069 do_action( 'better_payment/elementor/editor/pro_layout_amount_list_toggle_control', $this );
1085 1070
1086 1071 $this->add_control(
1087 1072 'better_payment_amount',
@@ -1111,11 +1096,8 @@
1111 1096 ] ),
1112 1097 ]
1113 1098 );
1114 1099
1115 - if ( $this->lite_registers_pro_layout_controls() ) {
1116 - ProPaymentFormControls::amount_list_control( $this, $repeater );
1117 - }
1118 1100 do_action( 'better_payment/elementor/editor/pro_layout_amount_list_control', $this, $repeater );
1119 1101
1120 1102 do_action('better_payment/elementor/editor/layouts_form_settings_amount_list_section', $this);
1121 1103
@@ -1196,11 +1178,8 @@
1196 1178 'separator' => 'before',
1197 1179 ]
1198 1180 );
1199 1181
1200 - if ( $this->lite_registers_pro_layout_controls() ) {
1201 - ProPaymentFormControls::form_title_controls( $this );
1202 - }
1203 1182 do_action( 'better_payment/elementor/editor/pro_layout_form_title_controls', $this );
1204 1183
1205 1184 $this->add_control(
1206 1185 'better_payment_form_form_buttons_paypal_button_text',
@@ -3697,23 +3676,19 @@
3697 3676
3698 3677 /**
3699 3678 * Render amount element
3700 3679 *
3701 - * `'version' => 'v2'` is the amount list of Pro layouts 4 and 5, and only Pro's
3702 - * templates ask for it. Better Payment Pro prints it itself once it declares
3703 - * `elementor_pro_layout_rendering`; Lite's copy (Classes\ProPaymentFormLayouts)
3704 - * serves Pro 1.4.3 and older, and nothing is printed otherwise. The method stays
3705 - * public with this signature because Pro 1.4.3 calls it
3706 - * (tests/Unit/ProCouplingContractTest.php).
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).
3707 3686 *
3708 3687 * @since 0.0.1
3709 3688 */
3710 3689 public function render_amount_element( $settings, $args = [] ) {
3711 3690 if ( ! empty( $args['version'] ) ) {
3712 - if ( ProPaymentFormLayouts::lite_copy_applies() ) {
3713 - ProPaymentFormLayouts::render_amount_element( $this, $settings );
3714 - }
3715 -
3716 3691 return;
3717 3692 }
3718 3693
3719 3694 $layout_form_currency_symbol = $this->get_currency_symbol( esc_html($settings[ 'better_payment_form_currency' ]) );
@@ -3739,8 +3714,20 @@
3739 3714 <!-- </div> -->
3740 3715 <?php
3741 3716 }
3742 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 + */
3743 3730 public function render_attribute_default_text( $settings ) {
3744 3731 $render_attribute_default_text = '';
3745 3732
3746 3733 $items = [];
@@ -3753,13 +3740,8 @@
3753 3740 $items = ! empty( $settings['better_payment_form_fields'] ) ? $settings['better_payment_form_fields'] : [];
3754 3741 break;
3755 3742
3756 3743 default:
3757 - // Pro layouts 4, 5 and 6. Better Payment Pro reads its own repeater once it
3758 - // declares `elementor_pro_layout_rendering`; Lite's copy serves older Pro.
3759 - if ( ProPaymentFormLayouts::lite_copy_applies() ) {
3760 - $items = ProPaymentFormLayouts::default_text_items( $settings );
3761 - }
3762 3744 break;
3763 3745 }
3764 3746
3765 3747 if (!empty($items)) :
@@ -3825,35 +3807,19 @@
3825 3807 return $conditions;
3826 3808 }
3827 3809
3828 3810 /**
3829 - * Whether Lite registers its copy of the controls only Pro layouts (4, 5, 6) use.
3830 - *
3831 - * Only for an active Pro that does not declare `elementor_payment_form_pro_controls`
3832 - * (1.4.3 and older); the copy is Classes\ProPaymentFormControls. A current Pro
3833 - * registers its own copy of each group on the `better_payment/elementor/editor/pro_layout_*`
3834 - * action fired right after each call, so the panel position is unchanged. A free
3835 - * install registers none of them: a Pro layout shows only its upgrade banner there,
3836 - * and Elementor keeps the saved value of a control that is not registered, so a site
3837 - * that loses Pro keeps its configuration. Control ids must never change: saved
3838 - * Elementor data, PaymentRequestGuard and the payment handlers read them.
3839 - *
3840 - * @return bool
3841 - */
3842 - protected function lite_registers_pro_layout_controls() {
3843 - return ProCompatibility::lite_copy_applies( ProPaymentFormControls::FEATURE );
3844 - }
3845 -
3846 - /**
3847 3811 * A free control's condition, plus what Pro's payment types add to it.
3848 3812 *
3849 3813 * PayPal, Paystack and the amount list hide for a recurring or split payment. That
3850 3814 * condition names `better_payment_form_payment_type`, a Pro-layout control, and
3851 3815 * Elementor hides — and nulls when rendering — a control whose condition names a
3852 - * control that is not registered. So a free install gets the bare condition, Better
3853 - * Payment Pro adds the payment type on
3854 - * `better_payment/elementor/editor/pro_layout_control_condition`, and Lite adds it
3855 - * itself only while it registers the Pro-layout controls for an older Pro.
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.
3856 3822 *
3857 3823 * @param string $control_id The control id.
3858 3824 * @param array $condition The control's own condition.
3859 3825 * @return array
@@ -3858,12 +3824,8 @@
3858 3824 * @param array $condition The control's own condition.
3859 3825 * @return array
3860 3826 */
3861 3827 protected function pro_layout_control_condition( $control_id, array $condition = [] ) {
3862 - if ( $this->lite_registers_pro_layout_controls() ) {
3863 - $condition = ProPaymentFormControls::control_condition( $condition, $control_id );
3864 - }
3865 -
3866 3828 $filtered = apply_filters( 'better_payment/elementor/editor/pro_layout_control_condition', $condition, $control_id, $this );
3867 3829
3868 3830 return is_array( $filtered ) ? $filtered : $condition;
3869 3831 }
@@ -3871,12 +3833,10 @@
3871 3833 /**
3872 3834 * The template that renders a Pro layout (`layout-4-pro`, `layout-5-pro`, `layout-6-pro`).
3873 3835 *
3874 3836 * Without Pro it is the upgrade banner. With Pro it is whatever
3875 - * `better_payment/elementor/widget/layout_template` returns: Better Payment Pro
3876 - * supplies its template there once it declares `elementor_pro_layout_rendering`, and
3877 - * for an older Pro the filter starts at Pro's own template
3878 - * (Classes\ProPaymentFormLayouts). An active Pro never gets the banner; with no
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
3879 3839 * template nothing renders.
3880 3840 *
3881 3841 * @param string $layout Whitelisted `-pro` layout key.
3882 3842 * @param array $settings Widget settings.
@@ -3886,10 +3846,9 @@
3886 3846 if ( ! $this->pro_enabled ) {
3887 3847 return BETTER_PAYMENT_ADMIN_VIEWS_PATH . '/partials/layout-pro-banners.php';
3888 3848 }
3889 3849
3890 - $template = ProPaymentFormLayouts::lite_copy_applies() ? ProPaymentFormLayouts::template_file( $layout ) : '';
3891 - $template = apply_filters( 'better_payment/elementor/widget/layout_template', $template, $layout, $settings, $this );
3850 + $template = apply_filters( 'better_payment/elementor/widget/layout_template', '', $layout, $settings, $this );
3892 3851
3893 3852 return is_string( $template ) ? $template : '';
3894 3853 }
3895 3854 }