PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.02
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.02
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/FrmEntry.php +159 -424 6.275.0.02 View file →
@@ -5,67 +5,45 @@
5 5
6 6 class FrmEntry {
7 7
8 8 /**
9 - * @since 6.16.3
10 - *
11 - * @var array
12 - */
13 - private static $unique_id_match_checks = array();
14 -
15 - /**
16 9 * Create a new entry
17 10 *
18 11 * @param array $values
19 12 *
20 - * @return bool|int $entry_id
13 + * @return int | boolean $entry_id
21 14 */
22 15 public static function create( $values ) {
23 - return self::create_entry( $values, 'standard' );
16 + $entry_id = self::create_entry( $values, 'standard' );
17 +
18 + return $entry_id;
24 19 }
25 20
26 21 /**
27 22 * Create a new entry with some differences depending on type
28 23 *
29 - * @param array $values
24 + * @param array $values
30 25 * @param string $type
31 26 *
32 - * @return bool|int $entry_id
27 + * @return int | boolean $entry_id
33 28 */
34 29 private static function create_entry( $values, $type ) {
35 30 $new_values = self::before_insert_entry_in_database( $values, $type );
36 31
37 32 // Don't check XML entries for duplicates
38 - if ( $type !== 'xml' && self::is_duplicate( $new_values, $values ) ) {
33 + if ( $type != 'xml' && self::is_duplicate( $new_values, $values ) ) {
39 34 return false;
40 35 }
41 36
42 - return self::continue_to_create_entry( $values, $new_values );
43 - }
37 + $entry_id = self::continue_to_create_entry( $values, $new_values );
44 38
45 - /**
46 - * Flag the memoized unique id check after a new entry is created.
47 - * This prevents possibly DB requests and helps avoid issues when creating repeater entries.
48 - *
49 - * @since 6.16.3
50 - *
51 - * @param string $unique_id
52 - *
53 - * @return void
54 - */
55 - private static function flag_new_unique_key( $unique_id ) {
56 - if ( ! isset( self::$unique_id_match_checks[ $unique_id ] ) ) {
57 - self::$unique_id_match_checks[ $unique_id ] = false;
58 - }
39 + return $entry_id;
59 40 }
60 41
61 42 /**
62 43 * Check for duplicate entries created in the last minute
63 44 *
64 - * @param array $new_values New values.
65 - * @param array $values Values.
66 - *
67 - * @return bool
45 + * @return boolean
68 46 */
69 47 public static function is_duplicate( $new_values, $values ) {
70 48 $duplicate_entry_time = apply_filters( 'frm_time_to_check_duplicates', 60, $new_values );
71 49
@@ -72,18 +50,13 @@
72 50 if ( false === self::is_duplicate_check_needed( $values, $duplicate_entry_time ) ) {
73 51 return false;
74 52 }
75 53
76 - if ( self::maybe_check_for_unique_id_match( $values, $new_values['created_at'] ) ) {
77 - return true;
78 - }
79 -
80 54 $check_val = $new_values;
81 - $check_val['created_at >'] = gmdate( 'Y-m-d H:i:s', strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) );
55 + $check_val['created_at >'] = gmdate( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) );
82 56
83 57 unset( $check_val['created_at'], $check_val['updated_at'], $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
84 58
85 - // phpcs:ignore Universal.Operators.StrictComparisons
86 59 if ( $new_values['item_key'] == $new_values['name'] ) {
87 60 unset( $check_val['name'] );
88 61 }
89 62
@@ -95,12 +68,9 @@
95 68 if ( ! $entry_exists || ! isset( $values['item_meta'] ) ) {
96 69 return false;
97 70 }
98 71
99 - global $frm_vars;
100 - $frm_vars['checking_duplicates'] = true;
101 - $is_duplicate = false;
102 -
72 + $is_duplicate = false;
103 73 foreach ( $entry_exists as $entry_exist ) {
104 74 $is_duplicate = true;
105 75
106 76 // make sure it's a duplicate
@@ -105,14 +75,9 @@
105 75
106 76 // make sure it's a duplicate
107 77 $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist );
108 78 $field_metas = array();
109 -
110 79 foreach ( $metas as $meta ) {
111 - if ( 0 === (int) $meta->field_id ) {
112 - continue;
113 - }
114 -
115 80 $field_metas[ $meta->field_id ] = $meta->meta_value;
116 81 }
117 82
118 83 $filtered_vals = array_filter( $values['item_meta'] );
@@ -119,9 +84,9 @@
119 84 $filtered_vals = self::convert_values_to_their_saved_value( $filtered_vals, $entry_exist );
120 85 $field_metas = array_filter( $field_metas );
121 86
122 87 // If prev entry is empty and current entry is not, they are not duplicates
123 - if ( ! $field_metas && $filtered_vals ) {
88 + if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
124 89 return false;
125 90 }
126 91
127 92 // compare serialized values and not arrays
@@ -138,12 +103,12 @@
138 103 continue;
139 104 }
140 105
141 106 $diff = array_diff_assoc( $field_metas, $new_meta );
142 -
143 - foreach ( $diff as $meta_value ) {
107 + foreach ( $diff as $field_id => $meta_value ) {
144 108 if ( ! empty( $meta_value ) ) {
145 109 $is_duplicate = false;
110 + continue;
146 111 }
147 112 }
148 113
149 114 if ( $is_duplicate ) {
@@ -148,103 +113,31 @@
148 113
149 114 if ( $is_duplicate ) {
150 115 break;
151 116 }
152 - }//end foreach
117 + }
153 118
154 - $frm_vars['checking_duplicates'] = false;
155 -
156 119 return $is_duplicate;
157 120 }
158 121
159 122 /**
160 - * @since 6.16.3
161 - *
162 - * @param array $values POST request data.
163 - * @param string $created_at The timestamp of the entry we are checking for.
164 - *
165 - * @return bool
166 - */
167 - private static function maybe_check_for_unique_id_match( $values, $created_at ) {
168 - if ( ! self::should_check_for_unique_id_match() ) {
169 - return false;
170 - }
171 -
172 - if ( empty( $values['unique_id'] ) ) {
173 - return false;
174 - }
175 -
176 - $unique_id = sanitize_key( $values['unique_id'] );
177 -
178 - if ( ! $unique_id ) {
179 - // Only continue if a unique ID was generated on form submit.
180 - return false;
181 - }
182 -
183 - if ( isset( self::$unique_id_match_checks[ $unique_id ] ) ) {
184 - return self::$unique_id_match_checks[ $unique_id ];
185 - }
186 -
187 - $timestamp = strtotime( $created_at );
188 -
189 - if ( false === $timestamp ) {
190 - $timestamp = time();
191 - }
192 -
193 - self::$unique_id_match_checks[ $unique_id ] = (bool) FrmDb::get_var(
194 - 'frm_item_metas',
195 - array(
196 - 'field_id' => 0,
197 - 'meta_value' => serialize( compact( 'unique_id' ) ),
198 - 'created_at >' => gmdate( 'Y-m-d H:i:s', $timestamp - MONTH_IN_SECONDS ),
199 - ),
200 - 'id'
201 - );
202 -
203 - return self::$unique_id_match_checks[ $unique_id ];
204 - }
205 -
206 - /**
207 - * @since 6.16.3
208 - *
209 - * @return bool
210 - */
211 - private static function should_check_for_unique_id_match() {
212 - /**
213 - * Allow users to opt out of the DB query, in case it causes performance issues.
214 - *
215 - * @since 6.16.3
216 - *
217 - * @param bool $should_extend
218 - */
219 - $should_check = apply_filters( 'frm_check_for_unique_id_match', true );
220 - return (bool) $should_check;
221 - }
222 -
223 - /**
224 123 * Convert form data to the actual value that would be saved into the database.
124 + * This is important for the duplicate check as something like 'a:2:{s:5:"typed";s:0:"";s:6:"output";s:0:"";}' (a signature value) is actually an empty string and does not get saved.
225 125 *
226 - * This is important for the duplicate check as something like 'a:2:{s:5:"typed";s:0:"";s:6:"output";s:0:"";}'
227 - * (a signature value) is actually an empty string and does not get saved.
228 - *
229 126 * @param array $filter_vals
230 127 * @param int $entry_id
231 - *
232 128 * @return array
233 129 */
234 130 private static function convert_values_to_their_saved_value( $filter_vals, $entry_id ) {
235 131 $reduced = array();
236 -
237 132 foreach ( $filter_vals as $field_id => $value ) {
238 133 $field = FrmFieldFactory::get_field_object( $field_id );
239 134 $reduced[ $field_id ] = $field->get_value_to_save( $value, array( 'entry_id' => $entry_id ) );
240 135 $reduced[ $field_id ] = $field->set_value_before_save( $reduced[ $field_id ] );
241 -
242 136 if ( '' === $reduced[ $field_id ] || ( is_array( $reduced[ $field_id ] ) && 0 === count( $reduced[ $field_id ] ) ) ) {
243 137 unset( $reduced[ $field_id ] );
244 138 }
245 139 }
246 -
247 140 return $reduced;
248 141 }
249 142
250 143 /**
@@ -252,15 +145,15 @@
252 145 *
253 146 * @since 2.0.23
254 147 *
255 148 * @param array $values
256 - * @param int $duplicate_entry_time
149 + * @param int $duplicate_entry_time
257 150 *
258 151 * @return bool
259 152 */
260 153 private static function is_duplicate_check_needed( $values, $duplicate_entry_time ) {
261 154 // If time for checking duplicates is set to an empty value, don't check for duplicates
262 - if ( ! $duplicate_entry_time ) {
155 + if ( empty( $duplicate_entry_time ) ) {
263 156 return false;
264 157 }
265 158
266 159 // If CSV is importing, don't check for duplicates
@@ -268,20 +161,20 @@
268 161 return false;
269 162 }
270 163
271 164 // If repeating field entries are getting created, don't check for duplicates
272 - return empty( $values['parent_form_id'] );
165 + if ( isset( $values['parent_form_id'] ) && $values['parent_form_id'] ) {
166 + return false;
167 + }
168 +
169 + return true;
273 170 }
274 171
275 - /**
276 - * @param int|string $id
277 - *
278 - * @return false|int
279 - */
280 172 public static function duplicate( $id ) {
281 173 global $wpdb;
282 174
283 - $values = self::getOne( $id );
175 + $values = self::getOne( $id );
176 +
284 177 $new_values = array();
285 178 $new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
286 179 $new_values['name'] = $values->name;
287 180 $new_values['is_draft'] = $values->is_draft;
@@ -291,9 +184,8 @@
291 184 $new_values['created_at'] = current_time( 'mysql', 1 );
292 185 $new_values['updated_at'] = $new_values['created_at'];
293 186
294 187 $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
295 -
296 188 if ( ! $query_results ) {
297 189 return false;
298 190 }
299 191
@@ -299,9 +191,8 @@
299 191
300 192 $entry_id = $wpdb->insert_id;
301 193
302 194 global $frm_vars;
303 -
304 195 if ( ! isset( $frm_vars['saved_entries'] ) ) {
305 196 $frm_vars['saved_entries'] = array();
306 197 }
307 198 $frm_vars['saved_entries'][] = (int) $entry_id;
@@ -316,15 +207,17 @@
316 207
317 208 /**
318 209 * Update an entry (not via XML)
319 210 *
320 - * @param int $id
211 + * @param int $id
321 212 * @param array $values
322 213 *
323 - * @return bool|int $update_results
214 + * @return boolean|int $update_results
324 215 */
325 216 public static function update( $id, $values ) {
326 - return self::update_entry( $id, $values, 'standard' );
217 + $update_results = self::update_entry( $id, $values, 'standard' );
218 +
219 + return $update_results;
327 220 }
328 221
329 222 /**
330 223 * Update an entry with some differences depending on the update type
@@ -330,24 +223,23 @@
330 223 * Update an entry with some differences depending on the update type
331 224 *
332 225 * @since 2.0.16
333 226 *
334 - * @param int $id
335 - * @param array $values
336 - * @param string $update_type
227 + * @param int $id
228 + * @param array $values
337 229 *
338 - * @return bool|int $query_results
230 + * @return boolean|int $query_results
339 231 */
340 232 private static function update_entry( $id, $values, $update_type ) {
341 233 global $wpdb;
342 234
343 235 $update = self::before_update_entry( $id, $values, $update_type );
344 -
345 236 if ( ! $update ) {
346 237 return false;
347 238 }
348 239
349 - $new_values = self::package_entry_to_update( $id, $values );
240 + $new_values = self::package_entry_to_update( $id, $values );
241 +
350 242 $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) );
351 243
352 244 self::after_update_entry( $query_results, $id, $values, $new_values );
353 245
@@ -353,32 +245,19 @@
353 245
354 246 return $query_results;
355 247 }
356 248
357 - /**
358 - * Delete an entry.
359 - *
360 - * @param int|string $id
361 - *
362 - * @return bool True on success, false if nothing was deleted.
363 - */
364 249 public static function destroy( $id ) {
365 250 global $wpdb;
366 251 $id = (int) $id;
367 252
368 - // Item meta is required for conditional logic in actions with 'delete' events.
369 - $entry = self::getOne( $id, true );
253 + $entry = self::getOne( $id );
254 + if ( ! $entry ) {
255 + $result = false;
370 256
371 - if ( ! $entry ) {
372 - return false;
257 + return $result;
373 258 }
374 259
375 - /**
376 - * Trigger an action to run custom logic before the entry is deleted.
377 - *
378 - * @param int $id The id of the entry that was destroyed.
379 - * @param stdClass $entry The entry object.
380 - */
381 260 do_action( 'frm_before_destroy_entry', $id, $entry );
382 261
383 262 $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
384 263 $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
@@ -384,34 +263,15 @@
384 263 $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
385 264
386 265 self::clear_cache();
387 266
388 - /**
389 - * Trigger an action to run custom logic after the entry is deleted.
390 - * Use this hook if you need to update caching after an entry is deleted.
391 - *
392 - * @since 5.4.1
393 - *
394 - * @param int $id The id of the entry that was destroyed.
395 - * @param stdClass $entry The entry object.
396 - */
397 - do_action( 'frm_after_destroy_entry', $id, $entry );
398 -
399 267 return $result;
400 268 }
401 269
402 - /**
403 - * @param int $id
404 - * @param mixed $value
405 - * @param int|string $form_id
406 - *
407 - * @return false|int
408 - */
409 270 public static function update_form( $id, $value, $form_id ) {
410 271 global $wpdb;
411 272 $form_id = isset( $value ) ? $form_id : null;
412 273 $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
413 -
414 274 if ( $result ) {
415 275 self::clear_cache();
416 276 }
417 277
@@ -422,10 +282,8 @@
422 282 * Clear entry caching
423 283 * Called when an entry is changed
424 284 *
425 285 * @since 2.0.5
426 - *
427 - * @return void
428 286 */
429 287 public static function clear_cache() {
430 288 FrmDb::cache_delete_group( 'frm_entry' );
431 289 FrmDb::cache_delete_group( 'frm_item' );
@@ -437,17 +295,11 @@
437 295 * After switching to the wp_loaded hook for processing entries,
438 296 * we can no longer use 'name', but check it as a fallback
439 297 *
440 298 * @since 2.0.11
441 - *
442 - * @param array $values
443 - * @param array|string $default
444 - *
445 - * @return string
446 299 */
447 300 public static function get_new_entry_name( $values, $default = '' ) {
448 - $name = $values['item_name'] ?? $values['name'] ?? $default;
449 -
301 + $name = isset( $values['item_name'] ) ? $values['item_name'] : ( isset( $values['name'] ) ? $values['name'] : $default );
450 302 if ( is_array( $name ) ) {
451 303 $name = reset( $name );
452 304 }
453 305
@@ -456,28 +308,20 @@
456 308
457 309 /**
458 310 * If $entry is numeric, get the entry object
459 311 *
312 + * @param int|object $entry by reference
313 + *
460 314 * @since 2.0.9
461 - *
462 - * @param int|object $entry By reference.
463 - *
464 - * @return void
465 315 */
466 316 public static function maybe_get_entry( &$entry ) {
467 317 if ( $entry && is_numeric( $entry ) ) {
468 318 $entry = self::getOne( $entry );
469 - } elseif ( ! $entry || 'false' === $entry ) {
319 + } elseif ( empty( $entry ) || 'false' === $entry ) {
470 320 $entry = false;
471 321 }
472 322 }
473 323
474 - /**
475 - * @param int|string $id
476 - * @param bool $meta
477 - *
478 - * @return object|null
479 - */
480 324 public static function getOne( $id, $meta = false ) {
481 325 global $wpdb;
482 326
483 327 $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
@@ -482,11 +326,11 @@
482 326
483 327 $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
484 328 LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
485 329
486 - $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
330 + $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
487 331 $query_args = array( $id );
488 - $query = $wpdb->prepare( $query, $query_args ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
332 + $query = $wpdb->prepare( $query, $query_args ); // WPCS: unprepared SQL ok.
489 333
490 334 if ( ! $meta ) {
491 335 $entry = FrmDb::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
492 336 self::prepare_entry( $entry );
@@ -493,15 +337,14 @@
493 337 return $entry;
494 338 }
495 339
496 340 $entry = FrmDb::check_cache( $id, 'frm_entry' );
497 -
498 341 if ( $entry !== false ) {
499 342 self::prepare_entry( $entry );
500 343 return $entry;
501 344 }
502 345
503 - $entry = $wpdb->get_row( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
346 + $entry = $wpdb->get_row( $query ); // WPCS: unprepared SQL ok.
504 347 $entry = self::get_meta( $entry );
505 348 self::prepare_entry( $entry );
506 349
507 350 return $entry;
@@ -510,19 +353,16 @@
510 353 /**
511 354 * @since 4.02.03
512 355 *
513 356 * @param object $entry
514 - *
515 - * @return void
516 357 */
517 358 private static function prepare_entry( &$entry ) {
518 - if ( ! $entry ) {
359 + if ( empty( $entry ) ) {
519 360 return;
520 361 }
521 362
522 363 FrmAppHelper::unserialize_or_decode( $entry->description );
523 - // TODO: Remove slashes on input only, not output.
524 - $entry = wp_unslash( $entry );
364 + $entry = wp_unslash( $entry ); // TODO: Remove slashes on input only, not output.
525 365 }
526 366
527 367 /**
528 368 * @since 4.02.03
@@ -527,10 +367,8 @@
527 367 /**
528 368 * @since 4.02.03
529 369 *
530 370 * @param array $entries
531 - *
532 - * @return void
533 371 */
534 372 private static function prepare_entries( &$entries ) {
535 373 foreach ( $entries as $k => $entry ) {
536 374 self::prepare_entry( $entry );
@@ -537,13 +375,8 @@
537 375 $entries[ $k ] = $entry;
538 376 }
539 377 }
540 378
541 - /**
542 - * @param object|null $entry
543 - *
544 - * @return object|null
545 - */
546 379 public static function get_meta( $entry ) {
547 380 if ( ! $entry ) {
548 381 return $entry;
549 382 }
@@ -554,21 +387,18 @@
554 387 array(
555 388 'item_id' => $entry->id,
556 389 'field_id !' => 0,
557 390 ),
558 - 'field_id, meta_value, field_key, item_id, f.type'
391 + 'field_id, meta_value, field_key, item_id'
559 392 );
560 393
561 394 $entry->metas = array();
562 395
563 396 $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) );
564 -
565 397 foreach ( $metas as $meta_val ) {
566 - FrmFieldsHelper::prepare_field_value( $meta_val->meta_value, $meta_val->type );
567 -
568 - if ( (int) $meta_val->item_id === (int) $entry->id ) {
398 + if ( $meta_val->item_id == $entry->id ) {
399 + FrmAppHelper::unserialize_or_decode( $meta_val->meta_value );
569 400 $entry->metas[ $meta_val->field_id ] = $meta_val->meta_value;
570 -
571 401 if ( $include_key ) {
572 402 $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
573 403 }
574 404 continue;
@@ -578,12 +408,13 @@
578 408 if ( ! isset( $entry->metas[ $meta_val->field_id ] ) ) {
579 409 $entry->metas[ $meta_val->field_id ] = array();
580 410 }
581 411
412 + FrmAppHelper::unserialize_or_decode( $meta_val->meta_value );
582 413 $entry->metas[ $meta_val->field_id ][] = $meta_val->meta_value;
583 414
584 415 unset( $meta_val );
585 - }//end foreach
416 + }
586 417 unset( $metas );
587 418
588 419 FrmDb::set_cache( $entry->id, $entry, 'frm_entry' );
589 420
@@ -591,62 +422,60 @@
591 422 }
592 423
593 424 /**
594 425 * @param string $id
595 - *
596 - * @return bool
597 426 */
598 427 public static function exists( $id ) {
599 428 global $wpdb;
600 429
601 430 if ( FrmDb::check_cache( $id, 'frm_entry' ) ) {
602 - return true;
431 + $exists = true;
432 +
433 + return $exists;
603 434 }
604 435
605 - $where = is_numeric( $id ) ? array( 'id' => $id ) : array( 'item_key' => $id );
606 - $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
436 + if ( is_numeric( $id ) ) {
437 + $where = array( 'id' => $id );
438 + } else {
439 + $where = array( 'item_key' => $id );
440 + }
441 + $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
607 442
608 - return $id && $id > 0;
443 + return ( $id && $id > 0 );
609 444 }
610 445
611 - /**
612 - * @param array|string $where
613 - * @param string $order_by
614 - * @param string $limit
615 - * @param bool $meta
616 - * @param bool $inc_form
617 - *
618 - * @return array
619 - */
620 446 public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
621 447 global $wpdb;
622 448
623 - $limit = FrmDb::esc_limit( $limit );
449 + $limit = FrmDb::esc_limit( $limit );
450 +
624 451 $cache_key = FrmAppHelper::maybe_json_encode( $where ) . $order_by . $limit . $inc_form;
625 452 $entries = wp_cache_get( $cache_key, 'frm_entry' );
626 453
627 454 if ( false === $entries ) {
628 - $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft, it.description'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
455 + $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
629 456 $table = $wpdb->prefix . 'frm_items it ';
630 457
631 458 if ( $inc_form ) {
632 459 $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
633 - $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
460 + $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
634 461 }
635 462
636 463 if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
637 - $fields .= self::sort_by_field( $order_matches[1] );
638 - unset( $order_matches );
464 + // sort by a requested field
465 + $field_id = (int) $order_matches[1];
466 + $fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
467 + unset( $order_matches, $field_id );
639 468 }
640 469
641 470 // prepare the query
642 471 $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
643 472
644 - $entries = $wpdb->get_results( $query, OBJECT_K ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
473 + $entries = $wpdb->get_results( $query, OBJECT_K ); // WPCS: unprepared SQL ok.
645 474 unset( $query );
646 475
647 476 FrmDb::set_cache( $cache_key, $entries, 'frm_entry' );
648 - }//end if
477 + }
649 478
650 479 if ( ! $meta || ! $entries ) {
651 480 self::prepare_entries( $entries );
652 481 return $entries;
@@ -657,21 +486,15 @@
657 486 $where = array( 'it.form_id' => substr( $where, 11 ) );
658 487 }
659 488
660 489 $meta_where = array( 'field_id !' => 0 );
661 -
662 - // phpcs:ignore Universal.Operators.StrictComparisons
663 - if ( $limit == '' && is_array( $where ) && count( $where ) === 1 && isset( $where['it.form_id'] ) ) {
490 + if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
664 491 $meta_where['fi.form_id'] = $where['it.form_id'];
665 492 } else {
666 493 $meta_where['item_id'] = array_keys( $entries );
667 494 }
668 495
669 - $metas = FrmDb::get_results(
670 - $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id = fi.id',
671 - $meta_where,
672 - 'item_id, meta_value, field_id, field_key, form_id, fi.type'
673 - );
496 + $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
674 497
675 498 unset( $meta_where );
676 499
677 500 if ( ! $metas ) {
@@ -687,9 +510,9 @@
687 510 if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
688 511 $entries[ $meta_val->item_id ]->metas = array();
689 512 }
690 513
691 - FrmFieldsHelper::prepare_field_value( $meta_val->meta_value, $meta_val->type );
514 + FrmAppHelper::unserialize_or_decode( $meta_val->meta_value );
692 515 $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = $meta_val->meta_value;
693 516 unset( $m_key, $meta_val );
694 517 }
695 518
@@ -703,37 +526,15 @@
703 526 self::prepare_entries( $entries );
704 527 return $entries;
705 528 }
706 529
707 - /**
708 - * @param int|string $field_id
709 - *
710 - * @return string
711 - */
712 - private static function sort_by_field( $field_id ) {
713 - global $wpdb;
714 - $field_id = (int) $field_id;
715 - $field_options = FrmDb::get_var( 'frm_fields', array( 'id' => $field_id ), 'field_options' );
716 - FrmAppHelper::unserialize_or_decode( $field_options );
717 -
718 - if ( empty( $field_options['post_field'] ) ) {
719 - $sort = ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
720 - } else {
721 - $sort = '';
722 - }
723 -
724 - return apply_filters( 'frm_handle_field_column_sort', $sort, $field_id, $field_options );
725 - }
726 -
727 530 // Pagination Methods
728 531 /**
729 - * @param array|int|string $where If int, use the form id.
730 - *
731 - * @return int|string
532 + * @param int|array|string If int, use the form id.
732 533 */
733 534 public static function getRecordCount( $where = '' ) {
734 535 global $wpdb;
735 - $table_join = $wpdb->prefix . 'frm_items it JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
536 + $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
736 537
737 538 if ( is_numeric( $where ) ) {
738 539 $table_join = 'frm_items';
739 540 $where = array( 'form_id' => $where );
@@ -739,32 +540,25 @@
739 540 $where = array( 'form_id' => $where );
740 541 }
741 542
742 543 if ( is_array( $where ) ) {
743 - return FrmDb::get_count( $table_join, $where );
544 + $count = FrmDb::get_count( $table_join, $where );
545 + } else {
546 + $cache_key = 'count_' . FrmAppHelper::maybe_json_encode( $where );
547 + $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmDb::prepend_and_or_where( ' WHERE ', $where );
548 + $count = FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_var' );
744 549 }
745 550
746 - $cache_key = 'count_' . FrmAppHelper::maybe_json_encode( $where );
747 - $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmDb::prepend_and_or_where( ' WHERE ', $where );
748 -
749 - return FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_var' );
551 + return $count;
750 552 }
751 553
752 - /**
753 - * @param int|string $p_size
754 - * @param array|int|string $where
755 - *
756 - * @return int
757 - */
758 554 public static function getPageCount( $p_size, $where = '' ) {
759 555 $p_size = (int) $p_size;
760 556 $count = 1;
761 -
762 557 if ( $p_size ) {
763 558 if ( ! is_numeric( $where ) ) {
764 559 $where = self::getRecordCount( $where );
765 560 }
766 -
767 561 $count = ceil( (int) $where / $p_size );
768 562 }
769 563
770 564 return $count;
@@ -774,21 +568,24 @@
774 568 * Prepare the data before inserting it into the database
775 569 *
776 570 * @since 2.0.16
777 571 *
778 - * @param array $values
572 + * @param array $values
779 573 * @param string $type
780 574 *
781 575 * @return array $new_values
782 576 */
783 577 private static function before_insert_entry_in_database( &$values, $type ) {
578 +
784 579 self::sanitize_entry_post( $values );
785 580
786 - if ( $type !== 'xml' ) {
581 + if ( $type != 'xml' ) {
787 582 $values = apply_filters( 'frm_pre_create_entry', $values );
788 583 }
789 584
790 - return self::package_entry_data( $values );
585 + $new_values = self::package_entry_data( $values );
586 +
587 + return $new_values;
791 588 }
792 589
793 590 /**
794 591 * Create an entry and perform after create actions
@@ -797,13 +594,12 @@
797 594 *
798 595 * @param array $values
799 596 * @param array $new_values
800 597 *
801 - * @return bool|int $entry_id
598 + * @return boolean|int $entry_id
802 599 */
803 600 private static function continue_to_create_entry( $values, $new_values ) {
804 601 $entry_id = self::insert_entry_into_database( $new_values );
805 -
806 602 if ( ! $entry_id ) {
807 603 return false;
808 604 }
809 605
@@ -816,11 +612,9 @@
816 612 * Sanitize the POST values before we use them
817 613 *
818 614 * @since 2.0
819 615 *
820 - * @param array $values The POST values by reference.
821 - *
822 - * @return void
616 + * @param array $values The POST values by reference
823 617 */
824 618 public static function sanitize_entry_post( &$values ) {
825 619 $sanitize_method = array(
826 620 'form_id' => 'absint',
@@ -869,22 +663,15 @@
869 663 'description' => self::get_entry_description( $values ),
870 664 'user_id' => self::get_entry_user_id( $values ),
871 665 );
872 666
873 - $new_values['updated_by'] = $values['updated_by'] ?? $new_values['user_id'];
667 + $new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id'];
874 668
875 669 return $new_values;
876 670 }
877 671
878 - /**
879 - * @param array $values
880 - * @param string $name
881 - * @param mixed $default
882 - *
883 - * @return mixed
884 - */
885 672 private static function get_entry_value( $values, $name, $default ) {
886 - return $values[ $name ] ?? $default;
673 + return isset( $values[ $name ] ) ? $values[ $name ] : $default;
887 674 }
888 675
889 676 /**
890 677 * Get the ip for a new entry.
@@ -901,9 +688,8 @@
901 688 return '';
902 689 }
903 690
904 691 $ip = FrmAppHelper::get_ip_address();
905 -
906 692 if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
907 693 $ip = self::get_entry_value( $values, 'ip', $ip );
908 694 }
909 695
@@ -919,13 +705,9 @@
919 705 *
920 706 * @return int
921 707 */
922 708 private static function get_is_draft_value( $values ) {
923 - if ( isset( $values['frm_saving_draft'] ) && FrmEntriesHelper::DRAFT_ENTRY_STATUS === (int) $values['frm_saving_draft'] ) {
924 - return FrmEntriesHelper::DRAFT_ENTRY_STATUS;
925 - }
926 -
927 - return isset( $values['is_draft'] ) ? absint( $values['is_draft'] ) : FrmEntriesHelper::SUBMITTED_ENTRY_STATUS;
709 + return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
928 710 }
929 711
930 712 /**
931 713 * Get the created_at value for a new entry
@@ -949,9 +731,15 @@
949 731 *
950 732 * @return string
951 733 */
952 734 private static function get_updated_at( $values ) {
953 - return $values['updated_at'] ?? self::get_created_at( $values );
735 + if ( isset( $values['updated_at'] ) ) {
736 + $updated_at = $values['updated_at'];
737 + } else {
738 + $updated_at = self::get_created_at( $values );
739 + }
740 +
741 + return $updated_at;
954 742 }
955 743
956 744 /**
957 745 * Get the description value for a new entry
@@ -962,18 +750,20 @@
962 750 *
963 751 * @return string
964 752 */
965 753 private static function get_entry_description( $values ) {
966 - if ( ! empty( $values['description'] ) ) {
967 - return FrmAppHelper::maybe_json_encode( $values['description'] );
754 + if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) {
755 + $description = FrmAppHelper::maybe_json_encode( $values['description'] );
756 + } else {
757 + $description = json_encode(
758 + array(
759 + 'browser' => FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ),
760 + 'referrer' => FrmAppHelper::get_server_value( 'HTTP_REFERER' ),
761 + )
762 + );
968 763 }
969 764
970 - return json_encode(
971 - array(
972 - 'browser' => FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ),
973 - 'referrer' => FrmAppHelper::get_server_value( 'HTTP_REFERER' ),
974 - )
975 - );
765 + return $description;
976 766 }
977 767
978 768 /**
979 769 * Get the user_id value for a new entry
@@ -985,13 +775,15 @@
985 775 * @return int
986 776 */
987 777 private static function get_entry_user_id( $values ) {
988 778 if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) {
989 - return $values['frm_user_id'];
779 + $user_id = $values['frm_user_id'];
780 + } else {
781 + $current_user_id = get_current_user_id();
782 + $user_id = $current_user_id ? $current_user_id : 0;
990 783 }
991 784
992 - $current_user_id = get_current_user_id();
993 - return $current_user_id ? $current_user_id : 0;
785 + return $user_id;
994 786 }
995 787
996 788 /**
997 789 * Insert new entry into the database
@@ -999,9 +791,9 @@
999 791 * @since 2.0.16
1000 792 *
1001 793 * @param array $new_values
1002 794 *
1003 - * @return bool|int $entry_id
795 + * @return int | boolean $entry_id
1004 796 */
1005 797 private static function insert_entry_into_database( $new_values ) {
1006 798 global $wpdb;
1007 799
@@ -1006,9 +798,15 @@
1006 798 global $wpdb;
1007 799
1008 800 $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
1009 801
1010 - return ! $query_results ? false : $wpdb->insert_id;
802 + if ( ! $query_results ) {
803 + $entry_id = false;
804 + } else {
805 + $entry_id = $wpdb->insert_id;
806 + }
807 +
808 + return $entry_id;
1011 809 }
1012 810
1013 811 /**
1014 812 * Add the new entry to global $frm_vars
@@ -1014,11 +812,9 @@
1014 812 * Add the new entry to global $frm_vars
1015 813 *
1016 814 * @since 2.0.16
1017 815 *
1018 - * @param int|string $entry_id
1019 - *
1020 - * @return void
816 + * @param int $entry_id
1021 817 */
1022 818 private static function add_new_entry_to_frm_vars( $entry_id ) {
1023 819 global $frm_vars;
1024 820
@@ -1033,75 +829,28 @@
1033 829 * Add entry metas, if there are any
1034 830 *
1035 831 * @since 2.0.16
1036 832 *
1037 - * @param array $values
1038 - * @param int|string $entry_id
1039 - *
1040 - * @return void
833 + * @param array $values
834 + * @param int $entry_id
1041 835 */
1042 836 private static function maybe_add_entry_metas( $values, $entry_id ) {
1043 837 if ( isset( $values['item_meta'] ) ) {
1044 838 FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
1045 - self::maybe_add_unique_id_meta( $values, $entry_id );
1046 839 }
1047 - self::maybe_add_captcha_meta( (int) $values['form_id'], (int) $entry_id );
1048 840 }
1049 841
1050 842 /**
1051 - * @since 6.16.3
1052 - *
1053 - * @param array $values
1054 - * @param int $entry_id
1055 - *
1056 - * @return void
1057 - */
1058 - private static function maybe_add_unique_id_meta( $values, $entry_id ) {
1059 - if ( ! empty( $values['parent_form_id'] ) || empty( $values['unique_id'] ) || ! self::should_check_for_unique_id_match() ) {
1060 - return;
1061 - }
1062 -
1063 - // This unique ID is inserted with JS on form submit.
1064 - // It is used to check for duplicate entries.
1065 - $unique_id = sanitize_key( $values['unique_id'] );
1066 -
1067 - if ( $unique_id ) {
1068 - FrmEntryMeta::add_entry_meta( $entry_id, 0, '', compact( 'unique_id' ) );
1069 - self::flag_new_unique_key( $unique_id );
1070 - }
1071 - }
1072 -
1073 - /**
1074 - * @since 5.0.15
1075 - *
1076 - * @param int $form_id
1077 - * @param int $entry_id
1078 - *
1079 - * @return void
1080 - */
1081 - private static function maybe_add_captcha_meta( $form_id, $entry_id ) {
1082 - global $frm_vars;
1083 -
1084 - if ( array_key_exists( 'captcha_scores', $frm_vars ) && array_key_exists( $form_id, $frm_vars['captcha_scores'] ) ) {
1085 - $captcha_score_meta = array( 'captcha_score' => $frm_vars['captcha_scores'][ $form_id ] );
1086 - FrmEntryMeta::add_entry_meta( $entry_id, 0, '', maybe_serialize( $captcha_score_meta ) );
1087 - }
1088 - }
1089 -
1090 - /**
1091 843 * Trigger frm_after_create_entry hooks
1092 844 *
1093 845 * @since 2.0.16
1094 846 *
1095 - * @param int $entry_id
1096 - * @param array $values
847 + * @param int $entry_id
1097 848 * @param array $new_values
1098 - *
1099 - * @return void
1100 849 */
1101 850 private static function after_entry_created_actions( $entry_id, $values, $new_values ) {
1102 - // This is a child entry.
1103 - $is_child = isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
851 + // this is a child entry
852 + $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
1104 853
1105 854 do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) );
1106 855 do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) );
1107 856 }
@@ -1112,13 +861,12 @@
1112 861 * @since 2.0.16
1113 862 *
1114 863 * @param array $values
1115 864 * @param array $new_values
1116 - * @param int $entry_id
1117 - *
1118 - * @return void
865 + * @param int $entry_id
1119 866 */
1120 867 private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) {
868 +
1121 869 self::add_new_entry_to_frm_vars( $entry_id );
1122 870
1123 871 self::maybe_add_entry_metas( $values, $entry_id );
1124 872
@@ -1131,13 +879,13 @@
1131 879 * Perform some actions right before updating an entry
1132 880 *
1133 881 * @since 2.0.16
1134 882 *
1135 - * @param int|string $id
1136 - * @param array $values
1137 - * @param string $update_type
883 + * @param int $id
884 + * @param array $values
885 + * @param string $update_type
1138 886 *
1139 - * @return bool $update
887 + * @return boolean $update
1140 888 */
1141 889 private static function before_update_entry( $id, &$values, $update_type ) {
1142 890 $update = true;
1143 891
@@ -1142,14 +890,13 @@
1142 890 $update = true;
1143 891
1144 892 global $frm_vars;
1145 893
1146 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
1147 - if ( isset( $frm_vars['saved_entries'] ) && is_array( $frm_vars['saved_entries'] ) && in_array( (int) $id, $frm_vars['saved_entries'] ) ) {
894 + if ( isset( $frm_vars['saved_entries'] ) && is_array( $frm_vars['saved_entries'] ) && in_array( (int) $id, (array) $frm_vars['saved_entries'] ) ) {
1148 895 $update = false;
1149 896 }
1150 897
1151 - if ( $update && $update_type !== 'xml' ) {
898 + if ( $update && $update_type != 'xml' ) {
1152 899 $values = apply_filters( 'frm_pre_update_entry', $values, $id );
1153 900 }
1154 901
1155 902 return $update;
@@ -1159,9 +906,9 @@
1159 906 * Package the entry data for updating
1160 907 *
1161 908 * @since 2.0.16
1162 909 *
1163 - * @param int $id
910 + * @param int $id
1164 911 * @param array $values
1165 912 *
1166 913 * @return array $new_values
1167 914 */
@@ -1172,9 +919,9 @@
1172 919 'name' => self::get_new_entry_name( $values ),
1173 920 'form_id' => (int) self::get_entry_value( $values, 'form_id', null ),
1174 921 'is_draft' => self::get_is_draft_value( $values ),
1175 922 'updated_at' => current_time( 'mysql', 1 ),
1176 - 'updated_by' => $values['updated_by'] ?? get_current_user_id(),
923 + 'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(),
1177 924 );
1178 925
1179 926 if ( isset( $values['post_id'] ) ) {
1180 927 $new_values['post_id'] = (int) $values['post_id'];
@@ -1191,9 +938,11 @@
1191 938 if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) {
1192 939 $new_values['user_id'] = $values['frm_user_id'];
1193 940 }
1194 941
1195 - return apply_filters( 'frm_update_entry', $new_values, $id );
942 + $new_values = apply_filters( 'frm_update_entry', $new_values, $id );
943 +
944 + return $new_values;
1196 945 }
1197 946
1198 947 /**
1199 948 * Perform some actions right after updating an entry
@@ -1199,14 +948,12 @@
1199 948 * Perform some actions right after updating an entry
1200 949 *
1201 950 * @since 2.0.16
1202 951 *
1203 - * @param bool|int $query_results
1204 - * @param int|string $id
1205 - * @param array $values
1206 - * @param array $new_values
1207 - *
1208 - * @return void
952 + * @param boolean|int $query_results
953 + * @param int $id
954 + * @param array $values
955 + * @param array $new_values
1209 956 */
1210 957 private static function after_update_entry( $query_results, $id, $values, $new_values ) {
1211 958 if ( $query_results ) {
1212 959 self::clear_cache();
@@ -1212,9 +959,8 @@
1212 959 self::clear_cache();
1213 960 }
1214 961
1215 962 global $frm_vars;
1216 -
1217 963 if ( ! isset( $frm_vars['saved_entries'] ) ) {
1218 964 $frm_vars['saved_entries'] = array();
1219 965 }
1220 966
@@ -1235,12 +981,14 @@
1235 981 * @since 2.0.16
1236 982 *
1237 983 * @param array $values
1238 984 *
1239 - * @return bool|int $entry_id
985 + * @return int | boolean $entry_id
1240 986 */
1241 987 public static function create_entry_from_xml( $values ) {
1242 - return self::create_entry( $values, 'xml' );
988 + $entry_id = self::create_entry( $values, 'xml' );
989 +
990 + return $entry_id;
1243 991 }
1244 992
1245 993 /**
1246 994 * Update entry from an XML import
@@ -1247,15 +995,17 @@
1247 995 * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
1248 996 *
1249 997 * @since 2.0.16
1250 998 *
1251 - * @param int $id
999 + * @param int $id
1252 1000 * @param array $values
1253 1001 *
1254 - * @return bool|int $updated
1002 + * @return int | boolean $updated
1255 1003 */
1256 1004 public static function update_entry_from_xml( $id, $values ) {
1257 - return self::update_entry( $id, $values, 'xml' );
1005 + $updated = self::update_entry( $id, $values, 'xml' );
1006 +
1007 + return $updated;
1258 1008 }
1259 1009
1260 1010 /**
1261 1011 * @param string $key
@@ -1263,23 +1013,8 @@
1263 1013 * @return int entry_id
1264 1014 */
1265 1015 public static function get_id_by_key( $key ) {
1266 1016 $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
1017 +
1267 1018 return (int) $entry_id;
1268 - }
1269 -
1270 - /**
1271 - * Get entries count.
1272 - *
1273 - * @since 6.8
1274 - *
1275 - * @return int|string
1276 - */
1277 - public static function get_entries_count() {
1278 - $args = array(
1279 - 'or' => 1,
1280 - 'parent_form_id' => null,
1281 - 'parent_form_id <' => 1,
1282 - );
1283 - return self::getRecordCount( $args );
1284 1019 }
1285 1020 }