PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / trunk
JetFormBuilder — Dynamic Blocks Form Builder vtrunk
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 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / form-response / response.php
jetformbuilder / includes / form-response Last commit date
types 2 years ago response.php 2 years ago
response.php
72 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Form_Response;
5
6 use Jet_Form_Builder\Form_Response\Types\Response_It;
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 class Response {
14
15 public $manager;
16 private $query_args = array();
17 public $args = array();
18
19 public $default_args = array(
20 'status' => 'success',
21 'errors' => array(),
22 );
23
24 public function __construct( Response_It $instance, $query_args = array() ) {
25 $this->manager = $instance;
26 $this->add_query_args( $query_args );
27 }
28
29 public function send() {
30 $this->manager->send(
31 apply_filters( 'jet-fb/response-handler/query-args', $this->query_args, $this )
32 );
33 }
34
35 private function init_query_args() {
36 $this->add_query_args(
37 array( 'status' => $this->manager->parse_status( $this->args['status'] ) )
38 );
39 }
40
41 public function init( array $args ) {
42 $this->args = wp_parse_args( $args, $this->default_args );
43
44 $this->init_query_args();
45 $this->call_on_status();
46
47 return $this;
48 }
49
50 private function call_on_status() {
51 $callable = array( $this, 'on_' . $this->args['status'] );
52
53 if ( is_callable( $callable ) ) {
54 call_user_func( $callable );
55 }
56 }
57
58 private function add_query_args( $args ) {
59 $this->query_args = array_merge( $this->query_args, $args );
60 }
61
62 public function on_validation_failed() {
63 $this->add_query_args(
64 array(
65 'fields' => $this->manager->get_field_errors( $this->args['errors'] ),
66 )
67 );
68 }
69
70
71 }
72