PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.1.1
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.1.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
weforms / includes / class-ajax.php

class-ajax.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.1.1, at includes/class-ajax.php

770 lines 24.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The ajax handler class
5 */
6 class WeForms_Ajax {
7
8 public function __construct() {
9
10 // backend requests
11 add_action( 'wp_ajax_weforms_form_list', array( $this, 'get_contact_forms' ) );
12 add_action( 'wp_ajax_weforms_form_names', array( $this, 'get_contact_form_names' ) );
13 add_action( 'wp_ajax_weforms_form_create', array( $this, 'create_form' ) );
14 add_action( 'wp_ajax_weforms_form_delete', array( $this, 'delete_form' ) );
15 add_action( 'wp_ajax_weforms_form_delete_bulk', array( $this, 'delete_form_bulk' ) );
16 add_action( 'wp_ajax_weforms_form_duplicate', array( $this, 'duplicate_form' ) );
17
18 // create from a template
19 add_filter( 'wp_ajax_weforms_contact_form_template', array( $this, 'create_form_from_template' ) );
20
21 // form settings
22 add_action( 'wp_ajax_weforms_save_settings', array( $this, 'save_settings' ) );
23 add_action( 'wp_ajax_weforms_get_settings', array( $this, 'get_settings' ) );
24
25 // import
26 add_action( 'wp_ajax_weforms_import_form', array( $this, 'import_form' ) );
27
28 // form editing
29 add_action( 'wp_ajax_weforms_get_form', array( $this, 'get_form' ) );
30 add_action( 'wp_ajax_wpuf_form_builder_save_form', array( $this, 'save_form' ) );
31
32 // entries
33 add_action( 'wp_ajax_weforms_form_entries', array( $this, 'get_entries' ) );
34 add_action( 'wp_ajax_weforms_form_entry_details', array( $this, 'get_entry_detail' ) );
35 add_action( 'wp_ajax_weforms_form_entry_trash', array( $this, 'trash_entry' ) );
36 add_action( 'wp_ajax_weforms_form_entry_trash_bulk', array( $this, 'bulk_delete_entry' ) );
37
38 // frontend requests
39 add_action( 'wp_ajax_weforms_frontend_submit', array( $this, 'handle_frontend_submission' ) );
40 add_action( 'wp_ajax_nopriv_weforms_frontend_submit', array( $this, 'handle_frontend_submission' ) );
41 }
42
43 /**
44 * Administrator validation
45 *
46 * @return void
47 */
48 public function check_admin() {
49 if ( !current_user_can( weforms_form_access_capability() ) ) {
50 wp_send_json_error( __( 'You do not have sufficient permission.', 'weforms' ) );
51 }
52 }
53
54 /**
55 * Get a form to edit
56 *
57 * @return void
58 */
59 public function get_form() {
60
61 $this->check_admin();
62
63 $form_id = isset( $_REQUEST['form_id'] ) ? absint( $_REQUEST['form_id'] ) : 0;
64
65 $form = weforms()->form->get( $form_id );
66
67 $data = array(
68 'post' => $form->data,
69 'form_fields' => $form->get_fields(),
70 'settings' => $form->get_settings(),
71 'notifications' => $form->get_notifications(),
72 'integrations' => $form->get_integrations()
73 );
74
75 wp_send_json_success( $data );
76 }
77
78 /**
79 * Save the form
80 *
81 * @return void
82 */
83 public function save_form() {
84 parse_str( $_POST['form_data'], $form_data );
85
86 if ( ! wp_verify_nonce( $form_data['wpuf_form_builder_nonce'], 'wpuf_form_builder_save_form' ) ) {
87 wp_send_json_error( __( 'Unauthorized operation', 'wpuf' ) );
88 }
89
90 if ( empty( $form_data['wpuf_form_id'] ) ) {
91 wp_send_json_error( __( 'Invalid form id', 'wpuf' ) );
92 }
93
94 $form_fields = isset( $_POST['form_fields'] ) ? $_POST['form_fields'] : '';
95 $notifications = isset( $_POST['notifications'] ) ? $_POST['notifications'] : '';
96 $settings = array();
97 $integrations = array();
98
99 if ( isset( $_POST['settings'] ) ) {
100 $settings = (array) json_decode( wp_unslash( $_POST['settings'] ) );
101 } else {
102 $settings = isset( $form_data['wpuf_settings'] ) ? $form_data['wpuf_settings'] : array();
103 }
104
105 if ( isset( $_POST['integrations'] ) ) {
106 $integrations = (array) json_decode( wp_unslash( $_POST['integrations'] ) );
107 }
108
109 $form_fields = wp_unslash( $form_fields );
110 $notifications = wp_unslash( $notifications );
111
112 $form_fields = json_decode( $form_fields, true );
113 $notifications = json_decode( $notifications, true );
114
115 $data = array(
116 'form_id' => absint( $form_data['wpuf_form_id'] ),
117 'post_title' => sanitize_text_field( $form_data['post_title'] ),
118 'form_fields' => $form_fields,
119 'form_settings' => $settings,
120 'form_settings_key' => isset( $form_data['form_settings_key'] ) ? $form_data['form_settings_key'] : '',
121 'notifications' => $notifications,
122 'integrations' => $integrations
123 );
124
125 $form_fields = weforms()->form->save( $data );
126
127 wp_send_json_success( array( 'form_fields' => $form_fields ) );
128 }
129
130 /**
131 * Get all contact forms
132 *
133 * @return void
134 */
135 public function get_contact_forms() {
136 check_ajax_referer( 'weforms' );
137
138 $this->check_admin();
139
140 $args = array(
141 'posts_per_page' => 10,
142 'paged' => isset( $_POST['page'] ) ? absint( $_POST['page'] ) : 1,
143 'order' => 'DESC',
144 'orderby' => 'post_date'
145 );
146
147 $contact_forms = weforms()->form->get_forms( $args );
148
149 array_map( function($form) {
150 $form->entries = $form->num_form_entries();
151 $form->views = $form->num_form_views();
152 }, $contact_forms['forms'] );
153
154 $contact_forms = apply_filters( 'weforms_ajax_get_contact_forms', $contact_forms );
155
156 wp_send_json_success( $contact_forms );
157 }
158
159 /**
160 * Get the names of contact forms for generating dropdown
161 *
162 * @return void
163 */
164 public function get_contact_form_names() {
165 check_ajax_referer( 'weforms' );
166
167 $this->check_admin();
168
169 $contact_forms = weforms()->form->all();
170 $response = array();
171
172 foreach ($contact_forms['forms'] as $form) {
173 $response[] = array(
174 'id' => $form->get_id(),
175 'title' => $form->get_name() . ' (#' . $form->get_id() . ')'
176 );
177 }
178
179 wp_send_json_success( $response );
180 }
181
182 /**
183 * Create a form
184 *
185 * @return void
186 */
187 public function create_form() {
188 check_ajax_referer( 'weforms' );
189
190 $this->check_admin();
191
192 $form_name = isset( $_POST['form_name'] ) ? sanitize_text_field( $_POST['form_name'] ) : '';
193
194 if ( empty( $form_name ) ) {
195 wp_send_json_error( __( 'Please provide a form name', 'weforms' ) );
196 }
197
198 $form_id = weforms()->form->create( $form_name );
199
200 if ( is_wp_error( $form_id )) {
201 wp_send_json_error( $form_id->get_error_message() );
202 }
203
204 wp_send_json_success( array(
205 'form_id' => $form_id,
206 'form_name' => $form_name
207 ) );
208 }
209
210 /**
211 * Delete a form
212 *
213 * @return void
214 */
215 public function delete_form() {
216 check_ajax_referer( 'weforms' );
217
218 $this->check_admin();
219
220 $form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0;
221
222 if ( ! $form_id ) {
223 wp_send_json_error( __( 'No form id provided!', 'weforms' ) );
224 }
225
226 weforms()->form->delete( $form_id );
227
228 wp_send_json_success();
229 }
230
231 public function delete_form_bulk() {
232 check_ajax_referer( 'weforms' );
233
234 $this->check_admin();
235
236 $form_ids = isset( $_POST['ids'] ) ? array_map( 'absint', $_POST['ids'] ) : array();
237
238 if ( ! $form_ids ) {
239 wp_send_json_error( __( 'No form ids provided!', 'weforms' ) );
240 }
241
242 foreach ($form_ids as $form_id) {
243 weforms()->form->delete( $form_id );
244 }
245
246 wp_send_json_success();
247 }
248
249 /**
250 * Duplicate a form
251 *
252 * @return voiud
253 */
254 public function duplicate_form() {
255 check_ajax_referer( 'weforms' );
256
257 $this->check_admin();
258
259 $form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0;
260
261 $form = weforms()->form->duplicate( $form_id );
262
263 wp_send_json_success( $form );
264 }
265
266 /**
267 * Create form from a template
268 *
269 * @return void
270 */
271 public function create_form_from_template() {
272 check_ajax_referer( 'weforms' );
273
274 $template = isset( $_REQUEST['template'] ) ? sanitize_text_field( $_REQUEST['template'] ) : '';
275
276 $form_id = weforms()->templates->create( $template );
277
278 if ( is_wp_error( $form_id ) ) {
279 wp_send_json_error( __( 'Could not create the form', 'weforms' ) );
280 }
281
282 wp_send_json_success( array(
283 'id' => $form_id
284 ) );
285 }
286
287 /**
288 * Save the weForms settings
289 *
290 * @return void
291 */
292 public function save_settings() {
293 check_ajax_referer( 'weforms' );
294
295 $this->check_admin();
296
297 $requires_wpuf_update = false;
298 $wpuf_update_array = array();
299 $settings = (array) json_decode( wp_unslash( $_POST['settings'] ) );
300
301 update_option( 'weforms_settings', $settings );
302
303 // wpuf settings sync
304 if ( isset( $settings['gmap_api'] ) ) {
305 $requires_wpuf_update = true;
306 $wpuf_update_array['gmap_api_key'] = $settings['gmap_api'];
307 }
308
309 if ( isset( $settings['recaptcha'] ) ) {
310 $requires_wpuf_update = true;
311 $wpuf_update_array['recaptcha_public'] = $settings['recaptcha']->key;
312 $wpuf_update_array['recaptcha_private'] = $settings['recaptcha']->secret;
313 }
314
315 if ( $requires_wpuf_update ) {
316 $wpuf_settings = get_option( 'wpuf_general', array() );
317
318 $wpuf_settings = array_merge( $wpuf_settings, $wpuf_update_array );
319 update_option( 'wpuf_general', $wpuf_settings );
320 }
321
322 do_action( 'weforms_save_settings', $settings );
323
324 wp_send_json_success( $settings );
325 }
326
327 /**
328 * Get the weForms Settings
329 *
330 * @return void
331 */
332 public function get_settings() {
333 check_ajax_referer( 'weforms' );
334
335 $this->check_admin();
336
337 $settings = weforms_get_settings();
338
339 // checking to prevent js error, will be removed in future
340 if ( ! isset( $settings['credit'] ) ) {
341 $settings['credit'] = false;
342 }
343
344 if ( ! isset( $settings['permission'] ) ) {
345 $settings['permission'] = 'manage_options';
346 }
347
348 wp_send_json_success( $settings );
349 }
350
351 /**
352 * Get all entries
353 *
354 * @return void
355 */
356 public function get_entries() {
357 check_ajax_referer( 'weforms' );
358
359 $this->check_admin();
360
361 $form_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
362 $current_page = isset( $_REQUEST['page'] ) ? intval( $_REQUEST['page'] ) : 1;
363 $per_page = 20;
364 $offset = ( $current_page - 1 ) * $per_page;
365
366 if ( ! $form_id ) {
367 wp_send_json_error( __( 'No form id provided!', 'weforms' ) );
368 }
369
370 $entries = weforms_get_form_entries( $form_id, array(
371 'number' => $per_page,
372 'offset' => $offset
373 ) );
374
375 $columns = weforms_get_entry_columns( $form_id );
376 $total_entries = weforms_count_form_entries( $form_id );
377
378 array_map( function( $entry ) use ($columns) {
379 $entry_id = $entry->id;
380 $entry->fields = array();
381
382 foreach ($columns as $meta_key => $label) {
383 $value = weforms_get_entry_meta( $entry_id, $meta_key, true );
384 $entry->fields[$meta_key] = str_replace( WeForms::$field_separator, ' ', $value );
385 }
386 }, $entries );
387
388 $entries = apply_filters('weforms_get_entries', $entries, $form_id );
389
390 $response = array(
391 'columns' => $columns,
392 'entries' => $entries,
393 'form_title' => get_post_field( 'post_title', $form_id ),
394 'pagination' => array(
395 'total' => $total_entries,
396 'per_page' => $per_page,
397 'pages' => ceil( $total_entries / $per_page ),
398 'current' => $current_page
399 )
400 );
401
402 wp_send_json_success( $response );
403 }
404
405 /**
406 * Get an entry details
407 *
408 * @return void
409 */
410 public function get_entry_detail() {
411 check_ajax_referer( 'weforms' );
412
413 $this->check_admin();
414
415 $form_id = isset( $_REQUEST['form_id'] ) ? intval( $_REQUEST['form_id'] ) : 0;
416 $entry_id = isset( $_REQUEST['entry_id'] ) ? intval( $_REQUEST['entry_id'] ) : 0;
417
418 $form = weforms()->form->get( $form_id );
419 $entry = $form->entries()->get( $entry_id );
420 $fields = $entry->get_fields();
421 $metadata = $entry->get_metadata();
422
423 if ( false === $data ) {
424 wp_send_json_error( __( 'No form fields found!', 'weforms' ) );
425 }
426
427 $response = array(
428 'form_fields' => $fields,
429 'meta_data' => $metadata
430 );
431
432 wp_send_json_success( $response );
433 }
434
435 /**
436 * Trash an entry
437 *
438 * @return void
439 */
440 public function trash_entry() {
441 check_ajax_referer( 'weforms' );
442
443 $this->check_admin();
444
445 $entry_id = isset( $_REQUEST['entry_id'] ) ? intval( $_REQUEST['entry_id'] ) : 0;
446
447 weforms_change_entry_status( $entry_id, 'trash' );
448 wp_send_json_success();
449 }
450
451 /**
452 * Bulk trash entries
453 *
454 * @return void
455 */
456 public function bulk_delete_entry() {
457 check_ajax_referer( 'weforms' );
458
459 $this->check_admin();
460
461 $entry_ids = isset( $_POST['ids'] ) ? array_map( 'absint', $_POST['ids'] ) : array();
462
463 if ( ! $entry_ids ) {
464 wp_send_json_error( __( 'No entry ids provided!', 'weforms' ) );
465 }
466
467 foreach ($entry_ids as $entry_id) {
468 weforms_change_entry_status( $entry_id, 'trash' );
469 }
470
471 wp_send_json_success();
472 }
473
474 /**
475 * Handle the frontend submission
476 *
477 * @return void
478 */
479 public function handle_frontend_submission() {
480 check_ajax_referer( 'wpuf_form_add' );
481
482 $form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0;
483 $page_id = isset( $_POST['page_id'] ) ? intval( $_POST['page_id'] ) : 0;
484
485 $form = weforms()->form->get( $form_id );
486 $form_fields = $form->get_fields();
487 $entry_fields = $form->prepare_entries();
488 $form_settings = $form->get_settings();
489
490 if ( !$form_fields ) {
491 wp_send_json( array(
492 'success' => false,
493 'error' => __( 'No form field was found.', 'weforms' ),
494 ) );
495 }
496
497 if ( $form->has_field( 'recaptcha' ) ) {
498 $this->validate_reCaptcha();
499 }
500
501 $entry_id = weforms_insert_entry( array(
502 'form_id' => $form_id
503 ), $entry_fields );
504
505 if ( is_wp_error( $entry_id ) ) {
506 wp_send_json( array(
507 'success' => false,
508 'error' => $entry_id->get_error_message(),
509 ) );
510 }
511
512 // redirect URL
513 $show_message = false;
514 $redirect_to = false;
515
516 if ( $form_settings['redirect_to'] == 'page' ) {
517 $redirect_to = get_permalink( $form_settings['page_id'] );
518 } elseif ( $form_settings['redirect_to'] == 'url' ) {
519 $redirect_to = $form_settings['url'];
520 } elseif ( $form_settings['redirect_to'] == 'same' ) {
521 $show_message = true;
522 } else {
523 $redirect_to = get_permalink( $post_id );
524 }
525
526 // Fire a hook for integration
527 do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings );
528
529 // send the response
530 $response = array(
531 'success' => true,
532 'redirect_to' => $redirect_to,
533 'show_message' => $show_message,
534 'message' => $form_settings['message'],
535 'data' => $_POST
536 );
537
538 $notification = new WeForms_Notification( array(
539 'form_id' => $form_id,
540 'page_id' => $page_id,
541 'entry_id' => $entry_id
542 ) );
543
544 $notification->send_notifications();
545
546 weforms_clear_buffer();
547 wp_send_json( $response );
548 }
549
550 /**
551 * reCaptcha Validation
552 *
553 * @return void
554 */
555 function validate_reCaptcha() {
556
557 // add reCaptcha library if not found
558 if ( !function_exists( 'recaptcha_get_html' ) ) {
559 require_once WEFORMS_INCLUDES . '/library/reCaptcha/recaptchalib.php';
560 require_once WEFORMS_INCLUDES . '/library/reCaptcha/recaptchalib_noCaptcha.php';
561 }
562
563
564 $invisible = isset( $_POST["g-recaptcha-response"] ) ? false : true;
565
566 $recaptcha_settings = weforms_get_settings( 'recaptcha' );
567 $secret = isset( $recaptcha_settings->secret ) ? $recaptcha_settings->secret : '';
568
569 if ( ! $invisible ) {
570
571 $response = null;
572 $reCaptcha = new ReCaptcha($secret);
573
574 $resp = $reCaptcha->verifyResponse(
575 $_SERVER["REMOTE_ADDR"],
576 $_POST["g-recaptcha-response"]
577 );
578
579 if ( !$resp->success ) {
580 wp_send_json( array(
581 'success' => false,
582 'error' => __( 'reCAPTCHA validation failed', 'wpuf' ),
583 ) );
584 }
585
586 } else {
587
588 $recap_challenge = isset( $_POST['recaptcha_challenge_field'] ) ? $_POST['recaptcha_challenge_field'] : '';
589 $recap_response = isset( $_POST['recaptcha_response_field'] ) ? $_POST['recaptcha_response_field'] : '';
590
591 $resp = recaptcha_check_answer( $secret, $_SERVER["REMOTE_ADDR"], $recap_challenge, $recap_response );
592
593 if ( !$resp->is_valid ) {
594 wp_send_json( array(
595 'success' => false,
596 'error' => __( 'reCAPTCHA validation failed', 'wpuf' ),
597 ) );
598 }
599 }
600
601 }
602
603 public static function prepare_meta_fields( $meta_vars ) {
604 // loop through custom fields
605 // skip files, put in a key => value paired array for later executation
606 // process repeatable fields separately
607 // if the input is array type, implode with separator in a field
608
609 $files = array();
610 $meta_key_value = array();
611 $multi_repeated = array(); //multi repeated fields will in sotre duplicated meta key
612
613 foreach ($meta_vars as $key => $value) {
614
615 switch ( $value['template'] ) {
616
617 // put files in a separate array, we'll process it later
618 case 'file_upload':
619 case 'image_upload':
620
621 $files[] = array(
622 'name' => $value['name'],
623 'value' => isset( $_POST['wpuf_files'][$value['name']] ) ? $_POST['wpuf_files'][$value['name']] : array(),
624 'count' => $value['count']
625 );
626 break;
627
628 case 'repeat_field':
629
630 // if it is a multi column repeat field
631 if ( isset( $value['multiple'] ) && $value['multiple'] == 'true' ) {
632
633 // if there's any items in the array, process it
634 if ( $_POST[$value['name']] ) {
635
636 $ref_arr = array();
637 $cols = count( $value['columns'] );
638 $first = array_shift( array_values( $_POST[$value['name']] ) ); //first element
639 $rows = count( $first );
640
641 // loop through columns
642 for ($i = 0; $i < $rows; $i++) {
643
644 // loop through the rows and store in a temp array
645 $temp = array();
646 for ($j = 0; $j < $cols; $j++) {
647
648 $temp[] = $_POST[$value['name']][$j][$i];
649 }
650
651 // store all fields in a row with WeForms::$field_separator separated
652 $ref_arr[] = implode( WeForms::$field_separator, $temp );
653 }
654
655 // now, if we found anything in $ref_arr, store to $multi_repeated
656 if ( $ref_arr ) {
657 $multi_repeated[$value['name']] = array_slice( $ref_arr, 0, $rows );
658 }
659 }
660 } else {
661 $meta_key_value[$value['name']] = implode( WeForms::$field_separator, $_POST[$value['name']] );
662 }
663
664 break;
665
666 case 'address_field':
667
668 if ( isset( $_POST[ $value['name'] ] ) && is_array( $_POST[ $value['name'] ] ) ) {
669 foreach ( $_POST[ $value['name'] ] as $address_field => $field_value ) {
670 $meta_key_value[ $value['name'] ][ $address_field ] = sanitize_text_field( $field_value );
671 }
672 }
673
674 break;
675
676 case 'text_field':
677 case 'email_address':
678 case 'numeric_text_field':
679 case 'date_field':
680
681 $meta_key_value[$value['name']] = sanitize_text_field( trim( $_POST[$value['name']] ) );
682
683 break;
684
685 case 'textarea_field':
686
687 $meta_key_value[$value['name']] = wp_kses_post( $_POST[$value['name']] );
688
689 break;
690
691 case 'dropdown_field':
692 case 'radio_field':
693
694 $val = $_POST[$value['name']];
695 $meta_key_value[$value['name']] = isset( $value['options'][$val] ) ? $value['options'][$val] : '';
696 break;
697
698 case 'multiple_select':
699 case 'checkbox_field':
700
701 $val = ( is_array( $_POST[$value['name']] ) && $_POST[$value['name']] ) ? $_POST[$value['name']] : array();
702 $meta_key_value[$value['name']] = $val;
703
704 if ( $val ) {
705 $new_val = array();
706
707 foreach ($val as $option_key) {
708 $new_val[] = isset( $value['options'][$option_key] ) ? $value['options'][$option_key] : '';
709 }
710
711 $meta_key_value[$value['name']] = implode( WeForms::$field_separator, $new_val );
712 }
713 break;
714
715 default:
716 // if it's an array, implode with this->separator
717 if ( is_array( $_POST[$value['name']] ) ) {
718
719 $meta_key_value[$value['name']] = implode( WeForms::$field_separator, $_POST[$value['name']] );
720
721 } else {
722 $meta_key_value[$value['name']] = trim( $_POST[$value['name']] );
723 }
724
725 break;
726 }
727
728 } //end foreach
729
730 return array($meta_key_value, $multi_repeated, $files);
731 }
732
733 /**
734 * Import a form from a JSON file
735 *
736 * @return void
737 */
738 public function import_form() {
739 check_ajax_referer( 'weforms' );
740
741 $this->check_admin();
742
743 $the_file = isset( $_FILES['importFile'] ) ? $_FILES['importFile'] : false;
744
745 if ( ! $the_file ) {
746 wp_send_json_error( __( 'No file found to import.', 'weforms' ) );
747 }
748
749 $file_ext = pathinfo( $the_file['name'], PATHINFO_EXTENSION );
750
751 if ( ! class_exists( 'WeForms_Admin_Tools' ) ) {
752 require_once dirname( __FILE__ ) . '/admin/class-admin-tools.php';
753 }
754
755 if ( ( $file_ext == 'json' ) && ( $the_file['size'] < 500000 ) ) {
756
757 $status = WeForms_Admin_Tools::import_json_file( $the_file['tmp_name'] );
758
759 if ( $status ) {
760 wp_send_json_success( __( 'The forms have been imported successfully!', 'weforms' ) );
761 } else {
762 wp_send_json_error( __( 'Something went wrong importing the file.', 'weforms' ) );
763 }
764
765 } else {
766 wp_send_json_error( __( 'Invalid file or file size too big.', 'weforms' ) );
767 }
768 }
769
770 }