1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
<?php // phpcs:ignoreFile
namespace AutomateWoo\Fields;
use AutomateWoo\Clean;
if ( ! defined( 'ABSPATH' ) ) exit;
/** * @class Text_Area */ class Text_Area extends Text {
protected $name = 'text_area';
protected $type = 'text_area';
/** * Determines if HTML will be allowed in the field value. * By default HTML tags will be stripped. * * @var bool|string|array */ protected $allow_html = false;
function __construct() { parent::__construct(); $this->set_title( __( 'Text Area', 'automatewoo' ) ); }
/** * @param int $rows * * @return $this */ function set_rows( $rows ) { $this->add_extra_attr('rows', $rows ); return $this; }
/** * Determines if HTML will be allowed in the field value. * * @param bool|string|array $allow_html Default is false. * false - Strips all HTML * true - Sanitize content for allowed HTML tags in post content, uses wp_kses_post() * array|string - List of allowed HTML elements for wp_kses() * * @return $this */ function set_allow_html( $allow_html ) { $this->allow_html = $allow_html; return $this; }
/** * Output the field HTML. * * @param string $value */ function render( $value ) { if ( $this->decode_html_entities_before_render ) { $value = html_entity_decode( $value ); }
?> <textarea name="<?php echo esc_attr( $this->get_full_name() ); ?><?php echo $this->multiple ? '[]' : '' ?>" class="<?php echo esc_attr( $this->get_classes() ); ?>" placeholder="<?php echo esc_attr( $this->get_placeholder() ); ?>" <?php $this->output_extra_attrs(); ?> <?php echo ( $this->get_required() ? 'required' : '' ) ?> ><?php echo esc_textarea( $value ); ?></textarea> <?php }
/** * Sanitizes the value of the field. * Type of sanitization varies based on the value of $this->allow_html. * * @since 4.4.0 * * @param string $value * * @return string */ function sanitize_value( $value ) { if ( $this->allow_html ) { if ( $this->allow_html === true ) { return wp_kses_post( $value ); } else { return wp_kses( $value, $this->allow_html ); } } else { return Clean::textarea( $value ); } }
}
|