| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* @since 3.0 |
| 8 |
*/ |
| 9 |
class FrmFieldDefault extends FrmFieldType { |
| 10 |
|
| 11 |
/** |
| 12 |
* @var bool |
| 13 |
* |
| 14 |
* @since 3.0 |
| 15 |
*/ |
| 16 |
protected $holds_email_values = true; |
| 17 |
|
| 18 |
/** |
| 19 |
* @param string $type |
| 20 |
* |
| 21 |
* @return void |
| 22 |
*/ |
| 23 |
protected function set_type( $type ) { |
| 24 |
if ( ! $type ) { |
| 25 |
$type = 'text'; |
| 26 |
} |
| 27 |
parent::set_type( $type ); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* @param string $name |
| 32 |
* |
| 33 |
* @return void |
| 34 |
*/ |
| 35 |
public function show_on_form_builder( $name = '' ) { |
| 36 |
$field = FrmFieldsHelper::setup_edit_vars( $this->field ); |
| 37 |
|
| 38 |
ob_start(); |
| 39 |
do_action( 'frm_display_added_fields', $field ); |
| 40 |
do_action( 'frm_display_added_' . $this->type . '_field', $field ); |
| 41 |
$input_html = ob_get_clean(); |
| 42 |
|
| 43 |
if ( ! $input_html ) { |
| 44 |
echo $this->builder_text_field( $name ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 45 |
} else { |
| 46 |
echo $input_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* @param array $args |
| 52 |
* @param array $shortcode_atts |
| 53 |
* |
| 54 |
* @return string |
| 55 |
*/ |
| 56 |
public function front_field_input( $args, $shortcode_atts ) { |
| 57 |
$pass_args = array( |
| 58 |
'errors' => $args['errors'], |
| 59 |
'html_id' => $args['html_id'], |
| 60 |
); |
| 61 |
ob_start(); |
| 62 |
do_action( 'frm_form_fields', $this->field, $args['field_name'], $pass_args ); |
| 63 |
do_action( 'frm_form_field_' . $this->type, $this->field, $args['field_name'], $pass_args ); |
| 64 |
$input_html = ob_get_clean(); |
| 65 |
|
| 66 |
return is_string( $input_html ) ? $input_html : ''; |
| 67 |
} |
| 68 |
} |
| 69 |
|