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