PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.1
JetFormBuilder — Dynamic Blocks Form Builder v2.1.1
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 3 years ago base-meta-box.php 3 years ago base-table-box.php 3 years ago meta-box-options-converter.php 3 years ago meta-box-options.php 3 years ago meta-box-update-callback.php 3 years ago meta-table-options-converter.php 3 years ago meta-table-options.php 3 years ago
base-meta-box.php
97 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 Jet_Form_Builder\Classes\Repository\Repository_Item_Instance_Trait;
12 use Jet_Form_Builder\Classes\Repository\Repository_Item_With_Class;
13 use Jet_Form_Builder\Classes\Repository\Repository_Static_Item_It;
14 use Jet_Form_Builder\Db_Queries\Exceptions\Sql_Exception;
15 use Jet_Form_Builder\Db_Queries\Traits\Model_Dependencies;
16 use Jet_Form_Builder\Db_Queries\Traits\Model_Dependencies_Interface;
17
18 abstract class Base_Meta_Box
19 implements
20 Model_Dependencies_Interface,
21 Arrayable,
22 Repository_Static_Item_It {
23
24 const TYPE_LIST = 'list';
25 const TYPE_TABLE = 'table';
26
27 use Repository_Item_With_Class;
28 use Model_Dependencies;
29
30 private $id = 0;
31
32 abstract public function get_title(): string;
33
34 abstract public function get_values(): array;
35
36 public function get_slug(): string {
37 return str_replace( ' ', '-', strtolower( $this->get_title() ) );
38 }
39
40 public function is_active(): bool {
41 return true;
42 }
43
44 /**
45 * @return int
46 */
47 public function get_id(): int {
48 return $this->id;
49 }
50
51 /**
52 * @param int $id
53 *
54 * @return Base_Meta_Box
55 */
56 public function set_id( int $id ): Base_Meta_Box {
57 $this->id = $id;
58
59 return $this;
60 }
61
62 public function set_single_id(): Base_Meta_Box {
63 /** @var Base_Single_Page $single */
64 try {
65 $single = Pages_Manager::instance()->get_current();
66 } catch ( Not_Found_Page_Exception $e ) {
67 return $this;
68 }
69
70 return $this->set_id( $single->get_id() );
71 }
72
73 public function get_migrations(): \Generator {
74 foreach ( $this->get_dependencies() as $model ) {
75 yield from $model->get_migrations();
76 }
77 }
78
79 /**
80 * @return int[]
81 * @throws Empty_Box_Exception
82 */
83 public function to_array(): array {
84 try {
85 $this->prepare_dependencies();
86 } catch ( Sql_Exception $exception ) {
87 throw new Empty_Box_Exception( $exception->getMessage(), ...$exception->get_additional() );
88 }
89
90 return array(
91 'slug' => $this->get_slug(),
92 'title' => $this->get_title(),
93 'list' => $this->get_values(),
94 );
95 }
96 }
97