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 +26 -44 1.6.191.6.9 View file →
@@ -108,12 +108,9 @@
108 108 $settings = array();
109 109 $integrations = array();
110 110
111 111 if ( isset( $post_data['settings'] ) ) {
112 - $settings = json_decode( $post_data['settings'], true );
113 - $settings['message'] = sanitize_text_field( $settings['message'] );
114 - $settings['url'] = sanitize_url( $settings['url'] );
115 - $settings['limit_message'] = sanitize_text_field( $settings['limit_message'] );
112 + $settings = (array) json_decode( $post_data['settings'] );
116 113 } else {
117 114 $settings = isset( $form_data['wpuf_settings'] ) ? $form_data['wpuf_settings'] : [];
118 115 }
119 116
@@ -137,19 +134,14 @@
137 134
138 135 // Update Old Entry meta_key if changed
139 136 $form_id = $form_data['wpuf_form_id'];
140 137 $form = weforms()->form->get( $form_id );
141 -
138 +
142 139 $form->maybe_update_entries( $form_fields );
143 140
144 141 do_action( 'weforms_update_form', $form_data['wpuf_form_id'], $form_fields, $settings );
145 142
146 - wp_send_json_success(
147 - array(
148 - 'form_fields' => $form_fields,
149 - 'settings' => $settings,
150 - )
151 - );
143 + wp_send_json_success( [ 'form_fields' => $form_fields ] );
152 144 }
153 145
154 146 /**
155 147 * Get all contact forms
@@ -535,9 +527,9 @@
535 527
536 528 $has_empty = false;
537 529 $answers = [];
538 530 $respondentPoints = isset( $form_settings['total_points'] ) ? floatval( $form_settings['total_points'] ) : 0;
539 - $fields_formatted = array();
531 +
540 532 foreach ( $fields as $key => $field ) {
541 533 if ( $form_settings['quiz_form'] == 'yes' ) {
542 534 $selectedAnswers = isset( $field['selected_answers'] ) ? $field['selected_answers'] : '';
543 535 $givenAnswer = isset( $field['value'] ) ? $field['value'] : '';
@@ -546,8 +538,9 @@
546 538 $fieldPoints = isset( $field['points'] ) ? floatval( $field['points'] ) : 0;
547 539
548 540 if ( $template == 'radio_field' || $template == 'dropdown_field' ) {
549 541 $answers[$field['name']] = true;
542 +
550 543 if ( empty( $givenAnswer ) ) {
551 544 $answers[$field['name']] = false;
552 545 $respondentPoints -= $fieldPoints;
553 546 } else {
@@ -581,16 +574,14 @@
581 574 }
582 575 }
583 576 } elseif ( empty( $field['value'] ) ) {
584 577 $has_empty = true;
585 - continue;
586 - } else {
587 - $field = WeForms_Form_Entry_Manager::format_entry_value( $field );
588 - array_push( $fields_formatted, $field );
578 + break;
589 579 }
590 580 }
581 +
591 582 $response = [
592 - 'form_fields' => $fields_formatted,
583 + 'form_fields' => $fields,
593 584 'form_settings' => $form_settings,
594 585 'meta_data' => $metadata,
595 586 'payment_data' => $payment,
596 587 'has_empty' => $has_empty,
@@ -597,9 +588,8 @@
597 588 'respondent_points' => $respondentPoints,
598 589 'answers' => $answers,
599 590 ];
600 591
601 -
602 592 wp_send_json_success( $response );
603 593 }
604 594
605 595 /**
@@ -708,8 +698,9 @@
708 698 * @return void
709 699 */
710 700 public function handle_frontend_submission() {
711 701 check_ajax_referer( 'wpuf_form_add' );
702 +
712 703 $form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0;
713 704 $page_id = isset( $_POST['page_id'] ) ? intval( $_POST['page_id'] ) : 0;
714 705
715 706 $form = weforms()->form->get( $form_id );
@@ -767,37 +758,29 @@
767 758 $this->validate_submission( $entry_fields, $form, $form_settings, $form_fields );
768 759
769 760 $entry_fields = apply_filters( 'weforms_before_entry_submission', $entry_fields, $form, $form_settings, $form_fields );
770 761
771 - //check for entry_fields for a return error
772 - if ( is_wp_error( $entry_fields ) ) {
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 );
768 + if ( is_wp_error( $entry_id ) ) {
773 769 wp_send_json( [
774 770 'success' => false,
775 - 'error' => $entry_fields->get_error_message(),
771 + 'error' => $entry_id->get_error_message(),
776 772 ] );
777 - } else {
778 - $entry_id = 1;
779 - $global_settings = weforms_get_settings();
780 - if ( empty( $form_settings['after_submission'] ) ) {
781 - $entry_id = weforms_insert_entry( [
782 - 'form_id' => $form_id,
783 - ], $entry_fields );
784 - if ( is_wp_error( $entry_id ) ) {
785 - wp_send_json( [
786 - 'success' => false,
787 - 'error' => $entry_id->get_error_message(),
788 - ] );
789 - }
790 - // Fire a hook for integration
791 - do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
792 - $notification = new WeForms_Notification( [
793 - 'form_id' => $form_id,
794 - 'page_id' => $page_id,
795 - 'entry_id' => $entry_id,
796 - ] );
797 - $notification->send_notifications();
798 - }
799 773 }
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 + }
800 783 // redirect URL
801 784 $show_message = false;
802 785 $redirect_to = false;
803 786 if ( $form_settings['redirect_to'] == 'page' ) {
@@ -831,9 +814,8 @@
831 814 'form_id' => $form_id,
832 815 'entry_id' => $entry_id,
833 816 'entry_fields' =>$entry_fields,
834 817 ] );
835 -
836 818 weforms_clear_buffer();
837 819 wp_send_json( $response );
838 820 }
839 821