| 1 |
<?php |
| 2 |
|
| 3 |
namespace Better_Payment\Lite\Admin\Elementor; |
| 4 |
|
| 5 |
use Better_Payment\Lite\Admin\Elementor\Form_Actions\Better_Payment_Payment_Amount_Field; |
| 6 |
use Better_Payment\Lite\Admin\Elementor\Form_Actions\Better_Payment_Payment_Amount_Integration; |
| 7 |
use Better_Payment\Lite\Admin\Elementor\Form_Actions\Better_Payment_Paypal_Integration; |
| 8 |
use Better_Payment\Lite\Admin\Elementor\Form_Actions\Better_Payment_Stripe_Integration; |
| 9 |
use Better_Payment\Lite\Classes\Better_Payment_Handler; |
| 10 |
|
| 11 |
/** |
| 12 |
* Exit if accessed directly |
| 13 |
*/ |
| 14 |
if (!defined('ABSPATH')) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* The elementor integration class |
| 20 |
* |
| 21 |
* @since 0.0.1 |
| 22 |
*/ |
| 23 |
class Better_Payment_EL_Integration { |
| 24 |
|
| 25 |
private $payment_amount = 'payment_amount'; |
| 26 |
|
| 27 |
/** |
| 28 |
* Init |
| 29 |
* |
| 30 |
* @since 0.0.1 |
| 31 |
*/ |
| 32 |
public function init() { |
| 33 |
add_action( 'elementor/widgets/register', array( $this, 'register_widget' ) ); |
| 34 |
add_action( 'elementor/widgets/register', [ $this, 'elementor_form_integration' ], 10 ); |
| 35 |
add_action( 'elementor-pro/forms/pre_render', [ $this, 'elementor_pro_form_response' ], 10, 2 ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Register widget |
| 40 |
* |
| 41 |
* @since 0.0.1 |
| 42 |
*/ |
| 43 |
public function register_widget( $widgets_manager ) { |
| 44 |
$widgets_manager->register_widget_type( new Better_Payment_Widget() ); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Elementor form integration |
| 49 |
* |
| 50 |
* @since 0.0.1 |
| 51 |
*/ |
| 52 |
public function elementor_form_integration() { |
| 53 |
if(!defined('ELEMENTOR_PRO_VERSION')){ |
| 54 |
return false; |
| 55 |
} |
| 56 |
|
| 57 |
wp_enqueue_style( 'better-payment-common-style' ); |
| 58 |
|
| 59 |
\ElementorPro\Modules\Forms\Module::instance()->add_form_action( 'better-payment', new Better_Payment_Payment_Amount_Integration() ); |
| 60 |
\ElementorPro\Modules\Forms\Module::instance()->add_form_action( 'PayPal', new Better_Payment_Paypal_Integration() ); |
| 61 |
\ElementorPro\Modules\Forms\Module::instance()->add_form_action( 'Stripe', new Better_Payment_Stripe_Integration() ); |
| 62 |
\ElementorPro\Modules\Forms\Module::instance()->add_form_field_type( 'payment_amount', new Better_Payment_Payment_Amount_Field() ); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Elementor pro form response |
| 67 |
* |
| 68 |
* @since 0.0.1 |
| 69 |
*/ |
| 70 |
public function elementor_pro_form_response( $settings, $obj ) { |
| 71 |
wp_enqueue_style( 'better-payment-el' ); |
| 72 |
$response = Better_Payment_Handler::manage_response( $settings ); |
| 73 |
if ( $response ) { |
| 74 |
return false; |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
|