1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
4
|
|
|
exit; // Exit if accessed directly |
5
|
|
|
} |
6
|
|
|
|
7
|
|
|
class WPInv_Payment_Form_Elements { |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @param array payment form elements |
11
|
|
|
*/ |
12
|
|
|
protected $elements; |
13
|
|
|
|
14
|
|
|
public function __construct() { |
15
|
|
|
|
16
|
|
|
foreach( $this->get_elements() as $element ) { |
17
|
|
|
$element = $element['type']; |
18
|
|
|
|
19
|
|
|
if ( method_exists( $this, "render_{$element}_template" ) ) { |
20
|
|
|
add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 ); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
if ( method_exists( $this, "edit_{$element}_template" ) ) { |
24
|
|
|
add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 ); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
if ( method_exists( $this, "frontend_render_{$element}_template" ) ) { |
28
|
|
|
add_action( "wpinv_frontend_render_payment_form_$element", array( $this, "frontend_render_{$element}_template" ), 10, 3 ); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Returns all the elements that can be added to a form. |
37
|
|
|
*/ |
38
|
|
|
public function get_elements() { |
39
|
|
|
|
40
|
|
|
if ( ! empty( $this->elements ) ) { |
41
|
|
|
return $this->elements; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$this->elements = array( |
45
|
|
|
|
46
|
|
|
array( |
47
|
|
|
'type' => 'heading', |
48
|
|
|
'name' => __( 'Heading', 'invoicing' ), |
49
|
|
|
'defaults' => array( |
50
|
|
|
'level' => 'h2', |
51
|
|
|
'text' => __( 'Heading', 'invoicing' ), |
52
|
|
|
) |
53
|
|
|
), |
54
|
|
|
|
55
|
|
|
array( |
56
|
|
|
'type' => 'paragraph', |
57
|
|
|
'name' => __( 'Paragraph', 'invoicing' ), |
58
|
|
|
'defaults' => array( |
59
|
|
|
'text' => __( 'Paragraph text', 'invoicing' ), |
60
|
|
|
) |
61
|
|
|
), |
62
|
|
|
|
63
|
|
|
array( |
64
|
|
|
'type' => 'alert', |
65
|
|
|
'name' => __( 'Alert', 'invoicing' ), |
66
|
|
|
'defaults' => array( |
67
|
|
|
'value' => '', |
68
|
|
|
'class' => 'alert-warning', |
69
|
|
|
'text' => __( 'Alert', 'invoicing' ), |
70
|
|
|
'dismissible' => false, |
71
|
|
|
) |
72
|
|
|
), |
73
|
|
|
|
74
|
|
|
/*array( |
75
|
|
|
'type' => 'separator', |
76
|
|
|
'name' => __( 'Separator', 'invoicing' ), |
77
|
|
|
'defaults' => array( |
78
|
|
|
'value' => '', |
79
|
|
|
'dismissible' => false, |
80
|
|
|
) |
81
|
|
|
),*/ |
82
|
|
|
|
83
|
|
|
array( |
84
|
|
|
'type' => 'text', |
85
|
|
|
'name' => __( 'Text Input', 'invoicing' ), |
86
|
|
|
'defaults' => array( |
87
|
|
|
'placeholder' => __( 'Enter some text', 'invoicing' ), |
88
|
|
|
'value' => '', |
89
|
|
|
'label' => __( 'Field Label', 'invoicing' ), |
90
|
|
|
'description' => '', |
91
|
|
|
'required' => false, |
92
|
|
|
) |
93
|
|
|
), |
94
|
|
|
|
95
|
|
|
array( |
96
|
|
|
'type' => 'textarea', |
97
|
|
|
'name' => __( 'Textarea', 'invoicing' ), |
98
|
|
|
'defaults' => array( |
99
|
|
|
'placeholder' => __( 'Enter your text hear', 'invoicing' ), |
100
|
|
|
'value' => '', |
101
|
|
|
'label' => __( 'Textarea Label', 'invoicing' ), |
102
|
|
|
'description' => '', |
103
|
|
|
'required' => false, |
104
|
|
|
) |
105
|
|
|
), |
106
|
|
|
|
107
|
|
|
array( |
108
|
|
|
'type' => 'select', |
109
|
|
|
'name' => __( 'Dropdown', 'invoicing' ), |
110
|
|
|
'defaults' => array( |
111
|
|
|
'placeholder' => __( 'Select a value', 'invoicing' ), |
112
|
|
|
'value' => '', |
113
|
|
|
'label' => __( 'Dropdown Label', 'invoicing' ), |
114
|
|
|
'description' => '', |
115
|
|
|
'required' => false, |
116
|
|
|
'options' => array( |
117
|
|
|
esc_attr__( 'Option One', 'invoicing' ), |
118
|
|
|
esc_attr__( 'Option Two', 'invoicing' ), |
119
|
|
|
esc_attr__( 'Option Three', 'invoicing' ) |
120
|
|
|
), |
121
|
|
|
) |
122
|
|
|
), |
123
|
|
|
|
124
|
|
|
array( |
125
|
|
|
'type' => 'checkbox', |
126
|
|
|
'name' => __( 'Checkbox', 'invoicing' ), |
127
|
|
|
'defaults' => array( |
128
|
|
|
'value' => '', |
129
|
|
|
'label' => __( 'Checkbox Label', 'invoicing' ), |
130
|
|
|
'description' => '', |
131
|
|
|
'required' => false, |
132
|
|
|
) |
133
|
|
|
), |
134
|
|
|
|
135
|
|
|
array( |
136
|
|
|
'type' => 'radio', |
137
|
|
|
'name' => __( 'Multiple Choice', 'invoicing' ), |
138
|
|
|
'defaults' => array( |
139
|
|
|
'label' => __( 'Select one choice', 'invoicing' ), |
140
|
|
|
'options' => array( |
141
|
|
|
esc_attr__( 'Choice One', 'invoicing' ), |
142
|
|
|
esc_attr__( 'Choice Two', 'invoicing' ), |
143
|
|
|
esc_attr__( 'Choice Three', 'invoicing' ) |
144
|
|
|
), |
145
|
|
|
) |
146
|
|
|
), |
147
|
|
|
|
148
|
|
|
array( |
149
|
|
|
'type' => 'date', |
150
|
|
|
'name' => __( 'Date', 'invoicing' ), |
151
|
|
|
'defaults' => array( |
152
|
|
|
'placeholder' => '', |
153
|
|
|
'value' => '', |
154
|
|
|
'label' => __( 'Date', 'invoicing' ), |
155
|
|
|
'description' => '', |
156
|
|
|
'required' => false, |
157
|
|
|
) |
158
|
|
|
), |
159
|
|
|
|
160
|
|
|
array( |
161
|
|
|
'type' => 'time', |
162
|
|
|
'name' => __( 'Time', 'invoicing' ), |
163
|
|
|
'defaults' => array( |
164
|
|
|
'placeholder' => '', |
165
|
|
|
'value' => '', |
166
|
|
|
'label' => __( 'Time', 'invoicing' ), |
167
|
|
|
'description' => '', |
168
|
|
|
'required' => false, |
169
|
|
|
) |
170
|
|
|
), |
171
|
|
|
|
172
|
|
|
array( |
173
|
|
|
'type' => 'number', |
174
|
|
|
'name' => __( 'Number', 'invoicing' ), |
175
|
|
|
'defaults' => array( |
176
|
|
|
'placeholder' => '', |
177
|
|
|
'value' => '', |
178
|
|
|
'label' => __( 'Number', 'invoicing' ), |
179
|
|
|
'description' => '', |
180
|
|
|
'required' => false, |
181
|
|
|
) |
182
|
|
|
), |
183
|
|
|
|
184
|
|
|
array( |
185
|
|
|
'type' => 'website', |
186
|
|
|
'name' => __( 'Website', 'invoicing' ), |
187
|
|
|
'defaults' => array( |
188
|
|
|
'placeholder' => 'http://example.com', |
189
|
|
|
'value' => '', |
190
|
|
|
'label' => __( 'Website', 'invoicing' ), |
191
|
|
|
'description' => '', |
192
|
|
|
'required' => false, |
193
|
|
|
) |
194
|
|
|
), |
195
|
|
|
|
196
|
|
|
array( |
197
|
|
|
'type' => 'email', |
198
|
|
|
'name' => __( 'Email', 'invoicing' ), |
199
|
|
|
'defaults' => array( |
200
|
|
|
'placeholder' => '[email protected]', |
201
|
|
|
'value' => '', |
202
|
|
|
'label' => __( 'Email Address', 'invoicing' ), |
203
|
|
|
'description' => '', |
204
|
|
|
'required' => false, |
205
|
|
|
) |
206
|
|
|
), |
207
|
|
|
|
208
|
|
|
array( |
209
|
|
|
'type' => 'billing_email', |
210
|
|
|
'name' => __( 'Billing Email', 'invoicing' ), |
211
|
|
|
'defaults' => array( |
212
|
|
|
'placeholder' => '[email protected]', |
213
|
|
|
'value' => '', |
214
|
|
|
'label' => __( 'Billing Email', 'invoicing' ), |
215
|
|
|
'description' => '', |
216
|
|
|
'premade' => true, |
217
|
|
|
) |
218
|
|
|
), |
219
|
|
|
/* |
220
|
|
|
array( |
221
|
|
|
'type' => 'discount', |
222
|
|
|
'name' => __( 'Discount Input', 'invoicing' ), |
223
|
|
|
'defaults' => array( |
224
|
|
|
'value' => '', |
225
|
|
|
'input_label' => __( 'Coupon Code', 'invoicing' ), |
226
|
|
|
'button_label' => __( 'Apply Coupon', 'invoicing' ), |
227
|
|
|
'description' => __( 'Have a discount code? Enter it above.', 'invoicing' ), |
228
|
|
|
) |
229
|
|
|
),*/ |
230
|
|
|
|
231
|
|
|
array( |
232
|
|
|
'type' => 'items', |
233
|
|
|
'name' => __( 'Items', 'invoicing' ), |
234
|
|
|
'defaults' => array( |
235
|
|
|
'value' => '', |
236
|
|
|
'items_type' => 'total', |
237
|
|
|
'description' => '', |
238
|
|
|
'premade' => true, |
239
|
|
|
) |
240
|
|
|
), |
241
|
|
|
|
242
|
|
|
array( |
243
|
|
|
'type' => 'pay_button', |
244
|
|
|
'name' => __( 'Payment Button', 'invoicing' ), |
245
|
|
|
'defaults' => array( |
246
|
|
|
'value' => '', |
247
|
|
|
'class' => 'btn-primary', |
248
|
|
|
'label' => __( 'Pay Now »', 'invoicing' ), |
249
|
|
|
'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
250
|
|
|
'premade' => true, |
251
|
|
|
) |
252
|
|
|
) |
253
|
|
|
); |
254
|
|
|
|
255
|
|
|
$this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements ); |
256
|
|
|
return $this->elements; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* Returns the restrict markup. |
261
|
|
|
*/ |
262
|
|
|
public function get_restrict_markup( $field, $field_type ) { |
263
|
|
|
$restrict = "$field.type=='$field_type'"; |
264
|
|
|
return "v-if=\"$restrict\""; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* Renders the title element template. |
269
|
|
|
*/ |
270
|
|
|
public function render_heading_template( $field ) { |
271
|
|
|
$restrict = $this->get_restrict_markup( $field, 'heading' ); |
272
|
|
|
echo "<component :is='$field.level' $restrict v-html='$field.text'></component>"; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* Renders the title element on the frontend. |
277
|
|
|
*/ |
278
|
|
|
public function frontend_render_heading_template( $field ) { |
279
|
|
|
$tag = $field['level']; |
280
|
|
|
echo "<$tag>{$field['text']}</$tag>"; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Renders the edit title element template. |
285
|
|
|
*/ |
286
|
|
|
public function edit_heading_template( $field ) { |
287
|
|
|
$restrict = $this->get_restrict_markup( $field, 'heading' ); |
288
|
|
|
$label = __( 'Heading', 'invoicing' ); |
289
|
|
|
$label2 = __( 'Select Heading Level', 'invoicing' ); |
290
|
|
|
$id = $field . '.id + "_edit"'; |
291
|
|
|
$id2 = $field . '.id + "_edit2"'; |
292
|
|
|
|
293
|
|
|
echo " |
294
|
|
|
<div $restrict> |
295
|
|
|
<div class='form-group'> |
296
|
|
|
<label :for='$id'>$label</label> |
297
|
|
|
<input class='form-control' :id='$id' v-model='$field.text' type='text' /> |
298
|
|
|
</div> |
299
|
|
|
|
300
|
|
|
<div class='form-group'> |
301
|
|
|
<label :for='$id2'>$label2</label> |
302
|
|
|
|
303
|
|
|
<select class='form-control custom-select' :id='$id2' v-model='$field.level'> |
304
|
|
|
<option value='h1'>H1</option> |
305
|
|
|
<option value='h2'>H2</option> |
306
|
|
|
<option value='h3'>H3</option> |
307
|
|
|
<option value='h4'>H4</option> |
308
|
|
|
<option value='h5'>H5</option> |
309
|
|
|
<option value='h6'>H6</option> |
310
|
|
|
<option value='h7'>H7</option> |
311
|
|
|
</select> |
312
|
|
|
</div> |
313
|
|
|
</div> |
314
|
|
|
"; |
315
|
|
|
|
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* Renders a paragraph element template. |
320
|
|
|
*/ |
321
|
|
|
public function render_paragraph_template( $field ) { |
322
|
|
|
$restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
323
|
|
|
$label = "$field.text"; |
324
|
|
|
echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>"; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* Renders the paragraph element on the frontend. |
329
|
|
|
*/ |
330
|
|
|
public function frontend_render_paragraph_template( $field ) { |
331
|
|
|
echo "<p>{$field['text']}</p>"; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* Renders the edit paragraph element template. |
336
|
|
|
*/ |
337
|
|
|
public function edit_paragraph_template( $field ) { |
338
|
|
|
$restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
339
|
|
|
$label = __( 'Enter your text', 'invoicing' ); |
340
|
|
|
$id = $field . '.id + "_edit"'; |
341
|
|
|
echo " |
342
|
|
|
<div $restrict> |
343
|
|
|
<div class='form-group'> |
344
|
|
|
<label :for='$id'>$label</label> |
345
|
|
|
<textarea :id='$id' v-model='$field.text' class='form-control' rows='3'></textarea> |
346
|
|
|
</div> |
347
|
|
|
</div> |
348
|
|
|
"; |
349
|
|
|
|
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
/** |
353
|
|
|
* Renders the text element template. |
354
|
|
|
*/ |
355
|
|
|
public function render_text_template( $field ) { |
356
|
|
|
$restrict = $this->get_restrict_markup( $field, 'text' ); |
357
|
|
|
$label = "$field.label"; |
358
|
|
|
echo " |
359
|
|
|
<div $restrict> |
360
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
361
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='text'> |
362
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
363
|
|
|
</div> |
364
|
|
|
"; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* Renders the text element on the frontend. |
369
|
|
|
*/ |
370
|
|
|
public function frontend_render_text_template( $field ) { |
371
|
|
|
|
372
|
|
|
echo "<div class='form-group'>"; |
373
|
|
|
|
374
|
|
|
echo aui()->input( |
|
|
|
|
375
|
|
|
array( |
376
|
|
|
'name' => esc_attr( $field['id'] ), |
377
|
|
|
'id' => esc_attr( $field['id'] ), |
378
|
|
|
'placeholder'=> esc_attr( $field['placeholder'] ), |
379
|
|
|
'required' => (bool) $field['required'], |
380
|
|
|
'label' => wp_kses_post( $field['label'] ), |
381
|
|
|
'no_wrap' => true, |
382
|
|
|
) |
383
|
|
|
); |
384
|
|
|
|
385
|
|
|
if ( ! empty( $field['description'] ) ) { |
386
|
|
|
$description = wp_kses_post( $field['description'] ); |
387
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
echo '</div>'; |
391
|
|
|
|
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* Renders the edit text element template. |
396
|
|
|
*/ |
397
|
|
|
public function edit_text_template( $field ) { |
398
|
|
|
$restrict = $this->get_restrict_markup( $field, 'text' ); |
399
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
400
|
|
|
$id = $field . '.id + "_edit"'; |
401
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
402
|
|
|
$id2 = $field . '.id + "_edit2"'; |
403
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
404
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
405
|
|
|
$id3 = $field . '.id + "_edit3"'; |
406
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
407
|
|
|
$id4 = $field . '.id + "_edit4"'; |
408
|
|
|
echo " |
409
|
|
|
<div $restrict> |
410
|
|
|
<div class='form-group'> |
411
|
|
|
<label :for='$id'>$label</label> |
412
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
413
|
|
|
</div> |
414
|
|
|
<div class='form-group'> |
415
|
|
|
<label :for='$id2'>$label2</label> |
416
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
417
|
|
|
</div> |
418
|
|
|
<div class='form-group'> |
419
|
|
|
<label :for='$id3'>$label3</label> |
420
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
421
|
|
|
</div> |
422
|
|
|
<div class='form-group form-check'> |
423
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
424
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
425
|
|
|
</div> |
426
|
|
|
</div> |
427
|
|
|
"; |
428
|
|
|
|
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* Renders the textarea element template. |
433
|
|
|
*/ |
434
|
|
|
public function render_textarea_template( $field ) { |
435
|
|
|
$restrict = $this->get_restrict_markup( $field, 'textarea' ); |
436
|
|
|
$label = "$field.label"; |
437
|
|
|
echo " |
438
|
|
|
<div $restrict> |
439
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
440
|
|
|
<textarea :placeholder='$field.placeholder' :id='$field.id' class='form-control' rows='3'></textarea> |
441
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
442
|
|
|
</div> |
443
|
|
|
"; |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* Renders the textarea element on the frontend. |
448
|
|
|
*/ |
449
|
|
|
public function frontend_render_textarea_template( $field ) { |
450
|
|
|
|
451
|
|
|
echo "<div class='form-group'>"; |
452
|
|
|
|
453
|
|
|
echo aui()->textarea( |
|
|
|
|
454
|
|
|
array( |
455
|
|
|
'name' => esc_attr( $field['id'] ), |
456
|
|
|
'id' => esc_attr( $field['id'] ), |
457
|
|
|
'placeholder'=> esc_attr( $field['placeholder'] ), |
458
|
|
|
'required' => (bool) $field['required'], |
459
|
|
|
'label' => wp_kses_post( $field['label'] ), |
460
|
|
|
'no_wrap' => true, |
461
|
|
|
'rows' => 3, |
462
|
|
|
) |
463
|
|
|
); |
464
|
|
|
|
465
|
|
|
if ( ! empty( $field['description'] ) ) { |
466
|
|
|
$description = wp_kses_post( $field['description'] ); |
467
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
echo '</div>'; |
471
|
|
|
|
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
/** |
475
|
|
|
* Renders the edit textarea element template. |
476
|
|
|
*/ |
477
|
|
|
public function edit_textarea_template( $field ) { |
478
|
|
|
$restrict = $this->get_restrict_markup( $field, 'textarea' ); |
479
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
480
|
|
|
$id = $field . '.id + "_edit"'; |
481
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
482
|
|
|
$id2 = $field . '.id + "_edit2"'; |
483
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
484
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
485
|
|
|
$id3 = $field . '.id + "_edit3"'; |
486
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
487
|
|
|
$id4 = $field . '.id + "_edit4"'; |
488
|
|
|
echo " |
489
|
|
|
<div $restrict> |
490
|
|
|
<div class='form-group'> |
491
|
|
|
<label :for='$id'>$label</label> |
492
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
493
|
|
|
</div> |
494
|
|
|
<div class='form-group'> |
495
|
|
|
<label :for='$id2'>$label2</label> |
496
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
497
|
|
|
</div> |
498
|
|
|
<div class='form-group'> |
499
|
|
|
<label :for='$id3'>$label3</label> |
500
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
501
|
|
|
</div> |
502
|
|
|
<div class='form-group form-check'> |
503
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
504
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
505
|
|
|
</div> |
506
|
|
|
</div> |
507
|
|
|
"; |
508
|
|
|
|
509
|
|
|
} |
510
|
|
|
|
511
|
|
|
/** |
512
|
|
|
* Renders the select element template. |
513
|
|
|
*/ |
514
|
|
|
public function render_select_template( $field ) { |
515
|
|
|
$restrict = $this->get_restrict_markup( $field, 'select' ); |
516
|
|
|
$label = "$field.label"; |
517
|
|
|
$placeholder = "$field.placeholder"; |
518
|
|
|
$id = $field . '.id'; |
519
|
|
|
echo " |
520
|
|
|
<div $restrict> |
521
|
|
|
<label :for='$id'>{{" . $label . "}}</label> |
522
|
|
|
<select id='$id' class='form-control custom-select' v-model='$field.value'> |
523
|
|
|
<option v-if='$placeholder' value='' disabled>{{" . $placeholder . "}}</option> |
524
|
|
|
<option v-for='option in $field.options' value='option'>{{option}}</option> |
525
|
|
|
</select> |
526
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
527
|
|
|
</div> |
528
|
|
|
"; |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
/** |
532
|
|
|
* Renders the select element on the frontend. |
533
|
|
|
*/ |
534
|
|
|
public function frontend_render_select_template( $field ) { |
535
|
|
|
|
536
|
|
|
echo "<div class='form-group'>"; |
537
|
|
|
|
538
|
|
|
echo aui()->select( |
|
|
|
|
539
|
|
|
array( |
540
|
|
|
'name' => esc_attr( $field['id'] ), |
541
|
|
|
'id' => esc_attr( $field['id'] ), |
542
|
|
|
'placeholder'=> esc_attr( $field['placeholder'] ), |
543
|
|
|
'required' => (bool) $field['required'], |
544
|
|
|
'label' => wp_kses_post( $field['label'] ), |
545
|
|
|
'no_wrap' => true, |
546
|
|
|
'options' => array_combine( $field['options'], $field['options'] ), |
547
|
|
|
) |
548
|
|
|
); |
549
|
|
|
|
550
|
|
|
if ( ! empty( $field['description'] ) ) { |
551
|
|
|
$description = wp_kses_post( $field['description'] ); |
552
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
echo '</div>'; |
556
|
|
|
|
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
/** |
560
|
|
|
* Renders the edit select element template. |
561
|
|
|
*/ |
562
|
|
|
public function edit_select_template( $field ) { |
563
|
|
|
$restrict = $this->get_restrict_markup( $field, 'select' ); |
564
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
565
|
|
|
$id = $field . '.id + "_edit"'; |
566
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
567
|
|
|
$id2 = $field . '.id + "_edit2"'; |
568
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
569
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
570
|
|
|
$id3 = $field . '.id + "_edit3"'; |
571
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
572
|
|
|
$id4 = $field . '.id + "_edit4"'; |
573
|
|
|
$label6 = __( 'Available Options', 'invoicing' ); |
574
|
|
|
echo " |
575
|
|
|
<div $restrict> |
576
|
|
|
<div class='form-group'> |
577
|
|
|
<label :for='$id'>$label</label> |
578
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
579
|
|
|
</div> |
580
|
|
|
<div class='form-group'> |
581
|
|
|
<label :for='$id2'>$label2</label> |
582
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
583
|
|
|
</div> |
584
|
|
|
<div class='form-group'> |
585
|
|
|
<label :for='$id3'>$label3</label> |
586
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
587
|
|
|
</div> |
588
|
|
|
<div class='form-group form-check'> |
589
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
590
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
591
|
|
|
</div> |
592
|
|
|
<hr class='featurette-divider mt-4'> |
593
|
|
|
<h5>$label6</h5> |
594
|
|
|
<div class='form-group input-group' v-for='(option, index) in $field.options'> |
595
|
|
|
<input type='text' class='form-control' v-model='$field.options[index]'> |
596
|
|
|
<div class='input-group-append'> |
597
|
|
|
<button class='button button-secondary border' type='button' @click.prevent='$field.options.splice(index, 1)'><span class='dashicons dashicons-trash'></span></button> |
598
|
|
|
</div> |
599
|
|
|
</div> |
600
|
|
|
<div class='form-group'> |
601
|
|
|
<button class='button button-secondary' type='button' @click.prevent='$field.options.push(\"\")'>Add Option</button> |
602
|
|
|
</div> |
603
|
|
|
</div> |
604
|
|
|
"; |
605
|
|
|
|
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* Renders the checkbox element template. |
610
|
|
|
*/ |
611
|
|
|
public function render_checkbox_template( $field ) { |
612
|
|
|
$restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
613
|
|
|
$label = "$field.label"; |
614
|
|
|
echo " |
615
|
|
|
<div class='form-check' $restrict> |
616
|
|
|
<input :id='$field.id' class='form-check-input' type='checkbox' /> |
617
|
|
|
<label class='form-check-label' :for='$field.id'>{{" . $label . "}}</label> |
618
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
619
|
|
|
</div> |
620
|
|
|
"; |
621
|
|
|
} |
622
|
|
|
|
623
|
|
|
/** |
624
|
|
|
* Renders the checkbox element on the frontend. |
625
|
|
|
*/ |
626
|
|
|
public function frontend_render_checkbox_template( $field ) { |
627
|
|
|
|
628
|
|
|
echo "<div class='form-group'>"; |
629
|
|
|
|
630
|
|
|
echo aui()->input( |
|
|
|
|
631
|
|
|
array( |
632
|
|
|
'name' => esc_attr( $field['id'] ), |
633
|
|
|
'id' => esc_attr( $field['id'] ), |
634
|
|
|
'required' => (bool) $field['required'], |
635
|
|
|
'label' => wp_kses_post( $field['label'] ), |
636
|
|
|
'no_wrap' => true, |
637
|
|
|
'value' => esc_attr__( 'Yes', 'invoicing' ), |
638
|
|
|
'type' => 'checkbox', |
639
|
|
|
) |
640
|
|
|
); |
641
|
|
|
|
642
|
|
|
if ( ! empty( $field['description'] ) ) { |
643
|
|
|
$description = wp_kses_post( $field['description'] ); |
644
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
645
|
|
|
} |
646
|
|
|
|
647
|
|
|
echo '</div>'; |
648
|
|
|
|
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
/** |
652
|
|
|
* Renders the edit checkbox element template. |
653
|
|
|
*/ |
654
|
|
|
public function edit_checkbox_template( $field ) { |
655
|
|
|
$restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
656
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
657
|
|
|
$id = $field . '.id + "_edit"'; |
658
|
|
|
$label2 = __( 'Help text', 'invoicing' ); |
659
|
|
|
$label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
660
|
|
|
$id2 = $field . '.id + "_edit2"'; |
661
|
|
|
$label4 = __( 'Is this field required?', 'invoicing' ); |
662
|
|
|
$id3 = $field . '.id + "_edit3"'; |
663
|
|
|
echo " |
664
|
|
|
<div $restrict> |
665
|
|
|
<div class='form-group'> |
666
|
|
|
<label :for='$id'>$label</label> |
667
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
668
|
|
|
</div> |
669
|
|
|
<div class='form-group'> |
670
|
|
|
<label :for='$id2'>$label2</label> |
671
|
|
|
<textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
672
|
|
|
</div> |
673
|
|
|
<div class='form-group form-check'> |
674
|
|
|
<input :id='$id3' v-model='$field.required' type='checkbox' class='form-check-input' /> |
675
|
|
|
<label class='form-check-label' :for='$id3'>$label4</label> |
676
|
|
|
</div> |
677
|
|
|
</div> |
678
|
|
|
"; |
679
|
|
|
|
680
|
|
|
} |
681
|
|
|
|
682
|
|
|
/** |
683
|
|
|
* Renders the radio element template. |
684
|
|
|
*/ |
685
|
|
|
public function render_radio_template( $field ) { |
686
|
|
|
$restrict = $this->get_restrict_markup( $field, 'radio' ); |
687
|
|
|
$label = "$field.label"; |
688
|
|
|
$id = $field . '.id'; |
689
|
|
|
echo " |
690
|
|
|
<div $restrict> |
691
|
|
|
<legend class='col-form-label' v-if='$label'>{{" . $label . "}}</legend> |
692
|
|
|
<div class='form-check' v-for='(option, index) in $field.options'> |
693
|
|
|
<input class='form-check-input' type='radio' :id='$id + index'> |
694
|
|
|
<label class='form-check-label' :for='$id + index'>{{option}}</label> |
695
|
|
|
</div> |
696
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
697
|
|
|
</div> |
698
|
|
|
"; |
699
|
|
|
} |
700
|
|
|
|
701
|
|
|
/** |
702
|
|
|
* Renders the radio element on the frontend. |
703
|
|
|
*/ |
704
|
|
|
public function frontend_render_radio_template( $field ) { |
705
|
|
|
|
706
|
|
|
echo "<div class='form-group'>"; |
707
|
|
|
|
708
|
|
|
if ( ! empty( $field['label'] ) ) { |
709
|
|
|
$label = wp_kses_post( $field['label'] ); |
710
|
|
|
echo "<legend class='col-form-label'>$label</legend>"; |
711
|
|
|
} |
712
|
|
|
|
713
|
|
|
foreach( $field['options'] as $index => $option ) { |
714
|
|
|
$id = $field['id'] . $index; |
715
|
|
|
$name = $field['id']; |
716
|
|
|
$value = esc_attr( $option ); |
717
|
|
|
$label = wp_kses_post( $option ); |
718
|
|
|
|
719
|
|
|
echo " |
720
|
|
|
<div class='form-check'> |
721
|
|
|
<input class='form-check-input' type='radio' name='$name' id='$id' value='$value'> |
722
|
|
|
<label class='form-check-label' for='$id'>$label</label> |
723
|
|
|
</div> |
724
|
|
|
"; |
725
|
|
|
} |
726
|
|
|
|
727
|
|
|
if ( ! empty( $field['description'] ) ) { |
728
|
|
|
$description = wp_kses_post( $field['description'] ); |
729
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
730
|
|
|
} |
731
|
|
|
|
732
|
|
|
echo '</div>'; |
733
|
|
|
|
734
|
|
|
} |
735
|
|
|
|
736
|
|
|
/** |
737
|
|
|
* Renders the edit radio element template. |
738
|
|
|
*/ |
739
|
|
|
public function edit_radio_template( $field ) { |
740
|
|
|
$restrict = $this->get_restrict_markup( $field, 'radio' ); |
741
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
742
|
|
|
$id = $field . '.id + "_edit"'; |
743
|
|
|
$label2 = __( 'Help text', 'invoicing' ); |
744
|
|
|
$label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
745
|
|
|
$id2 = $field . '.id + "_edit3"'; |
746
|
|
|
$label4 = __( 'Is this field required?', 'invoicing' ); |
747
|
|
|
$id3 = $field . '.id + "_edit4"'; |
748
|
|
|
$label5 = __( 'Available Options', 'invoicing' ); |
749
|
|
|
echo " |
750
|
|
|
<div $restrict> |
751
|
|
|
<div class='form-group'> |
752
|
|
|
<label :for='$id'>$label</label> |
753
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
754
|
|
|
</div> |
755
|
|
|
<div class='form-group'> |
756
|
|
|
<label :for='$id2'>$label2</label> |
757
|
|
|
<textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
758
|
|
|
</div> |
759
|
|
|
<div class='form-group form-check'> |
760
|
|
|
<input :id='$id3' v-model='$field.required' type='checkbox' class='form-check-input' /> |
761
|
|
|
<label class='form-check-label' :for='$id3'>$label4</label> |
762
|
|
|
</div> |
763
|
|
|
<hr class='featurette-divider mt-4'> |
764
|
|
|
<h5>$label5</h5> |
765
|
|
|
<div class='form-group input-group' v-for='(option, index) in $field.options'> |
766
|
|
|
<input type='text' class='form-control' v-model='$field.options[index]'> |
767
|
|
|
<div class='input-group-append'> |
768
|
|
|
<button class='button button-secondary border' type='button' @click.prevent='$field.options.splice(index, 1)'><span class='dashicons dashicons-trash'></span></button> |
769
|
|
|
</div> |
770
|
|
|
</div> |
771
|
|
|
<div class='form-group'> |
772
|
|
|
<button class='button button-secondary' type='button' @click.prevent='$field.options.push(\"\")'>Add Option</button> |
773
|
|
|
</div> |
774
|
|
|
</div> |
775
|
|
|
"; |
776
|
|
|
|
777
|
|
|
} |
778
|
|
|
|
779
|
|
|
/** |
780
|
|
|
* Renders the email element template. |
781
|
|
|
*/ |
782
|
|
|
public function render_email_template( $field ) { |
783
|
|
|
$restrict = $this->get_restrict_markup( $field, 'email' ); |
784
|
|
|
$label = "$field.label"; |
785
|
|
|
echo " |
786
|
|
|
<div $restrict> |
787
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
788
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='email'> |
789
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
790
|
|
|
</div> |
791
|
|
|
"; |
792
|
|
|
} |
793
|
|
|
|
794
|
|
|
/** |
795
|
|
|
* Renders the billing_email element template. |
796
|
|
|
*/ |
797
|
|
|
public function render_billing_email_template( $field ) { |
798
|
|
|
$restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
799
|
|
|
$label = "$field.label"; |
800
|
|
|
echo " |
801
|
|
|
<div $restrict> |
802
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
803
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='email'> |
804
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
805
|
|
|
</div> |
806
|
|
|
"; |
807
|
|
|
} |
808
|
|
|
|
809
|
|
|
/** |
810
|
|
|
* Renders the email element on the frontend. |
811
|
|
|
*/ |
812
|
|
|
public function frontend_render_email_template( $field ) { |
813
|
|
|
|
814
|
|
|
echo "<div class='form-group'>"; |
815
|
|
|
|
816
|
|
|
echo aui()->input( |
|
|
|
|
817
|
|
|
array( |
818
|
|
|
'name' => esc_attr( $field['id'] ), |
819
|
|
|
'id' => esc_attr( $field['id'] ), |
820
|
|
|
'required' => (bool) $field['required'], |
821
|
|
|
'label' => wp_kses_post( $field['label'] ), |
822
|
|
|
'no_wrap' => true, |
823
|
|
|
'placeholder' => esc_attr( $field['placeholder'] ), |
824
|
|
|
'type' => 'email', |
825
|
|
|
) |
826
|
|
|
); |
827
|
|
|
|
828
|
|
|
if ( ! empty( $field['description'] ) ) { |
829
|
|
|
$description = wp_kses_post( $field['description'] ); |
830
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
831
|
|
|
} |
832
|
|
|
|
833
|
|
|
echo '</div>'; |
834
|
|
|
|
835
|
|
|
} |
836
|
|
|
|
837
|
|
|
/** |
838
|
|
|
* Renders the billing email element on the frontend. |
839
|
|
|
*/ |
840
|
|
|
public function frontend_render_billing_email_template( $field ) { |
841
|
|
|
|
842
|
|
|
echo "<div class='form-group'>"; |
843
|
|
|
$value = ''; |
844
|
|
|
|
845
|
|
|
if ( is_user_logged_in() ) { |
846
|
|
|
$user = wp_get_current_user(); |
847
|
|
|
$value = sanitize_email( $user->user_email ); |
848
|
|
|
} |
849
|
|
|
echo aui()->input( |
|
|
|
|
850
|
|
|
array( |
851
|
|
|
'name' => 'billing_email', |
852
|
|
|
'value' => $value, |
853
|
|
|
'id' => esc_attr( $field['id'] ), |
854
|
|
|
'required' => true, |
855
|
|
|
'label' => wp_kses_post( $field['label'] ), |
856
|
|
|
'no_wrap' => true, |
857
|
|
|
'placeholder' => esc_attr( $field['placeholder'] ), |
858
|
|
|
'type' => 'email', |
859
|
|
|
) |
860
|
|
|
); |
861
|
|
|
|
862
|
|
|
if ( ! empty( $field['description'] ) ) { |
863
|
|
|
$description = wp_kses_post( $field['description'] ); |
864
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
865
|
|
|
} |
866
|
|
|
|
867
|
|
|
echo '</div>'; |
868
|
|
|
|
869
|
|
|
} |
870
|
|
|
|
871
|
|
|
/** |
872
|
|
|
* Renders the edit email element template. |
873
|
|
|
*/ |
874
|
|
|
public function edit_email_template( $field ) { |
875
|
|
|
$restrict = $this->get_restrict_markup( $field, 'email' ); |
876
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
877
|
|
|
$id = $field . '.id + "_edit"'; |
878
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
879
|
|
|
$id2 = $field . '.id + "_edit2"'; |
880
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
881
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
882
|
|
|
$id3 = $field . '.id + "_edit3"'; |
883
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
884
|
|
|
$id4 = $field . '.id + "_edit4"'; |
885
|
|
|
echo " |
886
|
|
|
<div $restrict> |
887
|
|
|
<div class='form-group'> |
888
|
|
|
<label :for='$id'>$label</label> |
889
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
890
|
|
|
</div> |
891
|
|
|
<div class='form-group'> |
892
|
|
|
<label :for='$id2'>$label2</label> |
893
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
894
|
|
|
</div> |
895
|
|
|
<div class='form-group'> |
896
|
|
|
<label :for='$id3'>$label3</label> |
897
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
898
|
|
|
</div> |
899
|
|
|
<div class='form-group form-check'> |
900
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
901
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
902
|
|
|
</div> |
903
|
|
|
</div> |
904
|
|
|
"; |
905
|
|
|
|
906
|
|
|
} |
907
|
|
|
|
908
|
|
|
/** |
909
|
|
|
* Renders the edit billing_email element template. |
910
|
|
|
*/ |
911
|
|
|
public function edit_billing_email_template( $field ) { |
912
|
|
|
$restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
913
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
914
|
|
|
$id = $field . '.id + "_edit"'; |
915
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
916
|
|
|
$id2 = $field . '.id + "_edit2"'; |
917
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
918
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
919
|
|
|
$id3 = $field . '.id + "_edit3"'; |
920
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
|
|
|
|
921
|
|
|
$id4 = $field . '.id + "_edit4"'; |
|
|
|
|
922
|
|
|
echo " |
923
|
|
|
<div $restrict> |
924
|
|
|
<div class='form-group'> |
925
|
|
|
<label :for='$id'>$label</label> |
926
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
927
|
|
|
</div> |
928
|
|
|
<div class='form-group'> |
929
|
|
|
<label :for='$id2'>$label2</label> |
930
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
931
|
|
|
</div> |
932
|
|
|
<div class='form-group'> |
933
|
|
|
<label :for='$id3'>$label3</label> |
934
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
935
|
|
|
</div> |
936
|
|
|
</div> |
937
|
|
|
"; |
938
|
|
|
|
939
|
|
|
} |
940
|
|
|
|
941
|
|
|
/** |
942
|
|
|
* Renders the website element template. |
943
|
|
|
*/ |
944
|
|
|
public function render_website_template( $field ) { |
945
|
|
|
$restrict = $this->get_restrict_markup( $field, 'website' ); |
946
|
|
|
$label = "$field.label"; |
947
|
|
|
echo " |
948
|
|
|
<div $restrict> |
949
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
950
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='url'> |
951
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
952
|
|
|
</div> |
953
|
|
|
"; |
954
|
|
|
} |
955
|
|
|
|
956
|
|
|
/** |
957
|
|
|
* Renders the website element on the frontend. |
958
|
|
|
*/ |
959
|
|
|
public function frontend_render_website_template( $field ) { |
960
|
|
|
|
961
|
|
|
echo "<div class='form-group'>"; |
962
|
|
|
|
963
|
|
|
echo aui()->input( |
|
|
|
|
964
|
|
|
array( |
965
|
|
|
'name' => esc_attr( $field['id'] ), |
966
|
|
|
'id' => esc_attr( $field['id'] ), |
967
|
|
|
'required' => (bool) $field['required'], |
968
|
|
|
'label' => wp_kses_post( $field['label'] ), |
969
|
|
|
'no_wrap' => true, |
970
|
|
|
'placeholder' => esc_attr( $field['placeholder'] ), |
971
|
|
|
'type' => 'url', |
972
|
|
|
) |
973
|
|
|
); |
974
|
|
|
|
975
|
|
|
if ( ! empty( $field['description'] ) ) { |
976
|
|
|
$description = wp_kses_post( $field['description'] ); |
977
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
978
|
|
|
} |
979
|
|
|
|
980
|
|
|
echo '</div>'; |
981
|
|
|
|
982
|
|
|
} |
983
|
|
|
|
984
|
|
|
/** |
985
|
|
|
* Renders the edit website element template. |
986
|
|
|
*/ |
987
|
|
|
public function edit_website_template( $field ) { |
988
|
|
|
$restrict = $this->get_restrict_markup( $field, 'website' ); |
989
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
990
|
|
|
$id = $field . '.id + "_edit"'; |
991
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
992
|
|
|
$id2 = $field . '.id + "_edit2"'; |
993
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
994
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
995
|
|
|
$id3 = $field . '.id + "_edit3"'; |
996
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
997
|
|
|
$id4 = $field . '.id + "_edit4"'; |
998
|
|
|
echo " |
999
|
|
|
<div $restrict> |
1000
|
|
|
<div class='form-group'> |
1001
|
|
|
<label :for='$id'>$label</label> |
1002
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
1003
|
|
|
</div> |
1004
|
|
|
<div class='form-group'> |
1005
|
|
|
<label :for='$id2'>$label2</label> |
1006
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
1007
|
|
|
</div> |
1008
|
|
|
<div class='form-group'> |
1009
|
|
|
<label :for='$id3'>$label3</label> |
1010
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
1011
|
|
|
</div> |
1012
|
|
|
<div class='form-group form-check'> |
1013
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
1014
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
1015
|
|
|
</div> |
1016
|
|
|
</div> |
1017
|
|
|
"; |
1018
|
|
|
|
1019
|
|
|
} |
1020
|
|
|
|
1021
|
|
|
/** |
1022
|
|
|
* Renders the date element template. |
1023
|
|
|
*/ |
1024
|
|
|
public function render_date_template( $field ) { |
1025
|
|
|
$restrict = $this->get_restrict_markup( $field, 'date' ); |
1026
|
|
|
$label = "$field.label"; |
1027
|
|
|
echo " |
1028
|
|
|
<div $restrict> |
1029
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
1030
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='date'> |
1031
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
1032
|
|
|
</div> |
1033
|
|
|
"; |
1034
|
|
|
} |
1035
|
|
|
|
1036
|
|
|
/** |
1037
|
|
|
* Renders the date element on the frontend. |
1038
|
|
|
*/ |
1039
|
|
|
public function frontend_render_date_template( $field ) { |
1040
|
|
|
|
1041
|
|
|
echo "<div class='form-group'>"; |
1042
|
|
|
|
1043
|
|
|
echo aui()->input( |
|
|
|
|
1044
|
|
|
array( |
1045
|
|
|
'name' => esc_attr( $field['id'] ), |
1046
|
|
|
'id' => esc_attr( $field['id'] ), |
1047
|
|
|
'required' => (bool) $field['required'], |
1048
|
|
|
'label' => wp_kses_post( $field['label'] ), |
1049
|
|
|
'placeholder' => esc_attr( $field['placeholder'] ), |
1050
|
|
|
'no_wrap' => true, |
1051
|
|
|
'type' => 'date', |
1052
|
|
|
) |
1053
|
|
|
); |
1054
|
|
|
|
1055
|
|
|
if ( ! empty( $field['description'] ) ) { |
1056
|
|
|
$description = wp_kses_post( $field['description'] ); |
1057
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
1058
|
|
|
} |
1059
|
|
|
|
1060
|
|
|
echo '</div>'; |
1061
|
|
|
|
1062
|
|
|
} |
1063
|
|
|
|
1064
|
|
|
/** |
1065
|
|
|
* Renders the edit date element template. |
1066
|
|
|
*/ |
1067
|
|
|
public function edit_date_template( $field ) { |
1068
|
|
|
$restrict = $this->get_restrict_markup( $field, 'date' ); |
1069
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
1070
|
|
|
$id = $field . '.id + "_edit"'; |
1071
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
1072
|
|
|
$id2 = $field . '.id + "_edit2"'; |
1073
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
1074
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
1075
|
|
|
$id3 = $field . '.id + "_edit3"'; |
1076
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
1077
|
|
|
$id4 = $field . '.id + "_edit4"'; |
1078
|
|
|
echo " |
1079
|
|
|
<div $restrict> |
1080
|
|
|
<div class='form-group'> |
1081
|
|
|
<label :for='$id'>$label</label> |
1082
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
1083
|
|
|
</div> |
1084
|
|
|
<div class='form-group'> |
1085
|
|
|
<label :for='$id2'>$label2</label> |
1086
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
1087
|
|
|
</div> |
1088
|
|
|
<div class='form-group'> |
1089
|
|
|
<label :for='$id3'>$label3</label> |
1090
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
1091
|
|
|
</div> |
1092
|
|
|
<div class='form-group form-check'> |
1093
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
1094
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
1095
|
|
|
</div> |
1096
|
|
|
</div> |
1097
|
|
|
"; |
1098
|
|
|
|
1099
|
|
|
} |
1100
|
|
|
|
1101
|
|
|
/** |
1102
|
|
|
* Renders the time element template. |
1103
|
|
|
*/ |
1104
|
|
|
public function render_time_template( $field ) { |
1105
|
|
|
$restrict = $this->get_restrict_markup( $field, 'time' ); |
1106
|
|
|
$label = "$field.label"; |
1107
|
|
|
echo " |
1108
|
|
|
<div $restrict> |
1109
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
1110
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='time'> |
1111
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
1112
|
|
|
</div> |
1113
|
|
|
"; |
1114
|
|
|
} |
1115
|
|
|
|
1116
|
|
|
/** |
1117
|
|
|
* Renders the time element on the frontend. |
1118
|
|
|
*/ |
1119
|
|
|
public function frontend_render_time_template( $field ) { |
1120
|
|
|
|
1121
|
|
|
echo "<div class='form-group'>"; |
1122
|
|
|
|
1123
|
|
|
echo aui()->input( |
|
|
|
|
1124
|
|
|
array( |
1125
|
|
|
'name' => esc_attr( $field['id'] ), |
1126
|
|
|
'id' => esc_attr( $field['id'] ), |
1127
|
|
|
'required' => (bool) $field['required'], |
1128
|
|
|
'label' => wp_kses_post( $field['label'] ), |
1129
|
|
|
'no_wrap' => true, |
1130
|
|
|
'placeholder' => esc_attr( $field['placeholder'] ), |
1131
|
|
|
'type' => 'time', |
1132
|
|
|
) |
1133
|
|
|
); |
1134
|
|
|
|
1135
|
|
|
if ( ! empty( $field['description'] ) ) { |
1136
|
|
|
$description = wp_kses_post( $field['description'] ); |
1137
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
1138
|
|
|
} |
1139
|
|
|
|
1140
|
|
|
echo '</div>'; |
1141
|
|
|
|
1142
|
|
|
} |
1143
|
|
|
|
1144
|
|
|
/** |
1145
|
|
|
* Renders the edit time element template. |
1146
|
|
|
*/ |
1147
|
|
|
public function edit_time_template( $field ) { |
1148
|
|
|
$restrict = $this->get_restrict_markup( $field, 'time' ); |
1149
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
1150
|
|
|
$id = $field . '.id + "_edit"'; |
1151
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
1152
|
|
|
$id2 = $field . '.id + "_edit2"'; |
1153
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
1154
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
1155
|
|
|
$id3 = $field . '.id + "_edit3"'; |
1156
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
1157
|
|
|
$id4 = $field . '.id + "_edit4"'; |
1158
|
|
|
echo " |
1159
|
|
|
<div $restrict> |
1160
|
|
|
<div class='form-group'> |
1161
|
|
|
<label :for='$id'>$label</label> |
1162
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
1163
|
|
|
</div> |
1164
|
|
|
<div class='form-group'> |
1165
|
|
|
<label :for='$id2'>$label2</label> |
1166
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
1167
|
|
|
</div> |
1168
|
|
|
<div class='form-group'> |
1169
|
|
|
<label :for='$id3'>$label3</label> |
1170
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
1171
|
|
|
</div> |
1172
|
|
|
<div class='form-group form-check'> |
1173
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
1174
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
1175
|
|
|
</div> |
1176
|
|
|
</div> |
1177
|
|
|
"; |
1178
|
|
|
|
1179
|
|
|
} |
1180
|
|
|
|
1181
|
|
|
/** |
1182
|
|
|
* Renders the number element template. |
1183
|
|
|
*/ |
1184
|
|
|
public function render_number_template( $field ) { |
1185
|
|
|
$restrict = $this->get_restrict_markup( $field, 'number' ); |
1186
|
|
|
$label = "$field.label"; |
1187
|
|
|
echo " |
1188
|
|
|
<div $restrict> |
1189
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
1190
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='number'> |
1191
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
1192
|
|
|
</div> |
1193
|
|
|
"; |
1194
|
|
|
} |
1195
|
|
|
|
1196
|
|
|
/** |
1197
|
|
|
* Renders the number element on the frontend. |
1198
|
|
|
*/ |
1199
|
|
|
public function frontend_render_number_template( $field ) { |
1200
|
|
|
|
1201
|
|
|
echo "<div class='form-group'>"; |
1202
|
|
|
|
1203
|
|
|
echo aui()->input( |
|
|
|
|
1204
|
|
|
array( |
1205
|
|
|
'name' => esc_attr( $field['id'] ), |
1206
|
|
|
'id' => esc_attr( $field['id'] ), |
1207
|
|
|
'required' => (bool) $field['required'], |
1208
|
|
|
'label' => wp_kses_post( $field['label'] ), |
1209
|
|
|
'placeholder' => esc_attr( $field['placeholder'] ), |
1210
|
|
|
'no_wrap' => true, |
1211
|
|
|
'type' => 'number', |
1212
|
|
|
) |
1213
|
|
|
); |
1214
|
|
|
|
1215
|
|
|
if ( ! empty( $field['description'] ) ) { |
1216
|
|
|
$description = wp_kses_post( $field['description'] ); |
1217
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
1218
|
|
|
} |
1219
|
|
|
|
1220
|
|
|
echo '</div>'; |
1221
|
|
|
|
1222
|
|
|
} |
1223
|
|
|
|
1224
|
|
|
/** |
1225
|
|
|
* Renders the edit number element template. |
1226
|
|
|
*/ |
1227
|
|
|
public function edit_number_template( $field ) { |
1228
|
|
|
$restrict = $this->get_restrict_markup( $field, 'number' ); |
1229
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
1230
|
|
|
$id = $field . '.id + "_edit"'; |
1231
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
1232
|
|
|
$id2 = $field . '.id + "_edit2"'; |
1233
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
1234
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
1235
|
|
|
$id3 = $field . '.id + "_edit3"'; |
1236
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
1237
|
|
|
$id4 = $field . '.id + "_edit4"'; |
1238
|
|
|
echo " |
1239
|
|
|
<div $restrict> |
1240
|
|
|
<div class='form-group'> |
1241
|
|
|
<label :for='$id'>$label</label> |
1242
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
1243
|
|
|
</div> |
1244
|
|
|
<div class='form-group'> |
1245
|
|
|
<label :for='$id2'>$label2</label> |
1246
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
1247
|
|
|
</div> |
1248
|
|
|
<div class='form-group'> |
1249
|
|
|
<label :for='$id3'>$label3</label> |
1250
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
1251
|
|
|
</div> |
1252
|
|
|
<div class='form-group form-check'> |
1253
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
1254
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
1255
|
|
|
</div> |
1256
|
|
|
</div> |
1257
|
|
|
"; |
1258
|
|
|
|
1259
|
|
|
} |
1260
|
|
|
|
1261
|
|
|
/** |
1262
|
|
|
* Renders the separator element template. |
1263
|
|
|
*/ |
1264
|
|
|
public function render_separator_template( $field ) { |
1265
|
|
|
$restrict = $this->get_restrict_markup( $field, 'separator' ); |
1266
|
|
|
echo "<hr class='featurette-divider mt-0 mb-2' $restrict>"; |
1267
|
|
|
} |
1268
|
|
|
|
1269
|
|
|
/** |
1270
|
|
|
* Renders the separator element on the frontend. |
1271
|
|
|
*/ |
1272
|
|
|
public function frontend_render_separator_template( $field ) { |
1273
|
|
|
echo '<hr class="featurette-divider mt-0 mb-2" />'; |
1274
|
|
|
} |
1275
|
|
|
|
1276
|
|
|
/** |
1277
|
|
|
* Renders the pay button element template. |
1278
|
|
|
*/ |
1279
|
|
|
public function render_pay_button_template( $field ) { |
1280
|
|
|
$restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
1281
|
|
|
$label = "$field.label"; |
1282
|
|
|
echo " |
1283
|
|
|
<div $restrict> |
1284
|
|
|
<button class='form-control btn submit-button' :class='$field.class' type='submit' @click.prevent=''>{{" . $label . "}}</button> |
1285
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
1286
|
|
|
</div> |
1287
|
|
|
"; |
1288
|
|
|
} |
1289
|
|
|
|
1290
|
|
|
/** |
1291
|
|
|
* Renders the pay_button element on the frontend. |
1292
|
|
|
*/ |
1293
|
|
|
public function frontend_render_pay_button_template( $field ) { |
1294
|
|
|
|
1295
|
|
|
echo "<div class='form-group'>"; |
1296
|
|
|
|
1297
|
|
|
$class = 'btn btn-block submit-button ' . sanitize_html_class( $field['class'] ); |
1298
|
|
|
echo aui()->input( |
|
|
|
|
1299
|
|
|
array( |
1300
|
|
|
'name' => esc_attr( $field['id'] ), |
1301
|
|
|
'id' => esc_attr( $field['id'] ), |
1302
|
|
|
'value' => esc_attr( $field['label'] ), |
1303
|
|
|
'no_wrap' => true, |
1304
|
|
|
'type' => 'submit', |
1305
|
|
|
'class' => $class, |
1306
|
|
|
) |
1307
|
|
|
); |
1308
|
|
|
|
1309
|
|
|
if ( ! empty( $field['description'] ) ) { |
1310
|
|
|
$description = wp_kses_post( $field['description'] ); |
1311
|
|
|
echo "<small class='form-text text-muted'>$description</small>"; |
1312
|
|
|
} |
1313
|
|
|
|
1314
|
|
|
echo '</div>'; |
1315
|
|
|
|
1316
|
|
|
} |
1317
|
|
|
|
1318
|
|
|
/** |
1319
|
|
|
* Renders the pay button element template. |
1320
|
|
|
*/ |
1321
|
|
|
public function edit_pay_button_template( $field ) { |
1322
|
|
|
$restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
1323
|
|
|
$label = __( 'Button Text', 'invoicing' ); |
1324
|
|
|
$id = $field . '.id + "_edit"'; |
1325
|
|
|
$label2 = __( 'Help text', 'invoicing' ); |
1326
|
|
|
$label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
1327
|
|
|
$id2 = $field . '.id + "_edit2"'; |
1328
|
|
|
$label4 = esc_attr__( 'Button Type', 'invoicing' ); |
1329
|
|
|
$id3 = $field . '.id + "_edit3"'; |
1330
|
|
|
echo " |
1331
|
|
|
<div $restrict> |
1332
|
|
|
<div class='form-group'> |
1333
|
|
|
<label :for='$id'>$label</label> |
1334
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
1335
|
|
|
</div> |
1336
|
|
|
<div class='form-group'> |
1337
|
|
|
<label :for='$id2'>$label2</label> |
1338
|
|
|
<textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
1339
|
|
|
</div> |
1340
|
|
|
<div class='form-group'> |
1341
|
|
|
<label :for='$id3'>$label4</label> |
1342
|
|
|
|
1343
|
|
|
<select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
1344
|
|
|
<option value='btn-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
1345
|
|
|
<option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
1346
|
|
|
<option value='btn-success'>" . __( 'Success', 'invoicing' ) ."</option> |
1347
|
|
|
<option value='btn-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
1348
|
|
|
<option value='btn-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
1349
|
|
|
<option value='btn-info'>" . __( 'Info', 'invoicing' ) ."</option> |
1350
|
|
|
<option value='btn-light'>" . __( 'Light', 'invoicing' ) ."</option> |
1351
|
|
|
<option value='btn-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
1352
|
|
|
<option value='btn-link'>" . __( 'Link', 'invoicing' ) ."</option> |
1353
|
|
|
</select> |
1354
|
|
|
</div> |
1355
|
|
|
</div> |
1356
|
|
|
"; |
1357
|
|
|
|
1358
|
|
|
} |
1359
|
|
|
|
1360
|
|
|
/** |
1361
|
|
|
* Renders the alert element template. |
1362
|
|
|
*/ |
1363
|
|
|
public function render_alert_template( $field ) { |
1364
|
|
|
$restrict = $this->get_restrict_markup( $field, 'alert' ); |
1365
|
|
|
$text = "$field.text"; |
1366
|
|
|
echo " |
1367
|
|
|
<div $restrict class='alert' :class='$field.class' role='alert'> |
1368
|
|
|
<span v-html='$text'></span> |
1369
|
|
|
<button v-if='$field.dismissible' type='button' class='close' @click.prevent=''> |
1370
|
|
|
<span aria-hidden='true'>×</span> |
1371
|
|
|
</button> |
1372
|
|
|
</div> |
1373
|
|
|
"; |
1374
|
|
|
} |
1375
|
|
|
|
1376
|
|
|
/** |
1377
|
|
|
* Renders the alert element on the frontend. |
1378
|
|
|
*/ |
1379
|
|
|
public function frontend_render_alert_template( $field ) { |
1380
|
|
|
|
1381
|
|
|
echo "<div class='form-group'>"; |
1382
|
|
|
|
1383
|
|
|
echo aui()->alert( |
|
|
|
|
1384
|
|
|
array( |
1385
|
|
|
'content' => wp_kses_post( $field['text'] ), |
1386
|
|
|
'dismissible' => $field['dismissible'], |
1387
|
|
|
'type' => str_replace( 'alert-', '', $field['class'] ), |
1388
|
|
|
) |
1389
|
|
|
); |
1390
|
|
|
|
1391
|
|
|
echo '</div>'; |
1392
|
|
|
|
1393
|
|
|
} |
1394
|
|
|
|
1395
|
|
|
/** |
1396
|
|
|
* Renders the alert element template. |
1397
|
|
|
*/ |
1398
|
|
|
public function edit_alert_template( $field ) { |
1399
|
|
|
$restrict = $this->get_restrict_markup( $field, 'alert' ); |
1400
|
|
|
$label = __( 'Alert Text', 'invoicing' ); |
1401
|
|
|
$label2 = esc_attr__( 'Enter your alert text here', 'invoicing' ); |
1402
|
|
|
$id = $field . '.id + "_edit"'; |
1403
|
|
|
$label3 = __( 'Is Dismissible?', 'invoicing' ); |
1404
|
|
|
$id2 = $field . '.id + "_edit2"'; |
1405
|
|
|
$label4 = esc_attr__( 'Alert Type', 'invoicing' ); |
1406
|
|
|
$id3 = $field . '.id + "_edit3"'; |
1407
|
|
|
echo " |
1408
|
|
|
<div $restrict> |
1409
|
|
|
<div class='form-group'> |
1410
|
|
|
<label :for='$id'>$label</label> |
1411
|
|
|
<textarea placeholder='$label2' :id='$id' v-model='$field.text' class='form-control' rows='3'></textarea> |
1412
|
|
|
</div> |
1413
|
|
|
<div class='form-group form-check'> |
1414
|
|
|
<input :id='$id2' v-model='$field.dismissible' type='checkbox' class='form-check-input' /> |
1415
|
|
|
<label class='form-check-label' :for='$id2'>$label3</label> |
1416
|
|
|
</div> |
1417
|
|
|
<div class='form-group'> |
1418
|
|
|
<label :for='$id3'>$label4</label> |
1419
|
|
|
|
1420
|
|
|
<select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
1421
|
|
|
<option value='alert-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
1422
|
|
|
<option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
1423
|
|
|
<option value='alert-success'>" . __( 'Success', 'invoicing' ) ."</option> |
1424
|
|
|
<option value='alert-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
1425
|
|
|
<option value='alert-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
1426
|
|
|
<option value='alert-info'>" . __( 'Info', 'invoicing' ) ."</option> |
1427
|
|
|
<option value='alert-light'>" . __( 'Light', 'invoicing' ) ."</option> |
1428
|
|
|
<option value='alert-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
1429
|
|
|
</select> |
1430
|
|
|
</div> |
1431
|
|
|
</div> |
1432
|
|
|
"; |
1433
|
|
|
|
1434
|
|
|
} |
1435
|
|
|
|
1436
|
|
|
/** |
1437
|
|
|
* Renders the discount element template. |
1438
|
|
|
*/ |
1439
|
|
|
public function render_discount_template( $field ) { |
1440
|
|
|
$restrict = $this->get_restrict_markup( $field, 'discount' ); |
1441
|
|
|
?> |
1442
|
|
|
|
1443
|
|
|
<div <?php echo $restrict; ?> class="discount_field border rounded p-3"> |
1444
|
|
|
<div class="discount_field_inner d-flex flex-column flex-md-row"> |
1445
|
|
|
<input :placeholder="<?php echo $field ?>.input_label" class="form-control mr-2 mb-2" style="flex: 1;" type="text"> |
1446
|
|
|
<button class="btn btn-secondary submit-button mb-2" type="submit" @click.prevent="">{{<?php echo $field; ?>.button_label}}</button> |
1447
|
|
|
</div> |
1448
|
|
|
<small v-if='<?php echo $field ?>.description' class='form-text text-muted' v-html='<?php echo $field ?>.description'></small> |
1449
|
|
|
</div> |
1450
|
|
|
|
1451
|
|
|
<?php |
1452
|
|
|
} |
1453
|
|
|
|
1454
|
|
|
/** |
1455
|
|
|
* Renders the discount element on the frontend. |
1456
|
|
|
*/ |
1457
|
|
|
public function frontend_render_discount_template( $field ) { |
1458
|
|
|
|
1459
|
|
|
$placeholder = esc_attr( $field['input_label'] ); |
1460
|
|
|
$label = sanitize_text_field( $field['button_label'] ); |
1461
|
|
|
$description = ''; |
1462
|
|
|
|
1463
|
|
|
if ( ! empty( $field['description'] ) ) { |
1464
|
|
|
$description = "<small class='form-text text-muted'>{$field['description']}</small>"; |
1465
|
|
|
} |
1466
|
|
|
?> |
1467
|
|
|
|
1468
|
|
|
<div class="form-group"> |
1469
|
|
|
<div class="discount_field border rounded p-3"> |
1470
|
|
|
<div class="discount_field_inner d-flex flex-column flex-md-row"> |
1471
|
|
|
<input placeholder="<?php echo $placeholder; ?>" class="form-control mr-2 mb-2" style="flex: 1;" type="text"> |
1472
|
|
|
<a href="#" class="btn btn-secondary submit-button mb-2 wpinv-payment-form-coupon-button"><?php echo $label; ?></a> |
1473
|
|
|
</div> |
1474
|
|
|
<?php echo $description ?> |
1475
|
|
|
</div> |
1476
|
|
|
</div> |
1477
|
|
|
|
1478
|
|
|
<?php |
1479
|
|
|
} |
1480
|
|
|
|
1481
|
|
|
/** |
1482
|
|
|
* Renders the discount element template. |
1483
|
|
|
*/ |
1484
|
|
|
public function edit_discount_template( $field ) { |
1485
|
|
|
$restrict = $this->get_restrict_markup( $field, 'discount' ); |
1486
|
|
|
$label = __( 'Discount Input Placeholder', 'invoicing' ); |
1487
|
|
|
$label2 = __( 'Help Text', 'invoicing' ); |
1488
|
|
|
$label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
1489
|
|
|
$label4 = __( 'Button Text', 'invoicing' ); |
1490
|
|
|
$id = $field . '.id + "_edit"'; |
1491
|
|
|
$id2 = $field . '.id + "_edit2"'; |
1492
|
|
|
$id3 = $field . '.id + "_edit3"'; |
1493
|
|
|
echo " |
1494
|
|
|
<div $restrict> |
1495
|
|
|
<div class='form-group'> |
1496
|
|
|
<label :for='$id'>$label</label> |
1497
|
|
|
<input :id='$id' v-model='$field.input_label' class='form-control' /> |
1498
|
|
|
</div> |
1499
|
|
|
|
1500
|
|
|
<div class='form-group'> |
1501
|
|
|
<label :for='$id2'>$label4</label> |
1502
|
|
|
<input :id='$id2' v-model='$field.button_label' class='form-control' /> |
1503
|
|
|
</div> |
1504
|
|
|
|
1505
|
|
|
<div class='form-group'> |
1506
|
|
|
<label :for='$id3'>$label2</label> |
1507
|
|
|
<textarea placeholder='$label3' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
1508
|
|
|
</div> |
1509
|
|
|
|
1510
|
|
|
</div> |
1511
|
|
|
"; |
1512
|
|
|
|
1513
|
|
|
} |
1514
|
|
|
|
1515
|
|
|
/** |
1516
|
|
|
* Renders the items element template. |
1517
|
|
|
*/ |
1518
|
|
|
public function render_items_template( $field ) { |
1519
|
|
|
$restrict = $this->get_restrict_markup( $field, 'items' ); |
1520
|
|
|
echo " |
1521
|
|
|
<div $restrict class='item_totals'> |
1522
|
|
|
|
1523
|
|
|
<div v-if='$field.items_type == \"total\"' class='border'> |
1524
|
|
|
|
1525
|
|
|
<div v-for='(item, index) in form_items'> |
1526
|
|
|
<div class='row pl-2 pr-2 pt-2'> |
1527
|
|
|
<div class='col-8'>{{item.title}}</div> |
1528
|
|
|
<div class='col-4'>{{formatPrice(item.price)}}</div> |
1529
|
|
|
</div> |
1530
|
|
|
<small v-if='item.description' class='form-text text-muted pl-2 pr-2 m-0' v-html='item.description'></small> |
1531
|
|
|
</div> |
1532
|
|
|
|
1533
|
|
|
<div class='mt-4 border-top'> |
1534
|
|
|
<div class='row p-2'> |
1535
|
|
|
<div class='col-8'><strong class='mr-5'>Total</strong></div> |
1536
|
|
|
<div class='col-4'><strong>{{totalPrice}}</strong></div> |
1537
|
|
|
</div> |
1538
|
|
|
</div> |
1539
|
|
|
</div> |
1540
|
|
|
|
1541
|
|
|
<div v-if='$field.items_type == \"checkbox\"'> |
1542
|
|
|
|
1543
|
|
|
<div class='form-check' v-for='(item, index) in form_items'> |
1544
|
|
|
<input class='form-check-input' type='checkbox' :id='$field.id + index'> |
1545
|
|
|
<label class='form-check-label' :for='$field.id + index'>{{item.title}} <strong>{{formatPrice(item.price)}}</strong></label> |
1546
|
|
|
<small v-if='item.description' class='form-text text-muted' v-html='item.description'></small> |
1547
|
|
|
</div> |
1548
|
|
|
|
1549
|
|
|
</div> |
1550
|
|
|
|
1551
|
|
|
<div v-if='$field.items_type == \"radio\"'> |
1552
|
|
|
|
1553
|
|
|
<div class='form-check' v-for='(item, index) in form_items'> |
1554
|
|
|
<input class='form-check-input' type='radio' :name='$field.id' :id='$field.id + index'> |
1555
|
|
|
<label class='form-check-label' :for='$field.id + index'>{{item.title}} <strong>{{formatPrice(item.price)}}</strong></label> |
1556
|
|
|
<small v-if='item.description' class='form-text text-muted' v-html='item.description'></small> |
1557
|
|
|
</div> |
1558
|
|
|
|
1559
|
|
|
</div> |
1560
|
|
|
|
1561
|
|
|
<div v-if='$field.items_type == \"select\"'> |
1562
|
|
|
|
1563
|
|
|
<select class='form-control custom-select'> |
1564
|
|
|
<option value='' disabled selected='selected'>" . __( 'Select an option', 'invoicing' ) ."</option> |
1565
|
|
|
<option v-for='(item, index) in form_items' :value='index'>{{item.title}} {{formatPrice(item.price)}}</option> |
1566
|
|
|
</select> |
1567
|
|
|
</div> |
1568
|
|
|
|
1569
|
|
|
<div v-if='$field.items_type == \"multi_select\"'> |
1570
|
|
|
|
1571
|
|
|
<select class='form-control custom-select' multiple> |
1572
|
|
|
<option v-for='(item, index) in form_items' :value='index'>{{item.title}} {{formatPrice(item.price)}}</option> |
1573
|
|
|
</select> |
1574
|
|
|
|
1575
|
|
|
</div> |
1576
|
|
|
|
1577
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
1578
|
|
|
</div> |
1579
|
|
|
"; |
1580
|
|
|
} |
1581
|
|
|
|
1582
|
|
|
/** |
1583
|
|
|
* Renders the items element on the frontend. |
1584
|
|
|
*/ |
1585
|
|
|
public function frontend_render_items_template( $field, $items ) { |
1586
|
|
|
|
1587
|
|
|
echo "<div class='form-group item_totals'>"; |
1588
|
|
|
|
1589
|
|
|
$id = esc_attr( $field['id'] ); |
1590
|
|
|
if ( 'total' == $field[ 'items_type' ] ) { |
1591
|
|
|
$total = 0; |
1592
|
|
|
|
1593
|
|
|
?> |
1594
|
|
|
<div class="border item_totals_type_total"> |
1595
|
|
|
|
1596
|
|
|
<?php |
1597
|
|
|
foreach( $items as $item ) { |
1598
|
|
|
$total = $total + floatval( $item['price'] ); |
1599
|
|
|
?> |
1600
|
|
|
<div class="item_totals_item"> |
1601
|
|
|
<div class='row pl-2 pr-2 pt-2'> |
1602
|
|
|
<div class='col-8'><?php echo esc_html( $item['title'] ) ?></div> |
1603
|
|
|
<div class='col-4'><?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?></div> |
1604
|
|
|
</div> |
1605
|
|
|
<?php if ( ! empty( $item['description'] )) { ?> |
1606
|
|
|
<small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
1607
|
|
|
<?php } ?> |
1608
|
|
|
</div> |
1609
|
|
|
<?php } ?> |
1610
|
|
|
|
1611
|
|
|
<div class='mt-4 border-top item_totals_total'> |
1612
|
|
|
<div class='row p-2'> |
1613
|
|
|
<div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
1614
|
|
|
<div class='col-4'><strong><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
1615
|
|
|
</div> |
1616
|
|
|
</div> |
1617
|
|
|
|
1618
|
|
|
</div> |
1619
|
|
|
<?php } ?> |
1620
|
|
|
|
1621
|
|
|
<?php if ( 'radio' == $field[ 'items_type' ] ) { ?> |
1622
|
|
|
<div class="item_totals_type_radio"> |
1623
|
|
|
|
1624
|
|
|
<?php foreach( $items as $index => $item ) { ?> |
1625
|
|
|
<div class="form-check"> |
1626
|
|
|
<input class='form-check-input' type='radio' value='<?php echo $item['id']; ?>' name='payment-form-items' id='<?php echo $id . $index; ?>'> |
1627
|
|
|
<label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field( $item['title'] ); ?> <strong><?php echo wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); ?></strong></label> |
1628
|
|
|
</div> |
1629
|
|
|
<?php if ( ! empty( $item['description'] )) { ?> |
1630
|
|
|
<small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
1631
|
|
|
<?php } ?> |
1632
|
|
|
<?php } ?> |
1633
|
|
|
|
1634
|
|
|
</div> |
1635
|
|
|
<?php } ?> |
1636
|
|
|
|
1637
|
|
|
<?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?> |
1638
|
|
|
|
1639
|
|
|
<div class="item_totals_type_checkbox"> |
1640
|
|
|
|
1641
|
|
|
<?php |
1642
|
|
|
foreach ( $items as $index => $item ) { |
1643
|
|
|
$title = sanitize_text_field( $item['title'] ); |
1644
|
|
|
$price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
1645
|
|
|
$item_id = esc_attr( $id . "_$index" ); |
1646
|
|
|
$value = esc_attr( $item['id'] ); |
1647
|
|
|
|
1648
|
|
|
echo " |
1649
|
|
|
<div class='custom-control custom-checkbox'> |
1650
|
|
|
<input type='checkbox' name='payment-form-items[]' id='$item_id' value='$value' class='form-control custom-control-input'> |
1651
|
|
|
<label for='$item_id' class='custom-control-label'>$title ($price)</label> |
1652
|
|
|
</div>"; |
1653
|
|
|
|
1654
|
|
|
if ( ! empty( $item['description'] ) ) { |
1655
|
|
|
echo "<small class='form-text text-muted'>{$item['description']}</small>"; |
1656
|
|
|
} |
1657
|
|
|
} |
1658
|
|
|
?> |
1659
|
|
|
|
1660
|
|
|
</div> |
1661
|
|
|
<?php } ?> |
1662
|
|
|
|
1663
|
|
|
<?php if ( 'select' == $field[ 'items_type' ] ) { ?> |
1664
|
|
|
|
1665
|
|
|
<div class="item_totals_type_select"> |
1666
|
|
|
|
1667
|
|
|
<?php |
1668
|
|
|
|
1669
|
|
|
$options = array(); |
1670
|
|
|
|
1671
|
|
|
foreach ( $items as $index => $item ) { |
1672
|
|
|
$title = sanitize_text_field( $item['title'] ); |
1673
|
|
|
$price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
1674
|
|
|
$options[ $item['id'] ] = "$title ($price)"; |
1675
|
|
|
} |
1676
|
|
|
|
1677
|
|
|
echo aui()->select( |
|
|
|
|
1678
|
|
|
array( |
1679
|
|
|
'name' => 'payment-form-items', |
1680
|
|
|
'id' => $id, |
1681
|
|
|
'placeholder' => __( 'Select an item', 'invoicing' ), |
1682
|
|
|
'no_wrap' => true, |
1683
|
|
|
'options' => $options, |
1684
|
|
|
'class' => 'wpi_select2' |
1685
|
|
|
) |
1686
|
|
|
); |
1687
|
|
|
?> |
1688
|
|
|
|
1689
|
|
|
</div> |
1690
|
|
|
<?php } ?> |
1691
|
|
|
|
1692
|
|
|
<?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?> |
1693
|
|
|
|
1694
|
|
|
<div class="item_totals_type_multi_select"> |
1695
|
|
|
|
1696
|
|
|
<?php |
1697
|
|
|
|
1698
|
|
|
$options = array(); |
1699
|
|
|
|
1700
|
|
|
foreach ( $items as $index => $item ) { |
1701
|
|
|
$title = sanitize_text_field( $item['title'] ); |
1702
|
|
|
$price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
1703
|
|
|
$options[ $item['id'] ] = "$title ($price)"; |
1704
|
|
|
} |
1705
|
|
|
|
1706
|
|
|
echo aui()->select( |
1707
|
|
|
array( |
1708
|
|
|
'name' => 'payment-form-items', |
1709
|
|
|
'id' => $id, |
1710
|
|
|
'placeholder' => __( 'Select one or more items', 'invoicing' ), |
1711
|
|
|
'no_wrap' => true, |
1712
|
|
|
'options' => $options, |
1713
|
|
|
'multiple' => true, |
1714
|
|
|
'class' => 'wpi_select2', |
1715
|
|
|
) |
1716
|
|
|
); |
1717
|
|
|
?> |
1718
|
|
|
|
1719
|
|
|
</div> |
1720
|
|
|
<?php } ?> |
1721
|
|
|
|
1722
|
|
|
</div> |
1723
|
|
|
<?php |
1724
|
|
|
} |
1725
|
|
|
|
1726
|
|
|
/** |
1727
|
|
|
* Renders the items element template. |
1728
|
|
|
*/ |
1729
|
|
|
public function edit_items_template( $field ) { |
1730
|
|
|
$restrict = $this->get_restrict_markup( $field, 'items' ); |
1731
|
|
|
$label = __( 'Let customers...', 'invoicing' ); |
1732
|
|
|
$label2 = __( 'Available Items', 'invoicing' ); |
1733
|
|
|
$label3 = esc_attr__( 'Add some help text for this element', 'invoicing' ); |
1734
|
|
|
$id = $field . '.id + "_edit"'; |
1735
|
|
|
$id2 = $field . '.id + "_edit2"'; |
1736
|
|
|
$id3 = $field . '.id + "_edit3"'; |
1737
|
|
|
$id4 = $field . '.id + "_edit4"'; |
|
|
|
|
1738
|
|
|
echo "<div $restrict> |
1739
|
|
|
|
1740
|
|
|
<label>$label2</label> |
1741
|
|
|
|
1742
|
|
|
<draggable v-model='form_items' group='selectable_form_items'> |
1743
|
|
|
<div class='wpinv-available-items-editor' v-for='(item, index) in form_items' :class='\"item_\" + item.id' :key='item.id'> |
1744
|
|
|
|
1745
|
|
|
<div class='wpinv-available-items-editor-header' @click.prevent='togglePanel(item.id)'> |
1746
|
|
|
<span class='label'>{{item.title}}</span> |
1747
|
|
|
<span class='price'>({{formatPrice(item.price)}})</span> |
1748
|
|
|
<span class='toggle-icon'> |
1749
|
|
|
<span class='dashicons dashicons-arrow-down'></span> |
1750
|
|
|
<span class='dashicons dashicons-arrow-up' style='display:none'></span> |
1751
|
|
|
</span> |
1752
|
|
|
</div> |
1753
|
|
|
|
1754
|
|
|
<div class='wpinv-available-items-editor-body'> |
1755
|
|
|
<div class='p-2'> |
1756
|
|
|
|
1757
|
|
|
<div class='form-group'> |
1758
|
|
|
<label :for='$id + item.id'>Item Name</label> |
1759
|
|
|
<input :id='$id + item.id' v-model='item.title' class='form-control' /> |
1760
|
|
|
</div> |
1761
|
|
|
|
1762
|
|
|
<div class='form-group'> |
1763
|
|
|
<label :for='$id + item.id + \"price\"'>Item Price</label> |
1764
|
|
|
<input :id='$id + item.id + \"price\"' v-model='item.price' class='form-control' /> |
1765
|
|
|
</div> |
1766
|
|
|
|
1767
|
|
|
<div class='form-group'> |
1768
|
|
|
<label :for='$id + item.id + \"description\"'>Item Description</label> |
1769
|
|
|
<textarea :id='$id + item.id + \"description\"' v-model='item.description' class='form-control'></textarea> |
1770
|
|
|
</div> |
1771
|
|
|
|
1772
|
|
|
<button type='button' class='button button-link button-link-delete' @click.prevent='removeItem(item)'>Delete Item</button> |
1773
|
|
|
|
1774
|
|
|
</div> |
1775
|
|
|
</div> |
1776
|
|
|
|
1777
|
|
|
</div> |
1778
|
|
|
</draggable> |
1779
|
|
|
|
1780
|
|
|
<small v-if='! form_items.length' class='form-text text-danger'> You have not set up any items. Please select an item below or create a new item.</small> |
1781
|
|
|
|
1782
|
|
|
<div class='form-group mt-2'> |
1783
|
|
|
|
1784
|
|
|
<select class='form-control custom-select' v-model='selected_item'> |
1785
|
|
|
<option value=''>" . __( 'Add an item to the form', 'invoicing' ) ."</option> |
1786
|
|
|
<option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option> |
1787
|
|
|
</select> |
1788
|
|
|
|
1789
|
|
|
</div> |
1790
|
|
|
|
1791
|
|
|
<div class='form-group'> |
1792
|
|
|
<input type='button' value='Add item' class='button button-primary' @click.prevent='addSelectedItem' :disabled='selected_item == \"\"'> |
1793
|
|
|
<small>Or <a href='' @click.prevent='addNewItem'>create a new item</a>.</small> |
1794
|
|
|
</div> |
1795
|
|
|
|
1796
|
|
|
<div class='form-group mt-5'> |
1797
|
|
|
<label :for='$id2'>$label</label> |
1798
|
|
|
|
1799
|
|
|
<select class='form-control custom-select' :id='$id2' v-model='$field.items_type'> |
1800
|
|
|
<option value='total'>" . __( 'Buy all items on the list', 'invoicing' ) ."</option> |
1801
|
|
|
<option value='radio'>" . __( 'Select a single item from the list', 'invoicing' ) ."</option> |
1802
|
|
|
<option value='checkbox'>" . __( 'Select one or more items on the list', 'invoicing' ) ."</option> |
1803
|
|
|
<option value='select'>" . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option> |
1804
|
|
|
<option value='multi_select'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option> |
1805
|
|
|
</select> |
1806
|
|
|
|
1807
|
|
|
</div> |
1808
|
|
|
|
1809
|
|
|
<div class='form-group'> |
1810
|
|
|
<label :for='$id3'>Help Text</label> |
1811
|
|
|
<textarea placeholder='$label3' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
1812
|
|
|
</div> |
1813
|
|
|
|
1814
|
|
|
</div> |
1815
|
|
|
"; |
1816
|
|
|
|
1817
|
|
|
} |
1818
|
|
|
|
1819
|
|
|
/** |
1820
|
|
|
* Returns an array of all published items. |
1821
|
|
|
*/ |
1822
|
|
|
public function get_published_items() { |
1823
|
|
|
|
1824
|
|
|
$item_args = array( |
1825
|
|
|
'post_type' => 'wpi_item', |
1826
|
|
|
'orderby' => 'title', |
1827
|
|
|
'order' => 'ASC', |
1828
|
|
|
'posts_per_page' => -1, |
1829
|
|
|
'post_status' => array( 'publish' ), |
1830
|
|
|
); |
1831
|
|
|
|
1832
|
|
|
$items = get_posts( apply_filters( 'wpinv_item_dropdown_query_args', $item_args ) ); |
1833
|
|
|
|
1834
|
|
|
if ( empty( $items ) ) { |
1835
|
|
|
return array(); |
1836
|
|
|
} |
1837
|
|
|
|
1838
|
|
|
$options = array(); |
1839
|
|
|
foreach ( $items as $item ) { |
1840
|
|
|
$title = esc_html( $item->post_title ); |
1841
|
|
|
$title .= wpinv_get_item_suffix( $item->ID, false ); |
1842
|
|
|
$id = absint( $item->ID ); |
1843
|
|
|
$price = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) ); |
1844
|
|
|
$recurring = (bool) get_post_meta( $id, '_wpinv_is_recurring', true ); |
1845
|
|
|
$description = $item->post_excerpt; |
1846
|
|
|
$options[] = compact( 'title', 'id', 'price', 'recurring', 'description' ); |
1847
|
|
|
|
1848
|
|
|
} |
1849
|
|
|
return $options; |
1850
|
|
|
|
1851
|
|
|
} |
1852
|
|
|
|
1853
|
|
|
/** |
1854
|
|
|
* Returns an array of items for the currently being edited form. |
1855
|
|
|
*/ |
1856
|
|
|
public function get_form_items( $id = false ) { |
1857
|
|
|
|
1858
|
|
|
if ( empty( $id ) ) { |
1859
|
|
|
return wpinv_get_data( 'sample-payment-form-items' ); |
1860
|
|
|
} |
1861
|
|
|
|
1862
|
|
|
$form_elements = get_post_meta( $id, 'wpinv_form_items', true ); |
1863
|
|
|
|
1864
|
|
|
if ( is_array( $form_elements ) ) { |
1865
|
|
|
return $form_elements; |
1866
|
|
|
} |
1867
|
|
|
|
1868
|
|
|
return wpinv_get_data( 'sample-payment-form-items' ); |
1869
|
|
|
|
1870
|
|
|
} |
1871
|
|
|
|
1872
|
|
|
/** |
1873
|
|
|
* Returns an array of elements for the currently being edited form. |
1874
|
|
|
*/ |
1875
|
|
|
public function get_form_elements( $id = false ) { |
1876
|
|
|
|
1877
|
|
|
if ( empty( $id ) ) { |
1878
|
|
|
return wpinv_get_data( 'sample-payment-form' ); |
1879
|
|
|
} |
1880
|
|
|
|
1881
|
|
|
$form_elements = get_post_meta( $id, 'wpinv_form_elements', true ); |
1882
|
|
|
|
1883
|
|
|
if ( is_array( $form_elements ) ) { |
1884
|
|
|
return $form_elements; |
1885
|
|
|
} |
1886
|
|
|
|
1887
|
|
|
return wpinv_get_data( 'sample-payment-form' ); |
1888
|
|
|
} |
1889
|
|
|
|
1890
|
|
|
} |
1891
|
|
|
|