1
|
|
|
<?php |
2
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
3
|
|
|
exit; |
4
|
|
|
} |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Invoicing checkout form widget. |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
class WPInv_Checkout_Widget extends WP_Super_Duper { |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Register the widget with WordPress. |
14
|
|
|
* |
15
|
|
|
*/ |
16
|
|
|
public function __construct() { |
17
|
|
|
|
18
|
|
|
$options = array( |
19
|
|
|
'textdomain' => 'invoicing', |
20
|
|
|
'block-icon' => 'admin-site', |
21
|
|
|
'block-category' => 'widgets', |
22
|
|
|
'block-keywords' => "['invoicing','checkout']", |
23
|
|
|
'class_name' => __CLASS__, |
24
|
|
|
'base_id' => 'wpinv_checkout', |
25
|
|
|
'name' => __( 'GetPaid > Checkout', 'invoicing' ), |
26
|
|
|
'widget_ops' => array( |
27
|
|
|
'classname' => 'getpaid-checkout bsui', |
28
|
|
|
'description' => esc_html__( 'Displays a checkout form.', 'invoicing' ), |
29
|
|
|
), |
30
|
|
|
'arguments' => array( |
31
|
|
|
'title' => array( |
32
|
|
|
'title' => __( 'Widget title', 'invoicing' ), |
33
|
|
|
'desc' => __( 'Enter widget title.', 'invoicing' ), |
34
|
|
|
'type' => 'text', |
35
|
|
|
'desc_tip' => true, |
36
|
|
|
'default' => '', |
37
|
|
|
'advanced' => false, |
38
|
|
|
), |
39
|
|
|
), |
40
|
|
|
|
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
parent::__construct( $options ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* The Super block output function. |
48
|
|
|
* |
49
|
|
|
* @param array $args |
50
|
|
|
* @param array $widget_args |
51
|
|
|
* @param string $content |
52
|
|
|
* |
53
|
|
|
* @return mixed|string|bool |
54
|
|
|
*/ |
55
|
|
|
public function output( $args = array(), $widget_args = array(), $content = '' ) { |
56
|
|
|
if ( $this->is_preview() ) { |
57
|
|
|
return $this->get_dummy_preview( $args ); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return wpinv_checkout_form(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function get_dummy_preview( $args ) { |
|
|
|
|
64
|
|
|
$output = '<form><div class="col-12">'; |
65
|
|
|
|
66
|
|
|
$output .= aui()->alert( |
67
|
|
|
array( |
68
|
|
|
'type'=> 'info', |
69
|
|
|
'content' => __( 'This is a simple preview for a checkout form.', 'invoicing' ) |
70
|
|
|
) |
71
|
|
|
); |
72
|
|
|
|
73
|
|
|
$output .= aui()->input( |
74
|
|
|
array( |
75
|
|
|
'name' => 'mmdwqzpox', |
76
|
|
|
'required' => true, |
77
|
|
|
'label' => __( 'Billing Email', 'invoicing' ), |
78
|
|
|
'label_type' => 'vertical', |
79
|
|
|
'type' => 'text', |
80
|
|
|
'placeholder' => '[email protected]', |
81
|
|
|
'class' => '', |
82
|
|
|
'value' => '' |
83
|
|
|
) |
84
|
|
|
); |
85
|
|
|
|
86
|
|
|
$output .= aui()->input( |
87
|
|
|
array( |
88
|
|
|
'name' => 'mmdwqzpoy', |
89
|
|
|
'required' => true, |
90
|
|
|
'label' => __( 'First Name', 'invoicing' ), |
91
|
|
|
'label_type' => 'vertical', |
92
|
|
|
'type' => 'text', |
93
|
|
|
'placeholder' => 'Jon', |
94
|
|
|
'class' => '', |
95
|
|
|
'value' => '' |
96
|
|
|
) |
97
|
|
|
); |
98
|
|
|
|
99
|
|
|
$output .= aui()->input( |
100
|
|
|
array( |
101
|
|
|
'name' => 'mmdwqzpoz', |
102
|
|
|
'required' => true, |
103
|
|
|
'label' => __( 'Last Name', 'invoicing' ), |
104
|
|
|
'label_type' => 'vertical', |
105
|
|
|
'type' => 'text', |
106
|
|
|
'placeholder' => 'Snow', |
107
|
|
|
'class' => '', |
108
|
|
|
'value' => '' |
109
|
|
|
) |
110
|
|
|
); |
111
|
|
|
|
112
|
|
|
$output .= aui()->button( |
113
|
|
|
array( |
114
|
|
|
'type' => 'button', |
115
|
|
|
'class' => 'btn btn-primary w-100', |
116
|
|
|
'content' => __( 'Pay Now »', 'invoicing' ), |
117
|
|
|
'description' => __( 'By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ) |
118
|
|
|
) |
119
|
|
|
); |
120
|
|
|
|
121
|
|
|
$output .= '</div></form>'; |
122
|
|
|
|
123
|
|
|
return $output; |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.