PluginProbe
Advanced Custom Fields (ACF®) / 3.3.1
Advanced Custom Fields (ACF®) v3.3.1
6.8.9 6.8.8 6.8.7 6.8.6 6.8.5 6.8.4 6.8.3 6.8.2 6.8.1 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 All 230 releases
advanced-custom-fields / core / fields / textarea.php
textarea.php
132 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class acf_Textarea extends acf_Field
4 {
5
6 /*--------------------------------------------------------------------------------------
7 *
8 * Constructor
9 *
10 * @author Elliot Condon
11 * @since 1.0.0
12 * @updated 2.2.0
13 *
14 *-------------------------------------------------------------------------------------*/
15
16 function __construct($parent)
17 {
18 parent::__construct($parent);
19
20 $this->name = 'textarea';
21 $this->title = __("Text Area",'acf');
22
23 }
24
25
26 /*--------------------------------------------------------------------------------------
27 *
28 * create_field
29 *
30 * @author Elliot Condon
31 * @since 2.0.5
32 * @updated 2.2.0
33 *
34 *-------------------------------------------------------------------------------------*/
35
36 function create_field($field)
37 {
38 // remove unwanted <br /> tags
39 $field['value'] = str_replace('<br />','',$field['value']);
40 echo '<textarea id="' . $field['name'] . '" rows="4" class="' . $field['class'] . '" name="' . $field['name'] . '" >' . $field['value'] . '</textarea>';
41 }
42
43
44 /*--------------------------------------------------------------------------------------
45 *
46 * create_options
47 *
48 * @author Elliot Condon
49 * @since 2.0.6
50 *
51 *-------------------------------------------------------------------------------------*/
52
53 function create_options($key, $field)
54 {
55 // defaults
56 $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : '';
57 $field['formatting'] = isset($field['formatting']) ? $field['formatting'] : 'br';
58
59 ?>
60 <tr class="field_option field_option_<?php echo $this->name; ?>">
61 <td class="label">
62 <label><?php _e("Default Value",'acf'); ?></label>
63 </td>
64 <td>
65 <?php
66 $this->parent->create_field(array(
67 'type' => 'textarea',
68 'name' => 'fields['.$key.'][default_value]',
69 'value' => $field['default_value'],
70 ));
71 ?>
72 </td>
73 </tr>
74 <tr class="field_option field_option_<?php echo $this->name; ?>">
75 <td class="label">
76 <label><?php _e("Formatting",'acf'); ?></label>
77 <p class="description"><?php _e("Define how to render html tags / new lines",'acf'); ?></p>
78 </td>
79 <td>
80 <?php
81 $this->parent->create_field(array(
82 'type' => 'select',
83 'name' => 'fields['.$key.'][formatting]',
84 'value' => $field['formatting'],
85 'choices' => array(
86 'none' => __("None",'acf'),
87 'br' => __("auto &lt;br /&gt;",'acf'),
88 'html' => __("HTML",'acf'),
89 )
90 ));
91 ?>
92 </td>
93 </tr>
94 <?php
95 }
96
97
98 /*--------------------------------------------------------------------------------------
99 *
100 * get_value_for_api
101 *
102 * @author Elliot Condon
103 * @since 3.0.0
104 *
105 *-------------------------------------------------------------------------------------*/
106
107 function get_value_for_api($post_id, $field)
108 {
109 // vars
110 $format = isset($field['formatting']) ? $field['formatting'] : 'br';
111
112 $value = parent::get_value($post_id, $field);
113
114 if($format == 'none')
115 {
116 $value = htmlspecialchars($value, ENT_QUOTES);
117 }
118 elseif($format == 'html')
119 {
120 $value = html_entity_decode($value);
121 }
122 elseif($format == 'br')
123 {
124 $value = htmlspecialchars($value, ENT_QUOTES);
125 $value = nl2br($value);
126 }
127
128 return $value;
129 }
130 }
131
132 ?>