PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.5
JetFormBuilder — Dynamic Blocks Form Builder v2.1.5
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 / status-info.php
jetformbuilder / includes / form-messages Last commit date
builder.php 3 years ago manager.php 3 years ago msg-router.php 3 years ago status-info.php 3 years ago
status-info.php
78 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Form_Messages;
5
6
7 class Status_Info {
8
9 private $raw = '';
10 private $is_dynamic;
11 private $is_success;
12 private $parsed;
13
14 public function __construct( string $status ) {
15 $this->raw = $status;
16 }
17
18 /**
19 * @return string
20 */
21 public function get_raw_message(): string {
22 return $this->raw;
23 }
24
25 public function is_dynamic(): bool {
26 if ( is_null( $this->is_dynamic ) ) {
27 $this->set_dynamic_and_success();
28 }
29
30 return $this->is_dynamic;
31 }
32
33 public function is_success(): bool {
34 if ( is_null( $this->is_success ) ) {
35 $this->set_dynamic_and_success();
36 }
37
38 return $this->is_success;
39 }
40
41 public function get_parsed(): array {
42 if ( ! is_array( $this->parsed ) ) {
43 $this->parsed = Manager::parse_message( $this->raw );
44 }
45
46 return $this->parsed;
47 }
48
49 public function get_message(): string {
50 $parsed = $this->get_parsed();
51
52 if ( $this->is_dynamic() ) {
53 return $parsed[1] ?? $parsed[0];
54 }
55
56 return $parsed[0];
57 }
58
59 private function set_dynamic_and_success(): Status_Info {
60 $dynamic = Manager::dynamic_types();
61 $message = $this->get_parsed();
62 $this->is_dynamic = isset( $dynamic[ $message[0] ] ) && ! empty( $message[1] );
63
64 if ( $this->is_dynamic ) {
65 $this->is_success = ( 'success' === ( $dynamic[ $message[0] ]['type'] ?? '' ) );
66 } else {
67 $this->is_success = in_array( $message[0], array( 'success' ), true );
68 }
69
70 return $this;
71 }
72
73
74 public function get_css_class(): string {
75 return $this->is_success() ? 'success' : 'error';
76 }
77
78 }