PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.9
JetFormBuilder — Dynamic Blocks Form Builder v3.1.9
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 / exceptions / handler-exception.php
jetformbuilder / includes / exceptions Last commit date
action-exception.php 2 years ago condition-exception.php 2 years ago condition-silence-exception.php 2 years ago gateway-exception.php 2 years ago handler-exception.php 2 years ago integration-exception.php 2 years ago invalid-macro-exception.php 2 years ago not-router-request.php 2 years ago parse-exception.php 2 years ago plain-default-exception.php 2 years ago preset-exception.php 2 years ago query-builder-exception.php 2 years ago repository-exception.php 2 years ago request-exception.php 2 years ago silence-exception.php 2 years ago
handler-exception.php
113 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Exceptions;
5
6 use Jet_Form_Builder\Form_Messages\Manager;
7 use Jet_Form_Builder\Form_Messages\Status_Info;
8 use JFB_Modules\Dev;
9 use JFB_Modules\Logger;
10
11 // If this file is called directly, abort.
12 if ( ! defined( 'WPINC' ) ) {
13 die;
14 }
15
16 abstract class Handler_Exception extends \Exception {
17
18 protected $default_type_message = 'failed';
19
20 protected $additional_data;
21
22 public function __construct( $message = '', ...$additional_data ) {
23 parent::__construct( $message, 0, null );
24
25 $this->additional_data = $additional_data;
26
27 $this->check_message_length();
28 $this->log();
29 }
30
31 public function set_code( $code ) {
32 $this->code = $code;
33
34 return $this;
35 }
36
37 public function dynamic_success(): Handler_Exception {
38 $this->message = Manager::dynamic_success( $this->message );
39
40 return $this;
41 }
42
43 public function dynamic_error(): Handler_Exception {
44 $this->message = Manager::dynamic_error( $this->message );
45
46 return $this;
47 }
48
49
50 public function get_form_status() {
51 return $this->message ?: $this->default_type_message;
52 }
53
54 public function get_additional() {
55 return $this->additional_data;
56 }
57
58 public function unset_log() {
59 Logger\Module::instance()->unset_last( static::class );
60 }
61
62 public function log() {
63 if ( ! jet_form_builder()->has_module( 'dev' ) ) {
64 return;
65 }
66 Logger\Module::instance()->push_log(
67 static::class,
68 array(
69 'message' => $this->getMessage(),
70 'file' => $this->make_pretty_filename( $this->getFile() ),
71 'line' => $this->getLine(),
72 'data' => $this->get_additional(),
73 'version' => jet_form_builder()->get_version(),
74 'action_id' => jet_fb_action_handler()->get_position(),
75 )
76 );
77 }
78
79 private function make_pretty_filename( string $file ) {
80 $path = explode( 'wp-content\\', $file );
81
82 return $path[1] ?? ( explode( 'wp-content/', $file )[1] ?? $file );
83 }
84
85 public function is_success(): bool {
86 if ( 'success' === $this->message ) {
87 return true;
88 }
89
90 return is_string( $this->message ) && 0 === strpos( $this->message, Manager::DYNAMIC_SUCCESS_PREF );
91 }
92
93 /**
94 * We need to check the status length for cases when it's too long.
95 * If it's long - we store it in `*_jet_fb_records_errors` table
96 *
97 * @since 3.1.8
98 *
99 * @see https://github.com/Crocoblock/issues-tracker/issues/4994
100 */
101 protected function check_message_length() {
102 if ( 255 > strlen( $this->message ) ) {
103 return;
104 }
105
106 $status = new Status_Info( $this->message );
107 $this->message = $status->is_success() ? 'success' : 'failed';
108
109 array_unshift( $this->additional_data, $status->get_raw_message() );
110 }
111
112 }
113