PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.0.1
JetFormBuilder — Dynamic Blocks Form Builder v3.0.1
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 / manager.php
jetformbuilder / includes / form-messages Last commit date
actions 3 years ago action-messages-manager.php 3 years ago builder.php 3 years ago manager.php 3 years ago msg-router.php 3 years ago status-info.php 3 years ago
manager.php
105 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Form_Messages;
5
6 use Jet_Form_Builder\Actions\Types\Base;
7 use Jet_Form_Builder\Plugin;
8
9 class Manager {
10
11 public $_types = array();
12
13 const DYNAMIC_SUCCESS_PREF = 'dsuccess|';
14 const DYNAMIC_FAILED_PREF = 'derror|';
15
16 /**
17 * @return Manager
18 */
19 public function set_up() {
20 if ( ! jet_form_builder()->msg_router->get_form_id() || $this->get_messages() ) {
21 return $this;
22 }
23
24 $this->_types = array_merge(
25 $this->get_form_types_messages(),
26 $this->get_action_types_messages()
27 );
28
29 return $this;
30 }
31
32 public function get_form_types_messages() {
33 return Plugin::instance()->post_type->get_messages(
34 jet_form_builder()->msg_router->get_form_id()
35 );
36 }
37
38 public function get_action_types_messages() {
39 $messages = array();
40
41 /** @var Base $action */
42 foreach ( jet_form_builder()->msg_router->get_actions() as $action ) {
43 $messages = array_merge( $messages, Action_Messages_Manager::instance()->get_messages_values( $action ) );
44 }
45
46 return $messages;
47 }
48
49 public function isset_message_type( $type ) {
50 return isset( $this->_types[ $type ] );
51 }
52
53 public function get_message( $type ): string {
54 $info = new Status_Info( $type );
55
56 /**
57 * Return dynamic message
58 */
59 return $this->get_message_by_info( $info );
60 }
61
62
63 public function get_message_by_info( Status_Info $info ): string {
64 if ( $info->is_dynamic() ) {
65 return $info->get_message();
66 }
67
68 $status = $info->get_message();
69
70 if ( $this->isset_message_type( $status ) ) {
71 return $this->_types[ $status ]['value'] ?? $this->_types[ $status ];
72 }
73
74 return $info->get_raw_message();
75 }
76
77 public static function dynamic_success( $message ) {
78 return self::DYNAMIC_SUCCESS_PREF . $message;
79 }
80
81 public static function dynamic_error( $message ) {
82 return self::DYNAMIC_FAILED_PREF . $message;
83 }
84
85 public static function dynamic_types() {
86 return array(
87 'dsuccess' => array(
88 'type' => 'success',
89 ),
90 'derror' => array(
91 'type' => 'failed',
92 ),
93 );
94 }
95
96 public function get_messages() {
97 return $this->_types;
98 }
99
100 public static function parse_message( $status ) {
101 return explode( '|', $status );
102 }
103
104 }
105