| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | class FrmForm { |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * @param array $values |
| 10 | - * @return bool|int id on success or false on failure. | |
| 10 | + * @return int|bool id on success or false on failure. | |
| 11 | 11 | */ |
| 12 | 12 | public static function create( $values ) { |
| 13 | 13 | global $wpdb; |
| 14 | 14 | |
| @@ -17,22 +17,22 @@ | ||
| 17 | 17 | $new_values = array( |
| 18 | 18 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 19 | 19 | 'name' => $values['name'], |
| 20 | 20 | 'description' => $values['description'], |
| 21 | - 'status' => $values['status'] ?? 'published', | |
| 22 | - 'logged_in' => $values['logged_in'] ?? 0, | |
| 21 | + 'status' => isset( $values['status'] ) ? $values['status'] : 'published', | |
| 22 | + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0, | |
| 23 | 23 | 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0, |
| 24 | 24 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
| 25 | 25 | 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0, |
| 26 | - 'created_at' => $values['created_at'] ?? current_time( 'mysql', 1 ), | |
| 26 | + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ), | |
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | 29 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
| 30 | 30 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 31 | 31 | |
| 32 | - $options['before_html'] = $values['options']['before_html'] ?? FrmFormsHelper::get_default_html( 'before' ); | |
| 33 | - $options['after_html'] = $values['options']['after_html'] ?? FrmFormsHelper::get_default_html( 'after' ); | |
| 34 | - $options['submit_html'] = $values['options']['submit_html'] ?? FrmFormsHelper::get_default_html( 'submit' ); | |
| 32 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); | |
| 33 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); | |
| 34 | + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); | |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Allows modifying form options before updating or creating. |
| 38 | 38 | * |
| @@ -69,9 +69,9 @@ | ||
| 69 | 69 | return FrmAppHelper::maybe_filter_array( $options, array( 'submit_value', 'success_msg', 'before_html', 'after_html' ) ); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | - * @return bool|int ID on success or false on failure | |
| 73 | + * @return int|boolean ID on success or false on failure | |
| 74 | 74 | */ |
| 75 | 75 | public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
| 76 | 76 | global $wpdb; |
| 77 | 77 | |
| @@ -93,10 +93,10 @@ | ||
| 93 | 93 | 'is_template' => $template ? 1 : 0, |
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | 96 | if ( $blog_id ) { |
| 97 | - $new_values['status'] = 'published'; | |
| 98 | - $new_options = $values->options; | |
| 97 | + $new_values['status'] = 'published'; | |
| 98 | + $new_options = $values->options; | |
| 99 | 99 | FrmAppHelper::unserialize_or_decode( $new_options ); |
| 100 | 100 | $new_options['email_to'] = get_option( 'admin_email' ); |
| 101 | 101 | $new_options['copy'] = false; |
| 102 | 102 | $new_values['options'] = $new_options; |
| @@ -126,9 +126,9 @@ | ||
| 126 | 126 | return false; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public static function after_duplicate( $form_id, $values ) { |
| 130 | - $new_opts = $values['options']; | |
| 130 | + $new_opts = $values['options']; | |
| 131 | 131 | FrmAppHelper::unserialize_or_decode( $new_opts ); |
| 132 | 132 | $values['options'] = $new_opts; |
| 133 | 133 | |
| 134 | 134 | if ( isset( $new_opts['success_msg'] ) ) { |
| @@ -158,9 +158,9 @@ | ||
| 158 | 158 | // Keys of fields that you want to check to replace field ID. |
| 159 | 159 | $keys = array( 'default_value', 'field_options' ); |
| 160 | 160 | $sql_cols = 'fi.id'; |
| 161 | 161 | foreach ( $keys as $key ) { |
| 162 | - $sql_cols .= ',fi.' . $key; | |
| 162 | + $sql_cols .= ( ',fi.' . $key ); | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $fields = FrmDb::get_results( |
| 166 | 166 | "{$wpdb->prefix}frm_fields AS fi LEFT OUTER JOIN {$wpdb->prefix}frm_forms AS fr ON fi.form_id = fr.id", |
| @@ -218,9 +218,9 @@ | ||
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | - * @return bool|int | |
| 222 | + * @return int|boolean | |
| 223 | 223 | */ |
| 224 | 224 | public static function update( $id, $values, $create_link = false ) { |
| 225 | 225 | global $wpdb; |
| 226 | 226 | |
| @@ -243,9 +243,9 @@ | ||
| 243 | 243 | $new_values[ $value_key ] = $value; |
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - if ( ! empty( $values['new_status'] ) ) { | |
| 247 | + if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { | |
| 248 | 248 | $new_values['status'] = $values['new_status']; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | if ( ! empty( $new_values ) ) { |
| @@ -279,12 +279,12 @@ | ||
| 279 | 279 | |
| 280 | 280 | $options = ! empty( $values['options'] ) ? (array) $values['options'] : array(); |
| 281 | 281 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 282 | 282 | |
| 283 | - $options['custom_style'] = $values['options']['custom_style'] ?? 0; | |
| 284 | - $options['before_html'] = $values['options']['before_html'] ?? FrmFormsHelper::get_default_html( 'before' ); | |
| 285 | - $options['after_html'] = $values['options']['after_html'] ?? FrmFormsHelper::get_default_html( 'after' ); | |
| 286 | - $options['submit_html'] = isset( $values['options']['submit_html'] ) && '' !== $values['options']['submit_html'] ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); | |
| 283 | + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0; | |
| 284 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); | |
| 285 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); | |
| 286 | + $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && '' !== $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); | |
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Allows modifying form options before updating or creating. |
| 290 | 290 | * |
| @@ -354,14 +354,10 @@ | ||
| 354 | 354 | // Don't check for POST html. |
| 355 | 355 | unset( $update_options['custom_html'] ); |
| 356 | 356 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
| 357 | 357 | |
| 358 | - if ( ! is_array( $field->field_options ) ) { | |
| 359 | - $field->field_options = array(); | |
| 360 | - } | |
| 361 | - | |
| 362 | 358 | foreach ( $update_options as $opt => $default ) { |
| 363 | - $field->field_options[ $opt ] = $values['field_options'][ $opt . '_' . $field_id ] ?? $default; | |
| 359 | + $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default; | |
| 364 | 360 | self::sanitize_field_opt( $opt, $field->field_options[ $opt ] ); |
| 365 | 361 | } |
| 366 | 362 | |
| 367 | 363 | $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
| @@ -477,16 +473,14 @@ | ||
| 477 | 473 | * @return string |
| 478 | 474 | */ |
| 479 | 475 | private static function normalize_calc_spaces( $calc ) { |
| 480 | 476 | // Check for a pattern with 5 parts |
| 481 | - // $1 \d|\] the first comparison digit or the end of a comparison shortcode. | |
| 477 | + // $1 \d the first comparison digit. | |
| 482 | 478 | // $2 a space (optional). |
| 483 | 479 | // $3 an equals sign (optional) that follows the < operator for <= comparisons. |
| 484 | 480 | // $4 another space (optional). |
| 485 | - // $5 \d|\[ the second comparison digit or the start of a comparison shortcode. | |
| 486 | - $calc = preg_replace( '/(\d|\])( ){0,1}<(=){0,1}( ){0,1}(\d|\[)/', '$1 <$3 $5', $calc ); | |
| 487 | - | |
| 488 | - return $calc; | |
| 481 | + // $5 \d the second comparison digit. | |
| 482 | + return preg_replace( '/(\d)( ){0,1}<(=){0,1}( ){0,1}(\d)/', '$1 <$3 $5', $calc ); | |
| 489 | 483 | } |
| 490 | 484 | |
| 491 | 485 | /** |
| 492 | 486 | * Updating the settings page |
| @@ -493,12 +487,12 @@ | ||
| 493 | 487 | */ |
| 494 | 488 | private static function get_settings_page_html( $values, &$field ) { |
| 495 | 489 | if ( isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ) { |
| 496 | 490 | $prev_opts = array(); |
| 497 | - $fallback_html = $field->field_options['custom_html'] ?? FrmFieldsHelper::get_default_html( $field->type ); | |
| 491 | + $fallback_html = isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ); | |
| 498 | 492 | |
| 499 | - $field->field_options['custom_html'] = $values['field_options'][ 'custom_html_' . $field->id ] ?? $fallback_html; | |
| 500 | - } elseif ( $field->type === 'hidden' || $field->type === 'user_id' ) { | |
| 493 | + $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field->id ] ) ? $values['field_options'][ 'custom_html_' . $field->id ] : $fallback_html; | |
| 494 | + } elseif ( $field->type == 'hidden' || $field->type == 'user_id' ) { | |
| 501 | 495 | $prev_opts = $field->field_options; |
| 502 | 496 | } |
| 503 | 497 | |
| 504 | 498 | if ( isset( $prev_opts ) ) { |
| @@ -519,14 +513,11 @@ | ||
| 519 | 513 | 'options' => '', |
| 520 | 514 | 'name' => '', |
| 521 | 515 | ); |
| 522 | 516 | foreach ( $field_cols as $col => $default ) { |
| 523 | - $default = $default === '' ? $field->{$col} : $default; | |
| 524 | - $new_field[ $col ] = $values['field_options'][ $col . '_' . $field->id ] ?? $default; | |
| 525 | - } | |
| 517 | + $default = ( $default === '' ) ? $field->{$col} : $default; | |
| 526 | 518 | |
| 527 | - if ( $field->type === 'submit' && isset( $new_field['field_order'] ) && (int) $new_field['field_order'] === FrmSubmitHelper::DEFAULT_ORDER ) { | |
| 528 | - $new_field['field_order'] = $field->field_order; | |
| 519 | + $new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default; | |
| 529 | 520 | } |
| 530 | 521 | |
| 531 | 522 | // Don't save the template option. |
| 532 | 523 | if ( is_array( $new_field['options'] ) && isset( $new_field['options']['000'] ) ) { |
| @@ -560,9 +551,9 @@ | ||
| 560 | 551 | /** |
| 561 | 552 | * @param int $id |
| 562 | 553 | * @param string $status |
| 563 | 554 | * |
| 564 | - * @return bool|int | |
| 555 | + * @return int|boolean | |
| 565 | 556 | */ |
| 566 | 557 | public static function set_status( $id, $status ) { |
| 567 | 558 | if ( 'trash' == $status ) { |
| 568 | 559 | return self::trash( $id ); |
| @@ -568,9 +559,9 @@ | ||
| 568 | 559 | return self::trash( $id ); |
| 569 | 560 | } |
| 570 | 561 | |
| 571 | 562 | $statuses = array( 'published', 'draft', 'trash' ); |
| 572 | - if ( ! in_array( $status, $statuses, true ) ) { | |
| 563 | + if ( ! in_array( $status, $statuses ) ) { | |
| 573 | 564 | return false; |
| 574 | 565 | } |
| 575 | 566 | |
| 576 | 567 | global $wpdb; |
| @@ -597,9 +588,9 @@ | ||
| 597 | 588 | return $query_results; |
| 598 | 589 | } |
| 599 | 590 | |
| 600 | 591 | /** |
| 601 | - * @return bool|int | |
| 592 | + * @return int|boolean | |
| 602 | 593 | */ |
| 603 | 594 | public static function trash( $id ) { |
| 604 | 595 | if ( ! EMPTY_TRASH_DAYS ) { |
| 605 | 596 | return self::destroy( $id ); |
| @@ -609,12 +600,8 @@ | ||
| 609 | 600 | if ( ! $form ) { |
| 610 | 601 | return false; |
| 611 | 602 | } |
| 612 | 603 | |
| 613 | - if ( $form->status === 'trash' ) { | |
| 614 | - return false; | |
| 615 | - } | |
| 616 | - | |
| 617 | 604 | $options = $form->options; |
| 618 | 605 | $options['trash_time'] = time(); |
| 619 | 606 | |
| 620 | 607 | global $wpdb; |
| @@ -647,9 +634,9 @@ | ||
| 647 | 634 | return $query_results; |
| 648 | 635 | } |
| 649 | 636 | |
| 650 | 637 | /** |
| 651 | - * @return bool|int | |
| 638 | + * @return int|boolean | |
| 652 | 639 | */ |
| 653 | 640 | public static function destroy( $id ) { |
| 654 | 641 | global $wpdb; |
| 655 | 642 | |
| @@ -671,11 +658,8 @@ | ||
| 671 | 658 | |
| 672 | 659 | $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) ); |
| 673 | 660 | if ( $query_results ) { |
| 674 | 661 | // Delete all form actions linked to this form |
| 675 | - /** | |
| 676 | - * @var FrmFormAction | |
| 677 | - */ | |
| 678 | 662 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
| 679 | 663 | $action_control->destroy( $id, 'all' ); |
| 680 | 664 | |
| 681 | 665 | // Clear form caching |
| @@ -711,9 +695,9 @@ | ||
| 711 | 695 | FrmAppHelper::unserialize_or_decode( $form->options ); |
| 712 | 696 | if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) { |
| 713 | 697 | self::destroy( $form->id ); |
| 714 | 698 | if ( empty( $form->parent_form_id ) ) { |
| 715 | - ++$count; | |
| 699 | + $count ++; | |
| 716 | 700 | } |
| 717 | 701 | } |
| 718 | 702 | |
| 719 | 703 | unset( $form ); |
| @@ -774,10 +758,11 @@ | ||
| 774 | 758 | |
| 775 | 759 | /** |
| 776 | 760 | * If $form is numeric, get the form object |
| 777 | 761 | * |
| 762 | + * @param object|int $form | |
| 763 | + * | |
| 778 | 764 | * @since 2.0.9 |
| 779 | - * @param int|object $form | |
| 780 | 765 | */ |
| 781 | 766 | public static function maybe_get_form( &$form ) { |
| 782 | 767 | if ( ! is_object( $form ) && ! is_array( $form ) && ! empty( $form ) ) { |
| 783 | 768 | $form = self::getOne( $form ); |
| @@ -784,11 +769,9 @@ | ||
| 784 | 769 | } |
| 785 | 770 | } |
| 786 | 771 | |
| 787 | 772 | /** |
| 788 | - * @param int|string $id | |
| 789 | - * @param false|int $blog_id | |
| 790 | - * @return stdClass|null | |
| 773 | + * @return object form | |
| 791 | 774 | */ |
| 792 | 775 | public static function getOne( $id, $blog_id = false ) { |
| 793 | 776 | global $wpdb; |
| 794 | 777 | |
| @@ -803,9 +786,10 @@ | ||
| 803 | 786 | if ( $cache ) { |
| 804 | 787 | if ( isset( $cache->options ) ) { |
| 805 | 788 | FrmAppHelper::unserialize_or_decode( $cache->options ); |
| 806 | 789 | } |
| 807 | - return self::prepare_form_row_data( $cache ); | |
| 790 | + | |
| 791 | + return apply_filters( 'frm_form_object', wp_unslash( $cache ) ); | |
| 808 | 792 | } |
| 809 | 793 | } |
| 810 | 794 | |
| 811 | 795 | if ( is_numeric( $id ) ) { |
| @@ -820,43 +804,17 @@ | ||
| 820 | 804 | FrmDb::set_cache( $results->id, $results, 'frm_form' ); |
| 821 | 805 | FrmAppHelper::unserialize_or_decode( $results->options ); |
| 822 | 806 | } |
| 823 | 807 | |
| 824 | - return self::prepare_form_row_data( $results ); | |
| 808 | + return apply_filters( 'frm_form_object', wp_unslash( $results ) ); | |
| 825 | 809 | } |
| 826 | 810 | |
| 827 | 811 | /** |
| 828 | - * Make sure that if $row is an object, that $row->options is an array and not a string. | |
| 829 | - * | |
| 830 | - * @since 6.8.3 | |
| 831 | - * | |
| 832 | - * @param stdClass|null $row The database row for a target form. | |
| 833 | - * @return stdClass|null | |
| 812 | + * @return object|array of objects | |
| 834 | 813 | */ |
| 835 | - private static function prepare_form_row_data( $row ) { | |
| 836 | - $row = wp_unslash( $row ); | |
| 837 | - if ( ! is_object( $row ) ) { | |
| 838 | - return $row; | |
| 839 | - } | |
| 840 | - | |
| 841 | - if ( ! is_array( $row->options ) ) { | |
| 842 | - $row->options = FrmFormsHelper::get_default_opts(); | |
| 843 | - } | |
| 844 | - | |
| 845 | - /** | |
| 846 | - * @since 4.03.02 | |
| 847 | - * | |
| 848 | - * @param stdClass $row | |
| 849 | - */ | |
| 850 | - return apply_filters( 'frm_form_object', $row ); | |
| 851 | - } | |
| 852 | - | |
| 853 | - /** | |
| 854 | - * @return array|object of objects | |
| 855 | - */ | |
| 856 | 814 | public static function getAll( $where = array(), $order_by = '', $limit = '' ) { |
| 857 | 815 | if ( is_array( $where ) && ! empty( $where ) ) { |
| 858 | - if ( ! empty( $where['is_template'] ) && ! isset( $where['status'] ) && ! isset( $where['status !'] ) ) { | |
| 816 | + if ( isset( $where['is_template'] ) && $where['is_template'] && ! isset( $where['status'] ) && ! isset( $where['status !'] ) ) { | |
| 859 | 817 | // don't get trashed templates |
| 860 | 818 | $where['status'] = array( null, '', 'published' ); |
| 861 | 819 | } |
| 862 | 820 | |
| @@ -875,9 +833,9 @@ | ||
| 875 | 833 | FrmAppHelper::unserialize_or_decode( $result->options ); |
| 876 | 834 | } |
| 877 | 835 | } |
| 878 | 836 | |
| 879 | - if ( $limit === ' LIMIT 1' || $limit == 1 ) { | |
| 837 | + if ( $limit == ' LIMIT 1' || $limit == 1 ) { | |
| 880 | 838 | // return the first form object if we are only getting one form |
| 881 | 839 | $results = reset( $results ); |
| 882 | 840 | } |
| 883 | 841 | |
| @@ -896,9 +854,9 @@ | ||
| 896 | 854 | */ |
| 897 | 855 | public static function get_published_forms( $query = array(), $limit = 999, $inc_children = 'exclude' ) { |
| 898 | 856 | $query['is_template'] = 0; |
| 899 | 857 | $query['status'] = array( null, '', 'published' ); |
| 900 | - if ( $inc_children === 'exclude' ) { | |
| 858 | + if ( $inc_children == 'exclude' ) { | |
| 901 | 859 | $query['parent_form_id'] = array( null, 0 ); |
| 902 | 860 | } |
| 903 | 861 | |
| 904 | 862 | $forms = self::getAll( $query, 'name', $limit ); |
| @@ -934,18 +892,18 @@ | ||
| 934 | 892 | |
| 935 | 893 | foreach ( $results as $row ) { |
| 936 | 894 | if ( 'trash' != $row->status ) { |
| 937 | 895 | if ( $row->is_template ) { |
| 938 | - ++$counts['template']; | |
| 896 | + $counts['template'] ++; | |
| 939 | 897 | } else { |
| 940 | - ++$counts['published']; | |
| 898 | + $counts['published'] ++; | |
| 941 | 899 | } |
| 942 | 900 | } else { |
| 943 | - ++$counts['trash']; | |
| 901 | + $counts['trash'] ++; | |
| 944 | 902 | } |
| 945 | 903 | |
| 946 | 904 | if ( 'draft' == $row->status ) { |
| 947 | - ++$counts['draft']; | |
| 905 | + $counts['draft'] ++; | |
| 948 | 906 | } |
| 949 | 907 | |
| 950 | 908 | unset( $row ); |
| 951 | 909 | } |
| @@ -1013,9 +971,9 @@ | ||
| 1013 | 971 | |
| 1014 | 972 | if ( $form->id == $values['posted_form_id'] ) { |
| 1015 | 973 | // If there are two forms on the same page, make sure not to submit both. |
| 1016 | 974 | foreach ( $default_values as $var => $default ) { |
| 1017 | - if ( $var === 'action' ) { | |
| 975 | + if ( $var == 'action' ) { | |
| 1018 | 976 | $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
| 1019 | 977 | } else { |
| 1020 | 978 | $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
| 1021 | 979 | } |
| @@ -1083,9 +1041,9 @@ | ||
| 1083 | 1041 | return $values; |
| 1084 | 1042 | } |
| 1085 | 1043 | |
| 1086 | 1044 | public static function get_current_form_id( $default_form = 'none' ) { |
| 1087 | - if ( 'first' === $default_form ) { | |
| 1045 | + if ( 'first' == $default_form ) { | |
| 1088 | 1046 | $form = self::get_current_form(); |
| 1089 | 1047 | } else { |
| 1090 | 1048 | $form = self::maybe_get_current_form(); |
| 1091 | 1049 | } |
| @@ -1096,9 +1054,9 @@ | ||
| 1096 | 1054 | |
| 1097 | 1055 | public static function maybe_get_current_form( $form_id = 0 ) { |
| 1098 | 1056 | global $frm_vars; |
| 1099 | 1057 | |
| 1100 | - if ( ! empty( $frm_vars['current_form'] ) && ( ! $form_id || $form_id == $frm_vars['current_form']->id ) ) { | |
| 1058 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && ( ! $form_id || $form_id == $frm_vars['current_form']->id ) ) { | |
| 1101 | 1059 | return $frm_vars['current_form']; |
| 1102 | 1060 | } |
| 1103 | 1061 | |
| 1104 | 1062 | $form_id = FrmAppHelper::get_param( 'form', $form_id, 'get', 'absint' ); |
| @@ -1145,9 +1103,9 @@ | ||
| 1145 | 1103 | $global_load = true; |
| 1146 | 1104 | $frm_vars['load_css'] = true; |
| 1147 | 1105 | } |
| 1148 | 1106 | |
| 1149 | - return empty( $frm_vars['css_loaded'] ) && $global_load; | |
| 1107 | + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load ); | |
| 1150 | 1108 | } |
| 1151 | 1109 | |
| 1152 | 1110 | /** |
| 1153 | 1111 | * @since 4.06.03 |
| @@ -1162,21 +1120,13 @@ | ||
| 1162 | 1120 | } else { |
| 1163 | 1121 | $visible = true; |
| 1164 | 1122 | } |
| 1165 | 1123 | |
| 1166 | - /** | |
| 1167 | - * @since 6.25 | |
| 1168 | - * | |
| 1169 | - * @param bool $visible | |
| 1170 | - * @param object $form | |
| 1171 | - */ | |
| 1172 | - $visible = (bool) apply_filters( 'frm_form_is_visible', $visible, $form ); | |
| 1173 | - | |
| 1174 | 1124 | return $visible; |
| 1175 | 1125 | } |
| 1176 | 1126 | |
| 1177 | 1127 | public static function show_submit( $form ) { |
| 1178 | - $show = ( ! $form->is_template && $form->status === 'published' && ! FrmAppHelper::is_admin() ); | |
| 1128 | + $show = ( ! $form->is_template && $form->status == 'published' && ! FrmAppHelper::is_admin() ); | |
| 1179 | 1129 | $show = apply_filters( 'frm_show_submit_button', $show, $form ); |
| 1180 | 1130 | |
| 1181 | 1131 | return $show; |
| 1182 | 1132 | } |
| @@ -1184,12 +1134,12 @@ | ||
| 1184 | 1134 | /** |
| 1185 | 1135 | * @since 2.3 |
| 1186 | 1136 | */ |
| 1187 | 1137 | public static function get_option( $atts ) { |
| 1188 | - $form = $atts['form']; | |
| 1189 | - $default = $atts['default'] ?? ''; | |
| 1138 | + $form = $atts['form']; | |
| 1139 | + $default = isset( $atts['default'] ) ? $atts['default'] : ''; | |
| 1190 | 1140 | |
| 1191 | - return $form->options[ $atts['option'] ] ?? $default; | |
| 1141 | + return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $default; | |
| 1192 | 1142 | } |
| 1193 | 1143 | |
| 1194 | 1144 | /** |
| 1195 | 1145 | * Get the link to edit this form. |
| @@ -1270,9 +1220,9 @@ | ||
| 1270 | 1220 | /** |
| 1271 | 1221 | * @deprecated 2.03.05 This is still referenced in the API add on as of v1.13. |
| 1272 | 1222 | * @codeCoverageIgnore |
| 1273 | 1223 | * |
| 1274 | - * @param int|string $id | |
| 1224 | + * @param string|int $id | |
| 1275 | 1225 | * @return string |
| 1276 | 1226 | */ |
| 1277 | 1227 | public static function getKeyById( $id ) { |
| 1278 | 1228 | _deprecated_function( __FUNCTION__, '2.03.05', 'FrmForm::get_key_by_id' ); |