PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 1.2.6
JetFormBuilder — Dynamic Blocks Form Builder v1.2.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 / pages / pages-manager.php
jetformbuilder / includes / admin / pages Last commit date
addons-page.php 4 years ago base-page.php 4 years ago page-config.php 4 years ago pages-manager.php 4 years ago settings-page.php 4 years ago
pages-manager.php
134 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Admin\Pages;
5
6
7 use Jet_Form_Builder\Plugin;
8
9 class Pages_Manager {
10
11 /**
12 * @var Base_Page[]
13 */
14 private $pages = array();
15
16 /**
17 * @var Base_Page
18 */
19 private $current_page;
20
21 /**
22 * [__construct description]
23 *
24 * @param array $pages [description]
25 */
26 public function __construct( $pages = array() ) {
27 $this->register_pages( $pages );
28 add_action( 'admin_menu', array( $this, 'add_pages' ) );
29
30 if ( $this->is_dashboard_page() ) {
31 $this->set_current_page();
32 add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
33 }
34 }
35
36 /**
37 * Register admin pages
38 *
39 * @param $pages
40 */
41 public function register_pages( $pages ) {
42 foreach ( $pages as $page ) {
43 $this->pages[ $page->slug() ] = $page;
44 }
45 }
46
47 /**
48 * Check if is dashboard page
49 *
50 * @return boolean [description]
51 */
52 public function is_dashboard_page() {
53
54 $page = ! empty( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : false;
55
56 if ( ! $page ) {
57 return false;
58 } else {
59 return isset( $this->pages[ $page ] );
60 }
61
62 }
63
64 /**
65 * Set current admin page
66 */
67 public function set_current_page() {
68 $this->current_page = $this->pages[ esc_attr( $_GET['page'] ) ];
69 }
70
71 /**
72 * Dashboard assets
73 */
74 public function assets() {
75 $ui_data = Plugin::instance()->framework->get_included_module_data( 'cherry-x-vue-ui.php' );
76 ( new \CX_Vue_UI( $ui_data ) )->enqueue_assets();
77
78 ( new Page_Config( $this->current_page ) )->render_config();
79
80 do_action( "jet-fb/admin-pages/before-assets/{$this->current_page->slug()}", $this );
81
82 $this->current_page->assets();
83 }
84
85 /**
86 * @param $page_slug
87 *
88 * @return string
89 */
90 public function get_url_of( $page_slug ): string {
91
92 if ( ! isset( $this->pages[ $page_slug ] ) ) {
93 return '';
94 }
95
96 return $this->pages[ $page_slug ]->get_url();
97 }
98
99 /**
100 * Check if passed page is currently displayed
101 *
102 * @param Base_Page $page
103 *
104 * @return bool
105 */
106 public function is_page_now( Base_Page $page ): bool {
107
108 if ( ! $this->is_dashboard_page() ) {
109 return false;
110 }
111
112 return ( $page->slug() === $this->current_page->slug() );
113
114 }
115
116 /**
117 * Register appointments
118 */
119 public function add_pages() {
120 $parent = 'edit.php?post_type=' . jet_form_builder()->post_type->slug();
121
122 foreach ( $this->pages as $page ) {
123 add_submenu_page(
124 $parent,
125 $page->title(),
126 $page->title(),
127 'manage_options',
128 $page->slug(),
129 array( $page, 'render' )
130 );
131 }
132 }
133
134 }