PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 3.06.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v3.06.06
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmFieldValue.php +15 -76 6.43.06.06 View file →
@@ -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 2.04
8 5 */
@@ -15,15 +12,8 @@
15 12 */
16 13 protected $field = null;
17 14
18 15 /**
19 - * @since 4.03
20 - *
21 - * @var object
22 - */
23 - protected $entry;
24 -
25 - /**
26 16 * @since 2.04
27 17 *
28 18 * @var int
29 19 */
@@ -53,38 +43,24 @@
53 43 if ( ! is_object( $field ) || ! is_object( $entry ) || ! isset( $entry->metas ) ) {
54 44 return;
55 45 }
56 46
57 - $this->entry = $entry;
58 47 $this->entry_id = $entry->id;
59 - $field = apply_filters( 'frm_field_value_object', $field );
60 - $this->field = $field;
48 + $this->field = $field;
61 49 $this->init_saved_value( $entry );
62 50 }
63 51
64 52 /**
65 - * Gets entry property.
66 - *
67 - * @since 5.0.16
68 - * @return stdClass
69 - */
70 - public function get_entry() {
71 - return $this->entry;
72 - }
73 -
74 - /**
75 53 * Initialize the saved_value property
76 54 *
77 55 * @since 2.04
78 56 *
79 57 * @param stdClass $entry
80 - *
81 - * @return void
82 58 */
83 59 protected function init_saved_value( $entry ) {
84 60 if ( $this->field->type === 'html' ) {
85 61 $this->saved_value = $this->field->description;
86 - } elseif ( isset( $entry->metas[ $this->field->id ] ) ) {
62 + } else if ( isset( $entry->metas[ $this->field->id ] ) ) {
87 63 $this->saved_value = $entry->metas[ $this->field->id ];
88 64 } else {
89 65 $this->saved_value = '';
90 66 }
@@ -97,14 +73,11 @@
97 73 *
98 74 * @since 2.05
99 75 *
100 76 * @param array $atts
101 - *
102 - * @return void
103 77 */
104 78 public function prepare_displayed_value( $atts = array() ) {
105 79 $this->displayed_value = $this->saved_value;
106 - unset( $atts['class'] ); // This class shouldn't affect values.
107 80 $this->generate_displayed_value_for_field_type( $atts );
108 81 $this->filter_displayed_value( $atts );
109 82 }
110 83
@@ -111,10 +84,8 @@
111 84 /**
112 85 * Get a value from the field settings
113 86 *
114 87 * @since 2.05.06
115 - *
116 - * @param string $value
117 88 */
118 89 public function get_field_option( $value ) {
119 90 return FrmField::get_option( $this->field, $value );
120 91 }
@@ -119,32 +90,14 @@
119 90 return FrmField::get_option( $this->field, $value );
120 91 }
121 92
122 93 /**
123 - * @since 4.03
124 - *
125 - * @param string $option
126 - */
127 - public function get_field_attr( $option ) {
128 - return is_object( $this->field ) ? $this->field->{$option} : '';
129 - }
130 -
131 - /**
132 - * @since 4.03
133 - *
134 - * @return stdClass
135 - */
136 - public function get_field() {
137 - return $this->field;
138 - }
139 -
140 - /**
141 94 * Get the field property's label
142 95 *
143 96 * @since 2.04
144 97 */
145 98 public function get_field_label() {
146 - return $this->get_field_attr( 'name' );
99 + return $this->field->name;
147 100 }
148 101
149 102 /**
150 103 * Get the field property's id
@@ -151,9 +104,9 @@
151 104 *
152 105 * @since 2.05
153 106 */
154 107 public function get_field_id() {
155 - return $this->get_field_attr( 'id' );
108 + return $this->field->id;
156 109 }
157 110
158 111 /**
159 112 * Get the field property's key
@@ -160,9 +113,9 @@
160 113 *
161 114 * @since 2.04
162 115 */
163 116 public function get_field_key() {
164 - return $this->get_field_attr( 'field_key' );
117 + return $this->field->field_key;
165 118 }
166 119
167 120 /**
168 121 * Get the field property's type
@@ -169,9 +122,9 @@
169 122 *
170 123 * @since 2.04
171 124 */
172 125 public function get_field_type() {
173 - return $this->get_field_attr( 'type' );
126 + return $this->field->type;
174 127 }
175 128
176 129 /**
177 130 * Get the saved_value property
@@ -201,14 +154,13 @@
201 154 * @since 3.0
202 155 *
203 156 * @param array $atts
204 157 *
205 - * @return void
158 + * @return mixed
206 159 */
207 160 protected function generate_displayed_value_for_field_type( $atts ) {
208 161 if ( ! FrmAppHelper::is_empty_value( $this->displayed_value, '' ) ) {
209 162 $field_obj = FrmFieldFactory::get_field_object( $this->field );
210 -
211 163 $this->displayed_value = $field_obj->get_display_value( $this->displayed_value, $atts );
212 164 }
213 165 }
214 166
@@ -217,24 +169,17 @@
217 169 *
218 170 * @since 2.04
219 171 *
220 172 * @param array $atts
221 - *
222 - * @return void
223 173 */
224 174 protected function filter_displayed_value( $atts ) {
225 - if ( ! is_object( $this->entry ) || empty( $this->entry->metas ) ) {
226 - $this->entry = FrmEntry::getOne( $this->entry_id, true );
227 - if ( ! is_object( $this->entry ) ) {
228 - return;
229 - }
230 - }
175 + $entry = FrmEntry::getOne( $this->entry_id, true );
231 176
232 177 // TODO: maybe change from 'source' to 'run_filters' = 'email'
233 178 if ( isset( $atts['source'] ) && $atts['source'] === 'entry_formatter' ) {
234 179 // Deprecated frm_email_value hook
235 - $meta = array(
236 - 'item_id' => $this->entry->id,
180 + $meta = array(
181 + 'item_id' => $entry->id,
237 182 'field_id' => $this->field->id,
238 183 'meta_value' => $this->saved_value,
239 184 'field_type' => $this->field->type,
240 185 );
@@ -244,9 +189,9 @@
244 189 $this->displayed_value = apply_filters(
245 190 'frm_email_value',
246 191 $this->displayed_value,
247 192 (object) $meta,
248 - $this->entry,
193 + $entry,
249 194 array(
250 195 'field' => $this->field,
251 196 )
252 197 );
@@ -258,28 +203,22 @@
258 203 'frm_display_' . $this->field->type . '_value_custom',
259 204 $this->displayed_value,
260 205 array(
261 206 'field' => $this->field,
262 - 'entry' => $this->entry,
207 + 'entry' => $entry,
263 208 )
264 209 );
265 -
266 - $this->displayed_value = apply_filters( 'frm_display_value', $this->displayed_value, $this->field, $atts );
267 210 }
268 211
269 212 /**
270 - * Clean a field's saved value.
213 + * Clean a field's saved value
271 214 *
272 215 * @since 2.04
273 - *
274 - * @return void
275 216 */
276 217 protected function clean_saved_value() {
277 218 if ( $this->saved_value !== '' ) {
278 - if ( ! is_array( $this->saved_value ) && ! is_object( $this->saved_value ) ) {
279 - $field_type = FrmField::get_field_type( $this->field );
280 - FrmFieldsHelper::prepare_field_value( $this->saved_value, $field_type );
281 - }
219 +
220 + $this->saved_value = maybe_unserialize( $this->saved_value );
282 221
283 222 if ( is_array( $this->saved_value ) && empty( $this->saved_value ) ) {
284 223 $this->saved_value = '';
285 224 }