| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
die( 'You are not allowed to call this page directly.' ); |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* @since 3.0 |
| 9 |
*/ |
| 10 |
class FrmFieldCreditCard extends FrmFieldType { |
| 11 |
|
| 12 |
/** |
| 13 |
* @var string |
| 14 |
* @since 3.0 |
| 15 |
*/ |
| 16 |
protected $type = 'credit_card'; |
| 17 |
|
| 18 |
/** |
| 19 |
* @var bool |
| 20 |
* @since 3.0 |
| 21 |
*/ |
| 22 |
protected $has_for_label = false; |
| 23 |
|
| 24 |
protected function field_settings_for_type() { |
| 25 |
$settings = array( |
| 26 |
'clear_on_focus' => false, |
| 27 |
'description' => false, |
| 28 |
'default' => false, |
| 29 |
'required' => false, |
| 30 |
); |
| 31 |
return $settings; |
| 32 |
} |
| 33 |
|
| 34 |
protected function include_form_builder_file() { |
| 35 |
return FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/field-credit-card.php'; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* @param array $args |
| 40 |
* @param array $shortcode_atts |
| 41 |
* @return string |
| 42 |
*/ |
| 43 |
public function front_field_input( $args, $shortcode_atts ) { |
| 44 |
$pass_args = array( |
| 45 |
'errors' => $args['errors'], |
| 46 |
'html_id' => $args['html_id'], |
| 47 |
'field_id' => $args['field_id'], |
| 48 |
); |
| 49 |
|
| 50 |
ob_start(); |
| 51 |
|
| 52 |
if ( FrmAppHelper::is_style_editor_page() ) { |
| 53 |
// The styler preview doesn't load the Stripe scripts. |
| 54 |
// We need to use the form builder view instead. |
| 55 |
$field = $this->field; |
| 56 |
include $this->include_form_builder_file(); |
| 57 |
} else { |
| 58 |
FrmStrpLiteActionsController::show_card( $this->field, $args['field_name'], $pass_args ); |
| 59 |
} |
| 60 |
|
| 61 |
$input_html = ob_get_contents(); |
| 62 |
ob_end_clean(); |
| 63 |
|
| 64 |
return $input_html; |
| 65 |
} |
| 66 |
} |
| 67 |
|