PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / modules / validation / handlers / ajax-validation-handler.php

ajax-validation-handler.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at modules/validation/handlers/ajax-validation-handler.php

38 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace JFB_Modules\Validation\Handlers;
3
4 use JFB_Modules\Validation\Handlers\Validation_Handler;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 class Ajax_Validation_Handler {
12 public function __construct() {
13 add_action( 'wp_ajax_jet_fb_ssr_validation_ajax', array( $this, 'jet_fb_ssr_validation_ajax' ) );
14 add_action( 'wp_ajax_nopriv_jet_fb_ssr_validation_ajax', array( $this, 'jet_fb_ssr_validation_ajax' ) );
15 }
16 public function jet_fb_ssr_validation_ajax() {
17 // phpcs:ignore WordPress.Security.NonceVerification.Missing
18 if ( ! isset( $_POST['data'] ) ) {
19 wp_send_json_error( array( 'message' => 'No data provided' ) );
20 }
21
22 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing
23 $body = json_decode( stripslashes( $_POST['data'] ), true );
24
25 foreach ( $body as $key => $value ) {
26 if ( strpos( $key, '[]' ) !== false ) {
27 unset( $body[ $key ] );
28 $new_key = str_replace( '[]', '', $key );
29 $body[ $new_key ] = is_array( $value ) ? $value : array( $value );
30 }
31 }
32
33 $result = Validation_Handler::validate( $body );
34
35 wp_send_json( $result );
36 }
37 }
38