PluginProbe
Advanced Custom Fields (ACF®) / 3.0.4
Advanced Custom Fields (ACF®) v3.0.4
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 / text.php
text.php
144 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class acf_Text 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 = 'text';
21 $this->title = __("Text",'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 echo '<input type="text" value="' . $field['value'] . '" id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" />';
39 }
40
41
42 /*--------------------------------------------------------------------------------------
43 *
44 * create_options
45 *
46 * @author Elliot Condon
47 * @since 2.0.6
48 * @updated 2.2.0
49 *
50 *-------------------------------------------------------------------------------------*/
51
52 function create_options($key, $field)
53 {
54 // defaults
55 $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : '';
56 $field['formatting'] = isset($field['formatting']) ? $field['formatting'] : 'html';
57
58 ?>
59 <tr class="field_option field_option_<?php echo $this->name; ?>">
60 <td class="label">
61 <label><?php _e("Default Value",'acf'); ?></label>
62 </td>
63 <td>
64 <?php
65 $this->parent->create_field(array(
66 'type' => 'text',
67 'name' => 'fields['.$key.'][default_value]',
68 'value' => $field['default_value'],
69 ));
70 ?>
71 </td>
72 </tr>
73 <tr class="field_option field_option_<?php echo $this->name; ?>">
74 <td class="label">
75 <label><?php _e("Formatting",'acf'); ?></label>
76 <p class="description"><?php _e("Define how to render html tags",'acf'); ?></p>
77 </td>
78 <td>
79 <?php
80 $this->parent->create_field(array(
81 'type' => 'select',
82 'name' => 'fields['.$key.'][formatting]',
83 'value' => $field['formatting'],
84 'choices' => array(
85 'none' => 'None',
86 'html' => 'HTML'
87 )
88 ));
89 ?>
90 </td>
91 </tr>
92 <?php
93 }
94
95
96 /*--------------------------------------------------------------------------------------
97 *
98 * get_value
99 *
100 * @author Elliot Condon
101 * @since 2.2.0
102 *
103 *-------------------------------------------------------------------------------------*/
104
105 function get_value($post_id, $field)
106 {
107 $value = parent::get_value($post_id, $field);
108
109 $value = htmlspecialchars($value, ENT_QUOTES);
110
111 return $value;
112 }
113
114 /*--------------------------------------------------------------------------------------
115 *
116 * get_value_for_api
117 *
118 * @author Elliot Condon
119 * @since 3.0.0
120 *
121 *-------------------------------------------------------------------------------------*/
122
123 function get_value_for_api($post_id, $field)
124 {
125 // vars
126 $format = isset($field['formatting']) ? $field['formatting'] : 'html';
127
128 $value = parent::get_value($post_id, $field);
129
130 if($format == 'none')
131 {
132 $value = htmlspecialchars($value, ENT_QUOTES);
133 }
134 elseif($format == 'html')
135 {
136 $value = html_entity_decode($value);
137 }
138
139 return $value;
140 }
141
142 }
143
144 ?>