PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 1.2.6
JetFormBuilder — Dynamic Blocks Form Builder v1.2.6
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-messages / builder.php
jetformbuilder / includes / form-messages Last commit date
builder.php 4 years ago manager.php 4 years ago
builder.php
112 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Form_Messages;
5
6 // If this file is called directly, abort.
7 use Jet_Form_Builder\Classes\Get_Template_Trait;
8
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 /**
14 * Form messages class
15 */
16 class Builder {
17
18 use Get_Template_Trait;
19
20 private $form_id;
21 private $status;
22
23
24 public $manager;
25
26 /**
27 * Class constructor
28 *
29 * @param $data
30 */
31 public function __construct( $data ) {
32 $this->form_id = $data->form_id;
33 $this->manager = new Manager( $this->form_id, $data->actions );
34 }
35
36 /**
37 * Set form submittion status
38 *
39 * @param [type] $status [description]
40 *
41 * @return Builder
42 */
43 public function set_form_status( $status ) {
44 $this->status = $status;
45
46 return $this;
47 }
48
49 /**
50 * Get form submitting status
51 */
52 public function get_form_status() {
53 if ( ! $this->status ) {
54 $this->status = isset( $_REQUEST['status'] ) ? esc_attr( $_REQUEST['status'] ) : null;
55 }
56
57 return $this->status;
58 }
59
60 public function render_empty_field_message() {
61 $message_content = $this->manager->get_message( 'empty_field' );
62
63 include $this->get_global_template( 'common/field-message.php' );
64 }
65
66 /**
67 * Render form messages
68 *
69 * @return void
70 */
71 public function render_messages() {
72 $status = $this->get_form_status();
73
74 if ( ! $status ) {
75 return;
76 }
77
78 $message_content = $this->manager->get_message( $status );
79
80 $class = 'jet-form-builder-message';
81 $class .= ' jet-form-builder-message--' . $this->manager->get_status_class( $status );
82
83 include $this->get_global_template( 'common/messages.php' );
84 }
85
86 /**
87 * Render message samples for editor
88 *
89 * @return [type] [description]
90 */
91 public function render_messages_samples() {
92 // Render success sample
93 $this->set_form_status( 'success' );
94 $this->render_messages();
95
96 // Render error sample
97 $this->set_form_status( 'failed' );
98 $this->render_messages();
99
100 // Reset status
101 $this->set_form_status( null );
102
103 }
104
105 public function get_rendered_messages() {
106 ob_start();
107 $this->render_messages();
108 return ob_get_clean();
109 }
110
111
112 }