| @@ -52,9 +52,8 @@ | ||
| 52 | 52 | * |
| 53 | 53 | * @since 6.16.3 |
| 54 | 54 | * |
| 55 | 55 | * @param string $unique_id |
| 56 | - * | |
| 57 | 56 | * @return void |
| 58 | 57 | */ |
| 59 | 58 | private static function flag_new_unique_key( $unique_id ) { |
| 60 | 59 | if ( ! isset( self::$unique_id_match_checks[ $unique_id ] ) ) { |
| @@ -64,11 +63,8 @@ | ||
| 64 | 63 | |
| 65 | 64 | /** |
| 66 | 65 | * Check for duplicate entries created in the last minute |
| 67 | 66 | * |
| 68 | - * @param array $new_values New values. | |
| 69 | - * @param array $values Values. | |
| 70 | - * | |
| 71 | 67 | * @return bool |
| 72 | 68 | */ |
| 73 | 69 | public static function is_duplicate( $new_values, $values ) { |
| 74 | 70 | $duplicate_entry_time = apply_filters( 'frm_time_to_check_duplicates', 60, $new_values ); |
| @@ -102,9 +98,8 @@ | ||
| 102 | 98 | global $frm_vars; |
| 103 | 99 | $frm_vars['checking_duplicates'] = true; |
| 104 | 100 | |
| 105 | 101 | $is_duplicate = false; |
| 106 | - | |
| 107 | 102 | foreach ( $entry_exists as $entry_exist ) { |
| 108 | 103 | $is_duplicate = true; |
| 109 | 104 | |
| 110 | 105 | // make sure it's a duplicate |
| @@ -109,9 +104,8 @@ | ||
| 109 | 104 | |
| 110 | 105 | // make sure it's a duplicate |
| 111 | 106 | $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist ); |
| 112 | 107 | $field_metas = array(); |
| 113 | - | |
| 114 | 108 | foreach ( $metas as $meta ) { |
| 115 | 109 | if ( 0 === (int) $meta->field_id ) { |
| 116 | 110 | continue; |
| 117 | 111 | } |
| @@ -141,9 +135,8 @@ | ||
| 141 | 135 | continue; |
| 142 | 136 | } |
| 143 | 137 | |
| 144 | 138 | $diff = array_diff_assoc( $field_metas, $new_meta ); |
| 145 | - | |
| 146 | 139 | foreach ( $diff as $meta_value ) { |
| 147 | 140 | if ( ! empty( $meta_value ) ) { |
| 148 | 141 | $is_duplicate = false; |
| 149 | 142 | } |
| @@ -163,9 +156,8 @@ | ||
| 163 | 156 | * @since 6.16.3 |
| 164 | 157 | * |
| 165 | 158 | * @param array $values POST request data. |
| 166 | 159 | * @param string $created_at The timestamp of the entry we are checking for. |
| 167 | - * | |
| 168 | 160 | * @return bool |
| 169 | 161 | */ |
| 170 | 162 | private static function maybe_check_for_unique_id_match( $values, $created_at ) { |
| 171 | 163 | if ( ! self::should_check_for_unique_id_match() ) { |
| @@ -176,9 +168,8 @@ | ||
| 176 | 168 | return false; |
| 177 | 169 | } |
| 178 | 170 | |
| 179 | 171 | $unique_id = sanitize_key( $values['unique_id'] ); |
| 180 | - | |
| 181 | 172 | if ( ! $unique_id ) { |
| 182 | 173 | // Only continue if a unique ID was generated on form submit. |
| 183 | 174 | return false; |
| 184 | 175 | } |
| @@ -187,9 +178,8 @@ | ||
| 187 | 178 | return self::$unique_id_match_checks[ $unique_id ]; |
| 188 | 179 | } |
| 189 | 180 | |
| 190 | 181 | $timestamp = strtotime( $created_at ); |
| 191 | - | |
| 192 | 182 | if ( false === $timestamp ) { |
| 193 | 183 | $timestamp = time(); |
| 194 | 184 | } |
| 195 | 185 | |
| @@ -207,10 +197,8 @@ | ||
| 207 | 197 | } |
| 208 | 198 | |
| 209 | 199 | /** |
| 210 | 200 | * @since 6.16.3 |
| 211 | - * | |
| 212 | - * @return bool | |
| 213 | 201 | */ |
| 214 | 202 | private static function should_check_for_unique_id_match() { |
| 215 | 203 | /** |
| 216 | 204 | * Allow users to opt out of the DB query, in case it causes performance issues. |
| @@ -228,19 +216,16 @@ | ||
| 228 | 216 | * 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. |
| 229 | 217 | * |
| 230 | 218 | * @param array $filter_vals |
| 231 | 219 | * @param int $entry_id |
| 232 | - * | |
| 233 | 220 | * @return array |
| 234 | 221 | */ |
| 235 | 222 | private static function convert_values_to_their_saved_value( $filter_vals, $entry_id ) { |
| 236 | 223 | $reduced = array(); |
| 237 | - | |
| 238 | 224 | foreach ( $filter_vals as $field_id => $value ) { |
| 239 | 225 | $field = FrmFieldFactory::get_field_object( $field_id ); |
| 240 | 226 | $reduced[ $field_id ] = $field->get_value_to_save( $value, array( 'entry_id' => $entry_id ) ); |
| 241 | 227 | $reduced[ $field_id ] = $field->set_value_before_save( $reduced[ $field_id ] ); |
| 242 | - | |
| 243 | 228 | if ( '' === $reduced[ $field_id ] || ( is_array( $reduced[ $field_id ] ) && 0 === count( $reduced[ $field_id ] ) ) ) { |
| 244 | 229 | unset( $reduced[ $field_id ] ); |
| 245 | 230 | } |
| 246 | 231 | } |
| @@ -275,13 +260,8 @@ | ||
| 275 | 260 | |
| 276 | 261 | return true; |
| 277 | 262 | } |
| 278 | 263 | |
| 279 | - /** | |
| 280 | - * @param int|string $id | |
| 281 | - * | |
| 282 | - * @return false|int | |
| 283 | - */ | |
| 284 | 264 | public static function duplicate( $id ) { |
| 285 | 265 | global $wpdb; |
| 286 | 266 | |
| 287 | 267 | $values = self::getOne( $id ); |
| @@ -296,9 +276,8 @@ | ||
| 296 | 276 | $new_values['created_at'] = current_time( 'mysql', 1 ); |
| 297 | 277 | $new_values['updated_at'] = $new_values['created_at']; |
| 298 | 278 | |
| 299 | 279 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
| 300 | - | |
| 301 | 280 | if ( ! $query_results ) { |
| 302 | 281 | return false; |
| 303 | 282 | } |
| 304 | 283 | |
| @@ -304,9 +283,8 @@ | ||
| 304 | 283 | |
| 305 | 284 | $entry_id = $wpdb->insert_id; |
| 306 | 285 | |
| 307 | 286 | global $frm_vars; |
| 308 | - | |
| 309 | 287 | if ( ! isset( $frm_vars['saved_entries'] ) ) { |
| 310 | 288 | $frm_vars['saved_entries'] = array(); |
| 311 | 289 | } |
| 312 | 290 | $frm_vars['saved_entries'][] = (int) $entry_id; |
| @@ -337,11 +315,10 @@ | ||
| 337 | 315 | * Update an entry with some differences depending on the update type |
| 338 | 316 | * |
| 339 | 317 | * @since 2.0.16 |
| 340 | 318 | * |
| 341 | - * @param int $id | |
| 342 | - * @param array $values | |
| 343 | - * @param string $update_type | |
| 319 | + * @param int $id | |
| 320 | + * @param array $values | |
| 344 | 321 | * |
| 345 | 322 | * @return bool|int $query_results |
| 346 | 323 | */ |
| 347 | 324 | private static function update_entry( $id, $values, $update_type ) { |
| @@ -347,9 +324,8 @@ | ||
| 347 | 324 | private static function update_entry( $id, $values, $update_type ) { |
| 348 | 325 | global $wpdb; |
| 349 | 326 | |
| 350 | 327 | $update = self::before_update_entry( $id, $values, $update_type ); |
| 351 | - | |
| 352 | 328 | if ( ! $update ) { |
| 353 | 329 | return false; |
| 354 | 330 | } |
| 355 | 331 | |
| @@ -365,9 +341,8 @@ | ||
| 365 | 341 | /** |
| 366 | 342 | * Delete an entry. |
| 367 | 343 | * |
| 368 | 344 | * @param int|string $id |
| 369 | - * | |
| 370 | 345 | * @return bool True on success, false if nothing was deleted. |
| 371 | 346 | */ |
| 372 | 347 | public static function destroy( $id ) { |
| 373 | 348 | global $wpdb; |
| @@ -374,9 +349,8 @@ | ||
| 374 | 349 | $id = (int) $id; |
| 375 | 350 | |
| 376 | 351 | // Item meta is required for conditional logic in actions with 'delete' events. |
| 377 | 352 | $entry = self::getOne( $id, true ); |
| 378 | - | |
| 379 | 353 | if ( ! $entry ) { |
| 380 | 354 | $result = false; |
| 381 | 355 | return $result; |
| 382 | 356 | } |
| @@ -407,20 +381,12 @@ | ||
| 407 | 381 | |
| 408 | 382 | return $result; |
| 409 | 383 | } |
| 410 | 384 | |
| 411 | - /** | |
| 412 | - * @param int $id | |
| 413 | - * @param mixed $value | |
| 414 | - * @param int|string $form_id | |
| 415 | - * | |
| 416 | - * @return false|int | |
| 417 | - */ | |
| 418 | 385 | public static function update_form( $id, $value, $form_id ) { |
| 419 | 386 | global $wpdb; |
| 420 | 387 | $form_id = isset( $value ) ? $form_id : null; |
| 421 | 388 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
| 422 | - | |
| 423 | 389 | if ( $result ) { |
| 424 | 390 | self::clear_cache(); |
| 425 | 391 | } |
| 426 | 392 | |
| @@ -431,10 +397,8 @@ | ||
| 431 | 397 | * Clear entry caching |
| 432 | 398 | * Called when an entry is changed |
| 433 | 399 | * |
| 434 | 400 | * @since 2.0.5 |
| 435 | - * | |
| 436 | - * @return void | |
| 437 | 401 | */ |
| 438 | 402 | public static function clear_cache() { |
| 439 | 403 | FrmDb::cache_delete_group( 'frm_entry' ); |
| 440 | 404 | FrmDb::cache_delete_group( 'frm_item' ); |
| @@ -446,17 +410,11 @@ | ||
| 446 | 410 | * After switching to the wp_loaded hook for processing entries, |
| 447 | 411 | * we can no longer use 'name', but check it as a fallback |
| 448 | 412 | * |
| 449 | 413 | * @since 2.0.11 |
| 450 | - * | |
| 451 | - * @param array $values | |
| 452 | - * @param array|string $default | |
| 453 | - * | |
| 454 | - * @return string | |
| 455 | 414 | */ |
| 456 | 415 | public static function get_new_entry_name( $values, $default = '' ) { |
| 457 | - $name = $values['item_name'] ?? $values['name'] ?? $default; | |
| 458 | - | |
| 416 | + $name = isset( $values['item_name'] ) ? $values['item_name'] : ( isset( $values['name'] ) ? $values['name'] : $default ); | |
| 459 | 417 | if ( is_array( $name ) ) { |
| 460 | 418 | $name = reset( $name ); |
| 461 | 419 | } |
| 462 | 420 | |
| @@ -468,9 +426,8 @@ | ||
| 468 | 426 | * |
| 469 | 427 | * @since 2.0.9 |
| 470 | 428 | * |
| 471 | 429 | * @param int|object $entry By reference. |
| 472 | - * | |
| 473 | 430 | * @return void |
| 474 | 431 | */ |
| 475 | 432 | public static function maybe_get_entry( &$entry ) { |
| 476 | 433 | if ( $entry && is_numeric( $entry ) ) { |
| @@ -479,14 +436,8 @@ | ||
| 479 | 436 | $entry = false; |
| 480 | 437 | } |
| 481 | 438 | } |
| 482 | 439 | |
| 483 | - /** | |
| 484 | - * @param int|string $id | |
| 485 | - * @param bool $meta | |
| 486 | - * | |
| 487 | - * @return object|null | |
| 488 | - */ | |
| 489 | 440 | public static function getOne( $id, $meta = false ) { |
| 490 | 441 | global $wpdb; |
| 491 | 442 | |
| 492 | 443 | $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
| @@ -502,9 +453,8 @@ | ||
| 502 | 453 | return $entry; |
| 503 | 454 | } |
| 504 | 455 | |
| 505 | 456 | $entry = FrmDb::check_cache( $id, 'frm_entry' ); |
| 506 | - | |
| 507 | 457 | if ( $entry !== false ) { |
| 508 | 458 | self::prepare_entry( $entry ); |
| 509 | 459 | return $entry; |
| 510 | 460 | } |
| @@ -519,10 +469,8 @@ | ||
| 519 | 469 | /** |
| 520 | 470 | * @since 4.02.03 |
| 521 | 471 | * |
| 522 | 472 | * @param object $entry |
| 523 | - * | |
| 524 | - * @return void | |
| 525 | 473 | */ |
| 526 | 474 | private static function prepare_entry( &$entry ) { |
| 527 | 475 | if ( empty( $entry ) ) { |
| 528 | 476 | return; |
| @@ -536,10 +484,8 @@ | ||
| 536 | 484 | /** |
| 537 | 485 | * @since 4.02.03 |
| 538 | 486 | * |
| 539 | 487 | * @param array $entries |
| 540 | - * | |
| 541 | - * @return void | |
| 542 | 488 | */ |
| 543 | 489 | private static function prepare_entries( &$entries ) { |
| 544 | 490 | foreach ( $entries as $k => $entry ) { |
| 545 | 491 | self::prepare_entry( $entry ); |
| @@ -546,13 +492,8 @@ | ||
| 546 | 492 | $entries[ $k ] = $entry; |
| 547 | 493 | } |
| 548 | 494 | } |
| 549 | 495 | |
| 550 | - /** | |
| 551 | - * @param object|null $entry | |
| 552 | - * | |
| 553 | - * @return object|null | |
| 554 | - */ | |
| 555 | 496 | public static function get_meta( $entry ) { |
| 556 | 497 | if ( ! $entry ) { |
| 557 | 498 | return $entry; |
| 558 | 499 | } |
| @@ -569,15 +510,13 @@ | ||
| 569 | 510 | |
| 570 | 511 | $entry->metas = array(); |
| 571 | 512 | |
| 572 | 513 | $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) ); |
| 573 | - | |
| 574 | 514 | foreach ( $metas as $meta_val ) { |
| 575 | 515 | FrmFieldsHelper::prepare_field_value( $meta_val->meta_value, $meta_val->type ); |
| 576 | 516 | |
| 577 | 517 | if ( $meta_val->item_id == $entry->id ) { |
| 578 | 518 | $entry->metas[ $meta_val->field_id ] = $meta_val->meta_value; |
| 579 | - | |
| 580 | 519 | if ( $include_key ) { |
| 581 | 520 | $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
| 582 | 521 | } |
| 583 | 522 | continue; |
| @@ -590,9 +529,9 @@ | ||
| 590 | 529 | |
| 591 | 530 | $entry->metas[ $meta_val->field_id ][] = $meta_val->meta_value; |
| 592 | 531 | |
| 593 | 532 | unset( $meta_val ); |
| 594 | - }//end foreach | |
| 533 | + } | |
| 595 | 534 | unset( $metas ); |
| 596 | 535 | |
| 597 | 536 | FrmDb::set_cache( $entry->id, $entry, 'frm_entry' ); |
| 598 | 537 | |
| @@ -600,10 +539,8 @@ | ||
| 600 | 539 | } |
| 601 | 540 | |
| 602 | 541 | /** |
| 603 | 542 | * @param string $id |
| 604 | - * | |
| 605 | - * @return bool | |
| 606 | 543 | */ |
| 607 | 544 | public static function exists( $id ) { |
| 608 | 545 | global $wpdb; |
| 609 | 546 | |
| @@ -617,23 +554,13 @@ | ||
| 617 | 554 | $where = array( 'id' => $id ); |
| 618 | 555 | } else { |
| 619 | 556 | $where = array( 'item_key' => $id ); |
| 620 | 557 | } |
| 621 | - | |
| 622 | 558 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
| 623 | 559 | |
| 624 | 560 | return $id && $id > 0; |
| 625 | 561 | } |
| 626 | 562 | |
| 627 | - /** | |
| 628 | - * @param array|string $where | |
| 629 | - * @param string $order_by | |
| 630 | - * @param string $limit | |
| 631 | - * @param bool $meta | |
| 632 | - * @param bool $inc_form | |
| 633 | - * | |
| 634 | - * @return array | |
| 635 | - */ | |
| 636 | 563 | public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
| 637 | 564 | global $wpdb; |
| 638 | 565 | |
| 639 | 566 | $limit = FrmDb::esc_limit( $limit ); |
| @@ -674,9 +601,8 @@ | ||
| 674 | 601 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
| 675 | 602 | } |
| 676 | 603 | |
| 677 | 604 | $meta_where = array( 'field_id !' => 0 ); |
| 678 | - | |
| 679 | 605 | if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { |
| 680 | 606 | $meta_where['fi.form_id'] = $where['it.form_id']; |
| 681 | 607 | } else { |
| 682 | 608 | $meta_where['item_id'] = array_keys( $entries ); |
| @@ -720,10 +646,9 @@ | ||
| 720 | 646 | return $entries; |
| 721 | 647 | } |
| 722 | 648 | |
| 723 | 649 | /** |
| 724 | - * @param int|string $field_id | |
| 725 | - * | |
| 650 | + * @param int $field_id | |
| 726 | 651 | * @return string |
| 727 | 652 | */ |
| 728 | 653 | private static function sort_by_field( $field_id ) { |
| 729 | 654 | global $wpdb; |
| @@ -743,9 +668,8 @@ | ||
| 743 | 668 | |
| 744 | 669 | // Pagination Methods |
| 745 | 670 | /** |
| 746 | 671 | * @param array|int|string $where If int, use the form id. |
| 747 | - * | |
| 748 | 672 | * @return int|string |
| 749 | 673 | */ |
| 750 | 674 | public static function getRecordCount( $where = '' ) { |
| 751 | 675 | global $wpdb; |
| @@ -767,22 +691,18 @@ | ||
| 767 | 691 | return $count; |
| 768 | 692 | } |
| 769 | 693 | |
| 770 | 694 | /** |
| 771 | - * @param int|string $p_size | |
| 772 | - * @param array|int|string $where | |
| 773 | - * | |
| 695 | + * @param int|string $p_size | |
| 774 | 696 | * @return int |
| 775 | 697 | */ |
| 776 | 698 | public static function getPageCount( $p_size, $where = '' ) { |
| 777 | 699 | $p_size = (int) $p_size; |
| 778 | 700 | $count = 1; |
| 779 | - | |
| 780 | 701 | if ( $p_size ) { |
| 781 | 702 | if ( ! is_numeric( $where ) ) { |
| 782 | 703 | $where = self::getRecordCount( $where ); |
| 783 | 704 | } |
| 784 | - | |
| 785 | 705 | $count = ceil( (int) $where / $p_size ); |
| 786 | 706 | } |
| 787 | 707 | |
| 788 | 708 | return $count; |
| @@ -822,9 +742,8 @@ | ||
| 822 | 742 | * @return bool|int $entry_id |
| 823 | 743 | */ |
| 824 | 744 | private static function continue_to_create_entry( $values, $new_values ) { |
| 825 | 745 | $entry_id = self::insert_entry_into_database( $new_values ); |
| 826 | - | |
| 827 | 746 | if ( ! $entry_id ) { |
| 828 | 747 | return false; |
| 829 | 748 | } |
| 830 | 749 | |
| @@ -838,10 +757,8 @@ | ||
| 838 | 757 | * |
| 839 | 758 | * @since 2.0 |
| 840 | 759 | * |
| 841 | 760 | * @param array $values The POST values by reference. |
| 842 | - * | |
| 843 | - * @return void | |
| 844 | 761 | */ |
| 845 | 762 | public static function sanitize_entry_post( &$values ) { |
| 846 | 763 | $sanitize_method = array( |
| 847 | 764 | 'form_id' => 'absint', |
| @@ -890,22 +807,15 @@ | ||
| 890 | 807 | 'description' => self::get_entry_description( $values ), |
| 891 | 808 | 'user_id' => self::get_entry_user_id( $values ), |
| 892 | 809 | ); |
| 893 | 810 | |
| 894 | - $new_values['updated_by'] = $values['updated_by'] ?? $new_values['user_id']; | |
| 811 | + $new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id']; | |
| 895 | 812 | |
| 896 | 813 | return $new_values; |
| 897 | 814 | } |
| 898 | 815 | |
| 899 | - /** | |
| 900 | - * @param array $values | |
| 901 | - * @param string $name | |
| 902 | - * @param mixed $default | |
| 903 | - * | |
| 904 | - * @return mixed | |
| 905 | - */ | |
| 906 | 816 | private static function get_entry_value( $values, $name, $default ) { |
| 907 | - return $values[ $name ] ?? $default; | |
| 817 | + return isset( $values[ $name ] ) ? $values[ $name ] : $default; | |
| 908 | 818 | } |
| 909 | 819 | |
| 910 | 820 | /** |
| 911 | 821 | * Get the ip for a new entry. |
| @@ -922,9 +832,8 @@ | ||
| 922 | 832 | return ''; |
| 923 | 833 | } |
| 924 | 834 | |
| 925 | 835 | $ip = FrmAppHelper::get_ip_address(); |
| 926 | - | |
| 927 | 836 | if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
| 928 | 837 | $ip = self::get_entry_value( $values, 'ip', $ip ); |
| 929 | 838 | } |
| 930 | 839 | |
| @@ -1051,11 +960,9 @@ | ||
| 1051 | 960 | * Add the new entry to global $frm_vars |
| 1052 | 961 | * |
| 1053 | 962 | * @since 2.0.16 |
| 1054 | 963 | * |
| 1055 | - * @param int|string $entry_id | |
| 1056 | - * | |
| 1057 | - * @return void | |
| 964 | + * @param int $entry_id | |
| 1058 | 965 | */ |
| 1059 | 966 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
| 1060 | 967 | global $frm_vars; |
| 1061 | 968 | |
| @@ -1070,11 +977,10 @@ | ||
| 1070 | 977 | * Add entry metas, if there are any |
| 1071 | 978 | * |
| 1072 | 979 | * @since 2.0.16 |
| 1073 | 980 | * |
| 1074 | - * @param array $values | |
| 1075 | - * @param int|string $entry_id | |
| 1076 | - * | |
| 981 | + * @param array $values | |
| 982 | + * @param int $entry_id | |
| 1077 | 983 | * @return void |
| 1078 | 984 | */ |
| 1079 | 985 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
| 1080 | 986 | if ( isset( $values['item_meta'] ) ) { |
| @@ -1088,9 +994,8 @@ | ||
| 1088 | 994 | * @since 6.16.3 |
| 1089 | 995 | * |
| 1090 | 996 | * @param array $values |
| 1091 | 997 | * @param int $entry_id |
| 1092 | - * | |
| 1093 | 998 | * @return void |
| 1094 | 999 | */ |
| 1095 | 1000 | private static function maybe_add_unique_id_meta( $values, $entry_id ) { |
| 1096 | 1001 | if ( ! empty( $values['parent_form_id'] ) || empty( $values['unique_id'] ) || ! self::should_check_for_unique_id_match() ) { |
| @@ -1099,9 +1004,8 @@ | ||
| 1099 | 1004 | |
| 1100 | 1005 | // This unique ID is inserted with JS on form submit. |
| 1101 | 1006 | // It is used to check for duplicate entries. |
| 1102 | 1007 | $unique_id = sanitize_key( $values['unique_id'] ); |
| 1103 | - | |
| 1104 | 1008 | if ( $unique_id ) { |
| 1105 | 1009 | FrmEntryMeta::add_entry_meta( $entry_id, 0, '', compact( 'unique_id' ) ); |
| 1106 | 1010 | self::flag_new_unique_key( $unique_id ); |
| 1107 | 1011 | } |
| @@ -1111,14 +1015,12 @@ | ||
| 1111 | 1015 | * @since 5.0.15 |
| 1112 | 1016 | * |
| 1113 | 1017 | * @param int $form_id |
| 1114 | 1018 | * @param int $entry_id |
| 1115 | - * | |
| 1116 | 1019 | * @return void |
| 1117 | 1020 | */ |
| 1118 | 1021 | private static function maybe_add_captcha_meta( $form_id, $entry_id ) { |
| 1119 | 1022 | global $frm_vars; |
| 1120 | - | |
| 1121 | 1023 | if ( array_key_exists( 'captcha_scores', $frm_vars ) && array_key_exists( $form_id, $frm_vars['captcha_scores'] ) ) { |
| 1122 | 1024 | $captcha_score_meta = array( 'captcha_score' => $frm_vars['captcha_scores'][ $form_id ] ); |
| 1123 | 1025 | FrmEntryMeta::add_entry_meta( $entry_id, 0, '', maybe_serialize( $captcha_score_meta ) ); |
| 1124 | 1026 | } |
| @@ -1131,10 +1033,8 @@ | ||
| 1131 | 1033 | * |
| 1132 | 1034 | * @param int $entry_id |
| 1133 | 1035 | * @param array $values |
| 1134 | 1036 | * @param array $new_values |
| 1135 | - * | |
| 1136 | - * @return void | |
| 1137 | 1037 | */ |
| 1138 | 1038 | private static function after_entry_created_actions( $entry_id, $values, $new_values ) { |
| 1139 | 1039 | // This is a child entry. |
| 1140 | 1040 | $is_child = isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
| @@ -1150,10 +1050,8 @@ | ||
| 1150 | 1050 | * |
| 1151 | 1051 | * @param array $values |
| 1152 | 1052 | * @param array $new_values |
| 1153 | 1053 | * @param int $entry_id |
| 1154 | - * | |
| 1155 | - * @return void | |
| 1156 | 1054 | */ |
| 1157 | 1055 | private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) { |
| 1158 | 1056 | |
| 1159 | 1057 | self::add_new_entry_to_frm_vars( $entry_id ); |
| @@ -1169,11 +1067,11 @@ | ||
| 1169 | 1067 | * Perform some actions right before updating an entry |
| 1170 | 1068 | * |
| 1171 | 1069 | * @since 2.0.16 |
| 1172 | 1070 | * |
| 1173 | - * @param int|string $id | |
| 1174 | - * @param array $values | |
| 1175 | - * @param string $update_type | |
| 1071 | + * @param int $id | |
| 1072 | + * @param array $values | |
| 1073 | + * @param string $update_type | |
| 1176 | 1074 | * |
| 1177 | 1075 | * @return bool $update |
| 1178 | 1076 | */ |
| 1179 | 1077 | private static function before_update_entry( $id, &$values, $update_type ) { |
| @@ -1209,9 +1107,9 @@ | ||
| 1209 | 1107 | 'name' => self::get_new_entry_name( $values ), |
| 1210 | 1108 | 'form_id' => (int) self::get_entry_value( $values, 'form_id', null ), |
| 1211 | 1109 | 'is_draft' => self::get_is_draft_value( $values ), |
| 1212 | 1110 | 'updated_at' => current_time( 'mysql', 1 ), |
| 1213 | - 'updated_by' => $values['updated_by'] ?? get_current_user_id(), | |
| 1111 | + 'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(), | |
| 1214 | 1112 | ); |
| 1215 | 1113 | |
| 1216 | 1114 | if ( isset( $values['post_id'] ) ) { |
| 1217 | 1115 | $new_values['post_id'] = (int) $values['post_id']; |
| @@ -1238,14 +1136,12 @@ | ||
| 1238 | 1136 | * Perform some actions right after updating an entry |
| 1239 | 1137 | * |
| 1240 | 1138 | * @since 2.0.16 |
| 1241 | 1139 | * |
| 1242 | - * @param bool|int $query_results | |
| 1243 | - * @param int|string $id | |
| 1244 | - * @param array $values | |
| 1245 | - * @param array $new_values | |
| 1246 | - * | |
| 1247 | - * @return void | |
| 1140 | + * @param bool|int $query_results | |
| 1141 | + * @param int $id | |
| 1142 | + * @param array $values | |
| 1143 | + * @param array $new_values | |
| 1248 | 1144 | */ |
| 1249 | 1145 | private static function after_update_entry( $query_results, $id, $values, $new_values ) { |
| 1250 | 1146 | if ( $query_results ) { |
| 1251 | 1147 | self::clear_cache(); |
| @@ -1251,9 +1147,8 @@ | ||
| 1251 | 1147 | self::clear_cache(); |
| 1252 | 1148 | } |
| 1253 | 1149 | |
| 1254 | 1150 | global $frm_vars; |
| 1255 | - | |
| 1256 | 1151 | if ( ! isset( $frm_vars['saved_entries'] ) ) { |
| 1257 | 1152 | $frm_vars['saved_entries'] = array(); |
| 1258 | 1153 | } |
| 1259 | 1154 | |