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 -67 1.6.141.6.1 View file →
@@ -109,10 +109,8 @@
109 109 $integrations = array();
110 110
111 111 if ( isset( $post_data['settings'] ) ) {
112 112 $settings = (array) json_decode( $post_data['settings'] );
113 - $settings['message'] = sanitize_text_field( $settings['message'] );
114 - error_log(print_r($settings, true));
115 113 } else {
116 114 $settings = isset( $form_data['wpuf_settings'] ) ? $form_data['wpuf_settings'] : [];
117 115 }
118 116
@@ -119,8 +117,11 @@
119 117 if ( isset( $post_data['integrations'] ) ) {
120 118 $integrations = (array) json_decode( $post_data['integrations'] );
121 119 }
122 120
121 + // $form_fields = wp_unslash( $form_fields );
122 + // $notifications = wp_unslash( $notifications );
123 +
123 124 $form_fields = json_decode( $form_fields, true );
124 125 $notifications = json_decode( $notifications, true );
125 126 $data = [
126 127 'form_id' => absint( $form_data['wpuf_form_id'] ),
@@ -133,14 +134,8 @@
133 134 ];
134 135
135 136 $form_fields = weforms()->form->save( $data );
136 137
137 - // Update Old Entry meta_key if changed
138 - $form_id = $form_data['wpuf_form_id'];
139 - $form = weforms()->form->get( $form_id );
140 -
141 - $form->maybe_update_entries( $form_fields );
142 -
143 138 do_action( 'weforms_update_form', $form_data['wpuf_form_id'], $form_fields, $settings );
144 139
145 140 wp_send_json_success( [ 'form_fields' => $form_fields ] );
146 141 }
@@ -529,9 +524,9 @@
529 524
530 525 $has_empty = false;
531 526 $answers = [];
532 527 $respondentPoints = isset( $form_settings['total_points'] ) ? floatval( $form_settings['total_points'] ) : 0;
533 - $fields_formatted = array();
528 +
534 529 foreach ( $fields as $key => $field ) {
535 530 if ( $form_settings['quiz_form'] == 'yes' ) {
536 531 $selectedAnswers = isset( $field['selected_answers'] ) ? $field['selected_answers'] : '';
537 532 $givenAnswer = isset( $field['value'] ) ? $field['value'] : '';
@@ -540,8 +535,9 @@
540 535 $fieldPoints = isset( $field['points'] ) ? floatval( $field['points'] ) : 0;
541 536
542 537 if ( $template == 'radio_field' || $template == 'dropdown_field' ) {
543 538 $answers[$field['name']] = true;
539 +
544 540 if ( empty( $givenAnswer ) ) {
545 541 $answers[$field['name']] = false;
546 542 $respondentPoints -= $fieldPoints;
547 543 } else {
@@ -576,15 +572,13 @@
576 572 }
577 573 } elseif ( empty( $field['value'] ) ) {
578 574 $has_empty = true;
579 575 break;
580 - } else {
581 - $field = WeForms_Form_Entry_Manager::format_entry_value( $field );
582 - array_push( $fields_formatted, $field );
583 576 }
584 577 }
578 +
585 579 $response = [
586 - 'form_fields' => $fields_formatted,
580 + 'form_fields' => $fields,
587 581 'form_settings' => $form_settings,
588 582 'meta_data' => $metadata,
589 583 'payment_data' => $payment,
590 584 'has_empty' => $has_empty,
@@ -591,9 +585,8 @@
591 585 'respondent_points' => $respondentPoints,
592 586 'answers' => $answers,
593 587 ];
594 588
595 -
596 589 wp_send_json_success( $response );
597 590 }
598 591
599 592 /**
@@ -762,32 +755,23 @@
762 755 $this->validate_submission( $entry_fields, $form, $form_settings, $form_fields );
763 756
764 757 $entry_fields = apply_filters( 'weforms_before_entry_submission', $entry_fields, $form, $form_settings, $form_fields );
765 758
766 - $entry_id = 1;
767 - $global_settings = weforms_get_settings();
768 - if ( empty( $form_settings['after_submission'] ) ) {
769 - $entry_id = weforms_insert_entry( [
770 - 'form_id' => $form_id,
771 - ], $entry_fields );
772 - if ( is_wp_error( $entry_id ) ) {
773 - wp_send_json( [
774 - 'success' => false,
775 - 'error' => $entry_id->get_error_message(),
776 - ] );
777 - }
778 - // Fire a hook for integration
779 - do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
780 - $notification = new WeForms_Notification( [
781 - 'form_id' => $form_id,
782 - 'page_id' => $page_id,
783 - '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(),
784 767 ] );
785 - $notification->send_notifications();
786 768 }
769 +
787 770 // redirect URL
788 771 $show_message = false;
789 - $redirect_to = false;
772 + $redirect_to = false;
773 +
790 774 if ( $form_settings['redirect_to'] == 'page' ) {
791 775 $redirect_to = get_permalink( $form_settings['page_id'] );
792 776 } elseif ( $form_settings['redirect_to'] == 'url' ) {
793 777 $redirect_to = $form_settings['url'];
@@ -795,11 +779,17 @@
795 779 $show_message = true;
796 780 } else {
797 781 $show_message = true;
798 782 }
783 +
784 + // Fire a hook for integration
785 + do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
786 +
799 787 $field_search = $field_replace = [];
788 +
800 789 foreach ( $form_fields as $r_field ) {
801 790 $field_search[] = '{' . $r_field['name'] . '}';
791 +
802 792 if ( $r_field['template'] == 'name_field' ) {
803 793 $field_replace[] = implode( ' ', explode( '|', $entry_fields[ $r_field['name'] ] ) );
804 794 } else if ( $r_field['template'] == 'address_field' ) {
805 795 $field_replace[] = implode( ', ', $entry_fields[ $r_field['name'] ] );
@@ -807,59 +797,68 @@
807 797 $field_replace[] = isset( $entry_fields[ $r_field['name'] ] ) ? $entry_fields[ $r_field['name'] ] : '';
808 798 }
809 799 }
810 800 $message = str_replace( $field_search, $field_replace, $form_settings['message'] );
801 +
811 802 // send the response
812 803 $response = apply_filters( 'weforms_entry_submission_response', [
813 - 'success' => true,
814 - 'redirect_to' => $redirect_to,
804 + 'success' => true,
805 + 'redirect_to' => $redirect_to,
815 806 'show_message' => $show_message,
816 - 'message' => $message,
817 - 'data' => $_POST,
818 - 'form_id' => $form_id,
819 - 'entry_id' => $entry_id,
820 - 'entry_fields' =>$entry_fields,
807 + 'message' => $message,
808 + 'data' => $_POST,
809 + 'form_id' => $form_id,
810 + 'entry_id' => $entry_id,
821 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 +
822 821 weforms_clear_buffer();
823 822 wp_send_json( $response );
824 - }
823 + }
825 824
826 - function validate_reCaptchav3( $secret ) {
827 - check_ajax_referer( 'wpuf_form_add' );
825 + function validate_reCaptchav3( $secret ) {
826 + check_ajax_referer( 'wpuf_form_add' );
828 827
829 - $post_data = wp_unslash($_POST);
830 - $token = $post_data['g-recaptcha-response'];
831 - $action = $post_data['g-action'];
832 - $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' );
833 832
834 - $response = wp_remote_post( $google_captcha_url,
835 - array(
836 - 'method' => 'POST',
837 - 'body' => array(
838 - 'secret' => $secret,
839 - 'response' => $token
840 - )
833 + $response = wp_remote_post( $google_captcha_url,
834 + array(
835 + 'method' => 'POST',
836 + 'body' => array(
837 + 'secret' => $secret,
838 + 'response' => $token
841 839 )
842 - );
840 + )
841 + );
843 842
844 843
845 - 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 {
846 854 wp_send_json( [
847 855 'success' => false,
848 856 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
849 857 ] );
850 - } else {
851 - $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
852 - if( $api_response["success"] == '1' && $api_response["action"] == $action ) {
853 - return true;
854 - } else {
855 - wp_send_json( [
856 - 'success' => false,
857 - 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
858 - ] );
859 - }
860 858 }
861 859 }
860 + }
862 861 /**
863 862 * reCaptcha Validation
864 863 *
865 864 * @return void