| Total Complexity | 192 |
| Total Lines | 2901 |
| Duplicated Lines | 0 % |
| Changes | 16 | ||
| Bugs | 0 | Features | 2 |
Complex classes like WPInv_Payment_Form_Elements often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use WPInv_Payment_Form_Elements, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 7 | class WPInv_Payment_Form_Elements { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @param array payment form elements |
||
| 11 | */ |
||
| 12 | protected $elements; |
||
| 13 | |||
| 14 | public function __construct() { |
||
| 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 | 'value' => '', |
||
| 153 | 'label' => __( 'Date', 'invoicing' ), |
||
| 154 | 'description' => '', |
||
| 155 | 'required' => false, |
||
| 156 | ) |
||
| 157 | ), |
||
| 158 | |||
| 159 | array( |
||
| 160 | 'type' => 'time', |
||
| 161 | 'name' => __( 'Time', 'invoicing' ), |
||
| 162 | 'defaults' => array( |
||
| 163 | 'value' => '', |
||
| 164 | 'label' => __( 'Time', 'invoicing' ), |
||
| 165 | 'description' => '', |
||
| 166 | 'required' => false, |
||
| 167 | ) |
||
| 168 | ), |
||
| 169 | |||
| 170 | array( |
||
| 171 | 'type' => 'number', |
||
| 172 | 'name' => __( 'Number', 'invoicing' ), |
||
| 173 | 'defaults' => array( |
||
| 174 | 'placeholder' => '', |
||
| 175 | 'value' => '', |
||
| 176 | 'label' => __( 'Number', 'invoicing' ), |
||
| 177 | 'description' => '', |
||
| 178 | 'required' => false, |
||
| 179 | ) |
||
| 180 | ), |
||
| 181 | |||
| 182 | array( |
||
| 183 | 'type' => 'website', |
||
| 184 | 'name' => __( 'Website', 'invoicing' ), |
||
| 185 | 'defaults' => array( |
||
| 186 | 'placeholder' => 'http://example.com', |
||
| 187 | 'value' => '', |
||
| 188 | 'label' => __( 'Website', 'invoicing' ), |
||
| 189 | 'description' => '', |
||
| 190 | 'required' => false, |
||
| 191 | ) |
||
| 192 | ), |
||
| 193 | |||
| 194 | array( |
||
| 195 | 'type' => 'email', |
||
| 196 | 'name' => __( 'Email', 'invoicing' ), |
||
| 197 | 'defaults' => array( |
||
| 198 | 'placeholder' => '[email protected]', |
||
| 199 | 'value' => '', |
||
| 200 | 'label' => __( 'Email Address', 'invoicing' ), |
||
| 201 | 'description' => '', |
||
| 202 | 'required' => false, |
||
| 203 | ) |
||
| 204 | ), |
||
| 205 | |||
| 206 | array( |
||
| 207 | 'type' => 'address', |
||
| 208 | 'name' => __( 'Address', 'invoicing' ), |
||
| 209 | 'defaults' => array( |
||
| 210 | |||
| 211 | 'fields' => array( |
||
| 212 | array( |
||
| 213 | 'placeholder' => 'Jon', |
||
| 214 | 'value' => '', |
||
| 215 | 'label' => __( 'First Name', 'invoicing' ), |
||
| 216 | 'description' => '', |
||
| 217 | 'required' => false, |
||
| 218 | 'visible' => true, |
||
| 219 | 'name' => 'wpinv_first_name', |
||
| 220 | ), |
||
| 221 | |||
| 222 | array( |
||
| 223 | 'placeholder' => 'Snow', |
||
| 224 | 'value' => '', |
||
| 225 | 'label' => __( 'Last Name', 'invoicing' ), |
||
| 226 | 'description' => '', |
||
| 227 | 'required' => false, |
||
| 228 | 'visible' => true, |
||
| 229 | 'name' => 'wpinv_last_name', |
||
| 230 | ), |
||
| 231 | |||
| 232 | array( |
||
| 233 | 'placeholder' => '', |
||
| 234 | 'value' => '', |
||
| 235 | 'label' => __( 'Address', 'invoicing' ), |
||
| 236 | 'description' => '', |
||
| 237 | 'required' => false, |
||
| 238 | 'visible' => true, |
||
| 239 | 'name' => 'wpinv_address', |
||
| 240 | ), |
||
| 241 | |||
| 242 | array( |
||
| 243 | 'placeholder' => '', |
||
| 244 | 'value' => '', |
||
| 245 | 'label' => __( 'City', 'invoicing' ), |
||
| 246 | 'description' => '', |
||
| 247 | 'required' => false, |
||
| 248 | 'visible' => true, |
||
| 249 | 'name' => 'wpinv_city', |
||
| 250 | ), |
||
| 251 | |||
| 252 | array( |
||
| 253 | 'placeholder' => __( 'Select your country' ), |
||
| 254 | 'value' => '', |
||
| 255 | 'label' => __( 'Country', 'invoicing' ), |
||
| 256 | 'description' => '', |
||
| 257 | 'required' => false, |
||
| 258 | 'visible' => true, |
||
| 259 | 'name' => 'wpinv_country', |
||
| 260 | ), |
||
| 261 | |||
| 262 | array( |
||
| 263 | 'placeholder' => __( 'Choose a state', 'invoicing' ), |
||
| 264 | 'value' => '', |
||
| 265 | 'label' => __( 'State / Province', 'invoicing' ), |
||
| 266 | 'description' => '', |
||
| 267 | 'required' => false, |
||
| 268 | 'visible' => true, |
||
| 269 | 'name' => 'wpinv_state', |
||
| 270 | ), |
||
| 271 | |||
| 272 | array( |
||
| 273 | 'placeholder' => '', |
||
| 274 | 'value' => '', |
||
| 275 | 'label' => __( 'ZIP / Postcode', 'invoicing' ), |
||
| 276 | 'description' => '', |
||
| 277 | 'required' => false, |
||
| 278 | 'visible' => true, |
||
| 279 | 'name' => 'wpinv_zip', |
||
| 280 | ), |
||
| 281 | |||
| 282 | array( |
||
| 283 | 'placeholder' => '', |
||
| 284 | 'value' => '', |
||
| 285 | 'label' => __( 'Phone', 'invoicing' ), |
||
| 286 | 'description' => '', |
||
| 287 | 'required' => false, |
||
| 288 | 'visible' => true, |
||
| 289 | 'name' => 'wpinv_phone', |
||
| 290 | ) |
||
| 291 | ) |
||
| 292 | ) |
||
| 293 | ), |
||
| 294 | |||
| 295 | array( |
||
| 296 | 'type' => 'billing_email', |
||
| 297 | 'name' => __( 'Billing Email', 'invoicing' ), |
||
| 298 | 'defaults' => array( |
||
| 299 | 'placeholder' => '[email protected]', |
||
| 300 | 'value' => '', |
||
| 301 | 'label' => __( 'Billing Email', 'invoicing' ), |
||
| 302 | 'description' => '', |
||
| 303 | 'premade' => true, |
||
| 304 | ) |
||
| 305 | ), |
||
| 306 | /* |
||
| 307 | array( |
||
| 308 | 'type' => 'discount', |
||
| 309 | 'name' => __( 'Discount Input', 'invoicing' ), |
||
| 310 | 'defaults' => array( |
||
| 311 | 'value' => '', |
||
| 312 | 'input_label' => __( 'Coupon Code', 'invoicing' ), |
||
| 313 | 'button_label' => __( 'Apply Coupon', 'invoicing' ), |
||
| 314 | 'description' => __( 'Have a discount code? Enter it above.', 'invoicing' ), |
||
| 315 | ) |
||
| 316 | ),*/ |
||
| 317 | |||
| 318 | array( |
||
| 319 | 'type' => 'items', |
||
| 320 | 'name' => __( 'Items', 'invoicing' ), |
||
| 321 | 'defaults' => array( |
||
| 322 | 'value' => '', |
||
| 323 | 'items_type' => 'total', |
||
| 324 | 'description' => '', |
||
| 325 | 'premade' => true, |
||
| 326 | ) |
||
| 327 | ), |
||
| 328 | |||
| 329 | array( |
||
| 330 | 'type' => 'pay_button', |
||
| 331 | 'name' => __( 'Payment Button', 'invoicing' ), |
||
| 332 | 'defaults' => array( |
||
| 333 | 'value' => '', |
||
| 334 | 'class' => 'btn-primary', |
||
| 335 | 'label' => __( 'Pay Now »', 'invoicing' ), |
||
| 336 | 'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
||
| 337 | 'premade' => true, |
||
| 338 | ) |
||
| 339 | ) |
||
| 340 | ); |
||
| 341 | |||
| 342 | $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements ); |
||
| 343 | return $this->elements; |
||
| 344 | } |
||
| 345 | |||
| 346 | /** |
||
| 347 | * Returns the restrict markup. |
||
| 348 | */ |
||
| 349 | public function get_restrict_markup( $field, $field_type ) { |
||
| 350 | $restrict = "$field.type=='$field_type'"; |
||
| 351 | return "v-if=\"$restrict\""; |
||
| 352 | } |
||
| 353 | |||
| 354 | /** |
||
| 355 | * Renders the title element template. |
||
| 356 | */ |
||
| 357 | public function render_heading_template( $field ) { |
||
| 358 | $restrict = $this->get_restrict_markup( $field, 'heading' ); |
||
| 359 | echo "<component :is='$field.level' $restrict v-html='$field.text'></component>"; |
||
| 360 | } |
||
| 361 | |||
| 362 | /** |
||
| 363 | * Renders the title element on the frontend. |
||
| 364 | */ |
||
| 365 | public function frontend_render_heading_template( $field ) { |
||
| 366 | $tag = $field['level']; |
||
| 367 | echo "<$tag>{$field['text']}</$tag>"; |
||
| 368 | } |
||
| 369 | |||
| 370 | /** |
||
| 371 | * Renders the edit title element template. |
||
| 372 | */ |
||
| 373 | public function edit_heading_template( $field ) { |
||
| 374 | $restrict = $this->get_restrict_markup( $field, 'heading' ); |
||
| 375 | $label = __( 'Heading', 'invoicing' ); |
||
| 376 | $label2 = __( 'Select Heading Level', 'invoicing' ); |
||
| 377 | $id = $field . '.id + "_edit"'; |
||
| 378 | $id2 = $field . '.id + "_edit2"'; |
||
| 379 | |||
| 380 | echo " |
||
| 381 | <div $restrict> |
||
| 382 | <div class='form-group'> |
||
| 383 | <label :for='$id'>$label</label> |
||
| 384 | <input class='form-control' :id='$id' v-model='$field.text' type='text' /> |
||
| 385 | </div> |
||
| 386 | |||
| 387 | <div class='form-group'> |
||
| 388 | <label :for='$id2'>$label2</label> |
||
| 389 | |||
| 390 | <select class='form-control custom-select' :id='$id2' v-model='$field.level'> |
||
| 391 | <option value='h1'>H1</option> |
||
| 392 | <option value='h2'>H2</option> |
||
| 393 | <option value='h3'>H3</option> |
||
| 394 | <option value='h4'>H4</option> |
||
| 395 | <option value='h5'>H5</option> |
||
| 396 | <option value='h6'>H6</option> |
||
| 397 | <option value='h7'>H7</option> |
||
| 398 | </select> |
||
| 399 | </div> |
||
| 400 | </div> |
||
| 401 | "; |
||
| 402 | |||
| 403 | } |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Renders a paragraph element template. |
||
| 407 | */ |
||
| 408 | public function render_paragraph_template( $field ) { |
||
| 409 | $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
||
| 410 | $label = "$field.text"; |
||
| 411 | echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>"; |
||
| 412 | } |
||
| 413 | |||
| 414 | /** |
||
| 415 | * Renders the paragraph element on the frontend. |
||
| 416 | */ |
||
| 417 | public function frontend_render_paragraph_template( $field ) { |
||
| 418 | echo "<p>{$field['text']}</p>"; |
||
| 419 | } |
||
| 420 | |||
| 421 | /** |
||
| 422 | * Renders the edit paragraph element template. |
||
| 423 | */ |
||
| 424 | public function edit_paragraph_template( $field ) { |
||
| 425 | $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
||
| 426 | $label = __( 'Enter your text', 'invoicing' ); |
||
| 427 | $id = $field . '.id + "_edit"'; |
||
| 428 | echo " |
||
| 429 | <div $restrict> |
||
| 430 | <div class='form-group'> |
||
| 431 | <label :for='$id'>$label</label> |
||
| 432 | <textarea :id='$id' v-model='$field.text' class='form-control' rows='3'></textarea> |
||
| 433 | </div> |
||
| 434 | </div> |
||
| 435 | "; |
||
| 436 | |||
| 437 | } |
||
| 438 | |||
| 439 | /** |
||
| 440 | * Renders the text element template. |
||
| 441 | */ |
||
| 442 | public function render_text_template( $field ) { |
||
| 443 | $restrict = $this->get_restrict_markup( $field, 'text' ); |
||
| 444 | $label = "$field.label"; |
||
| 445 | echo " |
||
| 446 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 447 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 448 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 449 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='text'> |
||
| 450 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 451 | </div> |
||
| 452 | "; |
||
| 453 | } |
||
| 454 | |||
| 455 | /** |
||
| 456 | * Renders the text element on the frontend. |
||
| 457 | */ |
||
| 458 | public function frontend_render_text_template( $field ) { |
||
| 459 | |||
| 460 | echo "<div class='form-group'>"; |
||
| 461 | |||
| 462 | echo aui()->input( |
||
|
|
|||
| 463 | array( |
||
| 464 | 'name' => esc_attr( $field['id'] ), |
||
| 465 | 'id' => esc_attr( $field['id'] ), |
||
| 466 | 'placeholder'=> esc_attr( $field['placeholder'] ), |
||
| 467 | 'required' => (bool) $field['required'], |
||
| 468 | 'label' => wp_kses_post( $field['label'] ), |
||
| 469 | 'no_wrap' => true, |
||
| 470 | ) |
||
| 471 | ); |
||
| 472 | |||
| 473 | if ( ! empty( $field['description'] ) ) { |
||
| 474 | $description = wp_kses_post( $field['description'] ); |
||
| 475 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 476 | } |
||
| 477 | |||
| 478 | echo '</div>'; |
||
| 479 | |||
| 480 | } |
||
| 481 | |||
| 482 | /** |
||
| 483 | * Renders the edit text element template. |
||
| 484 | */ |
||
| 485 | public function edit_text_template( $field ) { |
||
| 486 | $restrict = $this->get_restrict_markup( $field, 'text' ); |
||
| 487 | $label = __( 'Field Label', 'invoicing' ); |
||
| 488 | $id = $field . '.id + "_edit"'; |
||
| 489 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 490 | $id2 = $field . '.id + "_edit2"'; |
||
| 491 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 492 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 493 | $id3 = $field . '.id + "_edit3"'; |
||
| 494 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 495 | $id4 = $field . '.id + "_edit4"'; |
||
| 496 | echo " |
||
| 497 | <div $restrict> |
||
| 498 | <div class='form-group'> |
||
| 499 | <label :for='$id'>$label</label> |
||
| 500 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 501 | </div> |
||
| 502 | <div class='form-group'> |
||
| 503 | <label :for='$id2'>$label2</label> |
||
| 504 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 505 | </div> |
||
| 506 | <div class='form-group'> |
||
| 507 | <label :for='$id3'>$label3</label> |
||
| 508 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 509 | </div> |
||
| 510 | <div class='form-group form-check'> |
||
| 511 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 512 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 513 | </div> |
||
| 514 | </div> |
||
| 515 | "; |
||
| 516 | |||
| 517 | } |
||
| 518 | |||
| 519 | /** |
||
| 520 | * Renders the textarea element template. |
||
| 521 | */ |
||
| 522 | public function render_textarea_template( $field ) { |
||
| 523 | $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
||
| 524 | $label = "$field.label"; |
||
| 525 | echo " |
||
| 526 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 527 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 528 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 529 | <textarea :placeholder='$field.placeholder' :id='$field.id' class='form-control' rows='3'></textarea> |
||
| 530 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 531 | </div> |
||
| 532 | "; |
||
| 533 | } |
||
| 534 | |||
| 535 | /** |
||
| 536 | * Renders the textarea element on the frontend. |
||
| 537 | */ |
||
| 538 | public function frontend_render_textarea_template( $field ) { |
||
| 560 | |||
| 561 | } |
||
| 562 | |||
| 563 | /** |
||
| 564 | * Renders the edit textarea element template. |
||
| 565 | */ |
||
| 566 | public function edit_textarea_template( $field ) { |
||
| 594 | </div> |
||
| 595 | </div> |
||
| 596 | "; |
||
| 597 | |||
| 598 | } |
||
| 599 | |||
| 600 | /** |
||
| 601 | * Renders the select element template. |
||
| 602 | */ |
||
| 603 | public function render_select_template( $field ) { |
||
| 604 | $restrict = $this->get_restrict_markup( $field, 'select' ); |
||
| 605 | $label = "$field.label"; |
||
| 606 | $placeholder = "$field.placeholder"; |
||
| 607 | $id = $field . '.id'; |
||
| 608 | echo " |
||
| 609 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 610 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 611 | <label :for='$id'>{{" . $label . "}}</label> |
||
| 612 | <select id='$id' class='form-control custom-select' v-model='$field.value'> |
||
| 613 | <option v-if='$placeholder' value='' disabled>{{" . $placeholder . "}}</option> |
||
| 614 | <option v-for='option in $field.options' value='option'>{{option}}</option> |
||
| 615 | </select> |
||
| 616 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 617 | </div> |
||
| 618 | "; |
||
| 619 | } |
||
| 620 | |||
| 621 | /** |
||
| 622 | * Renders the select element on the frontend. |
||
| 623 | */ |
||
| 624 | public function frontend_render_select_template( $field ) { |
||
| 625 | |||
| 626 | echo "<div class='form-group'>"; |
||
| 627 | |||
| 628 | echo aui()->select( |
||
| 629 | array( |
||
| 630 | 'name' => esc_attr( $field['id'] ), |
||
| 631 | 'id' => esc_attr( $field['id'] ), |
||
| 632 | 'placeholder'=> esc_attr( $field['placeholder'] ), |
||
| 633 | 'required' => (bool) $field['required'], |
||
| 634 | 'label' => wp_kses_post( $field['label'] ), |
||
| 635 | 'no_wrap' => true, |
||
| 636 | 'options' => array_combine( $field['options'], $field['options'] ), |
||
| 637 | ) |
||
| 638 | ); |
||
| 639 | |||
| 640 | if ( ! empty( $field['description'] ) ) { |
||
| 641 | $description = wp_kses_post( $field['description'] ); |
||
| 642 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 643 | } |
||
| 644 | |||
| 645 | echo '</div>'; |
||
| 646 | |||
| 647 | } |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Renders the edit select element template. |
||
| 651 | */ |
||
| 652 | public function edit_select_template( $field ) { |
||
| 653 | $restrict = $this->get_restrict_markup( $field, 'select' ); |
||
| 654 | $label = __( 'Field Label', 'invoicing' ); |
||
| 655 | $id = $field . '.id + "_edit"'; |
||
| 656 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 657 | $id2 = $field . '.id + "_edit2"'; |
||
| 658 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 659 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 660 | $id3 = $field . '.id + "_edit3"'; |
||
| 661 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 662 | $id4 = $field . '.id + "_edit4"'; |
||
| 663 | $label6 = __( 'Available Options', 'invoicing' ); |
||
| 664 | echo " |
||
| 665 | <div $restrict> |
||
| 666 | <div class='form-group'> |
||
| 667 | <label :for='$id'>$label</label> |
||
| 668 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 669 | </div> |
||
| 670 | <div class='form-group'> |
||
| 671 | <label :for='$id2'>$label2</label> |
||
| 672 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 673 | </div> |
||
| 674 | <div class='form-group'> |
||
| 675 | <label :for='$id3'>$label3</label> |
||
| 676 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 677 | </div> |
||
| 678 | <div class='form-group form-check'> |
||
| 679 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 680 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 681 | </div> |
||
| 682 | <hr class='featurette-divider mt-4'> |
||
| 683 | <h5>$label6</h5> |
||
| 684 | <div class='form-group input-group' v-for='(option, index) in $field.options'> |
||
| 685 | <input type='text' class='form-control' v-model='$field.options[index]'> |
||
| 686 | <div class='input-group-append'> |
||
| 687 | <button class='button button-secondary border' type='button' @click.prevent='$field.options.splice(index, 1)'><span class='dashicons dashicons-trash'></span></button> |
||
| 688 | </div> |
||
| 689 | </div> |
||
| 690 | <div class='form-group'> |
||
| 691 | <button class='button button-secondary' type='button' @click.prevent='$field.options.push(\"\")'>Add Option</button> |
||
| 692 | </div> |
||
| 693 | </div> |
||
| 694 | "; |
||
| 695 | |||
| 696 | } |
||
| 697 | |||
| 698 | /** |
||
| 699 | * Renders the checkbox element template. |
||
| 700 | */ |
||
| 701 | public function render_checkbox_template( $field ) { |
||
| 702 | $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
||
| 703 | $label = "$field.label"; |
||
| 704 | echo " |
||
| 705 | <div class='form-check' $restrict> |
||
| 706 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 707 | <input :id='$field.id' class='form-check-input' type='checkbox' /> |
||
| 708 | <label class='form-check-label' :for='$field.id'>{{" . $label . "}}</label> |
||
| 709 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 710 | </div> |
||
| 711 | "; |
||
| 712 | } |
||
| 713 | |||
| 714 | /** |
||
| 715 | * Renders the checkbox element on the frontend. |
||
| 716 | */ |
||
| 717 | public function frontend_render_checkbox_template( $field ) { |
||
| 718 | |||
| 719 | echo "<div class='form-group'>"; |
||
| 720 | |||
| 721 | echo aui()->input( |
||
| 722 | array( |
||
| 723 | 'name' => esc_attr( $field['id'] ), |
||
| 724 | 'id' => esc_attr( $field['id'] ), |
||
| 725 | 'required' => (bool) $field['required'], |
||
| 726 | 'label' => wp_kses_post( $field['label'] ), |
||
| 727 | 'no_wrap' => true, |
||
| 728 | 'value' => esc_attr__( 'Yes', 'invoicing' ), |
||
| 729 | 'type' => 'checkbox', |
||
| 730 | ) |
||
| 731 | ); |
||
| 732 | |||
| 733 | if ( ! empty( $field['description'] ) ) { |
||
| 734 | $description = wp_kses_post( $field['description'] ); |
||
| 735 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 736 | } |
||
| 737 | |||
| 738 | echo '</div>'; |
||
| 739 | |||
| 740 | } |
||
| 741 | |||
| 742 | /** |
||
| 743 | * Renders the edit checkbox element template. |
||
| 744 | */ |
||
| 745 | public function edit_checkbox_template( $field ) { |
||
| 746 | $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
||
| 747 | $label = __( 'Field Label', 'invoicing' ); |
||
| 748 | $id = $field . '.id + "_edit"'; |
||
| 749 | $label2 = __( 'Help text', 'invoicing' ); |
||
| 750 | $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 751 | $id2 = $field . '.id + "_edit2"'; |
||
| 752 | $label4 = __( 'Is this field required?', 'invoicing' ); |
||
| 753 | $id3 = $field . '.id + "_edit3"'; |
||
| 754 | echo " |
||
| 755 | <div $restrict> |
||
| 756 | <div class='form-group'> |
||
| 757 | <label :for='$id'>$label</label> |
||
| 758 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 759 | </div> |
||
| 760 | <div class='form-group'> |
||
| 761 | <label :for='$id2'>$label2</label> |
||
| 762 | <textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 763 | </div> |
||
| 764 | <div class='form-group form-check'> |
||
| 765 | <input :id='$id3' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 766 | <label class='form-check-label' :for='$id3'>$label4</label> |
||
| 767 | </div> |
||
| 768 | </div> |
||
| 769 | "; |
||
| 770 | |||
| 771 | } |
||
| 772 | |||
| 773 | /** |
||
| 774 | * Renders the radio element template. |
||
| 775 | */ |
||
| 776 | public function render_radio_template( $field ) { |
||
| 777 | $restrict = $this->get_restrict_markup( $field, 'radio' ); |
||
| 778 | $label = "$field.label"; |
||
| 779 | $id = $field . '.id'; |
||
| 780 | echo " |
||
| 781 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 782 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 783 | <legend class='col-form-label' v-if='$label'>{{" . $label . "}}</legend> |
||
| 784 | <div class='form-check' v-for='(option, index) in $field.options'> |
||
| 785 | <input class='form-check-input' type='radio' :id='$id + index'> |
||
| 786 | <label class='form-check-label' :for='$id + index'>{{option}}</label> |
||
| 787 | </div> |
||
| 788 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 789 | </div> |
||
| 790 | "; |
||
| 791 | } |
||
| 792 | |||
| 793 | /** |
||
| 794 | * Renders the radio element on the frontend. |
||
| 795 | */ |
||
| 796 | public function frontend_render_radio_template( $field ) { |
||
| 797 | |||
| 798 | echo "<div class='form-group'>"; |
||
| 799 | |||
| 800 | if ( ! empty( $field['label'] ) ) { |
||
| 801 | $label = wp_kses_post( $field['label'] ); |
||
| 802 | echo "<legend class='col-form-label'>$label</legend>"; |
||
| 803 | } |
||
| 804 | |||
| 805 | foreach( $field['options'] as $index => $option ) { |
||
| 806 | $id = $field['id'] . $index; |
||
| 807 | $name = $field['id']; |
||
| 808 | $value = esc_attr( $option ); |
||
| 809 | $label = wp_kses_post( $option ); |
||
| 810 | |||
| 811 | echo " |
||
| 812 | <div class='form-check'> |
||
| 813 | <input class='form-check-input' type='radio' name='$name' id='$id' value='$value'> |
||
| 814 | <label class='form-check-label' for='$id'>$label</label> |
||
| 815 | </div> |
||
| 816 | "; |
||
| 817 | } |
||
| 818 | |||
| 819 | if ( ! empty( $field['description'] ) ) { |
||
| 820 | $description = wp_kses_post( $field['description'] ); |
||
| 821 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 822 | } |
||
| 823 | |||
| 824 | echo '</div>'; |
||
| 825 | |||
| 826 | } |
||
| 827 | |||
| 828 | /** |
||
| 829 | * Renders the edit radio element template. |
||
| 830 | */ |
||
| 831 | public function edit_radio_template( $field ) { |
||
| 832 | $restrict = $this->get_restrict_markup( $field, 'radio' ); |
||
| 833 | $label = __( 'Field Label', 'invoicing' ); |
||
| 834 | $id = $field . '.id + "_edit"'; |
||
| 835 | $label2 = __( 'Help text', 'invoicing' ); |
||
| 836 | $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 837 | $id2 = $field . '.id + "_edit3"'; |
||
| 838 | $label4 = __( 'Is this field required?', 'invoicing' ); |
||
| 839 | $id3 = $field . '.id + "_edit4"'; |
||
| 840 | $label5 = __( 'Available Options', 'invoicing' ); |
||
| 841 | echo " |
||
| 842 | <div $restrict> |
||
| 843 | <div class='form-group'> |
||
| 844 | <label :for='$id'>$label</label> |
||
| 845 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 846 | </div> |
||
| 847 | <div class='form-group'> |
||
| 848 | <label :for='$id2'>$label2</label> |
||
| 849 | <textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 850 | </div> |
||
| 851 | <div class='form-group form-check'> |
||
| 852 | <input :id='$id3' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 853 | <label class='form-check-label' :for='$id3'>$label4</label> |
||
| 854 | </div> |
||
| 855 | <hr class='featurette-divider mt-4'> |
||
| 856 | <h5>$label5</h5> |
||
| 857 | <div class='form-group input-group' v-for='(option, index) in $field.options'> |
||
| 858 | <input type='text' class='form-control' v-model='$field.options[index]'> |
||
| 859 | <div class='input-group-append'> |
||
| 860 | <button class='button button-secondary border' type='button' @click.prevent='$field.options.splice(index, 1)'><span class='dashicons dashicons-trash'></span></button> |
||
| 861 | </div> |
||
| 862 | </div> |
||
| 863 | <div class='form-group'> |
||
| 864 | <button class='button button-secondary' type='button' @click.prevent='$field.options.push(\"\")'>Add Option</button> |
||
| 865 | </div> |
||
| 866 | </div> |
||
| 867 | "; |
||
| 868 | |||
| 869 | } |
||
| 870 | |||
| 871 | /** |
||
| 872 | * Renders the address element template. |
||
| 873 | */ |
||
| 874 | public function render_address_template( $field ) { |
||
| 875 | $restrict = $this->get_restrict_markup( $field, 'address' ); |
||
| 876 | |||
| 877 | echo " |
||
| 878 | <div class='wpinv-address-wrapper' $restrict> |
||
| 879 | <draggable v-model='$field.fields' group='address_fields_preview'> |
||
| 880 | <div class='form-group address-field-preview wpinv-payment-form-field-preview' v-for='(field, index) in $field.fields' :key='field.name' v-show='field.visible'> |
||
| 881 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 882 | <label :for='field.name'>{{field.label}}<span class='text-danger' v-if='field.required'> *</span></label> |
||
| 883 | <input v-if='field.name !== \"wpinv_country\" && field.name !== \"wpinv_state\"' class='form-control' type='text' :id='field.name' :placeholder='field.placeholder'> |
||
| 884 | <select v-else class='form-control' :id='field.name'> |
||
| 885 | <option v-if='field.placeholder'>{{field.placeholder}}</option> |
||
| 886 | </select> |
||
| 887 | <small v-if='field.description' class='form-text text-muted' v-html='field.description'></small> |
||
| 888 | </div> |
||
| 889 | </draggable> |
||
| 890 | </div> |
||
| 891 | "; |
||
| 892 | } |
||
| 893 | |||
| 894 | /** |
||
| 895 | * Renders the address element on the frontend. |
||
| 896 | */ |
||
| 897 | public function frontend_render_address_template( $field ) { |
||
| 898 | |||
| 899 | echo "<div class='wpinv-address-fields'>"; |
||
| 900 | |||
| 901 | foreach( $field['fields'] as $address_field ) { |
||
| 902 | |||
| 903 | if ( empty( $address_field['visible'] ) ) { |
||
| 904 | continue; |
||
| 905 | } |
||
| 906 | |||
| 907 | $class = esc_attr( $address_field['name'] ); |
||
| 908 | echo "<div class='form-group $class'>"; |
||
| 909 | |||
| 910 | $label = $address_field['label']; |
||
| 911 | |||
| 912 | if ( ! empty( $address_field['required'] ) ) { |
||
| 913 | $label .= "<span class='text-danger'> *</span>"; |
||
| 914 | } |
||
| 915 | |||
| 916 | if ( 'wpinv_country' == $address_field['name'] ) { |
||
| 917 | |||
| 918 | echo aui()->select( array( |
||
| 919 | 'options' => wpinv_get_country_list(), |
||
| 920 | 'name' => esc_attr( $address_field['name'] ), |
||
| 921 | 'id' => esc_attr( $address_field['name'] ), |
||
| 922 | 'value' => wpinv_get_default_country(), |
||
| 923 | 'placeholder' => esc_attr( $address_field['placeholder'] ), |
||
| 924 | 'required' => (bool) $address_field['required'], |
||
| 925 | 'no_wrap' => true, |
||
| 926 | 'label' => wp_kses_post( $label ), |
||
| 927 | 'select2' => false, |
||
| 928 | )); |
||
| 929 | |||
| 930 | } else if ( 'wpinv_state' == $address_field['name'] ) { |
||
| 931 | |||
| 932 | $states = wpinv_get_country_states( wpinv_get_default_country() ); |
||
| 933 | $state = wpinv_get_default_state(); |
||
| 934 | |||
| 935 | if ( ! empty( $states ) ) { |
||
| 936 | |||
| 937 | echo aui()->select( array( |
||
| 938 | 'options' => $states, |
||
| 939 | 'name' => esc_attr( $address_field['name'] ), |
||
| 940 | 'id' => esc_attr( $address_field['name'] ), |
||
| 941 | 'value' => $state, |
||
| 942 | 'placeholder' => esc_attr( $address_field['placeholder'] ), |
||
| 943 | 'required' => (bool) $address_field['required'], |
||
| 944 | 'no_wrap' => true, |
||
| 945 | 'label' => wp_kses_post( $label ), |
||
| 946 | 'select2' => false, |
||
| 947 | )); |
||
| 948 | |||
| 949 | } else { |
||
| 950 | |||
| 951 | echo aui()->input( |
||
| 952 | array( |
||
| 953 | 'name' => esc_attr( $address_field['name'] ), |
||
| 954 | 'id' => esc_attr( $address_field['name'] ), |
||
| 955 | 'required' => (bool) $address_field['required'], |
||
| 956 | 'label' => wp_kses_post( $label ), |
||
| 957 | 'no_wrap' => true, |
||
| 958 | 'type' => 'text', |
||
| 959 | ) |
||
| 960 | ); |
||
| 961 | |||
| 962 | } |
||
| 963 | |||
| 964 | } else { |
||
| 965 | |||
| 966 | echo aui()->input( |
||
| 967 | array( |
||
| 968 | 'name' => esc_attr( $address_field['name'] ), |
||
| 969 | 'id' => esc_attr( $address_field['name'] ), |
||
| 970 | 'required' => (bool) $address_field['required'], |
||
| 971 | 'label' => wp_kses_post( $label ), |
||
| 972 | 'no_wrap' => true, |
||
| 973 | 'placeholder' => esc_attr( $address_field['placeholder'] ), |
||
| 974 | 'type' => 'text', |
||
| 975 | ) |
||
| 976 | ); |
||
| 977 | |||
| 978 | } |
||
| 979 | |||
| 980 | |||
| 981 | if ( ! empty( $address_field['description'] ) ) { |
||
| 982 | $description = wp_kses_post( $address_field['description'] ); |
||
| 983 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 984 | } |
||
| 985 | |||
| 986 | echo '</div>'; |
||
| 987 | |||
| 988 | } |
||
| 989 | |||
| 990 | echo '</div>'; |
||
| 991 | |||
| 992 | } |
||
| 993 | |||
| 994 | /** |
||
| 995 | * Renders the edit address element template. |
||
| 996 | */ |
||
| 997 | public function edit_address_template( $field ) { |
||
| 998 | $restrict = $this->get_restrict_markup( $field, 'address' ); |
||
| 999 | $label = __( 'Field Label', 'invoicing' ); |
||
| 1000 | $label2 = __( 'Placeholder', 'invoicing' ); |
||
| 1001 | $label3 = __( 'Description', 'invoicing' ); |
||
| 1002 | $label4 = __( 'Is required', 'invoicing' ); |
||
| 1003 | $label5 = __( 'Is visible', 'invoicing' ); |
||
| 1004 | $id = $field . '.id + "_edit_label"'; |
||
| 1005 | $id2 = $field . '.id + "_edit_placeholder"'; |
||
| 1006 | $id3 = $field . '.id + "_edit_description"'; |
||
| 1007 | $id4 = $field . '.id + "_edit_required"'; |
||
| 1008 | $id5 = $field . '.id + "_edit_visible"'; |
||
| 1009 | $id5 = $field . '.id + "_edit_visible"'; |
||
| 1010 | $id_main = $field . '.id'; |
||
| 1011 | |||
| 1012 | echo " |
||
| 1013 | <div $restrict :id='$id_main'> |
||
| 1014 | <draggable v-model='$field.fields' group='address_fields'> |
||
| 1015 | <div class='wpinv-form-address-field-editor' v-for='(field, index) in $field.fields' :class=\"[field.name, { 'visible' : field.visible }]\" :key='field.name'> |
||
| 1016 | |||
| 1017 | <div class='wpinv-form-address-field-editor-header' @click.prevent='toggleAddressPanel($id_main, field.name)'> |
||
| 1018 | <span class='label'>{{field.label}}</span> |
||
| 1019 | <span class='toggle-visibility-icon' @click.stop='field.visible = !field.visible;'> |
||
| 1020 | <span class='dashicons dashicons-hidden'></span> |
||
| 1021 | <span class='dashicons dashicons-visibility'></span> |
||
| 1022 | </span> |
||
| 1023 | <span class='toggle-icon'> |
||
| 1024 | <span class='dashicons dashicons-arrow-down'></span> |
||
| 1025 | <span class='dashicons dashicons-arrow-up' style='display:none'></span> |
||
| 1026 | </span> |
||
| 1027 | </div> |
||
| 1028 | |||
| 1029 | <div class='wpinv-form-address-field-editor-editor-body'> |
||
| 1030 | <div class='p-2'> |
||
| 1031 | |||
| 1032 | <div class='form-group'> |
||
| 1033 | <label :for='$id + index'>$label</label> |
||
| 1034 | <input :id='$id + index' v-model='field.label' class='form-control' /> |
||
| 1035 | </div> |
||
| 1036 | |||
| 1037 | <div class='form-group'> |
||
| 1038 | <label :for='$id2 + index'>$label2</label> |
||
| 1039 | <input :id='$id2 + index' v-model='field.placeholder' class='form-control' /> |
||
| 1040 | </div> |
||
| 1041 | |||
| 1042 | <div class='form-group'> |
||
| 1043 | <label :for='$id3 + index'>$label3</label> |
||
| 1044 | <textarea :id='$id3 + index' v-model='field.description' class='form-control'></textarea> |
||
| 1045 | </div> |
||
| 1046 | |||
| 1047 | <div class='form-group form-check'> |
||
| 1048 | <input :id='$id4 + index' v-model='field.required' type='checkbox' class='form-check-input' /> |
||
| 1049 | <label class='form-check-label' :for='$id4 + index'>$label4</label> |
||
| 1050 | </div> |
||
| 1051 | |||
| 1052 | <div class='form-group form-check'> |
||
| 1053 | <input :id='$id5 + index' v-model='field.visible' type='checkbox' class='form-check-input' /> |
||
| 1054 | <label class='form-check-label' :for='$id5 + index'>$label5</label> |
||
| 1055 | </div> |
||
| 1056 | |||
| 1057 | </div> |
||
| 1058 | </div> |
||
| 1059 | |||
| 1060 | </div> |
||
| 1061 | </draggable> |
||
| 1062 | |||
| 1063 | </div> |
||
| 1064 | "; |
||
| 1065 | |||
| 1066 | } |
||
| 1067 | |||
| 1068 | /** |
||
| 1069 | * Renders the email element template. |
||
| 1070 | */ |
||
| 1071 | public function render_email_template( $field ) { |
||
| 1072 | $restrict = $this->get_restrict_markup( $field, 'email' ); |
||
| 1073 | $label = "$field.label"; |
||
| 1074 | echo " |
||
| 1075 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 1076 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 1077 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 1078 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='email'> |
||
| 1079 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 1080 | </div> |
||
| 1081 | "; |
||
| 1082 | } |
||
| 1083 | |||
| 1084 | /** |
||
| 1085 | * Renders the billing_email element template. |
||
| 1086 | */ |
||
| 1087 | public function render_billing_email_template( $field ) { |
||
| 1088 | $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
||
| 1089 | $label = "$field.label"; |
||
| 1090 | echo " |
||
| 1091 | <div $restrict> |
||
| 1092 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 1093 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='email'> |
||
| 1094 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 1095 | </div> |
||
| 1096 | "; |
||
| 1097 | } |
||
| 1098 | |||
| 1099 | /** |
||
| 1100 | * Renders the email element on the frontend. |
||
| 1101 | */ |
||
| 1102 | public function frontend_render_email_template( $field ) { |
||
| 1103 | |||
| 1104 | echo "<div class='form-group'>"; |
||
| 1105 | |||
| 1106 | echo aui()->input( |
||
| 1107 | array( |
||
| 1108 | 'name' => esc_attr( $field['id'] ), |
||
| 1109 | 'id' => esc_attr( $field['id'] ), |
||
| 1110 | 'required' => (bool) $field['required'], |
||
| 1111 | 'label' => wp_kses_post( $field['label'] ), |
||
| 1112 | 'no_wrap' => true, |
||
| 1113 | 'placeholder' => esc_attr( $field['placeholder'] ), |
||
| 1114 | 'type' => 'email', |
||
| 1115 | ) |
||
| 1116 | ); |
||
| 1117 | |||
| 1118 | if ( ! empty( $field['description'] ) ) { |
||
| 1119 | $description = wp_kses_post( $field['description'] ); |
||
| 1120 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 1121 | } |
||
| 1122 | |||
| 1123 | echo '</div>'; |
||
| 1124 | |||
| 1125 | } |
||
| 1126 | |||
| 1127 | /** |
||
| 1128 | * Renders the billing email element on the frontend. |
||
| 1129 | */ |
||
| 1130 | public function frontend_render_billing_email_template( $field ) { |
||
| 1131 | |||
| 1132 | echo "<div class='form-group'>"; |
||
| 1133 | $value = ''; |
||
| 1134 | |||
| 1135 | if ( is_user_logged_in() ) { |
||
| 1136 | $user = wp_get_current_user(); |
||
| 1137 | $value = sanitize_email( $user->user_email ); |
||
| 1138 | } |
||
| 1139 | echo aui()->input( |
||
| 1140 | array( |
||
| 1141 | 'name' => 'billing_email', |
||
| 1142 | 'value' => $value, |
||
| 1143 | 'id' => esc_attr( $field['id'] ), |
||
| 1144 | 'required' => true, |
||
| 1145 | 'label' => wp_kses_post( $field['label'] ), |
||
| 1146 | 'no_wrap' => true, |
||
| 1147 | 'placeholder' => esc_attr( $field['placeholder'] ), |
||
| 1148 | 'type' => 'email', |
||
| 1149 | ) |
||
| 1150 | ); |
||
| 1151 | |||
| 1152 | if ( ! empty( $field['description'] ) ) { |
||
| 1153 | $description = wp_kses_post( $field['description'] ); |
||
| 1154 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 1155 | } |
||
| 1156 | |||
| 1157 | echo '</div>'; |
||
| 1158 | |||
| 1159 | } |
||
| 1160 | |||
| 1161 | /** |
||
| 1162 | * Renders the edit email element template. |
||
| 1163 | */ |
||
| 1164 | public function edit_email_template( $field ) { |
||
| 1165 | $restrict = $this->get_restrict_markup( $field, 'email' ); |
||
| 1166 | $label = __( 'Field Label', 'invoicing' ); |
||
| 1167 | $id = $field . '.id + "_edit"'; |
||
| 1168 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 1169 | $id2 = $field . '.id + "_edit2"'; |
||
| 1170 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 1171 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1172 | $id3 = $field . '.id + "_edit3"'; |
||
| 1173 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 1174 | $id4 = $field . '.id + "_edit4"'; |
||
| 1175 | echo " |
||
| 1176 | <div $restrict> |
||
| 1177 | <div class='form-group'> |
||
| 1178 | <label :for='$id'>$label</label> |
||
| 1179 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 1180 | </div> |
||
| 1181 | <div class='form-group'> |
||
| 1182 | <label :for='$id2'>$label2</label> |
||
| 1183 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 1184 | </div> |
||
| 1185 | <div class='form-group'> |
||
| 1186 | <label :for='$id3'>$label3</label> |
||
| 1187 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1188 | </div> |
||
| 1189 | <div class='form-group form-check'> |
||
| 1190 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 1191 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 1192 | </div> |
||
| 1193 | </div> |
||
| 1194 | "; |
||
| 1195 | |||
| 1196 | } |
||
| 1197 | |||
| 1198 | /** |
||
| 1199 | * Renders the edit billing_email element template. |
||
| 1200 | */ |
||
| 1201 | public function edit_billing_email_template( $field ) { |
||
| 1202 | $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
||
| 1203 | $label = __( 'Field Label', 'invoicing' ); |
||
| 1204 | $id = $field . '.id + "_edit"'; |
||
| 1205 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 1206 | $id2 = $field . '.id + "_edit2"'; |
||
| 1207 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 1208 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1209 | $id3 = $field . '.id + "_edit3"'; |
||
| 1210 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 1211 | $id4 = $field . '.id + "_edit4"'; |
||
| 1212 | echo " |
||
| 1213 | <div $restrict> |
||
| 1214 | <div class='form-group'> |
||
| 1215 | <label :for='$id'>$label</label> |
||
| 1216 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 1217 | </div> |
||
| 1218 | <div class='form-group'> |
||
| 1219 | <label :for='$id2'>$label2</label> |
||
| 1220 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 1221 | </div> |
||
| 1222 | <div class='form-group'> |
||
| 1223 | <label :for='$id3'>$label3</label> |
||
| 1224 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1225 | </div> |
||
| 1226 | </div> |
||
| 1227 | "; |
||
| 1228 | |||
| 1229 | } |
||
| 1230 | |||
| 1231 | /** |
||
| 1232 | * Renders the website element template. |
||
| 1233 | */ |
||
| 1234 | public function render_website_template( $field ) { |
||
| 1235 | $restrict = $this->get_restrict_markup( $field, 'website' ); |
||
| 1236 | $label = "$field.label"; |
||
| 1237 | echo " |
||
| 1238 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 1239 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 1240 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 1241 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='url'> |
||
| 1242 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 1243 | </div> |
||
| 1244 | "; |
||
| 1245 | } |
||
| 1246 | |||
| 1247 | /** |
||
| 1248 | * Renders the website element on the frontend. |
||
| 1249 | */ |
||
| 1250 | public function frontend_render_website_template( $field ) { |
||
| 1251 | |||
| 1252 | echo "<div class='form-group'>"; |
||
| 1253 | |||
| 1254 | echo aui()->input( |
||
| 1255 | array( |
||
| 1256 | 'name' => esc_attr( $field['id'] ), |
||
| 1257 | 'id' => esc_attr( $field['id'] ), |
||
| 1258 | 'required' => (bool) $field['required'], |
||
| 1259 | 'label' => wp_kses_post( $field['label'] ), |
||
| 1260 | 'no_wrap' => true, |
||
| 1261 | 'placeholder' => esc_attr( $field['placeholder'] ), |
||
| 1262 | 'type' => 'url', |
||
| 1263 | ) |
||
| 1264 | ); |
||
| 1265 | |||
| 1266 | if ( ! empty( $field['description'] ) ) { |
||
| 1267 | $description = wp_kses_post( $field['description'] ); |
||
| 1268 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 1269 | } |
||
| 1270 | |||
| 1271 | echo '</div>'; |
||
| 1272 | |||
| 1273 | } |
||
| 1274 | |||
| 1275 | /** |
||
| 1276 | * Renders the edit website element template. |
||
| 1277 | */ |
||
| 1278 | public function edit_website_template( $field ) { |
||
| 1279 | $restrict = $this->get_restrict_markup( $field, 'website' ); |
||
| 1280 | $label = __( 'Field Label', 'invoicing' ); |
||
| 1281 | $id = $field . '.id + "_edit"'; |
||
| 1282 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 1283 | $id2 = $field . '.id + "_edit2"'; |
||
| 1284 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 1285 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1286 | $id3 = $field . '.id + "_edit3"'; |
||
| 1287 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 1288 | $id4 = $field . '.id + "_edit4"'; |
||
| 1289 | echo " |
||
| 1290 | <div $restrict> |
||
| 1291 | <div class='form-group'> |
||
| 1292 | <label :for='$id'>$label</label> |
||
| 1293 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 1294 | </div> |
||
| 1295 | <div class='form-group'> |
||
| 1296 | <label :for='$id2'>$label2</label> |
||
| 1297 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 1298 | </div> |
||
| 1299 | <div class='form-group'> |
||
| 1300 | <label :for='$id3'>$label3</label> |
||
| 1301 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1302 | </div> |
||
| 1303 | <div class='form-group form-check'> |
||
| 1304 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 1305 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 1306 | </div> |
||
| 1307 | </div> |
||
| 1308 | "; |
||
| 1309 | |||
| 1310 | } |
||
| 1311 | |||
| 1312 | /** |
||
| 1313 | * Renders the date element template. |
||
| 1314 | */ |
||
| 1315 | public function render_date_template( $field ) { |
||
| 1316 | $restrict = $this->get_restrict_markup( $field, 'date' ); |
||
| 1317 | $label = "$field.label"; |
||
| 1318 | echo " |
||
| 1319 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 1320 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 1321 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 1322 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='date'> |
||
| 1323 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 1324 | </div> |
||
| 1325 | "; |
||
| 1326 | } |
||
| 1327 | |||
| 1328 | /** |
||
| 1329 | * Renders the date element on the frontend. |
||
| 1330 | */ |
||
| 1331 | public function frontend_render_date_template( $field ) { |
||
| 1332 | |||
| 1333 | echo "<div class='form-group'>"; |
||
| 1334 | |||
| 1335 | echo aui()->input( |
||
| 1336 | array( |
||
| 1337 | 'name' => esc_attr( $field['id'] ), |
||
| 1338 | 'id' => esc_attr( $field['id'] ), |
||
| 1339 | 'required' => (bool) $field['required'], |
||
| 1340 | 'label' => wp_kses_post( $field['label'] ), |
||
| 1341 | 'no_wrap' => true, |
||
| 1342 | 'type' => 'date', |
||
| 1343 | ) |
||
| 1344 | ); |
||
| 1345 | |||
| 1346 | if ( ! empty( $field['description'] ) ) { |
||
| 1347 | $description = wp_kses_post( $field['description'] ); |
||
| 1348 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 1349 | } |
||
| 1350 | |||
| 1351 | echo '</div>'; |
||
| 1352 | |||
| 1353 | } |
||
| 1354 | |||
| 1355 | /** |
||
| 1356 | * Renders the edit date element template. |
||
| 1357 | */ |
||
| 1358 | public function edit_date_template( $field ) { |
||
| 1359 | $restrict = $this->get_restrict_markup( $field, 'date' ); |
||
| 1360 | $label = __( 'Field Label', 'invoicing' ); |
||
| 1361 | $id = $field . '.id + "_edit"'; |
||
| 1362 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 1363 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1364 | $id3 = $field . '.id + "_edit3"'; |
||
| 1365 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 1366 | $id4 = $field . '.id + "_edit4"'; |
||
| 1367 | echo " |
||
| 1368 | <div $restrict> |
||
| 1369 | <div class='form-group'> |
||
| 1370 | <label :for='$id'>$label</label> |
||
| 1371 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 1372 | </div> |
||
| 1373 | <div class='form-group'> |
||
| 1374 | <label :for='$id3'>$label3</label> |
||
| 1375 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1376 | </div> |
||
| 1377 | <div class='form-group form-check'> |
||
| 1378 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 1379 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 1380 | </div> |
||
| 1381 | </div> |
||
| 1382 | "; |
||
| 1383 | |||
| 1384 | } |
||
| 1385 | |||
| 1386 | /** |
||
| 1387 | * Renders the time element template. |
||
| 1388 | */ |
||
| 1389 | public function render_time_template( $field ) { |
||
| 1390 | $restrict = $this->get_restrict_markup( $field, 'time' ); |
||
| 1391 | $label = "$field.label"; |
||
| 1392 | echo " |
||
| 1393 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 1394 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 1395 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 1396 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='time'> |
||
| 1397 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 1398 | </div> |
||
| 1399 | "; |
||
| 1400 | } |
||
| 1401 | |||
| 1402 | /** |
||
| 1403 | * Renders the time element on the frontend. |
||
| 1404 | */ |
||
| 1405 | public function frontend_render_time_template( $field ) { |
||
| 1406 | |||
| 1407 | echo "<div class='form-group'>"; |
||
| 1408 | |||
| 1409 | echo aui()->input( |
||
| 1410 | array( |
||
| 1411 | 'name' => esc_attr( $field['id'] ), |
||
| 1412 | 'id' => esc_attr( $field['id'] ), |
||
| 1413 | 'required' => (bool) $field['required'], |
||
| 1414 | 'label' => wp_kses_post( $field['label'] ), |
||
| 1415 | 'no_wrap' => true, |
||
| 1416 | 'type' => 'time', |
||
| 1417 | ) |
||
| 1418 | ); |
||
| 1419 | |||
| 1420 | if ( ! empty( $field['description'] ) ) { |
||
| 1421 | $description = wp_kses_post( $field['description'] ); |
||
| 1422 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 1423 | } |
||
| 1424 | |||
| 1425 | echo '</div>'; |
||
| 1426 | |||
| 1427 | } |
||
| 1428 | |||
| 1429 | /** |
||
| 1430 | * Renders the edit time element template. |
||
| 1431 | */ |
||
| 1432 | public function edit_time_template( $field ) { |
||
| 1433 | $restrict = $this->get_restrict_markup( $field, 'time' ); |
||
| 1434 | $label = __( 'Field Label', 'invoicing' ); |
||
| 1435 | $id = $field . '.id + "_edit"'; |
||
| 1436 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 1437 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1438 | $id3 = $field . '.id + "_edit3"'; |
||
| 1439 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 1440 | $id4 = $field . '.id + "_edit4"'; |
||
| 1441 | echo " |
||
| 1442 | <div $restrict> |
||
| 1443 | <div class='form-group'> |
||
| 1444 | <label :for='$id'>$label</label> |
||
| 1445 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 1446 | </div> |
||
| 1447 | <div class='form-group'> |
||
| 1448 | <label :for='$id3'>$label3</label> |
||
| 1449 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1450 | </div> |
||
| 1451 | <div class='form-group form-check'> |
||
| 1452 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 1453 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 1454 | </div> |
||
| 1455 | </div> |
||
| 1456 | "; |
||
| 1457 | |||
| 1458 | } |
||
| 1459 | |||
| 1460 | /** |
||
| 1461 | * Renders the number element template. |
||
| 1462 | */ |
||
| 1463 | public function render_number_template( $field ) { |
||
| 1464 | $restrict = $this->get_restrict_markup( $field, 'number' ); |
||
| 1465 | $label = "$field.label"; |
||
| 1466 | echo " |
||
| 1467 | <div $restrict class='wpinv-payment-form-field-preview'> |
||
| 1468 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
||
| 1469 | <label :for='$field.id'>{{" . $label . "}}</label> |
||
| 1470 | <input :placeholder='$field.placeholder' :id='$field.id' class='form-control' type='number'> |
||
| 1471 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 1472 | </div> |
||
| 1473 | "; |
||
| 1474 | } |
||
| 1475 | |||
| 1476 | /** |
||
| 1477 | * Renders the number element on the frontend. |
||
| 1478 | */ |
||
| 1479 | public function frontend_render_number_template( $field ) { |
||
| 1480 | |||
| 1481 | echo "<div class='form-group'>"; |
||
| 1482 | |||
| 1483 | echo aui()->input( |
||
| 1484 | array( |
||
| 1485 | 'name' => esc_attr( $field['id'] ), |
||
| 1486 | 'id' => esc_attr( $field['id'] ), |
||
| 1487 | 'required' => (bool) $field['required'], |
||
| 1488 | 'label' => wp_kses_post( $field['label'] ), |
||
| 1489 | 'placeholder' => esc_attr( $field['placeholder'] ), |
||
| 1490 | 'no_wrap' => true, |
||
| 1491 | 'type' => 'number', |
||
| 1492 | ) |
||
| 1493 | ); |
||
| 1494 | |||
| 1495 | if ( ! empty( $field['description'] ) ) { |
||
| 1496 | $description = wp_kses_post( $field['description'] ); |
||
| 1497 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 1498 | } |
||
| 1499 | |||
| 1500 | echo '</div>'; |
||
| 1501 | |||
| 1502 | } |
||
| 1503 | |||
| 1504 | /** |
||
| 1505 | * Renders the edit number element template. |
||
| 1506 | */ |
||
| 1507 | public function edit_number_template( $field ) { |
||
| 1508 | $restrict = $this->get_restrict_markup( $field, 'number' ); |
||
| 1509 | $label = __( 'Field Label', 'invoicing' ); |
||
| 1510 | $id = $field . '.id + "_edit"'; |
||
| 1511 | $label2 = __( 'Placeholder text', 'invoicing' ); |
||
| 1512 | $id2 = $field . '.id + "_edit2"'; |
||
| 1513 | $label3 = __( 'Help text', 'invoicing' ); |
||
| 1514 | $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1515 | $id3 = $field . '.id + "_edit3"'; |
||
| 1516 | $label5 = __( 'Is this field required?', 'invoicing' ); |
||
| 1517 | $id4 = $field . '.id + "_edit4"'; |
||
| 1518 | echo " |
||
| 1519 | <div $restrict> |
||
| 1520 | <div class='form-group'> |
||
| 1521 | <label :for='$id'>$label</label> |
||
| 1522 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 1523 | </div> |
||
| 1524 | <div class='form-group'> |
||
| 1525 | <label :for='$id2'>$label2</label> |
||
| 1526 | <input :id='$id2' v-model='$field.placeholder' class='form-control' /> |
||
| 1527 | </div> |
||
| 1528 | <div class='form-group'> |
||
| 1529 | <label :for='$id3'>$label3</label> |
||
| 1530 | <textarea placeholder='$label4' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1531 | </div> |
||
| 1532 | <div class='form-group form-check'> |
||
| 1533 | <input :id='$id4' v-model='$field.required' type='checkbox' class='form-check-input' /> |
||
| 1534 | <label class='form-check-label' :for='$id4'>$label5</label> |
||
| 1535 | </div> |
||
| 1536 | </div> |
||
| 1537 | "; |
||
| 1538 | |||
| 1539 | } |
||
| 1540 | |||
| 1541 | /** |
||
| 1542 | * Renders the separator element template. |
||
| 1543 | */ |
||
| 1544 | public function render_separator_template( $field ) { |
||
| 1545 | $restrict = $this->get_restrict_markup( $field, 'separator' ); |
||
| 1546 | echo "<hr class='featurette-divider mt-0 mb-2' $restrict>"; |
||
| 1547 | } |
||
| 1548 | |||
| 1549 | /** |
||
| 1550 | * Renders the separator element on the frontend. |
||
| 1551 | */ |
||
| 1552 | public function frontend_render_separator_template( $field ) { |
||
| 1553 | echo '<hr class="featurette-divider mt-0 mb-2" />'; |
||
| 1554 | } |
||
| 1555 | |||
| 1556 | /** |
||
| 1557 | * Renders the pay button element template. |
||
| 1558 | */ |
||
| 1559 | public function render_pay_button_template( $field ) { |
||
| 1560 | $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
||
| 1561 | $label = "$field.label"; |
||
| 1562 | echo " |
||
| 1563 | <div $restrict> |
||
| 1564 | <button class='form-control btn submit-button' :class='$field.class' type='submit' @click.prevent=''>{{" . $label . "}}</button> |
||
| 1565 | <small v-if='$field.description' class='form-text text-muted' v-html='$field.description'></small> |
||
| 1566 | </div> |
||
| 1567 | "; |
||
| 1568 | } |
||
| 1569 | |||
| 1570 | /** |
||
| 1571 | * Renders the pay_button element on the frontend. |
||
| 1572 | */ |
||
| 1573 | public function frontend_render_pay_button_template( $field ) { |
||
| 1574 | |||
| 1575 | echo "<div class='mt-4 mb-4'>"; |
||
| 1576 | do_action( 'wpinv_payment_mode_select' ); |
||
| 1577 | echo "</div>"; |
||
| 1578 | |||
| 1579 | echo "<div class='form-group'>"; |
||
| 1580 | |||
| 1581 | $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class( $field['class'] ); |
||
| 1582 | echo aui()->input( |
||
| 1583 | array( |
||
| 1584 | 'name' => esc_attr( $field['id'] ), |
||
| 1585 | 'id' => esc_attr( $field['id'] ), |
||
| 1586 | 'value' => esc_attr( $field['label'] ), |
||
| 1587 | 'no_wrap' => true, |
||
| 1588 | 'type' => 'submit', |
||
| 1589 | 'class' => $class, |
||
| 1590 | ) |
||
| 1591 | ); |
||
| 1592 | |||
| 1593 | if ( ! empty( $field['description'] ) ) { |
||
| 1594 | $description = wp_kses_post( $field['description'] ); |
||
| 1595 | echo "<small class='form-text text-muted'>$description</small>"; |
||
| 1596 | } |
||
| 1597 | |||
| 1598 | echo '</div>'; |
||
| 1599 | |||
| 1600 | } |
||
| 1601 | |||
| 1602 | /** |
||
| 1603 | * Renders the pay button element template. |
||
| 1604 | */ |
||
| 1605 | public function edit_pay_button_template( $field ) { |
||
| 1606 | $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
||
| 1607 | $label = __( 'Button Text', 'invoicing' ); |
||
| 1608 | $id = $field . '.id + "_edit"'; |
||
| 1609 | $label2 = __( 'Help text', 'invoicing' ); |
||
| 1610 | $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1611 | $id2 = $field . '.id + "_edit2"'; |
||
| 1612 | $label4 = esc_attr__( 'Button Type', 'invoicing' ); |
||
| 1613 | $id3 = $field . '.id + "_edit3"'; |
||
| 1614 | echo " |
||
| 1615 | <div $restrict> |
||
| 1616 | <div class='form-group'> |
||
| 1617 | <label :for='$id'>$label</label> |
||
| 1618 | <input :id='$id' v-model='$field.label' class='form-control' /> |
||
| 1619 | </div> |
||
| 1620 | <div class='form-group'> |
||
| 1621 | <label :for='$id2'>$label2</label> |
||
| 1622 | <textarea placeholder='$label3' :id='$id2' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 1623 | </div> |
||
| 1624 | <div class='form-group'> |
||
| 1625 | <label :for='$id3'>$label4</label> |
||
| 1626 | |||
| 1627 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
||
| 1628 | <option value='btn-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
||
| 1629 | <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
||
| 1630 | <option value='btn-success'>" . __( 'Success', 'invoicing' ) ."</option> |
||
| 1631 | <option value='btn-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
||
| 1632 | <option value='btn-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
||
| 1633 | <option value='btn-info'>" . __( 'Info', 'invoicing' ) ."</option> |
||
| 1634 | <option value='btn-light'>" . __( 'Light', 'invoicing' ) ."</option> |
||
| 1635 | <option value='btn-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
||
| 1636 | <option value='btn-link'>" . __( 'Link', 'invoicing' ) ."</option> |
||
| 1637 | </select> |
||
| 1638 | </div> |
||
| 1639 | </div> |
||
| 1640 | "; |
||
| 1641 | |||
| 1642 | } |
||
| 1643 | |||
| 1644 | /** |
||
| 1645 | * Renders the alert element template. |
||
| 1646 | */ |
||
| 1647 | public function render_alert_template( $field ) { |
||
| 1648 | $restrict = $this->get_restrict_markup( $field, 'alert' ); |
||
| 1649 | $text = "$field.text"; |
||
| 1650 | echo " |
||
| 1651 | <div $restrict class='alert' :class='$field.class' role='alert'> |
||
| 1652 | <span v-html='$text'></span> |
||
| 1653 | <button v-if='$field.dismissible' type='button' class='close' @click.prevent=''> |
||
| 1654 | <span aria-hidden='true'>×</span> |
||
| 1655 | </button> |
||
| 1656 | </div> |
||
| 1657 | "; |
||
| 1658 | } |
||
| 1659 | |||
| 1660 | /** |
||
| 1661 | * Renders the alert element on the frontend. |
||
| 1662 | */ |
||
| 1663 | public function frontend_render_alert_template( $field ) { |
||
| 1676 | |||
| 1677 | } |
||
| 1678 | |||
| 1679 | /** |
||
| 1680 | * Renders the alert element template. |
||
| 1681 | */ |
||
| 1682 | public function edit_alert_template( $field ) { |
||
| 1683 | $restrict = $this->get_restrict_markup( $field, 'alert' ); |
||
| 1684 | $label = __( 'Alert Text', 'invoicing' ); |
||
| 1685 | $label2 = esc_attr__( 'Enter your alert text here', 'invoicing' ); |
||
| 1713 | </select> |
||
| 1714 | </div> |
||
| 1715 | </div> |
||
| 1716 | "; |
||
| 1717 | |||
| 1718 | } |
||
| 1719 | |||
| 1720 | /** |
||
| 1721 | * Renders the discount element template. |
||
| 1722 | */ |
||
| 1723 | public function render_discount_template( $field ) { |
||
| 1724 | $restrict = $this->get_restrict_markup( $field, 'discount' ); |
||
| 1725 | ?> |
||
| 1726 | |||
| 1727 | <div <?php echo $restrict; ?> class="discount_field border rounded p-3"> |
||
| 1728 | <div class="discount_field_inner d-flex flex-column flex-md-row"> |
||
| 1729 | <input :placeholder="<?php echo $field ?>.input_label" class="form-control mr-2 mb-2" style="flex: 1;" type="text"> |
||
| 1730 | <button class="btn btn-secondary submit-button mb-2" type="submit" @click.prevent="">{{<?php echo $field; ?>.button_label}}</button> |
||
| 1731 | </div> |
||
| 1732 | <small v-if='<?php echo $field ?>.description' class='form-text text-muted' v-html='<?php echo $field ?>.description'></small> |
||
| 1733 | </div> |
||
| 1734 | |||
| 1735 | <?php |
||
| 1736 | } |
||
| 1737 | |||
| 1738 | /** |
||
| 1739 | * Renders the discount element on the frontend. |
||
| 1740 | */ |
||
| 1741 | public function frontend_render_discount_template( $field ) { |
||
| 1760 | </div> |
||
| 1761 | |||
| 1762 | <?php |
||
| 1763 | } |
||
| 1764 | |||
| 1765 | /** |
||
| 1766 | * Renders the discount element template. |
||
| 1767 | */ |
||
| 1768 | public function edit_discount_template( $field ) { |
||
| 1769 | $restrict = $this->get_restrict_markup( $field, 'discount' ); |
||
| 1770 | $label = __( 'Discount Input Placeholder', 'invoicing' ); |
||
| 1771 | $label2 = __( 'Help Text', 'invoicing' ); |
||
| 1772 | $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
||
| 1773 | $label4 = __( 'Button Text', 'invoicing' ); |
||
| 1792 | </div> |
||
| 1793 | |||
| 1794 | </div> |
||
| 1795 | "; |
||
| 1796 | |||
| 1797 | } |
||
| 1798 | |||
| 1799 | /** |
||
| 1800 | * Renders the items element template. |
||
| 1801 | */ |
||
| 1802 | public function render_items_template( $field ) { |
||
| 1803 | $restrict = $this->get_restrict_markup( $field, 'items' ); |
||
| 1804 | $label = __( 'Item totals will appear here. Click to set items.', 'invoicing' ); |
||
| 1805 | $label2 = __( 'Your form allows customers to buy several recurring items. This is not supported and will lead to unexpected behaviour.', 'invoicing' ); |
||
| 1806 | $label2 .= ' ' . __( 'To prevent this, limit customers to selecting a single item.', 'invoicing' ); |
||
| 1807 | $label3 = __( 'Item totals will appear here.', 'invoicing' ); |
||
| 1808 | echo " |
||
| 1809 | <div $restrict class='item_totals text-center'> |
||
| 1810 | <div v-if='!is_default'> |
||
| 1811 | <div v-if='canCheckoutSeveralSubscriptions($field)' class='p-4 bg-danger text-light'>$label2</div> |
||
| 1812 | <div v-if='! canCheckoutSeveralSubscriptions($field)' class='p-4 bg-warning'>$label</div> |
||
| 1813 | </div> |
||
| 1814 | <div v-if='is_default'> |
||
| 1815 | <div class='p-4 bg-warning'>$label3</div> |
||
| 1816 | </div> |
||
| 1817 | </div> |
||
| 1818 | "; |
||
| 1819 | } |
||
| 1820 | |||
| 1821 | /** |
||
| 1822 | * Renders the items element on the frontend. |
||
| 1823 | */ |
||
| 1824 | public function frontend_render_items_template( $field, $items ) { |
||
| 2600 | <?php |
||
| 2601 | } |
||
| 2602 | |||
| 2603 | /** |
||
| 2604 | * Renders the items element template. |
||
| 2605 | */ |
||
| 2606 | public function edit_items_template( $field ) { |
||
| 2607 | global $wpinv_euvat, $post; |
||
| 2608 | |||
| 2609 | $restrict = $this->get_restrict_markup( $field, 'items' ); |
||
| 2610 | $label = __( 'Let customers...', 'invoicing' ); |
||
| 2611 | $label2 = __( 'Available Items', 'invoicing' ); |
||
| 2612 | $label3 = esc_attr__( 'Add some help text for this element', 'invoicing' ); |
||
| 2613 | $id = $field . '.id + "_edit"'; |
||
| 2614 | $id2 = $field . '.id + "_edit2"'; |
||
| 2615 | $id3 = $field . '.id + "_edit3"'; |
||
| 2616 | $id4 = $field . '.id + "_edit4"'; |
||
| 2617 | $label4 = esc_attr__( 'This will be shown to the customer as the recommended price', 'invoicing' ); |
||
| 2618 | $label5 = esc_attr__( 'Allow users to pay what they want', 'invoicing' ); |
||
| 2619 | $label6 = esc_attr__( 'Enter the minimum price that a user can pay', 'invoicing' ); |
||
| 2620 | $label7 = esc_attr__( 'Allow users to buy several quantities', 'invoicing' ); |
||
| 2621 | $label8 = esc_attr__( 'This item is required', 'invoicing' ); |
||
| 2622 | |||
| 2623 | // Item types. |
||
| 2624 | $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
||
| 2625 | $item_types_html = ''; |
||
| 2626 | |||
| 2627 | foreach ( $item_types as $type => $_label ) { |
||
| 2628 | $type = esc_attr( $type ); |
||
| 2629 | $_label = esc_html( $_label ); |
||
| 2630 | $item_types_html .= "<option value='$type'>$_label</type>"; |
||
| 2631 | } |
||
| 2632 | |||
| 2633 | // Taxes. |
||
| 2634 | $taxes = ''; |
||
| 2635 | if ( $wpinv_euvat->allow_vat_rules() ) { |
||
| 2636 | $taxes .= "<div class='form-group'> <label :for='$id + item.id + \"rule\"'>"; |
||
| 2637 | $taxes .= __( 'VAT rule type', 'invoicing' ); |
||
| 2638 | $taxes .= "</label><select :id='$id + item.id + \"rule\"' class='form-control custom-select' v-model='item.rule'>"; |
||
| 2639 | |||
| 2640 | foreach ( $wpinv_euvat->get_rules() as $type => $_label ) { |
||
| 2641 | $type = esc_attr( $type ); |
||
| 2642 | $_label = esc_html( $_label ); |
||
| 2643 | $taxes .= "<option value='$type'>$_label</type>"; |
||
| 2644 | } |
||
| 2645 | |||
| 2646 | $taxes .= '</select></div>'; |
||
| 2647 | } |
||
| 2648 | |||
| 2649 | if ( $wpinv_euvat->allow_vat_classes() ) { |
||
| 2650 | $taxes .= "<div class='form-group'> <label :for='$id + item.id + \"class\"'>"; |
||
| 2651 | $taxes .= __( 'VAT class', 'invoicing' ); |
||
| 2652 | $taxes .= "</label><select :id='$id + item.id + \"class\"' class='form-control custom-select' v-model='item.class'>"; |
||
| 2653 | |||
| 2654 | foreach ( $wpinv_euvat->get_all_classes() as $type => $_label ) { |
||
| 2655 | $type = esc_attr( $type ); |
||
| 2656 | $_label = esc_html( $_label ); |
||
| 2657 | $taxes .= "<option value='$type'>$_label</type>"; |
||
| 2658 | } |
||
| 2659 | |||
| 2660 | $taxes .= '</select></div>'; |
||
| 2661 | } |
||
| 2662 | |||
| 2663 | echo "<div $restrict> |
||
| 2664 | |||
| 2665 | <label v-if='!is_default'>$label2</label> |
||
| 2666 | |||
| 2667 | <draggable v-model='form_items' group='selectable_form_items'> |
||
| 2668 | <div class='wpinv-available-items-editor' v-for='(item, index) in form_items' :class='\"item_\" + item.id' :key='item.id'> |
||
| 2669 | |||
| 2670 | <div class='wpinv-available-items-editor-header' @click.prevent='togglePanel(item.id)'> |
||
| 2671 | <span class='label'>{{item.title}}</span> |
||
| 2672 | <span class='price'>({{formatPrice(item.price)}})</span> |
||
| 2673 | <span class='toggle-icon'> |
||
| 2674 | <span class='dashicons dashicons-arrow-down'></span> |
||
| 2675 | <span class='dashicons dashicons-arrow-up' style='display:none'></span> |
||
| 2676 | </span> |
||
| 2677 | </div> |
||
| 2678 | |||
| 2679 | <div class='wpinv-available-items-editor-body'> |
||
| 2680 | <div class='p-2'> |
||
| 2681 | |||
| 2682 | <div class='form-group'> |
||
| 2683 | <label :for='$id + item.id'>Item Name</label> |
||
| 2684 | <input :id='$id + item.id' v-model='item.title' class='form-control' /> |
||
| 2685 | </div> |
||
| 2686 | |||
| 2687 | <div class='form-group'> |
||
| 2688 | <label :for='$id + item.id + \"price\"'>Item Price</label> |
||
| 2689 | <input :id='$id + item.id + \"price\"' v-model='item.price' class='form-control' /> |
||
| 2690 | <small class='form-text text-muted' v-if='item.custom_price'>$label4</small> |
||
| 2691 | </div> |
||
| 2692 | |||
| 2693 | <div class='form-group' v-if='item.new'> |
||
| 2694 | <label :for='$id + item.id + \"type\"'>Item Type</label> |
||
| 2695 | <select class='form-control custom-select' v-model='item.type'> |
||
| 2696 | $item_types_html |
||
| 2697 | </select> |
||
| 2698 | </div> |
||
| 2699 | |||
| 2700 | <div v-if='item.new'>$taxes</div> |
||
| 2701 | |||
| 2702 | <div class='form-group form-check'> |
||
| 2703 | <input :id='$id4 + item.id + \"custom_price\"' v-model='item.custom_price' type='checkbox' class='form-check-input' /> |
||
| 2704 | <label class='form-check-label' :for='$id4 + item.id + \"custom_price\"'>$label5</label> |
||
| 2705 | </div> |
||
| 2706 | |||
| 2707 | <div class='form-group' v-if='item.custom_price'> |
||
| 2708 | <label :for='$id + item.id + \"minimum_price\"'>Minimum Price</label> |
||
| 2709 | <input :id='$id + item.id + \"minimum_price\"' placeholder='0.00' v-model='item.minimum_price' class='form-control' /> |
||
| 2710 | <small class='form-text text-muted'>$label6</small> |
||
| 2711 | </div> |
||
| 2712 | |||
| 2713 | <div class='form-group form-check'> |
||
| 2714 | <input :id='$id + item.id + \"quantities\"' v-model='item.allow_quantities' type='checkbox' class='form-check-input' /> |
||
| 2715 | <label class='form-check-label' :for='$id + item.id + \"quantities\"'>$label7</label> |
||
| 2716 | </div> |
||
| 2717 | |||
| 2718 | <div class='form-group form-check'> |
||
| 2719 | <input :id='$id + item.id + \"required\"' v-model='item.required' type='checkbox' class='form-check-input' /> |
||
| 2720 | <label class='form-check-label' :for='$id + item.id + \"required\"'>$label8</label> |
||
| 2721 | </div> |
||
| 2722 | |||
| 2723 | <div class='form-group'> |
||
| 2724 | <label :for='$id + item.id + \"description\"'>Item Description</label> |
||
| 2725 | <textarea :id='$id + item.id + \"description\"' v-model='item.description' class='form-control'></textarea> |
||
| 2726 | </div> |
||
| 2727 | |||
| 2728 | <button type='button' class='button button-link button-link-delete' @click.prevent='removeItem(item)'>Delete Item</button> |
||
| 2729 | |||
| 2730 | </div> |
||
| 2731 | </div> |
||
| 2732 | |||
| 2733 | </div> |
||
| 2734 | </draggable> |
||
| 2735 | |||
| 2736 | <small v-if='! form_items.length && !is_default' class='form-text text-danger'> You have not set up any items. Please select an item below or create a new item.</small> |
||
| 2737 | |||
| 2738 | <div class='form-group mt-2' v-if='!is_default'> |
||
| 2739 | |||
| 2740 | <select class='form-control custom-select' v-model='selected_item' @change='addSelectedItem'> |
||
| 2741 | <option value=''>" . __( 'Add an existing item to the form', 'invoicing' ) ."</option> |
||
| 2742 | <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option> |
||
| 2743 | </select> |
||
| 2744 | |||
| 2745 | </div> |
||
| 2746 | |||
| 2747 | <div class='form-group' v-if='!is_default'> |
||
| 2748 | <input type='button' value='Add item' class='button button-primary' @click.prevent='addSelectedItem' :disabled='selected_item == \"\"'> |
||
| 2749 | <small>Or <a href='' @click.prevent='addNewItem'>create a new item</a>.</small> |
||
| 2750 | </div> |
||
| 2751 | |||
| 2752 | <div class='form-group mt-5' v-if='!is_default'> |
||
| 2753 | <label :for='$id2'>$label</label> |
||
| 2754 | |||
| 2755 | <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'> |
||
| 2756 | <option value='total' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __( 'Buy all items on the list', 'invoicing' ) ."</option> |
||
| 2757 | <option value='radio'>" . __( 'Select a single item from the list', 'invoicing' ) ."</option> |
||
| 2758 | <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __( 'Select one or more items on the list', 'invoicing' ) ."</option> |
||
| 2759 | <option value='select'>" . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option> |
||
| 2760 | <option value='multi_select' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option> |
||
| 2761 | </select> |
||
| 2762 | |||
| 2763 | </div> |
||
| 2764 | |||
| 2765 | <div class='form-group'> |
||
| 2766 | <label :for='$id3'>Help Text</label> |
||
| 2767 | <textarea placeholder='$label3' :id='$id3' v-model='$field.description' class='form-control' rows='3'></textarea> |
||
| 2768 | </div> |
||
| 2769 | |||
| 2770 | </div> |
||
| 2771 | "; |
||
| 2772 | |||
| 2773 | } |
||
| 2774 | |||
| 2775 | /** |
||
| 2776 | * Returns an array of all published items. |
||
| 2777 | */ |
||
| 2778 | public function get_published_items() { |
||
| 2779 | |||
| 2780 | $item_args = array( |
||
| 2781 | 'post_type' => 'wpi_item', |
||
| 2782 | 'orderby' => 'title', |
||
| 2783 | 'order' => 'ASC', |
||
| 2784 | 'posts_per_page' => -1, |
||
| 2785 | 'post_status' => array( 'publish' ), |
||
| 2786 | 'meta_query' => array( |
||
| 2787 | array( |
||
| 2788 | 'key' => '_wpinv_type', |
||
| 2789 | 'compare' => '!=', |
||
| 2790 | 'value' => 'package' |
||
| 2791 | ) |
||
| 2792 | ) |
||
| 2793 | ); |
||
| 2794 | |||
| 2795 | $items = get_posts( apply_filters( 'wpinv_payment_form_item_dropdown_query_args', $item_args ) ); |
||
| 2796 | |||
| 2797 | if ( empty( $items ) ) { |
||
| 2798 | return array(); |
||
| 2799 | } |
||
| 2800 | |||
| 2801 | $options = array(); |
||
| 2802 | foreach ( $items as $item ) { |
||
| 2803 | $title = esc_html( $item->post_title ); |
||
| 2804 | $title .= wpinv_get_item_suffix( $item->ID, false ); |
||
| 2805 | $id = absint( $item->ID ); |
||
| 2806 | $price = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) ); |
||
| 2807 | $recurring = (bool) get_post_meta( $id, '_wpinv_is_recurring', true ); |
||
| 2808 | $description = $item->post_excerpt; |
||
| 2809 | $custom_price = (bool) get_post_meta( $id, '_wpinv_dynamic_pricing', true ); |
||
| 2810 | $minimum_price = (float) get_post_meta( $id, '_minimum_price', true ); |
||
| 2811 | $allow_quantities = false; |
||
| 2812 | $options[] = compact( 'title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities' ); |
||
| 2813 | |||
| 2814 | } |
||
| 2815 | return $options; |
||
| 2816 | |||
| 2817 | } |
||
| 2818 | |||
| 2819 | /** |
||
| 2820 | * Returns an array of items for the currently being edited form. |
||
| 2821 | */ |
||
| 2822 | public function get_form_items( $id = false ) { |
||
| 2835 | |||
| 2836 | } |
||
| 2837 | |||
| 2838 | /** |
||
| 2839 | * Converts form items for use. |
||
| 2840 | */ |
||
| 2841 | public function convert_checkout_items( $items, $invoice ) { |
||
| 2842 | |||
| 2843 | $converted = array(); |
||
| 2844 | foreach ( $items as $item ) { |
||
| 2845 | |||
| 2846 | $item_id = $item['id']; |
||
| 2847 | $_item = new WPInv_Item( $item_id ); |
||
| 2848 | |||
| 2849 | if( ! $_item ) { |
||
| 2850 | continue; |
||
| 2851 | } |
||
| 2852 | |||
| 2853 | $converted[] = array( |
||
| 2854 | 'title' => esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $_item ), |
||
| 2855 | 'id' => $item['id'], |
||
| 2856 | 'price' => $item['subtotal'], |
||
| 2857 | 'custom_price' => $_item->get_is_dynamic_pricing(), |
||
| 2858 | 'recurring' => $_item->is_recurring(), |
||
| 2859 | 'description' => apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice ), |
||
| 2860 | ); |
||
| 2861 | } |
||
| 2862 | return $converted; |
||
| 2863 | |||
| 2864 | } |
||
| 2865 | |||
| 2866 | /** |
||
| 2867 | * Returns an array of elements for the currently being edited form. |
||
| 2868 | */ |
||
| 2869 | public function get_form_elements( $id = false ) { |
||
| 2882 | } |
||
| 2883 | |||
| 2884 | /** |
||
| 2885 | * Sends a redrect response to payment details. |
||
| 2886 | * |
||
| 2887 | */ |
||
| 2888 | public function send_redirect_response( $url ) { |
||
| 2889 | $url = urlencode( $url ); |
||
| 2890 | wp_send_json_success( $url ); |
||
| 2891 | } |
||
| 2892 | |||
| 2893 | /** |
||
| 2894 | * Fired when a checkout error occurs |
||
| 2895 | * |
||
| 2896 | */ |
||
| 2897 | public function checkout_error() { |
||
| 2908 | |||
| 2909 | } |
||
| 2910 | |||
| 2911 | } |
||
| 2912 |