PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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 +31 -51 6.265.0 View file →
@@ -10,11 +10,11 @@
10 10
11 11 /**
12 12 * @since 2.04
13 13 *
14 - * @var stdClass|null
14 + * @var stdClass
15 15 */
16 - protected $field;
16 + protected $field = null;
17 17
18 18 /**
19 19 * @since 4.03
20 20 *
@@ -55,32 +55,19 @@
55 55 }
56 56
57 57 $this->entry = $entry;
58 58 $this->entry_id = $entry->id;
59 - $field = apply_filters( 'frm_field_value_object', $field );
59 + $field = apply_filters( 'frm_field_value_object', $field );
60 60 $this->field = $field;
61 61 $this->init_saved_value( $entry );
62 62 }
63 63
64 64 /**
65 - * Gets entry property.
66 - *
67 - * @since 5.0.16
68 - *
69 - * @return stdClass
70 - */
71 - public function get_entry() {
72 - return $this->entry;
73 - }
74 -
75 - /**
76 65 * Initialize the saved_value property
77 66 *
78 67 * @since 2.04
79 68 *
80 69 * @param stdClass $entry
81 - *
82 - * @return void
83 70 */
84 71 protected function init_saved_value( $entry ) {
85 72 if ( $this->field->type === 'html' ) {
86 73 $this->saved_value = $this->field->description;
@@ -98,15 +85,12 @@
98 85 *
99 86 * @since 2.05
100 87 *
101 88 * @param array $atts
102 - *
103 - * @return void
104 89 */
105 90 public function prepare_displayed_value( $atts = array() ) {
106 91 $this->displayed_value = $this->saved_value;
107 - // This class shouldn't affect values.
108 - unset( $atts['class'] );
92 + unset( $atts['class'] ); // This class shouldn't affect values.
109 93 $this->generate_displayed_value_for_field_type( $atts );
110 94 $this->filter_displayed_value( $atts );
111 95 }
112 96
@@ -113,12 +97,8 @@
113 97 /**
114 98 * Get a value from the field settings
115 99 *
116 100 * @since 2.05.06
117 - *
118 - * @param string $value
119 - *
120 - * @return mixed
121 101 */
122 102 public function get_field_option( $value ) {
123 103 return FrmField::get_option( $this->field, $value );
124 104 }
@@ -124,12 +104,8 @@
124 104 }
125 105
126 106 /**
127 107 * @since 4.03
128 - *
129 - * @param string $option
130 - *
131 - * @return mixed
132 108 */
133 109 public function get_field_attr( $option ) {
134 110 return is_object( $this->field ) ? $this->field->{$option} : '';
135 111 }
@@ -135,10 +111,8 @@
135 111 }
136 112
137 113 /**
138 114 * @since 4.03
139 - *
140 - * @return stdClass
141 115 */
142 116 public function get_field() {
143 117 return $this->field;
144 118 }
@@ -146,10 +120,8 @@
146 120 /**
147 121 * Get the field property's label
148 122 *
149 123 * @since 2.04
150 - *
151 - * @return string
152 124 */
153 125 public function get_field_label() {
154 126 return $this->get_field_attr( 'name' );
155 127 }
@@ -157,10 +129,8 @@
157 129 /**
158 130 * Get the field property's id
159 131 *
160 132 * @since 2.05
161 - *
162 - * @return string
163 133 */
164 134 public function get_field_id() {
165 135 return $this->get_field_attr( 'id' );
166 136 }
@@ -168,10 +138,8 @@
168 138 /**
169 139 * Get the field property's key
170 140 *
171 141 * @since 2.04
172 - *
173 - * @return string
174 142 */
175 143 public function get_field_key() {
176 144 return $this->get_field_attr( 'field_key' );
177 145 }
@@ -179,10 +147,8 @@
179 147 /**
180 148 * Get the field property's type
181 149 *
182 150 * @since 2.04
183 - *
184 - * @return string
185 151 */
186 152 public function get_field_type() {
187 153 return $this->get_field_attr( 'type' );
188 154 }
@@ -190,10 +156,8 @@
190 156 /**
191 157 * Get the saved_value property
192 158 *
193 159 * @since 2.04
194 - *
195 - * @return mixed
196 160 */
197 161 public function get_saved_value() {
198 162 return $this->saved_value;
199 163 }
@@ -201,10 +165,8 @@
201 165 /**
202 166 * Get the displayed_value property
203 167 *
204 168 * @since 2.04
205 - *
206 - * @return mixed
207 169 */
208 170 public function get_displayed_value() {
209 171 if ( $this->displayed_value === 'frm_not_prepared' ) {
210 172 return __( 'The display value has not been prepared. Please use the prepare_display_value() method before calling get_displayed_value().', 'formidable' );
@@ -219,9 +181,9 @@
219 181 * @since 3.0
220 182 *
221 183 * @param array $atts
222 184 *
223 - * @return void
185 + * @return mixed
224 186 */
225 187 protected function generate_displayed_value_for_field_type( $atts ) {
226 188 if ( ! FrmAppHelper::is_empty_value( $this->displayed_value, '' ) ) {
227 189 $field_obj = FrmFieldFactory::get_field_object( $this->field );
@@ -235,20 +197,41 @@
235 197 *
236 198 * @since 2.04
237 199 *
238 200 * @param array $atts
239 - *
240 - * @return void
241 201 */
242 202 protected function filter_displayed_value( $atts ) {
243 203 if ( ! is_object( $this->entry ) || empty( $this->entry->metas ) ) {
244 204 $this->entry = FrmEntry::getOne( $this->entry_id, true );
245 -
246 205 if ( ! is_object( $this->entry ) ) {
247 206 return;
248 207 }
249 208 }
250 209
210 + // TODO: maybe change from 'source' to 'run_filters' = 'email'
211 + if ( isset( $atts['source'] ) && $atts['source'] === 'entry_formatter' ) {
212 + // Deprecated frm_email_value hook
213 + $meta = array(
214 + 'item_id' => $this->entry->id,
215 + 'field_id' => $this->field->id,
216 + 'meta_value' => $this->saved_value,
217 + 'field_type' => $this->field->type,
218 + );
219 +
220 + if ( has_filter( 'frm_email_value' ) ) {
221 + _deprecated_function( 'The frm_email_value filter', '2.04', 'the frm_display_{fieldtype}_value_custom filter' );
222 + $this->displayed_value = apply_filters(
223 + 'frm_email_value',
224 + $this->displayed_value,
225 + (object) $meta,
226 + $this->entry,
227 + array(
228 + 'field' => $this->field,
229 + )
230 + );
231 + }
232 + }
233 +
251 234 // frm_display_{fieldtype}_value_custom hook
252 235 $this->displayed_value = apply_filters(
253 236 'frm_display_' . $this->field->type . '_value_custom',
254 237 $this->displayed_value,
@@ -261,19 +244,16 @@
261 244 $this->displayed_value = apply_filters( 'frm_display_value', $this->displayed_value, $this->field, $atts );
262 245 }
263 246
264 247 /**
265 - * Clean a field's saved value.
248 + * Clean a field's saved value
266 249 *
267 250 * @since 2.04
268 - *
269 - * @return void
270 251 */
271 252 protected function clean_saved_value() {
272 253 if ( $this->saved_value !== '' ) {
273 254 if ( ! is_array( $this->saved_value ) && ! is_object( $this->saved_value ) ) {
274 - $field_type = FrmField::get_field_type( $this->field );
275 - FrmFieldsHelper::prepare_field_value( $this->saved_value, $field_type );
255 + FrmAppHelper::unserialize_or_decode( $this->saved_value );
276 256 }
277 257
278 258 if ( is_array( $this->saved_value ) && empty( $this->saved_value ) ) {
279 259 $this->saved_value = '';