PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.5.0
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.5.0
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 -67 1.6.131.5.0 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,16 +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 - do_action( 'weforms_update_form', $form_data['wpuf_form_id'], $form_fields, $settings );
142 -
143 138 wp_send_json_success( [ 'form_fields' => $form_fields ] );
144 139 }
145 140
146 141 /**
@@ -527,9 +522,9 @@
527 522
528 523 $has_empty = false;
529 524 $answers = [];
530 525 $respondentPoints = isset( $form_settings['total_points'] ) ? floatval( $form_settings['total_points'] ) : 0;
531 - $fields_formatted = array();
526 +
532 527 foreach ( $fields as $key => $field ) {
533 528 if ( $form_settings['quiz_form'] == 'yes' ) {
534 529 $selectedAnswers = isset( $field['selected_answers'] ) ? $field['selected_answers'] : '';
535 530 $givenAnswer = isset( $field['value'] ) ? $field['value'] : '';
@@ -538,8 +533,9 @@
538 533 $fieldPoints = isset( $field['points'] ) ? floatval( $field['points'] ) : 0;
539 534
540 535 if ( $template == 'radio_field' || $template == 'dropdown_field' ) {
541 536 $answers[$field['name']] = true;
537 +
542 538 if ( empty( $givenAnswer ) ) {
543 539 $answers[$field['name']] = false;
544 540 $respondentPoints -= $fieldPoints;
545 541 } else {
@@ -574,15 +570,13 @@
574 570 }
575 571 } elseif ( empty( $field['value'] ) ) {
576 572 $has_empty = true;
577 573 break;
578 - } else {
579 - $field = WeForms_Form_Entry_Manager::format_entry_value( $field );
580 - array_push( $fields_formatted, $field );
581 574 }
582 575 }
576 +
583 577 $response = [
584 - 'form_fields' => $fields_formatted,
578 + 'form_fields' => $fields,
585 579 'form_settings' => $form_settings,
586 580 'meta_data' => $metadata,
587 581 'payment_data' => $payment,
588 582 'has_empty' => $has_empty,
@@ -589,9 +583,8 @@
589 583 'respondent_points' => $respondentPoints,
590 584 'answers' => $answers,
591 585 ];
592 586
593 -
594 587 wp_send_json_success( $response );
595 588 }
596 589
597 590 /**
@@ -760,32 +753,23 @@
760 753 $this->validate_submission( $entry_fields, $form, $form_settings, $form_fields );
761 754
762 755 $entry_fields = apply_filters( 'weforms_before_entry_submission', $entry_fields, $form, $form_settings, $form_fields );
763 756
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,
757 + $entry_id = weforms_insert_entry( [
758 + 'form_id' => $form_id,
759 + ], $entry_fields );
760 +
761 + if ( is_wp_error( $entry_id ) ) {
762 + wp_send_json( [
763 + 'success' => false,
764 + 'error' => $entry_id->get_error_message(),
782 765 ] );
783 - $notification->send_notifications();
784 766 }
767 +
785 768 // redirect URL
786 769 $show_message = false;
787 - $redirect_to = false;
770 + $redirect_to = false;
771 +
788 772 if ( $form_settings['redirect_to'] == 'page' ) {
789 773 $redirect_to = get_permalink( $form_settings['page_id'] );
790 774 } elseif ( $form_settings['redirect_to'] == 'url' ) {
791 775 $redirect_to = $form_settings['url'];
@@ -793,11 +777,17 @@
793 777 $show_message = true;
794 778 } else {
795 779 $show_message = true;
796 780 }
781 +
782 + // Fire a hook for integration
783 + do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
784 +
797 785 $field_search = $field_replace = [];
786 +
798 787 foreach ( $form_fields as $r_field ) {
799 788 $field_search[] = '{' . $r_field['name'] . '}';
789 +
800 790 if ( $r_field['template'] == 'name_field' ) {
801 791 $field_replace[] = implode( ' ', explode( '|', $entry_fields[ $r_field['name'] ] ) );
802 792 } else if ( $r_field['template'] == 'address_field' ) {
803 793 $field_replace[] = implode( ', ', $entry_fields[ $r_field['name'] ] );
@@ -805,59 +795,68 @@
805 795 $field_replace[] = isset( $entry_fields[ $r_field['name'] ] ) ? $entry_fields[ $r_field['name'] ] : '';
806 796 }
807 797 }
808 798 $message = str_replace( $field_search, $field_replace, $form_settings['message'] );
799 +
809 800 // send the response
810 801 $response = apply_filters( 'weforms_entry_submission_response', [
811 - 'success' => true,
812 - 'redirect_to' => $redirect_to,
802 + 'success' => true,
803 + 'redirect_to' => $redirect_to,
813 804 '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,
805 + 'message' => $message,
806 + 'data' => $_POST,
807 + 'form_id' => $form_id,
808 + 'entry_id' => $entry_id,
819 809 ] );
810 +
811 + $notification = new WeForms_Notification( [
812 + 'form_id' => $form_id,
813 + 'page_id' => $page_id,
814 + 'entry_id' => $entry_id,
815 + ] );
816 +
817 + $notification->send_notifications();
818 +
820 819 weforms_clear_buffer();
821 820 wp_send_json( $response );
822 - }
821 + }
823 822
824 - function validate_reCaptchav3( $secret ) {
825 - check_ajax_referer( 'wpuf_form_add' );
823 + function validate_reCaptchav3( $secret ) {
824 + check_ajax_referer( 'wpuf_form_add' );
826 825
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' );
826 + $post_data = wp_unslash($_POST);
827 + $token = $post_data['g-recaptcha-response'];
828 + $action = $post_data['g-action'];
829 + $google_captcha_url = esc_url( 'https://www.google.com/recaptcha/api/siteverify' );
831 830
832 - $response = wp_remote_post( $google_captcha_url,
833 - array(
834 - 'method' => 'POST',
835 - 'body' => array(
836 - 'secret' => $secret,
837 - 'response' => $token
838 - )
831 + $response = wp_remote_post( $google_captcha_url,
832 + array(
833 + 'method' => 'POST',
834 + 'body' => array(
835 + 'secret' => $secret,
836 + 'response' => $token
839 837 )
840 - );
838 + )
839 + );
841 840
842 841
843 - if ( is_wp_error( $response ) ) {
842 + if ( is_wp_error( $response ) ) {
843 + wp_send_json( [
844 + 'success' => false,
845 + 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
846 + ] );
847 + } else {
848 + $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
849 + if( $api_response["success"] == '1' && $api_response["action"] == $action ) {
850 + return true;
851 + } else {
844 852 wp_send_json( [
845 853 'success' => false,
846 854 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
847 855 ] );
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 856 }
859 857 }
858 + }
860 859 /**
861 860 * reCaptcha Validation
862 861 *
863 862 * @return void