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