PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.1
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 +26 -50 6.265.1 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,32 +251,23 @@
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 +
260 + $browser = array(
271 261 'label' => __( 'User-Agent (Browser/OS)', 'formidable' ),
272 - 'value' => isset( $entry_description['browser'] ) ? FrmEntriesHelper::get_browser( $entry_description['browser'] ) : '',
262 + 'value' => FrmEntriesHelper::get_browser( $entry_description['browser'] ),
273 263 );
264 +
274 265 $referrer = array(
275 266 'label' => __( 'Referrer', 'formidable' ),
276 - 'value' => $entry_description['referrer'] ?? '',
267 + 'value' => $entry_description['referrer'],
277 268 );
278 269
279 - /**
280 - * Allow the referrer to be modified.
281 - *
282 - * @since 5.5.1
283 - *
284 - * @param array $referrer
285 - * @param array $entry_description
286 - * @param object $entry
287 - */
288 - $referrer = apply_filters( 'frm_user_info_referrer', $referrer, $entry_description, $this->entry );
289 -
290 270 $this->user_info = array(
291 271 'ip' => $ip,
292 272 'browser' => $browser,
293 273 'referrer' => $referrer,
@@ -315,9 +295,8 @@
315 295 * @return bool
316 296 */
317 297 protected function is_field_included( $field ) {
318 298 $is_included = true;
319 -
320 299 if ( ! empty( $this->include_fields ) ) {
321 300 $is_included = $this->is_field_in_array( $field, $this->include_fields );
322 301 }
323 302
@@ -322,9 +301,8 @@
322 301 }
323 302
324 303 if ( ! empty( $this->exclude_fields ) ) {
325 304 $is_excluded = $this->is_field_in_array( $field, $this->exclude_fields );
326 -
327 305 if ( $is_excluded ) {
328 306 $is_included = false;
329 307 }
330 308 }
@@ -337,9 +315,9 @@
337 315 *
338 316 * @since 2.04
339 317 *
340 318 * @param stdClass $field
341 - * @param array $array
319 + * @param array $array
342 320 *
343 321 * @return bool
344 322 */
345 323 protected function is_field_in_array( $field, $array ) {
@@ -351,10 +329,8 @@
351 329 *
352 330 * @since 2.04
353 331 *
354 332 * @param stdClass $field
355 - *
356 - * @return void
357 333 */
358 334 protected function add_field_values( $field ) {
359 335 $this->field_values[ $field->id ] = new FrmFieldValue( $field, $this->entry );
360 336 }