PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5.2
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 +25 -41 6.265.5.2 View file →
@@ -8,11 +8,11 @@
8 8 */
9 9 class FrmEntryValues {
10 10
11 11 /**
12 - * @var 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 }
@@ -86,9 +84,8 @@
86 84 /**
87 85 * Gets entry property.
88 86 *
89 87 * @since 5.0.16
90 - *
91 88 * @return stdClass
92 89 */
93 90 public function get_entry() {
94 91 return $this->entry;
@@ -97,10 +94,8 @@
97 94 /**
98 95 * Set the form_id property
99 96 *
100 97 * @since 2.04
101 - *
102 - * @return void
103 98 */
104 99 protected function init_form_id() {
105 100 $this->form_id = (int) $this->entry->form_id;
106 101 }
@@ -110,25 +105,27 @@
110 105 *
111 106 * @since 2.04
112 107 *
113 108 * @param array $atts
114 - *
115 - * @return void
116 109 */
117 110 protected function init_include_fields( $atts ) {
118 111
119 - // For reverse compatibility with the fields parameter.
120 - if ( empty( $atts['include_fields'] ) && ! empty( $atts['fields'] ) ) {
121 - if ( ! is_array( $atts['fields'] ) ) {
122 - $atts['include_fields'] = $atts['fields'];
123 - } else {
124 - $atts['include_fields'] = '';
112 + // For reverse compatibility with the fields parameter
113 + if ( ! isset( $atts['include_fields'] ) || empty( $atts['include_fields'] ) ) {
125 114
126 - foreach ( $atts['fields'] as $included_field ) {
127 - $atts['include_fields'] .= $included_field->id . ',';
115 + if ( isset( $atts['fields'] ) && ! empty( $atts['fields'] ) ) {
116 +
117 + if ( ! is_array( $atts['fields'] ) ) {
118 + $atts['include_fields'] = $atts['fields'];
119 + } else {
120 + $atts['include_fields'] = '';
121 +
122 + foreach ( $atts['fields'] as $included_field ) {
123 + $atts['include_fields'] .= $included_field->id . ',';
124 + }
125 +
126 + $atts['include_fields'] = rtrim( $atts['include_fields'], ',' );
128 127 }
129 -
130 - $atts['include_fields'] = rtrim( $atts['include_fields'], ',' );
131 128 }
132 129 }
133 130
134 131 $this->include_fields = $this->prepare_array_property( 'include_fields', $atts );
@@ -149,10 +146,8 @@
149 146 *
150 147 * @since 2.04
151 148 *
152 149 * @param array $atts
153 - *
154 - * @return void
155 150 */
156 151 protected function init_exclude_fields( $atts ) {
157 152 $this->exclude_fields = $this->prepare_array_property( 'exclude_fields', $atts );
158 153
@@ -172,14 +167,14 @@
172 167 *
173 168 * @since 2.04
174 169 *
175 170 * @param string $index
176 - * @param array $atts
171 + * @param array $atts
177 172 *
178 173 * @return array
179 174 */
180 175 private function prepare_array_property( $index, $atts ) {
181 - if ( ! empty( $atts[ $index ] ) ) {
176 + if ( isset( $atts[ $index ] ) && ! empty( $atts[ $index ] ) ) {
182 177
183 178 if ( is_array( $atts[ $index ] ) ) {
184 179 $property = $atts[ $index ];
185 180 } else {
@@ -195,10 +190,8 @@
195 190 /**
196 191 * Set the fields property
197 192 *
198 193 * @since 2.04
199 - *
200 - * @return void
201 194 */
202 195 protected function init_fields() {
203 196 $this->fields = FrmField::get_all_for_form( $this->form_id, '', 'exclude', 'exclude' );
204 197
@@ -223,10 +216,8 @@
223 216 /**
224 217 * Set the field_values property
225 218 *
226 219 * @since 2.04
227 - *
228 - * @return void
229 220 */
230 221 protected function init_field_values() {
231 222 foreach ( $this->fields as $field ) {
232 223 if ( $this->is_field_included( $field ) ) {
@@ -249,10 +240,8 @@
249 240 /**
250 241 * Set the user_info property
251 242 *
252 243 * @since 2.04
253 - *
254 - * @return void
255 244 */
256 245 protected function init_user_info() {
257 246 if ( isset( $this->entry->description ) ) {
258 247 $entry_description = (array) $this->entry->description;
@@ -262,19 +251,19 @@
262 251 'referrer' => '',
263 252 );
264 253 }
265 254
266 - $ip = array(
255 + $ip = array(
267 256 'label' => __( 'IP Address', 'formidable' ),
268 257 'value' => $this->entry->ip,
269 258 );
270 - $browser = array(
259 + $browser = array(
271 260 'label' => __( 'User-Agent (Browser/OS)', 'formidable' ),
272 261 'value' => isset( $entry_description['browser'] ) ? FrmEntriesHelper::get_browser( $entry_description['browser'] ) : '',
273 262 );
274 263 $referrer = array(
275 264 'label' => __( 'Referrer', 'formidable' ),
276 - 'value' => $entry_description['referrer'] ?? '',
265 + 'value' => isset( $entry_description['referrer'] ) ? $entry_description['referrer'] : '',
277 266 );
278 267
279 268 /**
280 269 * Allow the referrer to be modified.
@@ -280,11 +269,10 @@
280 269 * Allow the referrer to be modified.
281 270 *
282 271 * @since 5.5.1
283 272 *
284 - * @param array $referrer
285 - * @param array $entry_description
286 - * @param object $entry
273 + * @param array $referrer
274 + * @param array @entry_description
287 275 */
288 276 $referrer = apply_filters( 'frm_user_info_referrer', $referrer, $entry_description, $this->entry );
289 277
290 278 $this->user_info = array(
@@ -315,9 +303,8 @@
315 303 * @return bool
316 304 */
317 305 protected function is_field_included( $field ) {
318 306 $is_included = true;
319 -
320 307 if ( ! empty( $this->include_fields ) ) {
321 308 $is_included = $this->is_field_in_array( $field, $this->include_fields );
322 309 }
323 310
@@ -322,9 +309,8 @@
322 309 }
323 310
324 311 if ( ! empty( $this->exclude_fields ) ) {
325 312 $is_excluded = $this->is_field_in_array( $field, $this->exclude_fields );
326 -
327 313 if ( $is_excluded ) {
328 314 $is_included = false;
329 315 }
330 316 }
@@ -337,9 +323,9 @@
337 323 *
338 324 * @since 2.04
339 325 *
340 326 * @param stdClass $field
341 - * @param array $array
327 + * @param array $array
342 328 *
343 329 * @return bool
344 330 */
345 331 protected function is_field_in_array( $field, $array ) {
@@ -351,10 +337,8 @@
351 337 *
352 338 * @since 2.04
353 339 *
354 340 * @param stdClass $field
355 - *
356 - * @return void
357 341 */
358 342 protected function add_field_values( $field ) {
359 343 $this->field_values[ $field->id ] = new FrmFieldValue( $field, $this->entry );
360 344 }