PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.07
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.07
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 -33 6.255.0.07 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,31 +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 - * @return stdClass
69 - */
70 - public function get_entry() {
71 - return $this->entry;
72 - }
73 -
74 - /**
75 65 * Initialize the saved_value property
76 66 *
77 67 * @since 2.04
78 68 *
79 69 * @param stdClass $entry
80 - *
81 - * @return void
82 70 */
83 71 protected function init_saved_value( $entry ) {
84 72 if ( $this->field->type === 'html' ) {
85 73 $this->saved_value = $this->field->description;
@@ -97,15 +85,12 @@
97 85 *
98 86 * @since 2.05
99 87 *
100 88 * @param array $atts
101 - *
102 - * @return void
103 89 */
104 90 public function prepare_displayed_value( $atts = array() ) {
105 91 $this->displayed_value = $this->saved_value;
106 - // This class shouldn't affect values.
107 - unset( $atts['class'] );
92 + unset( $atts['class'] ); // This class shouldn't affect values.
108 93 $this->generate_displayed_value_for_field_type( $atts );
109 94 $this->filter_displayed_value( $atts );
110 95 }
111 96
@@ -112,10 +97,8 @@
112 97 /**
113 98 * Get a value from the field settings
114 99 *
115 100 * @since 2.05.06
116 - *
117 - * @param string $value
118 101 */
119 102 public function get_field_option( $value ) {
120 103 return FrmField::get_option( $this->field, $value );
121 104 }
@@ -121,10 +104,8 @@
121 104 }
122 105
123 106 /**
124 107 * @since 4.03
125 - *
126 - * @param string $option
127 108 */
128 109 public function get_field_attr( $option ) {
129 110 return is_object( $this->field ) ? $this->field->{$option} : '';
130 111 }
@@ -130,10 +111,8 @@
130 111 }
131 112
132 113 /**
133 114 * @since 4.03
134 - *
135 - * @return stdClass
136 115 */
137 116 public function get_field() {
138 117 return $this->field;
139 118 }
@@ -202,9 +181,9 @@
202 181 * @since 3.0
203 182 *
204 183 * @param array $atts
205 184 *
206 - * @return void
185 + * @return mixed
207 186 */
208 187 protected function generate_displayed_value_for_field_type( $atts ) {
209 188 if ( ! FrmAppHelper::is_empty_value( $this->displayed_value, '' ) ) {
210 189 $field_obj = FrmFieldFactory::get_field_object( $this->field );
@@ -218,10 +197,8 @@
218 197 *
219 198 * @since 2.04
220 199 *
221 200 * @param array $atts
222 - *
223 - * @return void
224 201 */
225 202 protected function filter_displayed_value( $atts ) {
226 203 if ( ! is_object( $this->entry ) || empty( $this->entry->metas ) ) {
227 204 $this->entry = FrmEntry::getOne( $this->entry_id, true );
@@ -229,8 +206,32 @@
229 206 return;
230 207 }
231 208 }
232 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 +
233 234 // frm_display_{fieldtype}_value_custom hook
234 235 $this->displayed_value = apply_filters(
235 236 'frm_display_' . $this->field->type . '_value_custom',
236 237 $this->displayed_value,
@@ -243,19 +244,16 @@
243 244 $this->displayed_value = apply_filters( 'frm_display_value', $this->displayed_value, $this->field, $atts );
244 245 }
245 246
246 247 /**
247 - * Clean a field's saved value.
248 + * Clean a field's saved value
248 249 *
249 250 * @since 2.04
250 - *
251 - * @return void
252 251 */
253 252 protected function clean_saved_value() {
254 253 if ( $this->saved_value !== '' ) {
255 254 if ( ! is_array( $this->saved_value ) && ! is_object( $this->saved_value ) ) {
256 - $field_type = FrmField::get_field_type( $this->field );
257 - FrmFieldsHelper::prepare_field_value( $this->saved_value, $field_type );
255 + FrmAppHelper::unserialize_or_decode( $this->saved_value );
258 256 }
259 257
260 258 if ( is_array( $this->saved_value ) && empty( $this->saved_value ) ) {
261 259 $this->saved_value = '';