PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 1.0.3
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v1.0.3
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
better-payment / includes / Admin / Elementor / Form_Actions / Payment_Amount_Integration.php

Payment_Amount_Integration.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 1.0.3, at includes/Admin/Elementor/Form_Actions/Payment_Amount_Integration.php

525 lines 18.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Better_Payment\Lite\Admin\Elementor\Form_Actions;
4
5 use Better_Payment\Lite\Admin\DB;
6 use Elementor\Controls_Manager;
7 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
8 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
9 use Elementor\Group_Control_Border;
10 use Elementor\Group_Control_Box_Shadow;
11 use Elementor\Group_Control_Typography;
12 use Elementor\Repeater;
13 use ElementorPro\Modules\Forms\Classes\Action_Base;
14 use ElementorPro\Modules\Forms\Classes\Ajax_Handler;
15 use ElementorPro\Modules\Forms\Classes\Form_Record;
16
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit; // Exit if accessed directly
19 }
20
21 /**
22 * Payment Amount integration class
23 *
24 * @since 0.0.1
25 */
26 class Payment_Amount_Integration extends Action_Base {
27 private $better_payment_global_settings = [];
28
29 public function get_name() {
30 return '';
31 }
32
33 public function get_label() {
34 return __( 'Better Payment', 'better-payment' );
35 }
36
37 /**
38 * @param \Elementor\Widget_Base $widget
39 */
40 public function register_settings_section( $widget ) {
41 $this->better_payment_global_settings = DB::get_settings();
42
43 $widget->start_controls_section(
44 'section_better_payment_payment_amount',
45 [
46 'label' => __( 'Better Payment', 'better-payment' ),
47 'condition' => [
48 ],
49 ]
50 );
51
52 $widget->add_control(
53 'better_payment_payment_amount_enable_notice',
54 [
55 'type' => Controls_Manager::RAW_HTML,
56 'raw' => __( 'Don\'t forget to add PayPal or Stripe on <strong>Actions After Submit</strong>', 'better-payment' ),
57 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
58 'conditions' => [
59 'relation' => 'or',
60 'terms' => [
61 [
62 'name' => 'better_payment_payment_amount_enable',
63 'value' => 'yes',
64 ],
65 [
66 'name' => 'better_payment_show_amount_list_enable',
67 'value' => 'yes',
68 ],
69 ],
70 ],
71 ]
72 );
73
74 $widget->add_control(
75 'better_payment_payment_amount_enable',
76 [
77 'label' => __( 'Payment Amount Field', 'better-payment' ),
78 'description' => __( 'We add an extra field type <b>Payment Amount</b> which offers you to accept payment via Paypal and Stripe. Disable it if you want to hide the field type.<br><br>', 'better-payment' ),
79 'type' => Controls_Manager::SWITCHER,
80 'label_on' => __( 'Yes', 'better-payment' ),
81 'label_off' => __( 'No', 'better-payment' ),
82 'return_value' => 'yes',
83 'default' => 'no',
84 ]
85 );
86
87 $repeater = new Repeater();
88
89
90 $repeater->add_control(
91 'better_payment_amount_val',
92 [
93 'label' => esc_html__( 'Payment Amount', 'better-payment' ),
94 'type' => Controls_Manager::NUMBER,
95 'min' => 1,
96 ]
97 );
98
99 $widget->add_control(
100 'better_payment_show_amount_list_enable',
101 [
102 'label' => __( 'Show Amount List', 'better-payment' ),
103 'type' => Controls_Manager::SWITCHER,
104 'label_on' => __( 'Yes', 'better-payment' ),
105 'label_off' => __( 'No', 'better-payment' ),
106 'return_value' => 'yes',
107 'default' => 'no',
108 'condition' => [
109 'better_payment_payment_amount_enable' => 'yes',
110 ],
111 'separator' => 'before',
112 ]
113 );
114
115 $widget->add_control(
116 'better_payment_show_amount_list_notice',
117 [
118 'type' => Controls_Manager::RAW_HTML,
119 'raw' => __( 'Form Fields => Payment Amount => <b>Field Type</b> helps to show Amount List with or without Input field.', 'better-payment' ),
120 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
121 'condition' => [
122 'better_payment_payment_amount_enable' => 'yes',
123 'better_payment_show_amount_list_enable' => 'yes',
124 ],
125 ]
126 );
127
128 $widget->add_control(
129 'better_payment_show_amount_list_items',
130 [
131 'label' => esc_html__( 'Amount List', 'better-payment' ),
132 'type' => Controls_Manager::REPEATER,
133 'default' => [
134 [
135 'better_payment_amount_val' => 5
136 ],
137 [
138 'better_payment_amount_val' => 10
139 ],
140 [
141 'better_payment_amount_val' => 15
142 ],
143 [
144 'better_payment_amount_val' => 20
145 ],
146 ],
147 'fields' => $repeater->get_controls(),
148 'title_field' => '<i class="{{ better_payment_amount_val }}" aria-hidden="true"></i> {{{ better_payment_amount_val }}}',
149 'condition' => [
150 'better_payment_payment_amount_enable' => 'yes',
151 'better_payment_show_amount_list_enable' => 'yes',
152 ],
153 ]
154 );
155
156 $widget->add_control(
157 'better_payment_payment_amount_style',
158 [
159 'label' => __( 'Field Style', 'better-payment' ),
160 'type' => Controls_Manager::SWITCHER,
161 'label_on' => __( 'Yes', 'better-payment' ),
162 'label_off' => __( 'No', 'better-payment' ),
163 'return_value' => 'yes',
164 'default' => 'no',
165 'condition' => [
166 'better_payment_payment_amount_enable' => 'yes',
167 ],
168 'separator' => 'before',
169 ]
170 );
171
172 $widget->add_control(
173 'better_payment_field_text_color',
174 [
175 'label' => esc_html__( 'Text Color', 'better-payment' ),
176 'type' => Controls_Manager::COLOR,
177 'selectors' => [
178 '{{WRAPPER}} .elementor-field-group .elementor-field.bp-elementor-field-textual-amount' => 'color: {{VALUE}};',
179 ],
180 'global' => [
181 'default' => Global_Colors::COLOR_TEXT,
182 ],
183 'condition' => [
184 'better_payment_payment_amount_style' => 'yes',
185 ],
186 ]
187 );
188
189 $widget->add_group_control(
190 Group_Control_Typography::get_type(),
191 [
192 'name' => 'better_payment_field_typography',
193 'selector' => '{{WRAPPER}} .elementor-field-group .elementor-field.bp-elementor-field-textual-amount',
194 'global' => [
195 'default' => Global_Typography::TYPOGRAPHY_TEXT,
196 ],
197 'condition' => [
198 'better_payment_payment_amount_style' => 'yes',
199 ],
200 ]
201 );
202
203 $widget->add_control(
204 'better_payment_field_background_color',
205 [
206 'label' => esc_html__( 'Background Color', 'better-payment' ),
207 'type' => Controls_Manager::COLOR,
208 'default' => '#ffffff',
209 'selectors' => [
210 '{{WRAPPER}} .elementor-field-group .elementor-field.bp-elementor-field-textual-amount' => 'background-color: {{VALUE}};',
211 ],
212 'condition' => [
213 'better_payment_payment_amount_style' => 'yes',
214 ],
215 ]
216 );
217
218 $widget->add_control(
219 'better_payment_field_border_color',
220 [
221 'label' => esc_html__( 'Border Color', 'better-payment' ),
222 'type' => Controls_Manager::COLOR,
223 'selectors' => [
224 '{{WRAPPER}} .elementor-field-group.elementor-field-type-payment_amount .bp-input-group' => 'border-color: {{VALUE}};border-style:solid;',
225 ],
226 'condition' => [
227 'better_payment_payment_amount_style' => 'yes',
228 ],
229 ]
230 );
231
232 $widget->add_control(
233 'better_payment_field_border_width',
234 [
235 'label' => esc_html__( 'Border Width', 'better-payment' ),
236 'type' => Controls_Manager::DIMENSIONS,
237 'placeholder' => '1',
238 'size_units' => [ 'px' ],
239 'selectors' => [
240 '{{WRAPPER}} .elementor-field-group.elementor-field-type-payment_amount .bp-input-group' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
241 ],
242 'condition' => [
243 'better_payment_payment_amount_style' => 'yes',
244 ],
245 ]
246 );
247
248 $widget->add_control(
249 'better_payment_field_border_radius',
250 [
251 'label' => esc_html__( 'Border Radius', 'better-payment' ),
252 'type' => Controls_Manager::DIMENSIONS,
253 'size_units' => [ 'px', '%' ],
254 'selectors' => [
255 '{{WRAPPER}} .elementor-field-group.elementor-field-type-payment_amount .bp-input-group' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
256 ],
257 'condition' => [
258 'better_payment_payment_amount_style' => 'yes',
259 ],
260 ]
261 );
262
263 $widget->add_control(
264 'better_payment_amount_list_style',
265 [
266 'label' => __( 'Amount List Style', 'better-payment' ),
267 'type' => Controls_Manager::SWITCHER,
268 'label_on' => __( 'Yes', 'better-payment' ),
269 'label_off' => __( 'No', 'better-payment' ),
270 'return_value' => 'yes',
271 'default' => 'no',
272 'condition' => [
273 'better_payment_payment_amount_enable' => 'yes',
274 'better_payment_show_amount_list_enable' => 'yes',
275 ],
276 'separator' => 'before',
277 ]
278 );
279
280 $widget->add_responsive_control(
281 'better_payment_form_fields_amount_width',
282 [
283 'label' => __( 'Input Width', 'better-payment' ),
284 'type' => Controls_Manager::SLIDER,
285 'range' => [
286 'px' => [
287 'min' => 0,
288 'max' => 1200,
289 'step' => 1,
290 ],
291 ],
292 'size_units' => [ 'px', 'em', '%' ],
293 'selectors' => [
294 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'width: {{SIZE}}{{UNIT}}',
295 ],
296 'condition' => [
297 'better_payment_amount_list_style' => 'yes',
298 ],
299 ]
300 );
301
302 $widget->add_responsive_control(
303 'better_payment_form_fields_amount_height',
304 [
305 'label' => __( 'Input Height', 'better-payment' ),
306 'type' => Controls_Manager::SLIDER,
307 'range' => [
308 'px' => [
309 'min' => 0,
310 'max' => 1200,
311 'step' => 1,
312 ],
313 ],
314 'size_units' => [ 'px', 'em', '%' ],
315 'selectors' => [
316 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'height: {{SIZE}}{{UNIT}}',
317 ],
318 'condition' => [
319 'better_payment_amount_list_style' => 'yes',
320 ],
321 ]
322 );
323
324 $widget->add_responsive_control(
325 'better_payment_form_fields_amount_spacing',
326 [
327 'label' => __( 'Spacing', 'better-payment' ),
328 'type' => Controls_Manager::SLIDER,
329 'default' => [
330 'size' => '0',
331 'unit' => 'px',
332 ],
333 'range' => [
334 'px' => [
335 'min' => 0,
336 'max' => 100,
337 'step' => 1,
338 ],
339 ],
340 'size_units' => [ 'px', 'em', '%' ],
341 'selectors' => [
342 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'margin-bottom: {{SIZE}}{{UNIT}}',
343 ],
344 'condition' => [
345 'better_payment_amount_list_style' => 'yes',
346 ],
347 ]
348 );
349
350 $widget->start_controls_tabs( 'better_payment_form_amount_tabs_button_style' );
351
352 $widget->start_controls_tab(
353 'better_payment_form_fields_amount_normal',
354 [
355 'label' => __( 'Normal', 'better-payment' ),
356 'condition' => [
357 'better_payment_amount_list_style' => 'yes',
358 ],
359 ]
360 );
361
362 $widget->add_control(
363 'better_payment_form_fields_amount_normal_bg',
364 [
365 'label' => __( 'Background Color', 'better-payment' ),
366 'type' => Controls_Manager::COLOR,
367 'default' => '',
368 'selectors' => [
369 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'background-color: {{VALUE}}',
370 ],
371 'condition' => [
372 'better_payment_amount_list_style' => 'yes',
373 ],
374 ]
375 );
376
377 $widget->add_control(
378 'better_payment_form_fields_amount_normal_text_color',
379 [
380 'label' => __( 'Text Color', 'better-payment' ),
381 'type' => Controls_Manager::COLOR,
382 'default' => '',
383 'selectors' => [
384 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'color: {{VALUE}}',
385 ],
386 'condition' => [
387 'better_payment_amount_list_style' => 'yes',
388 ],
389 ]
390 );
391
392 $widget->end_controls_tab();
393
394 $widget->start_controls_tab(
395 'better_payment_form_fields_amount_selected',
396 [
397 'label' => __( 'Selected', 'better-payment' ),
398 'condition' => [
399 'better_payment_amount_list_style' => 'yes',
400 ],
401 ]
402 );
403
404 $widget->add_control(
405 'better_payment_form_fields_amount_selected_bg',
406 [
407 'label' => __( 'Background Color', 'better-payment' ),
408 'type' => Controls_Manager::COLOR,
409 'default' => '',
410 'selectors' => [
411 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group input[type="radio"].bp-form__control:checked ~ label' => 'background-color: {{VALUE}}',
412 ],
413 'condition' => [
414 'better_payment_amount_list_style' => 'yes',
415 ],
416 ]
417 );
418
419 $widget->add_control(
420 'better_payment_form_fields_amount_selected_text_color',
421 [
422 'label' => __( 'Text Color', 'better-payment' ),
423 'type' => Controls_Manager::COLOR,
424 'default' => '',
425 'selectors' => [
426 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group input[type="radio"].bp-form__control:checked ~ label' => 'color: {{VALUE}}',
427 ],
428 'condition' => [
429 'better_payment_amount_list_style' => 'yes',
430 ],
431 ]
432 );
433
434 $widget->end_controls_tab();
435
436 $widget->end_controls_tabs();
437
438 $widget->add_group_control(
439 Group_Control_Border::get_type(),
440 [
441 'name' => 'better_payment_form_fields_amount_border',
442 'label' => __( 'Border', 'better-payment' ),
443 'placeholder' => '1px',
444 'default' => '1px',
445 'selector' => '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label',
446 'separator' => 'before',
447 'condition' => [
448 'better_payment_amount_list_style' => 'yes',
449 ],
450 ]
451 );
452
453 $widget->add_control(
454 'better_payment_form_fields_amount_border_radius',
455 [
456 'label' => __( 'Border Radius', 'better-payment' ),
457 'type' => Controls_Manager::DIMENSIONS,
458 'size_units' => [ 'px', 'em', '%' ],
459 'selectors' => [
460 '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
461 ],
462 'condition' => [
463 'better_payment_amount_list_style' => 'yes',
464 ],
465 ]
466 );
467
468 $widget->add_group_control(
469 Group_Control_Typography::get_type(),
470 [
471 'name' => 'better_payment_form_fields_amount_typography',
472 'label' => __( 'Typography', 'better-payment' ),
473 'selector' => '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label',
474 'separator' => 'before',
475 'condition' => [
476 'better_payment_amount_list_style' => 'yes',
477 ],
478 ]
479 );
480
481 $widget->add_group_control(
482 Group_Control_Box_Shadow::get_type(),
483 [
484 'name' => 'better_payment_form_fields_amount_box_shadow',
485 'selector' => '{{WRAPPER}} .payment-form-layout .bp-payment-amount-wrap .bp-form__group label',
486 'condition' => [
487 'better_payment_amount_list_style' => 'yes',
488 ],
489 ]
490 );
491
492 $widget->end_controls_section();
493 }
494
495 /**
496 * @param array $element
497 * @return array
498 */
499 public function on_export( $element ) {
500 unset(
501 $element[ 'settings' ][ 'better_payment_payment_amount_enable' ]
502 );
503
504 return $element;
505 }
506
507 /**
508 * @param Form_Record $record
509 * @param Ajax_Handler $ajax_handler
510 */
511 public function run( $record, $ajax_handler ) {
512 //Silence is golden!
513 wp_enqueue_style( 'better-payment-el' );
514 wp_enqueue_style( 'bp-icon-front' );
515 wp_enqueue_style( 'better-payment-style' );
516 wp_enqueue_style( 'better-payment-common-style' );
517 wp_enqueue_style( 'better-payment-admin-style' );
518
519 wp_enqueue_script( 'better-payment-common-script' );
520 wp_enqueue_script( 'better-payment' );
521 }
522 }
523
524
525