PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.14
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.14
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/FrmEntryValues.php +38 -65 6.335.0.14 View file →
@@ -8,11 +8,11 @@
8 8 */
9 9 class FrmEntryValues {
10 10
11 11 /**
12 - * @var false|stdClass|null
12 + * @var stdClass
13 13 */
14 - protected $entry;
14 + protected $entry = null;
15 15
16 16 /**
17 17 * @var int
18 18 */
@@ -48,9 +48,9 @@
48 48 *
49 49 * @since 2.04
50 50 *
51 51 * @param int|string $entry_id
52 - * @param array $atts
52 + * @param array $atts
53 53 */
54 54 public function __construct( $entry_id, $atts = array() ) {
55 55 if ( isset( $atts['entry'] ) && is_object( $atts['entry'] ) && ! empty( $atts['entry']->metas ) ) {
56 56 $this->entry = $atts['entry'];
@@ -75,10 +75,8 @@
75 75 *
76 76 * @since 2.04
77 77 *
78 78 * @param int|string $entry_id
79 - *
80 - * @return void
81 79 */
82 80 protected function init_entry( $entry_id ) {
83 81 $this->entry = FrmEntry::getOne( $entry_id, true );
84 82 }
@@ -83,24 +81,11 @@
83 81 $this->entry = FrmEntry::getOne( $entry_id, true );
84 82 }
85 83
86 84 /**
87 - * Gets entry property.
88 - *
89 - * @since 5.0.16
90 - *
91 - * @return stdClass
92 - */
93 - public function get_entry() {
94 - return $this->entry;
95 - }
96 -
97 - /**
98 85 * Set the form_id property
99 86 *
100 87 * @since 2.04
101 - *
102 - * @return void
103 88 */
104 89 protected function init_form_id() {
105 90 $this->form_id = (int) $this->entry->form_id;
106 91 }
@@ -110,24 +95,27 @@
110 95 *
111 96 * @since 2.04
112 97 *
113 98 * @param array $atts
114 - *
115 - * @return void
116 99 */
117 100 protected function init_include_fields( $atts ) {
118 - // For reverse compatibility with the fields parameter.
119 - if ( empty( $atts['include_fields'] ) && ! empty( $atts['fields'] ) ) {
120 - if ( is_array( $atts['fields'] ) ) {
121 - $atts['include_fields'] = '';
122 101
123 - foreach ( $atts['fields'] as $included_field ) {
124 - $atts['include_fields'] .= $included_field->id . ',';
102 + // For reverse compatibility with the fields parameter
103 + if ( ! isset( $atts['include_fields'] ) || empty( $atts['include_fields'] ) ) {
104 +
105 + if ( isset( $atts['fields'] ) && ! empty( $atts['fields'] ) ) {
106 +
107 + if ( ! is_array( $atts['fields'] ) ) {
108 + $atts['include_fields'] = $atts['fields'];
109 + } else {
110 + $atts['include_fields'] = '';
111 +
112 + foreach ( $atts['fields'] as $included_field ) {
113 + $atts['include_fields'] .= $included_field->id . ',';
114 + }
115 +
116 + $atts['include_fields'] = rtrim( $atts['include_fields'], ',' );
125 117 }
126 -
127 - $atts['include_fields'] = rtrim( $atts['include_fields'], ',' );
128 - } else {
129 - $atts['include_fields'] = $atts['fields'];
130 118 }
131 119 }
132 120
133 121 $this->include_fields = $this->prepare_array_property( 'include_fields', $atts );
@@ -148,10 +136,8 @@
148 136 *
149 137 * @since 2.04
150 138 *
151 139 * @param array $atts
152 - *
153 - * @return void
154 140 */
155 141 protected function init_exclude_fields( $atts ) {
156 142 $this->exclude_fields = $this->prepare_array_property( 'exclude_fields', $atts );
157 143
@@ -171,18 +157,25 @@
171 157 *
172 158 * @since 2.04
173 159 *
174 160 * @param string $index
175 - * @param array $atts
161 + * @param array $atts
176 162 *
177 163 * @return array
178 164 */
179 165 private function prepare_array_property( $index, $atts ) {
180 - if ( ! empty( $atts[ $index ] ) ) {
181 - return is_array( $atts[ $index ] ) ? $atts[ $index ] : explode( ',', $atts[ $index ] );
166 + if ( isset( $atts[ $index ] ) && ! empty( $atts[ $index ] ) ) {
167 +
168 + if ( is_array( $atts[ $index ] ) ) {
169 + $property = $atts[ $index ];
170 + } else {
171 + $property = explode( ',', $atts[ $index ] );
172 + }
173 + } else {
174 + $property = array();
182 175 }
183 176
184 - return array();
177 + return $property;
185 178 }
186 179
187 180 /**
188 181 * Set the fields property
@@ -187,10 +180,8 @@
187 180 /**
188 181 * Set the fields property
189 182 *
190 183 * @since 2.04
191 - *
192 - * @return void
193 184 */
194 185 protected function init_fields() {
195 186 $this->fields = FrmField::get_all_for_form( $this->form_id, '', 'exclude', 'exclude' );
196 187
@@ -215,10 +206,8 @@
215 206 /**
216 207 * Set the field_values property
217 208 *
218 209 * @since 2.04
219 - *
220 - * @return void
221 210 */
222 211 protected function init_field_values() {
223 212 foreach ( $this->fields as $field ) {
224 213 if ( $this->is_field_included( $field ) ) {
@@ -241,10 +230,8 @@
241 230 /**
242 231 * Set the user_info property
243 232 *
244 233 * @since 2.04
245 - *
246 - * @return void
247 234 */
248 235 protected function init_user_info() {
249 236 if ( isset( $this->entry->description ) ) {
250 237 $entry_description = (array) $this->entry->description;
@@ -254,32 +241,23 @@
254 241 'referrer' => '',
255 242 );
256 243 }
257 244
258 - $ip = array(
245 + $ip = array(
259 246 'label' => __( 'IP Address', 'formidable' ),
260 247 'value' => $this->entry->ip,
261 248 );
262 - $browser = array(
249 +
250 + $browser = array(
263 251 'label' => __( 'User-Agent (Browser/OS)', 'formidable' ),
264 - 'value' => isset( $entry_description['browser'] ) ? FrmEntriesHelper::get_browser( $entry_description['browser'] ) : '',
252 + 'value' => FrmEntriesHelper::get_browser( $entry_description['browser'] ),
265 253 );
254 +
266 255 $referrer = array(
267 256 'label' => __( 'Referrer', 'formidable' ),
268 - 'value' => $entry_description['referrer'] ?? '',
257 + 'value' => $entry_description['referrer'],
269 258 );
270 259
271 - /**
272 - * Allow the referrer to be modified.
273 - *
274 - * @since 5.5.1
275 - *
276 - * @param array $referrer
277 - * @param array $entry_description
278 - * @param object $entry
279 - */
280 - $referrer = apply_filters( 'frm_user_info_referrer', $referrer, $entry_description, $this->entry );
281 -
282 260 $this->user_info = array(
283 261 'ip' => $ip,
284 262 'browser' => $browser,
285 263 'referrer' => $referrer,
@@ -307,16 +285,14 @@
307 285 * @return bool
308 286 */
309 287 protected function is_field_included( $field ) {
310 288 $is_included = true;
311 -
312 - if ( $this->include_fields ) {
289 + if ( ! empty( $this->include_fields ) ) {
313 290 $is_included = $this->is_field_in_array( $field, $this->include_fields );
314 291 }
315 292
316 - if ( $this->exclude_fields ) {
293 + if ( ! empty( $this->exclude_fields ) ) {
317 294 $is_excluded = $this->is_field_in_array( $field, $this->exclude_fields );
318 -
319 295 if ( $is_excluded ) {
320 296 $is_included = false;
321 297 }
322 298 }
@@ -329,14 +305,13 @@
329 305 *
330 306 * @since 2.04
331 307 *
332 308 * @param stdClass $field
333 - * @param array $array
309 + * @param array $array
334 310 *
335 311 * @return bool
336 312 */
337 313 protected function is_field_in_array( $field, $array ) {
338 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
339 314 return in_array( $field->id, $array ) || in_array( (string) $field->field_key, $array, true );
340 315 }
341 316
342 317 /**
@@ -344,10 +319,8 @@
344 319 *
345 320 * @since 2.04
346 321 *
347 322 * @param stdClass $field
348 - *
349 - * @return void
350 323 */
351 324 protected function add_field_values( $field ) {
352 325 $this->field_values[ $field->id ] = new FrmFieldValue( $field, $this->entry );
353 326 }