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