| @@ -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,21 +6,12 @@ | ||
| 9 | 6 | class FrmFieldTextarea extends FrmFieldType { |
| 10 | 7 | |
| 11 | 8 | /** |
| 12 | 9 | * @var string |
| 13 | - * | |
| 14 | 10 | * @since 3.0 |
| 15 | 11 | */ |
| 16 | 12 | protected $type = 'textarea'; |
| 17 | 13 | |
| 18 | - /** | |
| 19 | - * @var bool | |
| 20 | - */ | |
| 21 | - protected $array_allowed = false; | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * @return bool[] | |
| 25 | - */ | |
| 26 | 14 | protected function field_settings_for_type() { |
| 27 | 15 | return array( |
| 28 | 16 | 'size' => true, |
| 29 | 17 | 'clear_on_focus' => true, |
| @@ -29,11 +17,8 @@ | ||
| 29 | 17 | 'clear_on_focus' => true, |
| 30 | 18 | ); |
| 31 | 19 | } |
| 32 | 20 | |
| 33 | - /** | |
| 34 | - * @return array | |
| 35 | - */ | |
| 36 | 21 | protected function extra_field_opts() { |
| 37 | 22 | return array( |
| 38 | 23 | 'max' => '5', |
| 39 | 24 | ); |
| @@ -40,37 +25,22 @@ | ||
| 40 | 25 | } |
| 41 | 26 | |
| 42 | 27 | /** |
| 43 | 28 | * @param string $name |
| 44 | - * | |
| 45 | - * @return void | |
| 46 | 29 | */ |
| 47 | 30 | public function show_on_form_builder( $name = '' ) { |
| 48 | 31 | $size = FrmField::get_option( $this->field, 'size' ); |
| 49 | - $max = FrmField::get_option( $this->field, 'max' ); | |
| 32 | + $size_html = $size ? ' style="width:' . esc_attr( $size . ( is_numeric( $size ) ? 'px' : '' ) ) . '";' : ''; | |
| 50 | 33 | |
| 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 ); | |
| 34 | + $max = FrmField::get_option( $this->field, 'max' ); | |
| 35 | + $default_value = FrmAppHelper::esc_textarea( force_balance_tags( $this->get_field_column( 'default_value' ) ) ); | |
| 60 | 36 | |
| 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>'; | |
| 37 | + echo '<textarea name="' . esc_attr( $this->html_name( $name ) ) . '" ' . // WPCS: XSS ok. | |
| 38 | + $size_html // WPCS: XSS ok. | |
| 39 | + . ' rows="' . esc_attr( $max ) . '" ' . | |
| 40 | + 'id="' . esc_attr( $this->html_id() ) . '" class="dyn_default_value">' . | |
| 41 | + $default_value // WPCS: XSS ok. | |
| 42 | + . '</textarea>'; | |
| 73 | 43 | } |
| 74 | 44 | |
| 75 | 45 | protected function prepare_display_value( $value, $atts ) { |
| 76 | 46 | FrmFieldsHelper::run_wpautop( $atts, $value ); |
| @@ -78,21 +48,8 @@ | ||
| 78 | 48 | return $value; |
| 79 | 49 | } |
| 80 | 50 | |
| 81 | 51 | /** |
| 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 | 52 | * @param array $args |
| 96 | 53 | * @param array $shortcode_atts |
| 97 | 54 | * |
| 98 | 55 | * @return string |
| @@ -99,9 +56,9 @@ | ||
| 99 | 56 | */ |
| 100 | 57 | public function front_field_input( $args, $shortcode_atts ) { |
| 101 | 58 | $input_html = $this->get_field_input_html_hook( $this->field ); |
| 102 | 59 | $this->add_aria_description( $args, $input_html ); |
| 103 | - $rows = $this->field['max'] ? 'rows="' . esc_attr( $this->field['max'] ) . '" ' : ''; | |
| 60 | + $rows = ( $this->field['max'] ) ? 'rows="' . esc_attr( $this->field['max'] ) . '" ' : ''; | |
| 104 | 61 | |
| 105 | 62 | return '<textarea name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" ' . |
| 106 | 63 | $rows . $input_html . '>' . |
| 107 | 64 | FrmAppHelper::esc_textarea( $this->field['value'] ) . |