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 +58 -49 1.6.81.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'] ),
@@ -752,14 +755,12 @@
752 755 $this->validate_submission( $entry_fields, $form, $form_settings, $form_fields );
753 756
754 757 $entry_fields = apply_filters( 'weforms_before_entry_submission', $entry_fields, $form, $form_settings, $form_fields );
755 758
756 - $entry_id = 1;
757 - $global_settings = weforms_get_settings();
758 - if ( empty( $global_settings['after_submission'] ) ) {
759 - $entry_id = weforms_insert_entry( [
760 - 'form_id' => $form_id,
761 - ], $entry_fields );
759 + $entry_id = weforms_insert_entry( [
760 + 'form_id' => $form_id,
761 + ], $entry_fields );
762 +
762 763 if ( is_wp_error( $entry_id ) ) {
763 764 wp_send_json( [
764 765 'success' => false,
765 766 'error' => $entry_id->get_error_message(),
@@ -764,20 +765,13 @@
764 765 'success' => false,
765 766 'error' => $entry_id->get_error_message(),
766 767 ] );
767 768 }
768 - // Fire a hook for integration
769 - do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
770 - $notification = new WeForms_Notification( [
771 - 'form_id' => $form_id,
772 - 'page_id' => $page_id,
773 - 'entry_id' => $entry_id,
774 - ] );
775 - $notification->send_notifications();
776 - }
769 +
777 770 // redirect URL
778 771 $show_message = false;
779 - $redirect_to = false;
772 + $redirect_to = false;
773 +
780 774 if ( $form_settings['redirect_to'] == 'page' ) {
781 775 $redirect_to = get_permalink( $form_settings['page_id'] );
782 776 } elseif ( $form_settings['redirect_to'] == 'url' ) {
783 777 $redirect_to = $form_settings['url'];
@@ -785,11 +779,17 @@
785 779 $show_message = true;
786 780 } else {
787 781 $show_message = true;
788 782 }
783 +
784 + // Fire a hook for integration
785 + do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
786 +
789 787 $field_search = $field_replace = [];
788 +
790 789 foreach ( $form_fields as $r_field ) {
791 790 $field_search[] = '{' . $r_field['name'] . '}';
791 +
792 792 if ( $r_field['template'] == 'name_field' ) {
793 793 $field_replace[] = implode( ' ', explode( '|', $entry_fields[ $r_field['name'] ] ) );
794 794 } else if ( $r_field['template'] == 'address_field' ) {
795 795 $field_replace[] = implode( ', ', $entry_fields[ $r_field['name'] ] );
@@ -797,59 +797,68 @@
797 797 $field_replace[] = isset( $entry_fields[ $r_field['name'] ] ) ? $entry_fields[ $r_field['name'] ] : '';
798 798 }
799 799 }
800 800 $message = str_replace( $field_search, $field_replace, $form_settings['message'] );
801 +
801 802 // send the response
802 803 $response = apply_filters( 'weforms_entry_submission_response', [
803 - 'success' => true,
804 - 'redirect_to' => $redirect_to,
804 + 'success' => true,
805 + 'redirect_to' => $redirect_to,
805 806 'show_message' => $show_message,
806 - 'message' => $message,
807 - 'data' => $_POST,
808 - 'form_id' => $form_id,
809 - 'entry_id' => $entry_id,
810 - 'entry_fields' =>$entry_fields,
807 + 'message' => $message,
808 + 'data' => $_POST,
809 + 'form_id' => $form_id,
810 + 'entry_id' => $entry_id,
811 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 +
812 821 weforms_clear_buffer();
813 822 wp_send_json( $response );
814 - }
823 + }
815 824
816 - function validate_reCaptchav3( $secret ) {
817 - check_ajax_referer( 'wpuf_form_add' );
825 + function validate_reCaptchav3( $secret ) {
826 + check_ajax_referer( 'wpuf_form_add' );
818 827
819 - $post_data = wp_unslash($_POST);
820 - $token = $post_data['g-recaptcha-response'];
821 - $action = $post_data['g-action'];
822 - $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' );
823 832
824 - $response = wp_remote_post( $google_captcha_url,
825 - array(
826 - 'method' => 'POST',
827 - 'body' => array(
828 - 'secret' => $secret,
829 - 'response' => $token
830 - )
833 + $response = wp_remote_post( $google_captcha_url,
834 + array(
835 + 'method' => 'POST',
836 + 'body' => array(
837 + 'secret' => $secret,
838 + 'response' => $token
831 839 )
832 - );
840 + )
841 + );
833 842
834 843
835 - 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 {
836 854 wp_send_json( [
837 855 'success' => false,
838 856 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
839 857 ] );
840 - } else {
841 - $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
842 - if( $api_response["success"] == '1' && $api_response["action"] == $action ) {
843 - return true;
844 - } else {
845 - wp_send_json( [
846 - 'success' => false,
847 - 'error' => __( 'reCAPTCHA validation failed', 'weforms' ),
848 - ] );
849 - }
850 858 }
851 859 }
860 + }
852 861 /**
853 862 * reCaptcha Validation
854 863 *
855 864 * @return void