PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5
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 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
actions 1 year ago action-messages-manager.php 1 year ago builder.php 5 days ago manager.php 2 years ago msg-router.php 1 year ago status-info.php 2 years ago
builder.php
118 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 use JFB_Modules\Rich_Content;
9
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 /**
15 * Form messages class
16 */
17 class Builder {
18
19 use Get_Template_Trait;
20
21 private $status;
22
23 /**
24 * Set form submittion status
25 *
26 * @param [type] $status [description]
27 *
28 * @return Builder
29 */
30 public function set_form_status( $status ) {
31 $this->status = $status;
32
33 return $this;
34 }
35
36 public function get_manager( $data = array() ) {
37 return jet_form_builder()->msg_router->get_manager( $data );
38 }
39
40 /**
41 * Get form submitting status
42 */
43 public function get_form_status() {
44 if ( ! $this->status ) {
45 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
46 $this->status = isset( $_GET['status'] ) ? sanitize_text_field( wp_unslash( $_GET['status'] ) ) : null;
47 }
48
49 return $this->status;
50 }
51
52 public function prepare_message_content( string $message ): string {
53 return jet_fb_handler()->parser->parse_macros(
54 $message,
55 jet_fb_context()->get_request()
56 );
57 }
58
59 public function render_empty_field_message() {
60 $message_content = $this->prepare_message_content(
61 $this->get_manager()->get_message( 'empty_field' )
62 );
63
64 include $this->get_global_template( 'common/field-message.php' );
65 }
66
67 /**
68 * Render form messages
69 *
70 * @return void
71 */
72 public function render_messages() {
73 $status = $this->get_form_status();
74
75 if ( ! $status ) {
76 return;
77 }
78
79 $info = new Status_Info( $status );
80
81 $message_content = Rich_Content\Module::rich(
82 $this->prepare_message_content(
83 $this->get_manager()->get_message_by_info( $info )
84 )
85 );
86
87 $class = 'jet-form-builder-message';
88 $class .= ' jet-form-builder-message--' . $info->get_css_class();
89
90 include $this->get_global_template( 'common/messages.php' );
91 }
92
93 /**
94 * Render message samples for editor
95 */
96 public function render_messages_samples() {
97 // Render success sample
98 $this->set_form_status( 'success' );
99 $this->render_messages();
100
101 // Render error sample
102 $this->set_form_status( 'failed' );
103 $this->render_messages();
104
105 // Reset status
106 $this->set_form_status( null );
107 }
108
109 public function get_rendered_messages() {
110 ob_start();
111 $this->render_messages();
112
113 return ob_get_clean();
114 }
115
116
117 }
118