PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.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 / admin / single-pages / meta-boxes / base-meta-box.php
jetformbuilder / includes / admin / single-pages / meta-boxes Last commit date
base-list-box.php 2 years ago base-meta-box.php 2 years ago base-table-box.php 2 years ago meta-box-options-converter.php 2 years ago meta-box-options.php 2 years ago meta-box-update-callback.php 2 years ago meta-table-options-converter.php 2 years ago meta-table-options.php 2 years ago
base-meta-box.php
104 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Admin\Single_Pages\Meta_Boxes;
5
6 use Jet_Form_Builder\Admin\Exceptions\Empty_Box_Exception;
7 use Jet_Form_Builder\Admin\Exceptions\Not_Found_Page_Exception;
8 use Jet_Form_Builder\Admin\Pages\Pages_Manager;
9 use Jet_Form_Builder\Admin\Single_Pages\Base_Single_Page;
10 use Jet_Form_Builder\Classes\Arrayable\Arrayable;
11 use JFB_Components\Repository\Repository_Item_With_Class;
12 use JFB_Components\Repository\Repository_Static_Item_It;
13 use Jet_Form_Builder\Db_Queries\Exceptions\Sql_Exception;
14 use Jet_Form_Builder\Db_Queries\Traits\Model_Dependencies;
15 use Jet_Form_Builder\Db_Queries\Traits\Model_Dependencies_Interface;
16
17 // If this file is called directly, abort.
18 if ( ! defined( 'WPINC' ) ) {
19 die;
20 }
21
22 abstract class Base_Meta_Box implements
23 Model_Dependencies_Interface,
24 Arrayable,
25 Repository_Static_Item_It {
26
27 const TYPE_LIST = 'list';
28 const TYPE_TABLE = 'table';
29
30 use Repository_Item_With_Class;
31 use Model_Dependencies;
32
33 private $id = 0;
34
35 abstract public function get_title(): string;
36
37 abstract public function get_values(): array;
38
39 public function get_slug(): string {
40 return str_replace( ' ', '-', strtolower( $this->get_title() ) );
41 }
42
43 public function is_active(): bool {
44 return true;
45 }
46
47 /**
48 * @return int
49 */
50 public function get_id(): int {
51 return $this->id;
52 }
53
54 /**
55 * @param int $id
56 *
57 * @return Base_Meta_Box
58 */
59 public function set_id( int $id ): Base_Meta_Box {
60 $this->id = $id;
61
62 return $this;
63 }
64
65 public function set_single_id(): Base_Meta_Box {
66 /** @var Base_Single_Page $single */
67 try {
68 $single = Pages_Manager::instance()->get_current();
69 } catch ( Not_Found_Page_Exception $e ) {
70 return $this;
71 }
72
73 return $this->set_id( $single->get_id() );
74 }
75
76 public function get_migrations(): \Generator {
77 foreach ( $this->get_dependencies() as $model ) {
78 yield from $model->get_migrations();
79 }
80 }
81
82 /**
83 * @return int[]
84 * @throws Empty_Box_Exception
85 */
86 public function to_array(): array {
87 try {
88 $this->prepare_dependencies();
89 } catch ( Sql_Exception $exception ) {
90 throw new Empty_Box_Exception(
91 esc_html( $exception->getMessage() ),
92 // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
93 ...$exception->get_additional()
94 );
95 }
96
97 return array(
98 'slug' => $this->get_slug(),
99 'title' => $this->get_title(),
100 'list' => $this->get_values(),
101 );
102 }
103 }
104