| @@ -9,21 +9,12 @@ | ||
| 9 | 9 | class FrmFieldTextarea extends FrmFieldType { |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @var string |
| 13 | - * | |
| 14 | 13 | * @since 3.0 |
| 15 | 14 | */ |
| 16 | 15 | protected $type = 'textarea'; |
| 17 | 16 | |
| 18 | - /** | |
| 19 | - * @var bool | |
| 20 | - */ | |
| 21 | - protected $array_allowed = false; | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * @return bool[] | |
| 25 | - */ | |
| 26 | 17 | protected function field_settings_for_type() { |
| 27 | 18 | return array( |
| 28 | 19 | 'size' => true, |
| 29 | 20 | 'clear_on_focus' => true, |
| @@ -29,11 +20,8 @@ | ||
| 29 | 20 | 'clear_on_focus' => true, |
| 30 | 21 | ); |
| 31 | 22 | } |
| 32 | 23 | |
| 33 | - /** | |
| 34 | - * @return array | |
| 35 | - */ | |
| 36 | 24 | protected function extra_field_opts() { |
| 37 | 25 | return array( |
| 38 | 26 | 'max' => '5', |
| 39 | 27 | ); |
| @@ -40,37 +28,22 @@ | ||
| 40 | 28 | } |
| 41 | 29 | |
| 42 | 30 | /** |
| 43 | 31 | * @param string $name |
| 44 | - * | |
| 45 | - * @return void | |
| 46 | 32 | */ |
| 47 | 33 | public function show_on_form_builder( $name = '' ) { |
| 48 | - $size = FrmField::get_option( $this->field, 'size' ); | |
| 49 | - $max = FrmField::get_option( $this->field, 'max' ); | |
| 34 | + $size = FrmField::get_option( $this->field, 'size' ); | |
| 35 | + $size_html = $size ? ' style="width:' . esc_attr( $size . ( is_numeric( $size ) ? 'px' : '' ) ) . '";' : ''; | |
| 50 | 36 | |
| 51 | - $html_atts = array( | |
| 52 | - 'name' => $this->html_name( $name ), | |
| 53 | - 'id' => $this->html_id(), | |
| 54 | - 'rows' => $max, | |
| 55 | - 'class' => 'dyn_default_value', | |
| 56 | - 'placeholder' => FrmField::get_option( $this->field, 'placeholder' ), | |
| 57 | - ); | |
| 58 | - echo '<textarea'; | |
| 59 | - FrmAppHelper::array_to_html_params( $html_atts, true ); | |
| 37 | + $max = FrmField::get_option( $this->field, 'max' ); | |
| 38 | + $default_value = FrmAppHelper::esc_textarea( force_balance_tags( $this->get_field_column( 'default_value' ) ) ); | |
| 60 | 39 | |
| 61 | - if ( $size ) { | |
| 62 | - if ( is_numeric( $size ) ) { | |
| 63 | - $size .= 'px'; | |
| 64 | - } | |
| 65 | - | |
| 66 | - $style = 'width:' . $size . ';'; | |
| 67 | - echo ' style="' . esc_attr( $style ) . '"'; | |
| 68 | - } | |
| 69 | - | |
| 70 | - echo '>'; | |
| 71 | - echo FrmAppHelper::esc_textarea( force_balance_tags( $this->get_field_column( 'default_value' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 72 | - echo '</textarea>'; | |
| 40 | + echo '<textarea name="' . esc_attr( $this->html_name( $name ) ) . '" ' . // WPCS: XSS ok. | |
| 41 | + $size_html // WPCS: XSS ok. | |
| 42 | + . ' rows="' . esc_attr( $max ) . '" ' . | |
| 43 | + 'id="' . esc_attr( $this->html_id() ) . '" class="dyn_default_value">' . | |
| 44 | + $default_value // WPCS: XSS ok. | |
| 45 | + . '</textarea>'; | |
| 73 | 46 | } |
| 74 | 47 | |
| 75 | 48 | protected function prepare_display_value( $value, $atts ) { |
| 76 | 49 | FrmFieldsHelper::run_wpautop( $atts, $value ); |
| @@ -78,21 +51,8 @@ | ||
| 78 | 51 | return $value; |
| 79 | 52 | } |
| 80 | 53 | |
| 81 | 54 | /** |
| 82 | - * @since 6.0 | |
| 83 | - * | |
| 84 | - * @param array $field | |
| 85 | - * @param string $default_name | |
| 86 | - * @param mixed $default_value | |
| 87 | - * | |
| 88 | - * @return void | |
| 89 | - */ | |
| 90 | - public function show_default_value_field( $field, $default_name, $default_value ) { | |
| 91 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/textarea-default-value-field.php'; | |
| 92 | - } | |
| 93 | - | |
| 94 | - /** | |
| 95 | 55 | * @param array $args |
| 96 | 56 | * @param array $shortcode_atts |
| 97 | 57 | * |
| 98 | 58 | * @return string |
| @@ -99,9 +59,9 @@ | ||
| 99 | 59 | */ |
| 100 | 60 | public function front_field_input( $args, $shortcode_atts ) { |
| 101 | 61 | $input_html = $this->get_field_input_html_hook( $this->field ); |
| 102 | 62 | $this->add_aria_description( $args, $input_html ); |
| 103 | - $rows = $this->field['max'] ? 'rows="' . esc_attr( $this->field['max'] ) . '" ' : ''; | |
| 63 | + $rows = ( $this->field['max'] ) ? 'rows="' . esc_attr( $this->field['max'] ) . '" ' : ''; | |
| 104 | 64 | |
| 105 | 65 | return '<textarea name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" ' . |
| 106 | 66 | $rows . $input_html . '>' . |
| 107 | 67 | FrmAppHelper::esc_textarea( $this->field['value'] ) . |