PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.6.1
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.6.1
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 +66 -65 1.6.131.6.1 View file →
@@ -117,8 +117,11 @@
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 +
121 124 $form_fields = json_decode( $form_fields, true );
122 125 $notifications = json_decode( $notifications, true );
123 126 $data = [
124 127 'form_id' => absint( $form_data['wpuf_form_id'] ),
@@ -131,14 +134,8 @@
131 134 ];
132 135
133 136 $form_fields = weforms()->form->save( $data );
134 137
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 -
141 138 do_action( 'weforms_update_form', $form_data['wpuf_form_id'], $form_fields, $settings );
142 139
143 140 wp_send_json_success( [ 'form_fields' => $form_fields ] );
144 141 }
@@ -527,9 +524,9 @@
527 524
528 525 $has_empty = false;
529 526 $answers = [];
530 527 $respondentPoints = isset( $form_settings['total_points'] ) ? floatval( $form_settings['total_points'] ) : 0;
531 - $fields_formatted = array();
528 +
532 529 foreach ( $fields as $key => $field ) {
533 530 if ( $form_settings['quiz_form'] == 'yes' ) {
534 531 $selectedAnswers = isset( $field['selected_answers'] ) ? $field['selected_answers'] : '';
535 532 $givenAnswer = isset( $field['value'] ) ? $field['value'] : '';
@@ -538,8 +535,9 @@
538 535 $fieldPoints = isset( $field['points'] ) ? floatval( $field['points'] ) : 0;
539 536
540 537 if ( $template == 'radio_field' || $template == 'dropdown_field' ) {
541 538 $answers[$field['name']] = true;
539 +
542 540 if ( empty( $givenAnswer ) ) {
543 541 $answers[$field['name']] = false;
544 542 $respondentPoints -= $fieldPoints;
545 543 } else {
@@ -574,15 +572,13 @@
574 572 }
575 573 } elseif ( empty( $field['value'] ) ) {
576 574 $has_empty = true;
577 575 break;
578 - } else {
579 - $field = WeForms_Form_Entry_Manager::format_entry_value( $field );
580 - array_push( $fields_formatted, $field );
581 576 }
582 577 }
578 +
583 579 $response = [
584 - 'form_fields' => $fields_formatted,
580 + 'form_fields' => $fields,
585 581 'form_settings' => $form_settings,
586 582 'meta_data' => $metadata,
587 583 'payment_data' => $payment,
588 584 'has_empty' => $has_empty,
@@ -589,9 +585,8 @@
589 585 'respondent_points' => $respondentPoints,
590 586 'answers' => $answers,
591 587 ];
592 588
593 -
594 589 wp_send_json_success( $response );
595 590 }
596 591
597 592 /**
@@ -760,32 +755,23 @@
760 755 $this->validate_submission( $entry_fields, $form, $form_settings, $form_fields );
761 756
762 757 $entry_fields = apply_filters( 'weforms_before_entry_submission', $entry_fields, $form, $form_settings, $form_fields );
763 758
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,
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(),
782 767 ] );
783 - $notification->send_notifications();
784 768 }
769 +
785 770 // redirect URL
786 771 $show_message = false;
787 - $redirect_to = false;
772 + $redirect_to = false;
773 +
788 774 if ( $form_settings['redirect_to'] == 'page' ) {
789 775 $redirect_to = get_permalink( $form_settings['page_id'] );
790 776 } elseif ( $form_settings['redirect_to'] == 'url' ) {
791 777 $redirect_to = $form_settings['url'];
@@ -793,11 +779,17 @@
793 779 $show_message = true;
794 780 } else {
795 781 $show_message = true;
796 782 }
783 +
784 + // Fire a hook for integration
785 + do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
786 +
797 787 $field_search = $field_replace = [];
788 +
798 789 foreach ( $form_fields as $r_field ) {
799 790 $field_search[] = '{' . $r_field['name'] . '}';
791 +
800 792 if ( $r_field['template'] == 'name_field' ) {
801 793 $field_replace[] = implode( ' ', explode( '|', $entry_fields[ $r_field['name'] ] ) );
802 794 } else if ( $r_field['template'] == 'address_field' ) {
803 795 $field_replace[] = implode( ', ', $entry_fields[ $r_field['name'] ] );
@@ -805,59 +797,68 @@
805 797 $field_replace[] = isset( $entry_fields[ $r_field['name'] ] ) ? $entry_fields[ $r_field['name'] ] : '';
806 798 }
807 799 }
808 800 $message = str_replace( $field_search, $field_replace, $form_settings['message'] );
801 +
809 802 // send the response
810 803 $response = apply_filters( 'weforms_entry_submission_response', [
811 - 'success' => true,
812 - 'redirect_to' => $redirect_to,
804 + 'success' => true,
805 + 'redirect_to' => $redirect_to,
813 806 'show_message' => $show_message,
814 - 'message' => $message,
815 - 'data' => $_POST,
816 - 'form_id' => $form_id,
817 - 'entry_id' => $entry_id,
818 - 'entry_fields' =>$entry_fields,
807 + 'message' => $message,
808 + 'data' => $_POST,
809 + 'form_id' => $form_id,
810 + 'entry_id' => $entry_id,
819 811 ] );
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 +
820 821 weforms_clear_buffer();
821 822 wp_send_json( $response );
822 - }
823 + }
823 824
824 - function validate_reCaptchav3( $secret ) {
825 - check_ajax_referer( 'wpuf_form_add' );
825 + function validate_reCaptchav3( $secret ) {
826 + check_ajax_referer( 'wpuf_form_add' );
826 827
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' );
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' );
831 832
832 - $response = wp_remote_post( $google_captcha_url,
833 - array(
834 - 'method' => 'POST',
835 - 'body' => array(
836 - 'secret' => $secret,
837 - 'response' => $token
838 - )
833 + $response = wp_remote_post( $google_captcha_url,
834 + array(
835 + 'method' => 'POST',
836 + 'body' => array(
837 + 'secret' => $secret,
838 + 'response' => $token
839 839 )
840 - );
840 + )
841 + );
841 842
842 843
843 - if ( is_wp_error( $response ) ) {
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 {
844 854 wp_send_json( [
845 855 'success' => false,
846 856 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
847 857 ] );
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 + }
860 861 /**
861 862 * reCaptcha Validation
862 863 *
863 864 * @return void