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
|
|
|
} |
28
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Returns all the elements that can be added to a form. |
33
|
|
|
*/ |
34
|
|
|
public function get_elements() { |
35
|
|
|
|
36
|
|
|
if ( ! empty( $this->elements ) ) { |
37
|
|
|
return $this->elements; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$this->elements = array( |
41
|
|
|
|
42
|
|
|
array( |
43
|
|
|
'type' => 'heading', |
44
|
|
|
'name' => __( 'Heading', 'invoicing' ), |
45
|
|
|
'defaults' => array( |
46
|
|
|
'level' => 'h2', |
47
|
|
|
'text' => __( 'Heading', 'invoicing' ), |
48
|
|
|
) |
49
|
|
|
), |
50
|
|
|
|
51
|
|
|
array( |
52
|
|
|
'type' => 'paragraph', |
53
|
|
|
'name' => __( 'Paragraph', 'invoicing' ), |
54
|
|
|
'defaults' => array( |
55
|
|
|
'text' => __( 'Paragraph text', 'invoicing' ), |
56
|
|
|
) |
57
|
|
|
), |
58
|
|
|
|
59
|
|
|
array( |
60
|
|
|
'type' => 'alert', |
61
|
|
|
'name' => __( 'Alert', 'invoicing' ), |
62
|
|
|
'defaults' => array( |
63
|
|
|
'value' => '', |
64
|
|
|
'class' => 'alert-warning', |
65
|
|
|
'text' => __( 'Alert', 'invoicing' ), |
66
|
|
|
'dismissible' => false, |
67
|
|
|
) |
68
|
|
|
), |
69
|
|
|
|
70
|
|
|
array( |
71
|
|
|
'type' => 'text', |
72
|
|
|
'name' => __( 'Text Input', 'invoicing' ), |
73
|
|
|
'defaults' => array( |
74
|
|
|
'placeholder' => __( 'Enter some text', 'invoicing' ), |
75
|
|
|
'value' => '', |
76
|
|
|
'label' => __( 'Field Label', 'invoicing' ), |
77
|
|
|
'description' => '', |
78
|
|
|
'required' => false, |
79
|
|
|
) |
80
|
|
|
), |
81
|
|
|
|
82
|
|
|
array( |
83
|
|
|
'type' => 'textarea', |
84
|
|
|
'name' => __( 'Textarea', 'invoicing' ), |
85
|
|
|
'defaults' => array( |
86
|
|
|
'placeholder' => __( 'Enter your text hear', 'invoicing' ), |
87
|
|
|
'value' => '', |
88
|
|
|
'label' => __( 'Textarea Label', 'invoicing' ), |
89
|
|
|
'description' => '', |
90
|
|
|
'required' => false, |
91
|
|
|
) |
92
|
|
|
), |
93
|
|
|
|
94
|
|
|
array( |
95
|
|
|
'type' => 'select', |
96
|
|
|
'name' => __( 'Dropdown', 'invoicing' ), |
97
|
|
|
'defaults' => array( |
98
|
|
|
'placeholder' => __( 'Select a value', 'invoicing' ), |
99
|
|
|
'value' => '', |
100
|
|
|
'label' => __( 'Dropdown Label', 'invoicing' ), |
101
|
|
|
'description' => '', |
102
|
|
|
'required' => false, |
103
|
|
|
'options' => array( |
104
|
|
|
esc_attr__( 'Option One', 'invoicing' ), |
105
|
|
|
esc_attr__( 'Option Two', 'invoicing' ), |
106
|
|
|
esc_attr__( 'Option Three', 'invoicing' ) |
107
|
|
|
), |
108
|
|
|
) |
109
|
|
|
), |
110
|
|
|
|
111
|
|
|
array( |
112
|
|
|
'type' => 'checkbox', |
113
|
|
|
'name' => __( 'Checkbox', 'invoicing' ), |
114
|
|
|
'defaults' => array( |
115
|
|
|
'value' => '', |
116
|
|
|
'label' => __( 'Checkbox Label', 'invoicing' ), |
117
|
|
|
'description' => '', |
118
|
|
|
'required' => false, |
119
|
|
|
) |
120
|
|
|
), |
121
|
|
|
|
122
|
|
|
array( |
123
|
|
|
'type' => 'radio', |
124
|
|
|
'name' => __( 'Multiple Choice', 'invoicing' ), |
125
|
|
|
'defaults' => array( |
126
|
|
|
'label' => __( 'Select one choice', 'invoicing' ), |
127
|
|
|
'options' => array( |
128
|
|
|
esc_attr__( 'Choice One', 'invoicing' ), |
129
|
|
|
esc_attr__( 'Choice Two', 'invoicing' ), |
130
|
|
|
esc_attr__( 'Choice Three', 'invoicing' ) |
131
|
|
|
), |
132
|
|
|
) |
133
|
|
|
), |
134
|
|
|
|
135
|
|
|
array( |
136
|
|
|
'type' => 'date', |
137
|
|
|
'name' => __( 'Date', 'invoicing' ), |
138
|
|
|
'defaults' => array( |
139
|
|
|
'placeholder' => '', |
140
|
|
|
'value' => '', |
141
|
|
|
'label' => __( 'Date', 'invoicing' ), |
142
|
|
|
'description' => '', |
143
|
|
|
'required' => false, |
144
|
|
|
) |
145
|
|
|
), |
146
|
|
|
|
147
|
|
|
array( |
148
|
|
|
'type' => 'time', |
149
|
|
|
'name' => __( 'Time', 'invoicing' ), |
150
|
|
|
'defaults' => array( |
151
|
|
|
'placeholder' => '', |
152
|
|
|
'value' => '', |
153
|
|
|
'label' => __( 'Time', 'invoicing' ), |
154
|
|
|
'description' => '', |
155
|
|
|
'required' => false, |
156
|
|
|
) |
157
|
|
|
), |
158
|
|
|
|
159
|
|
|
array( |
160
|
|
|
'type' => 'number', |
161
|
|
|
'name' => __( 'Number', 'invoicing' ), |
162
|
|
|
'defaults' => array( |
163
|
|
|
'placeholder' => '', |
164
|
|
|
'value' => '', |
165
|
|
|
'label' => __( 'Number', 'invoicing' ), |
166
|
|
|
'description' => '', |
167
|
|
|
'required' => false, |
168
|
|
|
) |
169
|
|
|
), |
170
|
|
|
|
171
|
|
|
array( |
172
|
|
|
'type' => 'website', |
173
|
|
|
'name' => __( 'Website', 'invoicing' ), |
174
|
|
|
'defaults' => array( |
175
|
|
|
'placeholder' => 'http://example.com', |
176
|
|
|
'value' => '', |
177
|
|
|
'label' => __( 'Website', 'invoicing' ), |
178
|
|
|
'description' => '', |
179
|
|
|
'required' => false, |
180
|
|
|
) |
181
|
|
|
), |
182
|
|
|
|
183
|
|
|
array( |
184
|
|
|
'type' => 'email', |
185
|
|
|
'name' => __( 'Email', 'invoicing' ), |
186
|
|
|
'defaults' => array( |
187
|
|
|
'placeholder' => '[email protected]', |
188
|
|
|
'value' => '', |
189
|
|
|
'label' => __( 'Email Address', 'invoicing' ), |
190
|
|
|
'description' => '', |
191
|
|
|
'required' => false, |
192
|
|
|
) |
193
|
|
|
), |
194
|
|
|
|
195
|
|
|
array( |
196
|
|
|
'type' => 'discount', |
197
|
|
|
'name' => __( 'Discount Input', 'invoicing' ), |
198
|
|
|
'defaults' => array( |
199
|
|
|
'value' => '', |
200
|
|
|
'input_label' => __( 'Coupon Code', 'invoicing' ), |
201
|
|
|
'button_label' => __( 'Apply Coupon', 'invoicing' ), |
202
|
|
|
'description' => __( 'Have a discount code? Enter it above.', 'invoicing' ), |
203
|
|
|
) |
204
|
|
|
), |
205
|
|
|
|
206
|
|
|
array( |
207
|
|
|
'type' => 'items', |
208
|
|
|
'name' => __( 'Items', 'invoicing' ), |
209
|
|
|
'defaults' => array( |
210
|
|
|
'value' => '', |
211
|
|
|
'items' => array(), |
212
|
|
|
'type' => 'total', |
213
|
|
|
'show_total' => false, |
214
|
|
|
'description' => '', |
215
|
|
|
) |
216
|
|
|
), |
217
|
|
|
|
218
|
|
|
array( |
219
|
|
|
'type' => 'pay_button', |
220
|
|
|
'name' => __( 'Payment Button', 'invoicing' ), |
221
|
|
|
'defaults' => array( |
222
|
|
|
'value' => '', |
223
|
|
|
'class' => 'btn-primary', |
224
|
|
|
'label' => __( 'Pay Now »', 'invoicing' ), |
225
|
|
|
'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
226
|
|
|
) |
227
|
|
|
) |
228
|
|
|
); |
229
|
|
|
|
230
|
|
|
$this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements ); |
231
|
|
|
return $this->elements; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Returns the restrict markup. |
236
|
|
|
*/ |
237
|
|
|
public function get_restrict_markup( $field, $field_type ) { |
238
|
|
|
$restrict = "$field.type=='$field_type'"; |
239
|
|
|
return "v-if=\"$restrict\""; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* Renders the title element template. |
244
|
|
|
*/ |
245
|
|
|
public function render_heading_template( $field ) { |
246
|
|
|
$restrict = $this->get_restrict_markup( $field, 'heading' ); |
247
|
|
|
echo "<component :is='$field.level' $restrict v-html='$field.text'></component>"; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Renders the edit title element template. |
252
|
|
|
*/ |
253
|
|
|
public function edit_heading_template( $field ) { |
254
|
|
|
$restrict = $this->get_restrict_markup( $field, 'heading' ); |
255
|
|
|
$label = __( 'Heading', 'invoicing' ); |
256
|
|
|
$label2 = __( 'Select Heading Level', 'invoicing' ); |
257
|
|
|
$id = $field . '.id + "_edit"'; |
258
|
|
|
$id2 = $field . '.id + "_edit2"'; |
259
|
|
|
|
260
|
|
|
echo " |
261
|
|
|
<div $restrict> |
262
|
|
|
<div class='form-group'> |
263
|
|
|
<label :for='$id'>$label</label> |
264
|
|
|
<input class='form-control' :id='$id' v-model='$field.text' type='text' /> |
265
|
|
|
</div> |
266
|
|
|
|
267
|
|
|
<div class='form-group'> |
268
|
|
|
<label :for='$id2'>$label2</label> |
269
|
|
|
|
270
|
|
|
<select class='form-control custom-select' :id='$id2' v-model='$field.level'> |
271
|
|
|
<option value='h1'>H1</option> |
272
|
|
|
<option value='h2'>H2</option> |
273
|
|
|
<option value='h3'>H3</option> |
274
|
|
|
<option value='h4'>H4</option> |
275
|
|
|
<option value='h5'>H5</option> |
276
|
|
|
<option value='h6'>H6</option> |
277
|
|
|
<option value='h7'>H7</option> |
278
|
|
|
</select> |
279
|
|
|
</div> |
280
|
|
|
</div> |
281
|
|
|
"; |
282
|
|
|
|
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* Renders a paragraph element template. |
287
|
|
|
*/ |
288
|
|
|
public function render_paragraph_template( $field ) { |
289
|
|
|
$restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
290
|
|
|
$label = "$field.text"; |
291
|
|
|
echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>"; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* Renders the edit paragraph element template. |
296
|
|
|
*/ |
297
|
|
|
public function edit_paragraph_template( $field ) { |
298
|
|
|
$restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
299
|
|
|
$label = __( 'Enter your text', 'invoicing' ); |
300
|
|
|
$id = $field . '.id + "_edit"'; |
301
|
|
|
echo " |
302
|
|
|
<div $restrict> |
303
|
|
|
<div class='form-group'> |
304
|
|
|
<label :for='$id'>$label</label> |
305
|
|
|
<textarea :id='$id' v-model='$field.text' class='form-control' rows='3'></textarea> |
306
|
|
|
</div> |
307
|
|
|
</div> |
308
|
|
|
"; |
309
|
|
|
|
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
/** |
313
|
|
|
* Renders the text element template. |
314
|
|
|
*/ |
315
|
|
|
public function render_text_template( $field ) { |
316
|
|
|
$restrict = $this->get_restrict_markup( $field, 'text' ); |
317
|
|
|
$label = "$field.label"; |
318
|
|
|
echo " |
319
|
|
|
<div $restrict> |
320
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
321
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='text'> |
322
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
323
|
|
|
</div> |
324
|
|
|
"; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* Renders the edit text element template. |
329
|
|
|
*/ |
330
|
|
|
public function edit_text_template( $field ) { |
331
|
|
|
$restrict = $this->get_restrict_markup( $field, 'text' ); |
332
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
333
|
|
|
$id = $field . '.id + "_edit"'; |
334
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
335
|
|
|
$id2 = $field . '.id + "_edit2"'; |
336
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
337
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
338
|
|
|
$id3 = $field . '.id + "_edit3"'; |
339
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
340
|
|
|
$id4 = $field . '.id + "_edit4"'; |
341
|
|
|
echo " |
342
|
|
|
<div $restrict> |
343
|
|
|
<div class='form-group'> |
344
|
|
|
<label :for='$id'>$label</label> |
345
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
346
|
|
|
</div> |
347
|
|
|
<div class='form-group'> |
348
|
|
|
<label :for='$id2'>$label2</label> |
349
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
350
|
|
|
</div> |
351
|
|
|
<div class='form-group'> |
352
|
|
|
<label :for='$id3'>$label3</label> |
353
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
354
|
|
|
</div> |
355
|
|
|
<div class='form-group form-check'> |
356
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
357
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
358
|
|
|
</div> |
359
|
|
|
</div> |
360
|
|
|
"; |
361
|
|
|
|
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* Renders the textarea element template. |
366
|
|
|
*/ |
367
|
|
|
public function render_textarea_template( $field ) { |
368
|
|
|
$restrict = $this->get_restrict_markup( $field, 'textarea' ); |
369
|
|
|
$label = "$field.label"; |
370
|
|
|
echo " |
371
|
|
|
<div $restrict> |
372
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
373
|
|
|
<textarea :placeholder='$field.placeholder' :id='$field.id' class='form-control' rows='3'></textarea> |
374
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
375
|
|
|
</div> |
376
|
|
|
"; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Renders the edit textarea element template. |
381
|
|
|
*/ |
382
|
|
|
public function edit_textarea_template( $field ) { |
383
|
|
|
$restrict = $this->get_restrict_markup( $field, 'textarea' ); |
384
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
385
|
|
|
$id = $field . '.id + "_edit"'; |
386
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
387
|
|
|
$id2 = $field . '.id + "_edit2"'; |
388
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
389
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
390
|
|
|
$id3 = $field . '.id + "_edit3"'; |
391
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
392
|
|
|
$id4 = $field . '.id + "_edit4"'; |
393
|
|
|
echo " |
394
|
|
|
<div $restrict> |
395
|
|
|
<div class='form-group'> |
396
|
|
|
<label :for='$id'>$label</label> |
397
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
398
|
|
|
</div> |
399
|
|
|
<div class='form-group'> |
400
|
|
|
<label :for='$id2'>$label2</label> |
401
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
402
|
|
|
</div> |
403
|
|
|
<div class='form-group'> |
404
|
|
|
<label :for='$id3'>$label3</label> |
405
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
406
|
|
|
</div> |
407
|
|
|
<div class='form-group form-check'> |
408
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
409
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
410
|
|
|
</div> |
411
|
|
|
</div> |
412
|
|
|
"; |
413
|
|
|
|
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
/** |
417
|
|
|
* Renders the select element template. |
418
|
|
|
*/ |
419
|
|
|
public function render_select_template( $field ) { |
420
|
|
|
$restrict = $this->get_restrict_markup( $field, 'select' ); |
421
|
|
|
$label = "$field.label"; |
422
|
|
|
$placeholder = "$field.placeholder"; |
423
|
|
|
$id = $field . '.id'; |
424
|
|
|
echo " |
425
|
|
|
<div $restrict> |
426
|
|
|
<label :for='$id'>{{" . $label . "}}</label> |
427
|
|
|
<select id='$id' class='form-control custom-select' v-model='$field.value'> |
428
|
|
|
<option v-if='$placeholder' value='' disabled>{{" . $placeholder . "}}</option> |
429
|
|
|
<option v-for='option in $field.options' value='option'>{{option}}</option> |
430
|
|
|
</select> |
431
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
432
|
|
|
</div> |
433
|
|
|
"; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* Renders the edit select element template. |
438
|
|
|
*/ |
439
|
|
|
public function edit_select_template( $field ) { |
440
|
|
|
$restrict = $this->get_restrict_markup( $field, 'select' ); |
441
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
442
|
|
|
$id = $field . '.id + "_edit"'; |
443
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
444
|
|
|
$id2 = $field . '.id + "_edit2"'; |
445
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
446
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
447
|
|
|
$id3 = $field . '.id + "_edit3"'; |
448
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
449
|
|
|
$id4 = $field . '.id + "_edit4"'; |
450
|
|
|
$label6 = __( 'Available Options', 'invoicing' ); |
451
|
|
|
echo " |
452
|
|
|
<div $restrict> |
453
|
|
|
<div class='form-group'> |
454
|
|
|
<label :for='$id'>$label</label> |
455
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
456
|
|
|
</div> |
457
|
|
|
<div class='form-group'> |
458
|
|
|
<label :for='$id2'>$label2</label> |
459
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
460
|
|
|
</div> |
461
|
|
|
<div class='form-group'> |
462
|
|
|
<label :for='$id3'>$label3</label> |
463
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
464
|
|
|
</div> |
465
|
|
|
<div class='form-group form-check'> |
466
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
467
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
468
|
|
|
</div> |
469
|
|
|
<hr class='featurette-divider mt-4'> |
470
|
|
|
<h5>$label6</h5> |
471
|
|
|
<div class='form-group input-group' v-for='(option, index) in $field.options'> |
472
|
|
|
<input type='text' class='form-control' v-model='$field.options[index]'> |
473
|
|
|
<div class='input-group-append'> |
474
|
|
|
<button class='btn btn-outline-secondary' type='button' @click.prevent='$field.options.splice(index, 1)'><span class='dashicons dashicons-trash'></span></button> |
475
|
|
|
</div> |
476
|
|
|
</div> |
477
|
|
|
<div class='form-group'> |
478
|
|
|
<button class='btn btn-outline-secondary' type='button' @click.prevent='$field.options.push(\"\")'>Add Option</button> |
479
|
|
|
</div> |
480
|
|
|
</div> |
481
|
|
|
"; |
482
|
|
|
|
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* Renders the checkbox element template. |
487
|
|
|
*/ |
488
|
|
|
public function render_checkbox_template( $field ) { |
489
|
|
|
$restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
490
|
|
|
$label = "$field.label"; |
491
|
|
|
echo " |
492
|
|
|
<div class='form-check' $restrict> |
493
|
|
|
<input :id='$field.id' class='form-check-input' type='checkbox' /> |
494
|
|
|
<label class='form-check-label' :for='$field.id'>{{" . $label . "}}</label> |
495
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
496
|
|
|
</div> |
497
|
|
|
"; |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
/** |
501
|
|
|
* Renders the edit checkbox element template. |
502
|
|
|
*/ |
503
|
|
|
public function edit_checkbox_template( $field ) { |
504
|
|
|
$restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
505
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
506
|
|
|
$id = $field . '.id + "_edit"'; |
507
|
|
|
$label2 = __( 'Help text', 'invoicing' ); |
508
|
|
|
$label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
509
|
|
|
$id2 = $field . '.id + "_edit2"'; |
510
|
|
|
$label4 = __( 'Is this field required?', 'invoicing' ); |
511
|
|
|
$id3 = $field . '.id + "_edit3"'; |
512
|
|
|
echo " |
513
|
|
|
<div $restrict> |
514
|
|
|
<div class='form-group'> |
515
|
|
|
<label :for='$id'>$label</label> |
516
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
517
|
|
|
</div> |
518
|
|
|
<div class='form-group'> |
519
|
|
|
<label :for='$id2'>$label2</label> |
520
|
|
|
<textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
521
|
|
|
</div> |
522
|
|
|
<div class='form-group form-check'> |
523
|
|
|
<input :id='$id3' v-model='$field.required' type='checkbox' class='form-check-input' /> |
524
|
|
|
<label class='form-check-label' :for='$id3'>$label4</label> |
525
|
|
|
</div> |
526
|
|
|
</div> |
527
|
|
|
"; |
528
|
|
|
|
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
/** |
532
|
|
|
* Renders the radio element template. |
533
|
|
|
*/ |
534
|
|
|
public function render_radio_template( $field ) { |
535
|
|
|
$restrict = $this->get_restrict_markup( $field, 'radio' ); |
536
|
|
|
$label = "$field.label"; |
537
|
|
|
$id = $field . '.id'; |
538
|
|
|
echo " |
539
|
|
|
<div $restrict> |
540
|
|
|
<legend class='col-form-label' v-if='$label'>{{" . $label . "}}</legend> |
541
|
|
|
<div class='form-check' v-for='(option, index) in $field.options'> |
542
|
|
|
<input class='form-check-input' type='radio' :id='$id + index'> |
543
|
|
|
<label class='form-check-label' :for='$id + index'>{{option}}</label> |
544
|
|
|
</div> |
545
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
546
|
|
|
</div> |
547
|
|
|
"; |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
/** |
551
|
|
|
* Renders the edit radio element template. |
552
|
|
|
*/ |
553
|
|
|
public function edit_radio_template( $field ) { |
554
|
|
|
$restrict = $this->get_restrict_markup( $field, 'radio' ); |
555
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
556
|
|
|
$id = $field . '.id + "_edit"'; |
557
|
|
|
$label2 = __( 'Help text', 'invoicing' ); |
558
|
|
|
$label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
559
|
|
|
$id2 = $field . '.id + "_edit3"'; |
560
|
|
|
$label4 = __( 'Is this field required?', 'invoicing' ); |
561
|
|
|
$id3 = $field . '.id + "_edit4"'; |
562
|
|
|
$label5 = __( 'Available Options', 'invoicing' ); |
563
|
|
|
echo " |
564
|
|
|
<div $restrict> |
565
|
|
|
<div class='form-group'> |
566
|
|
|
<label :for='$id'>$label</label> |
567
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
568
|
|
|
</div> |
569
|
|
|
<div class='form-group'> |
570
|
|
|
<label :for='$id2'>$label2</label> |
571
|
|
|
<textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
572
|
|
|
</div> |
573
|
|
|
<div class='form-group form-check'> |
574
|
|
|
<input :id='$id3' v-model='$field.required' type='checkbox' class='form-check-input' /> |
575
|
|
|
<label class='form-check-label' :for='$id3'>$label4</label> |
576
|
|
|
</div> |
577
|
|
|
<hr class='featurette-divider mt-4'> |
578
|
|
|
<h5>$label5</h5> |
579
|
|
|
<div class='form-group input-group' v-for='(option, index) in $field.options'> |
580
|
|
|
<input type='text' class='form-control' v-model='$field.options[index]'> |
581
|
|
|
<div class='input-group-append'> |
582
|
|
|
<button class='btn btn-outline-secondary' type='button' @click.prevent='$field.options.splice(index, 1)'><span class='dashicons dashicons-trash'></span></button> |
583
|
|
|
</div> |
584
|
|
|
</div> |
585
|
|
|
<div class='form-group'> |
586
|
|
|
<button class='btn btn-outline-secondary' type='button' @click.prevent='$field.options.push(\"\")'>Add Option</button> |
587
|
|
|
</div> |
588
|
|
|
</div> |
589
|
|
|
"; |
590
|
|
|
|
591
|
|
|
} |
592
|
|
|
|
593
|
|
|
/** |
594
|
|
|
* Renders the email element template. |
595
|
|
|
*/ |
596
|
|
|
public function render_email_template( $field ) { |
597
|
|
|
$restrict = $this->get_restrict_markup( $field, 'email' ); |
598
|
|
|
$label = "$field.label"; |
599
|
|
|
echo " |
600
|
|
|
<div $restrict> |
601
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
602
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='email'> |
603
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
604
|
|
|
</div> |
605
|
|
|
"; |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* Renders the edit email element template. |
610
|
|
|
*/ |
611
|
|
|
public function edit_email_template( $field ) { |
612
|
|
|
$restrict = $this->get_restrict_markup( $field, 'email' ); |
613
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
614
|
|
|
$id = $field . '.id + "_edit"'; |
615
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
616
|
|
|
$id2 = $field . '.id + "_edit2"'; |
617
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
618
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
619
|
|
|
$id3 = $field . '.id + "_edit3"'; |
620
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
621
|
|
|
$id4 = $field . '.id + "_edit4"'; |
622
|
|
|
echo " |
623
|
|
|
<div $restrict> |
624
|
|
|
<div class='form-group'> |
625
|
|
|
<label :for='$id'>$label</label> |
626
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
627
|
|
|
</div> |
628
|
|
|
<div class='form-group'> |
629
|
|
|
<label :for='$id2'>$label2</label> |
630
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
631
|
|
|
</div> |
632
|
|
|
<div class='form-group'> |
633
|
|
|
<label :for='$id3'>$label3</label> |
634
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
635
|
|
|
</div> |
636
|
|
|
<div class='form-group form-check'> |
637
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
638
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
639
|
|
|
</div> |
640
|
|
|
</div> |
641
|
|
|
"; |
642
|
|
|
|
643
|
|
|
} |
644
|
|
|
|
645
|
|
|
/** |
646
|
|
|
* Renders the website element template. |
647
|
|
|
*/ |
648
|
|
|
public function render_website_template( $field ) { |
649
|
|
|
$restrict = $this->get_restrict_markup( $field, 'website' ); |
650
|
|
|
$label = "$field.label"; |
651
|
|
|
echo " |
652
|
|
|
<div $restrict> |
653
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
654
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='url'> |
655
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
656
|
|
|
</div> |
657
|
|
|
"; |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* Renders the edit website element template. |
662
|
|
|
*/ |
663
|
|
|
public function edit_website_template( $field ) { |
664
|
|
|
$restrict = $this->get_restrict_markup( $field, 'website' ); |
665
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
666
|
|
|
$id = $field . '.id + "_edit"'; |
667
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
668
|
|
|
$id2 = $field . '.id + "_edit2"'; |
669
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
670
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
671
|
|
|
$id3 = $field . '.id + "_edit3"'; |
672
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
673
|
|
|
$id4 = $field . '.id + "_edit4"'; |
674
|
|
|
echo " |
675
|
|
|
<div $restrict> |
676
|
|
|
<div class='form-group'> |
677
|
|
|
<label :for='$id'>$label</label> |
678
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
679
|
|
|
</div> |
680
|
|
|
<div class='form-group'> |
681
|
|
|
<label :for='$id2'>$label2</label> |
682
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
683
|
|
|
</div> |
684
|
|
|
<div class='form-group'> |
685
|
|
|
<label :for='$id3'>$label3</label> |
686
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
687
|
|
|
</div> |
688
|
|
|
<div class='form-group form-check'> |
689
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
690
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
691
|
|
|
</div> |
692
|
|
|
</div> |
693
|
|
|
"; |
694
|
|
|
|
695
|
|
|
} |
696
|
|
|
|
697
|
|
|
/** |
698
|
|
|
* Renders the date element template. |
699
|
|
|
*/ |
700
|
|
|
public function render_date_template( $field ) { |
701
|
|
|
$restrict = $this->get_restrict_markup( $field, 'date' ); |
702
|
|
|
$label = "$field.label"; |
703
|
|
|
echo " |
704
|
|
|
<div $restrict> |
705
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
706
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='date'> |
707
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
708
|
|
|
</div> |
709
|
|
|
"; |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
/** |
713
|
|
|
* Renders the edit date element template. |
714
|
|
|
*/ |
715
|
|
|
public function edit_date_template( $field ) { |
716
|
|
|
$restrict = $this->get_restrict_markup( $field, 'date' ); |
717
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
718
|
|
|
$id = $field . '.id + "_edit"'; |
719
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
720
|
|
|
$id2 = $field . '.id + "_edit2"'; |
721
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
722
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
723
|
|
|
$id3 = $field . '.id + "_edit3"'; |
724
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
725
|
|
|
$id4 = $field . '.id + "_edit4"'; |
726
|
|
|
echo " |
727
|
|
|
<div $restrict> |
728
|
|
|
<div class='form-group'> |
729
|
|
|
<label :for='$id'>$label</label> |
730
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
731
|
|
|
</div> |
732
|
|
|
<div class='form-group'> |
733
|
|
|
<label :for='$id2'>$label2</label> |
734
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
735
|
|
|
</div> |
736
|
|
|
<div class='form-group'> |
737
|
|
|
<label :for='$id3'>$label3</label> |
738
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
739
|
|
|
</div> |
740
|
|
|
<div class='form-group form-check'> |
741
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
742
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
743
|
|
|
</div> |
744
|
|
|
</div> |
745
|
|
|
"; |
746
|
|
|
|
747
|
|
|
} |
748
|
|
|
|
749
|
|
|
/** |
750
|
|
|
* Renders the time element template. |
751
|
|
|
*/ |
752
|
|
|
public function render_time_template( $field ) { |
753
|
|
|
$restrict = $this->get_restrict_markup( $field, 'time' ); |
754
|
|
|
$label = "$field.label"; |
755
|
|
|
echo " |
756
|
|
|
<div $restrict> |
757
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
758
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='time'> |
759
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
760
|
|
|
</div> |
761
|
|
|
"; |
762
|
|
|
} |
763
|
|
|
|
764
|
|
|
/** |
765
|
|
|
* Renders the edit time element template. |
766
|
|
|
*/ |
767
|
|
|
public function edit_time_template( $field ) { |
768
|
|
|
$restrict = $this->get_restrict_markup( $field, 'time' ); |
769
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
770
|
|
|
$id = $field . '.id + "_edit"'; |
771
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
772
|
|
|
$id2 = $field . '.id + "_edit2"'; |
773
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
774
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
775
|
|
|
$id3 = $field . '.id + "_edit3"'; |
776
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
777
|
|
|
$id4 = $field . '.id + "_edit4"'; |
778
|
|
|
echo " |
779
|
|
|
<div $restrict> |
780
|
|
|
<div class='form-group'> |
781
|
|
|
<label :for='$id'>$label</label> |
782
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
783
|
|
|
</div> |
784
|
|
|
<div class='form-group'> |
785
|
|
|
<label :for='$id2'>$label2</label> |
786
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
787
|
|
|
</div> |
788
|
|
|
<div class='form-group'> |
789
|
|
|
<label :for='$id3'>$label3</label> |
790
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
791
|
|
|
</div> |
792
|
|
|
<div class='form-group form-check'> |
793
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
794
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
795
|
|
|
</div> |
796
|
|
|
</div> |
797
|
|
|
"; |
798
|
|
|
|
799
|
|
|
} |
800
|
|
|
|
801
|
|
|
/** |
802
|
|
|
* Renders the number element template. |
803
|
|
|
*/ |
804
|
|
|
public function render_number_template( $field ) { |
805
|
|
|
$restrict = $this->get_restrict_markup( $field, 'number' ); |
806
|
|
|
$label = "$field.label"; |
807
|
|
|
echo " |
808
|
|
|
<div $restrict> |
809
|
|
|
<label :for='$field.id'>{{" . $label . "}}</label> |
810
|
|
|
<input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='number'> |
811
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
812
|
|
|
</div> |
813
|
|
|
"; |
814
|
|
|
} |
815
|
|
|
|
816
|
|
|
/** |
817
|
|
|
* Renders the edit number element template. |
818
|
|
|
*/ |
819
|
|
|
public function edit_number_template( $field ) { |
820
|
|
|
$restrict = $this->get_restrict_markup( $field, 'number' ); |
821
|
|
|
$label = __( 'Field Label', 'invoicing' ); |
822
|
|
|
$id = $field . '.id + "_edit"'; |
823
|
|
|
$label2 = __( 'Placeholder text', 'invoicing' ); |
824
|
|
|
$id2 = $field . '.id + "_edit2"'; |
825
|
|
|
$label3 = __( 'Help text', 'invoicing' ); |
826
|
|
|
$label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
827
|
|
|
$id3 = $field . '.id + "_edit3"'; |
828
|
|
|
$label5 = __( 'Is this field required?', 'invoicing' ); |
829
|
|
|
$id4 = $field . '.id + "_edit4"'; |
830
|
|
|
echo " |
831
|
|
|
<div $restrict> |
832
|
|
|
<div class='form-group'> |
833
|
|
|
<label :for='$id'>$label</label> |
834
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
835
|
|
|
</div> |
836
|
|
|
<div class='form-group'> |
837
|
|
|
<label :for='$id2'>$label2</label> |
838
|
|
|
<input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
839
|
|
|
</div> |
840
|
|
|
<div class='form-group'> |
841
|
|
|
<label :for='$id3'>$label3</label> |
842
|
|
|
<textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
843
|
|
|
</div> |
844
|
|
|
<div class='form-group form-check'> |
845
|
|
|
<input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
846
|
|
|
<label class='form-check-label' :for='$id4'>$label5</label> |
847
|
|
|
</div> |
848
|
|
|
</div> |
849
|
|
|
"; |
850
|
|
|
|
851
|
|
|
} |
852
|
|
|
|
853
|
|
|
/** |
854
|
|
|
* Renders the pay button element template. |
855
|
|
|
*/ |
856
|
|
|
public function render_pay_button_template( $field ) { |
857
|
|
|
$restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
858
|
|
|
$label = "$field.label"; |
859
|
|
|
echo " |
860
|
|
|
<div $restrict> |
861
|
|
|
<button class='form-control btn submit-button' :class='$field.class' type='submit' @click.prevent=''>{{" . $label . "}}</button> |
862
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
863
|
|
|
</div> |
864
|
|
|
"; |
865
|
|
|
} |
866
|
|
|
|
867
|
|
|
/** |
868
|
|
|
* Renders the pay button element template. |
869
|
|
|
*/ |
870
|
|
|
public function edit_pay_button_template( $field ) { |
871
|
|
|
$restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
872
|
|
|
$label = __( 'Button Text', 'invoicing' ); |
873
|
|
|
$id = $field . '.id + "_edit"'; |
874
|
|
|
$label2 = __( 'Help text', 'invoicing' ); |
875
|
|
|
$label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
876
|
|
|
$id2 = $field . '.id + "_edit2"'; |
877
|
|
|
$label4 = esc_attr__( 'Button Type', 'invoicing' ); |
878
|
|
|
$id3 = $field . '.id + "_edit3"'; |
879
|
|
|
echo " |
880
|
|
|
<div $restrict> |
881
|
|
|
<div class='form-group'> |
882
|
|
|
<label :for='$id'>$label</label> |
883
|
|
|
<input :id='$id' v-model='$field.label' class='form-control' /> |
884
|
|
|
</div> |
885
|
|
|
<div class='form-group'> |
886
|
|
|
<label :for='$id2'>$label2</label> |
887
|
|
|
<textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
888
|
|
|
</div> |
889
|
|
|
<div class='form-group'> |
890
|
|
|
<label :for='$id3'>$label4</label> |
891
|
|
|
|
892
|
|
|
<select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
893
|
|
|
<option value='btn-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
894
|
|
|
<option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
895
|
|
|
<option value='btn-success'>" . __( 'Success', 'invoicing' ) ."</option> |
896
|
|
|
<option value='btn-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
897
|
|
|
<option value='btn-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
898
|
|
|
<option value='btn-info'>" . __( 'Info', 'invoicing' ) ."</option> |
899
|
|
|
<option value='btn-light'>" . __( 'Light', 'invoicing' ) ."</option> |
900
|
|
|
<option value='btn-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
901
|
|
|
<option value='btn-link'>" . __( 'Link', 'invoicing' ) ."</option> |
902
|
|
|
</select> |
903
|
|
|
</div> |
904
|
|
|
</div> |
905
|
|
|
"; |
906
|
|
|
|
907
|
|
|
} |
908
|
|
|
|
909
|
|
|
/** |
910
|
|
|
* Renders the alert element template. |
911
|
|
|
*/ |
912
|
|
|
public function render_alert_template( $field ) { |
913
|
|
|
$restrict = $this->get_restrict_markup( $field, 'alert' ); |
914
|
|
|
$text = "$field.text"; |
915
|
|
|
echo " |
916
|
|
|
<div $restrict class='alert' :class='$field.class' role='alert'> |
917
|
|
|
<span v-html='$text'></span> |
918
|
|
|
<button v-if='$field.dismissible' type='button' class='close' @click.prevent=''> |
919
|
|
|
<span aria-hidden='true'>×</span> |
920
|
|
|
</button> |
921
|
|
|
</div> |
922
|
|
|
"; |
923
|
|
|
} |
924
|
|
|
|
925
|
|
|
/** |
926
|
|
|
* Renders the alert element template. |
927
|
|
|
*/ |
928
|
|
|
public function edit_alert_template( $field ) { |
929
|
|
|
$restrict = $this->get_restrict_markup( $field, 'alert' ); |
930
|
|
|
$label = __( 'Alert Text', 'invoicing' ); |
931
|
|
|
$label2 = esc_attr__( 'Enter your alert text here', 'invoicing' ); |
932
|
|
|
$id = $field . '.id + "_edit"'; |
933
|
|
|
$label3 = __( 'Is Dismissible?', 'invoicing' ); |
934
|
|
|
$id2 = $field . '.id + "_edit2"'; |
935
|
|
|
$label4 = esc_attr__( 'Alert Type', 'invoicing' ); |
936
|
|
|
$id3 = $field . '.id + "_edit3"'; |
937
|
|
|
echo " |
938
|
|
|
<div $restrict> |
939
|
|
|
<div class='form-group'> |
940
|
|
|
<label :for='$id'>$label</label> |
941
|
|
|
<textarea placeholder='$label2' :id='$id' v-model='$field.text' class='form-control' rows='3'></textarea> |
942
|
|
|
</div> |
943
|
|
|
<div class='form-group form-check'> |
944
|
|
|
<input :id='$id2' v-model='$field.dismissible' type='checkbox' class='form-check-input' /> |
945
|
|
|
<label class='form-check-label' :for='$id2'>$label3</label> |
946
|
|
|
</div> |
947
|
|
|
<div class='form-group'> |
948
|
|
|
<label :for='$id3'>$label4</label> |
949
|
|
|
|
950
|
|
|
<select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
951
|
|
|
<option value='alert-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
952
|
|
|
<option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
953
|
|
|
<option value='alert-success'>" . __( 'Success', 'invoicing' ) ."</option> |
954
|
|
|
<option value='alert-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
955
|
|
|
<option value='alert-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
956
|
|
|
<option value='alert-info'>" . __( 'Info', 'invoicing' ) ."</option> |
957
|
|
|
<option value='alert-light'>" . __( 'Light', 'invoicing' ) ."</option> |
958
|
|
|
<option value='alert-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
959
|
|
|
</select> |
960
|
|
|
</div> |
961
|
|
|
</div> |
962
|
|
|
"; |
963
|
|
|
|
964
|
|
|
} |
965
|
|
|
|
966
|
|
|
/** |
967
|
|
|
* Renders the discount element template. |
968
|
|
|
*/ |
969
|
|
|
public function render_discount_templates( $field ) { |
970
|
|
|
$restrict = $this->get_restrict_markup( $field, 'discount' ); |
971
|
|
|
echo " |
972
|
|
|
<div $restrict class='discount_field border rounded p-3'> |
973
|
|
|
<div class='discount_field_inner d-flex flex-column flex-md-row'> |
974
|
|
|
<input :placeholder='$field.input_label' class='form-control mr-2 mb-2' style='flex: 1;' type='text'> |
975
|
|
|
<button class='btn btn-secondary submit-button mb-2' type='submit' @click.prevent=''>{{" . "$field.button_label}}</button> |
976
|
|
|
</div> |
977
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
978
|
|
|
</div> |
979
|
|
|
"; |
980
|
|
|
} |
981
|
|
|
|
982
|
|
|
/** |
983
|
|
|
* Renders the discount element template. |
984
|
|
|
*/ |
985
|
|
|
public function edit_discount_template( $field ) { |
986
|
|
|
$restrict = $this->get_restrict_markup( $field, 'discount' ); |
987
|
|
|
$label = __( 'Discount Input Placeholder', 'invoicing' ); |
988
|
|
|
$label2 = __( 'Help Text', 'invoicing' ); |
989
|
|
|
$label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
990
|
|
|
$label4 = __( 'Button Text', 'invoicing' ); |
991
|
|
|
$id = $field . '.id + "_edit"'; |
992
|
|
|
$id2 = $field . '.id + "_edit2"'; |
993
|
|
|
$id3 = $field . '.id + "_edit3"'; |
994
|
|
|
echo " |
995
|
|
|
<div $restrict> |
996
|
|
|
<div class='form-group'> |
997
|
|
|
<label :for='$id'>$label</label> |
998
|
|
|
<input :id='$id' v-model='$field.input_label' class='form-control' /> |
999
|
|
|
</div> |
1000
|
|
|
|
1001
|
|
|
<div class='form-group'> |
1002
|
|
|
<label :for='$id2'>$label4</label> |
1003
|
|
|
<input :id='$id2' v-model='$field.button_label' class='form-control' /> |
1004
|
|
|
</div> |
1005
|
|
|
|
1006
|
|
|
<div class='form-group'> |
1007
|
|
|
<label :for='$id3'>$label2</label> |
1008
|
|
|
<textarea placeholder='$label3' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
1009
|
|
|
</div> |
1010
|
|
|
|
1011
|
|
|
</div> |
1012
|
|
|
"; |
1013
|
|
|
|
1014
|
|
|
} |
1015
|
|
|
|
1016
|
|
|
/** |
1017
|
|
|
* Renders the items element template. |
1018
|
|
|
*/ |
1019
|
|
|
public function render_items_template( $field ) { |
1020
|
|
|
$restrict = $this->get_restrict_markup( $field, 'items' ); |
1021
|
|
|
echo " |
1022
|
|
|
<div $restrict class='item_totals'> |
1023
|
|
|
|
1024
|
|
|
<div v-if='$field.type == \"total\"'> |
1025
|
|
|
|
1026
|
|
|
</div> |
1027
|
|
|
|
1028
|
|
|
<div v-if='$field.type == \"checkboxes\"'> |
1029
|
|
|
|
1030
|
|
|
</div> |
1031
|
|
|
|
1032
|
|
|
<div v-if='$field.type == \"radio\"'> |
1033
|
|
|
|
1034
|
|
|
</div> |
1035
|
|
|
|
1036
|
|
|
<div v-if='$field.show_total'> |
1037
|
|
|
|
1038
|
|
|
</div> |
1039
|
|
|
<small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
1040
|
|
|
|
1041
|
|
|
<pre> |
1042
|
|
|
// TODO: Ask admin to select which items he/she |
1043
|
|
|
// wants to sell via this form |
1044
|
|
|
|
1045
|
|
|
// TODO:- Let admin set whether they want customers to select some items, |
1046
|
|
|
// a single item( use case variations), or be tied to all items ( i.e |
1047
|
|
|
// Only display the totals) |
1048
|
|
|
</pre> |
1049
|
|
|
</div> |
1050
|
|
|
"; |
1051
|
|
|
} |
1052
|
|
|
|
1053
|
|
|
/** |
1054
|
|
|
* Renders the items element template. |
1055
|
|
|
*/ |
1056
|
|
|
public function edit_items_template( $field ) { |
1057
|
|
|
$restrict = $this->get_restrict_markup( $field, 'items' ); |
1058
|
|
|
$label = __( 'Items Type', 'invoicing' ); |
|
|
|
|
1059
|
|
|
$label2 = __( 'Help Text', 'invoicing' ); |
|
|
|
|
1060
|
|
|
$label3 = esc_attr__( 'Add some help text for this element', 'invoicing' ); |
|
|
|
|
1061
|
|
|
$label4 = __( 'Button Text', 'invoicing' ); |
|
|
|
|
1062
|
|
|
$label5 = __( 'Items', 'invoicing' ); |
|
|
|
|
1063
|
|
|
$label6 = esc_attr__( 'Select the items that you want to sell via this form.', 'invoicing' ); |
|
|
|
|
1064
|
|
|
$id = $field . '.id + "_edit"'; |
|
|
|
|
1065
|
|
|
$id2 = $field . '.id + "_edit2"'; |
|
|
|
|
1066
|
|
|
$id3 = $field . '.id + "_edit3"'; |
|
|
|
|
1067
|
|
|
$id4 = $field . '.id + "_edit4"'; |
|
|
|
|
1068
|
|
|
echo "<div $restrict> |
1069
|
|
|
|
1070
|
|
|
<pre> |
1071
|
|
|
{{items}} |
1072
|
|
|
</pre> |
1073
|
|
|
|
1074
|
|
|
</div> |
1075
|
|
|
"; |
1076
|
|
|
|
1077
|
|
|
} |
1078
|
|
|
|
1079
|
|
|
public function get_published_items() { |
1080
|
|
|
|
1081
|
|
|
$item_args = array( |
1082
|
|
|
'post_type' => 'wpi_item', |
1083
|
|
|
'orderby' => 'title', |
1084
|
|
|
'order' => 'ASC', |
1085
|
|
|
'posts_per_page' => -1, |
1086
|
|
|
'post_status' => array( 'publish' ), |
1087
|
|
|
); |
1088
|
|
|
|
1089
|
|
|
$items = get_posts( apply_filters( 'wpinv_item_dropdown_query_args', $item_args ) ); |
1090
|
|
|
|
1091
|
|
|
if ( empty( $items ) ) { |
1092
|
|
|
return array(); |
1093
|
|
|
} |
1094
|
|
|
|
1095
|
|
|
$options = array(); |
1096
|
|
|
foreach ( $items as $item ) { |
1097
|
|
|
$title = esc_html( $item->post_title ); |
1098
|
|
|
$title .= wpinv_get_item_suffix( $item->ID, false ); |
1099
|
|
|
$id = absint( $item->ID ); |
1100
|
|
|
$price = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) ); |
1101
|
|
|
$recurring = get_post_meta( $id, '_wpinv_is_recurring', true ); |
1102
|
|
|
|
1103
|
|
|
$options[] = compact( 'title', 'id', 'price', 'recurring'); |
1104
|
|
|
} |
1105
|
|
|
return $options; |
1106
|
|
|
|
1107
|
|
|
} |
1108
|
|
|
|
1109
|
|
|
} |
1110
|
|
|
|