PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.11
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.11
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
← All changes | includes/class-ajax.php +65 -66 1.6.51.6.11 View file →
@@ -117,11 +117,8 @@
117 117 if ( isset( $post_data['integrations'] ) ) {
118 118 $integrations = (array) json_decode( $post_data['integrations'] );
119 119 }
120 120
121 - // $form_fields = wp_unslash( $form_fields );
122 - // $notifications = wp_unslash( $notifications );
123 -
124 121 $form_fields = json_decode( $form_fields, true );
125 122 $notifications = json_decode( $notifications, true );
126 123 $data = [
127 124 'form_id' => absint( $form_data['wpuf_form_id'] ),
@@ -134,8 +131,14 @@
134 131 ];
135 132
136 133 $form_fields = weforms()->form->save( $data );
137 134
135 + // Update Old Entry meta_key if changed
136 + $form_id = $form_data['wpuf_form_id'];
137 + $form = weforms()->form->get( $form_id );
138 +
139 + $form->maybe_update_entries( $form_fields );
140 +
138 141 do_action( 'weforms_update_form', $form_data['wpuf_form_id'], $form_fields, $settings );
139 142
140 143 wp_send_json_success( [ 'form_fields' => $form_fields ] );
141 144 }
@@ -524,9 +527,9 @@
524 527
525 528 $has_empty = false;
526 529 $answers = [];
527 530 $respondentPoints = isset( $form_settings['total_points'] ) ? floatval( $form_settings['total_points'] ) : 0;
528 -
531 + $fields_formatted = array();
529 532 foreach ( $fields as $key => $field ) {
530 533 if ( $form_settings['quiz_form'] == 'yes' ) {
531 534 $selectedAnswers = isset( $field['selected_answers'] ) ? $field['selected_answers'] : '';
532 535 $givenAnswer = isset( $field['value'] ) ? $field['value'] : '';
@@ -535,9 +538,8 @@
535 538 $fieldPoints = isset( $field['points'] ) ? floatval( $field['points'] ) : 0;
536 539
537 540 if ( $template == 'radio_field' || $template == 'dropdown_field' ) {
538 541 $answers[$field['name']] = true;
539 -
540 542 if ( empty( $givenAnswer ) ) {
541 543 $answers[$field['name']] = false;
542 544 $respondentPoints -= $fieldPoints;
543 545 } else {
@@ -572,13 +574,15 @@
572 574 }
573 575 } elseif ( empty( $field['value'] ) ) {
574 576 $has_empty = true;
575 577 break;
578 + } else {
579 + $field = WeForms_Form_Entry_Manager::format_entry_value( $field );
580 + array_push( $fields_formatted, $field );
576 581 }
577 582 }
578 -
579 583 $response = [
580 - 'form_fields' => $fields,
584 + 'form_fields' => $fields_formatted,
581 585 'form_settings' => $form_settings,
582 586 'meta_data' => $metadata,
583 587 'payment_data' => $payment,
584 588 'has_empty' => $has_empty,
@@ -585,8 +589,9 @@
585 589 'respondent_points' => $respondentPoints,
586 590 'answers' => $answers,
587 591 ];
588 592
593 +
589 594 wp_send_json_success( $response );
590 595 }
591 596
592 597 /**
@@ -755,23 +760,32 @@
755 760 $this->validate_submission( $entry_fields, $form, $form_settings, $form_fields );
756 761
757 762 $entry_fields = apply_filters( 'weforms_before_entry_submission', $entry_fields, $form, $form_settings, $form_fields );
758 763
759 - $entry_id = weforms_insert_entry( [
760 - 'form_id' => $form_id,
761 - ], $entry_fields );
762 -
763 - if ( is_wp_error( $entry_id ) ) {
764 - wp_send_json( [
765 - 'success' => false,
766 - 'error' => $entry_id->get_error_message(),
764 + $entry_id = 1;
765 + $global_settings = weforms_get_settings();
766 + if ( empty( $form_settings['after_submission'] ) ) {
767 + $entry_id = weforms_insert_entry( [
768 + 'form_id' => $form_id,
769 + ], $entry_fields );
770 + if ( is_wp_error( $entry_id ) ) {
771 + wp_send_json( [
772 + 'success' => false,
773 + 'error' => $entry_id->get_error_message(),
774 + ] );
775 + }
776 + // Fire a hook for integration
777 + do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
778 + $notification = new WeForms_Notification( [
779 + 'form_id' => $form_id,
780 + 'page_id' => $page_id,
781 + 'entry_id' => $entry_id,
767 782 ] );
783 + $notification->send_notifications();
768 784 }
769 -
770 785 // redirect URL
771 786 $show_message = false;
772 - $redirect_to = false;
773 -
787 + $redirect_to = false;
774 788 if ( $form_settings['redirect_to'] == 'page' ) {
775 789 $redirect_to = get_permalink( $form_settings['page_id'] );
776 790 } elseif ( $form_settings['redirect_to'] == 'url' ) {
777 791 $redirect_to = $form_settings['url'];
@@ -779,17 +793,11 @@
779 793 $show_message = true;
780 794 } else {
781 795 $show_message = true;
782 796 }
783 -
784 - // Fire a hook for integration
785 - do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
786 -
787 797 $field_search = $field_replace = [];
788 -
789 798 foreach ( $form_fields as $r_field ) {
790 799 $field_search[] = '{' . $r_field['name'] . '}';
791 -
792 800 if ( $r_field['template'] == 'name_field' ) {
793 801 $field_replace[] = implode( ' ', explode( '|', $entry_fields[ $r_field['name'] ] ) );
794 802 } else if ( $r_field['template'] == 'address_field' ) {
795 803 $field_replace[] = implode( ', ', $entry_fields[ $r_field['name'] ] );
@@ -797,68 +805,59 @@
797 805 $field_replace[] = isset( $entry_fields[ $r_field['name'] ] ) ? $entry_fields[ $r_field['name'] ] : '';
798 806 }
799 807 }
800 808 $message = str_replace( $field_search, $field_replace, $form_settings['message'] );
801 -
802 809 // send the response
803 810 $response = apply_filters( 'weforms_entry_submission_response', [
804 - 'success' => true,
805 - 'redirect_to' => $redirect_to,
811 + 'success' => true,
812 + 'redirect_to' => $redirect_to,
806 813 'show_message' => $show_message,
807 - 'message' => $message,
808 - 'data' => $_POST,
809 - 'form_id' => $form_id,
810 - 'entry_id' => $entry_id,
814 + 'message' => $message,
815 + 'data' => $_POST,
816 + 'form_id' => $form_id,
817 + 'entry_id' => $entry_id,
818 + 'entry_fields' =>$entry_fields,
811 819 ] );
812 -
813 - $notification = new WeForms_Notification( [
814 - 'form_id' => $form_id,
815 - 'page_id' => $page_id,
816 - 'entry_id' => $entry_id,
817 - ] );
818 -
819 - $notification->send_notifications();
820 -
821 820 weforms_clear_buffer();
822 821 wp_send_json( $response );
823 - }
822 + }
824 823
825 - function validate_reCaptchav3( $secret ) {
826 - check_ajax_referer( 'wpuf_form_add' );
824 + function validate_reCaptchav3( $secret ) {
825 + check_ajax_referer( 'wpuf_form_add' );
827 826
828 - $post_data = wp_unslash($_POST);
829 - $token = $post_data['g-recaptcha-response'];
830 - $action = $post_data['g-action'];
831 - $google_captcha_url = esc_url( 'https://www.google.com/recaptcha/api/siteverify' );
827 + $post_data = wp_unslash($_POST);
828 + $token = $post_data['g-recaptcha-response'];
829 + $action = $post_data['g-action'];
830 + $google_captcha_url = esc_url( 'https://www.google.com/recaptcha/api/siteverify' );
832 831
833 - $response = wp_remote_post( $google_captcha_url,
834 - array(
835 - 'method' => 'POST',
836 - 'body' => array(
837 - 'secret' => $secret,
838 - 'response' => $token
832 + $response = wp_remote_post( $google_captcha_url,
833 + array(
834 + 'method' => 'POST',
835 + 'body' => array(
836 + 'secret' => $secret,
837 + 'response' => $token
838 + )
839 839 )
840 - )
841 - );
840 + );
842 841
843 842
844 - if ( is_wp_error( $response ) ) {
845 - wp_send_json( [
846 - 'success' => false,
847 - 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
848 - ] );
849 - } else {
850 - $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
851 - if( $api_response["success"] == '1' && $api_response["action"] == $action ) {
852 - return true;
853 - } else {
843 + if ( is_wp_error( $response ) ) {
854 844 wp_send_json( [
855 845 'success' => false,
856 846 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
857 847 ] );
848 + } else {
849 + $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
850 + if( $api_response["success"] == '1' && $api_response["action"] == $action ) {
851 + return true;
852 + } else {
853 + wp_send_json( [
854 + 'success' => false,
855 + 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
856 + ] );
857 + }
858 858 }
859 859 }
860 - }
861 860 /**
862 861 * reCaptcha Validation
863 862 *
864 863 * @return void