PluginProbe
TableKit – WordPress Table Builder for Data Tables, WooCommerce Product Tables & Post Tables / 2.0.0
TableKit – WordPress Table Builder for Data Tables, WooCommerce Product Tables & Post Tables v2.0.0
2.3.0 2.2.14 2.2.13 2.2.12 2.2.11 2.2.10 2.2.9 2.2.8 2.2.7 2.2.6 2.2.5 2.2.4 2.2.3 trunk 1.0.0 1.0.1 2.0.0 2.0.1 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2
table-builder-block / includes / Admin / Admin.php

Admin.php in TableKit – WordPress Table Builder for Data Tables, WooCommerce Product Tables & Post Tables 2.0.0, at includes/Admin/Admin.php

115 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TableBuilder\Admin;
4 use TableBuilder\Traits\PluginHelper;
5
6 defined('ABSPATH') || exit;
7
8 /**
9 * The admin class for TableBuilder
10 */
11 class Admin
12 {
13 use \TableBuilder\Traits\Singleton;
14 use PluginHelper;
15
16 /**
17 * @var string slug of the admin menu
18 */
19 private $menu_slug = 'tablebuilder';
20
21 /**
22 * @var string $menu_link_part Part of the menu link used in the admin panel.
23 */
24 private $menu_link_part;
25
26 /**
27 * Initialize the class
28 */
29 public function __construct()
30 {
31 $this->menu_link_part = admin_url('admin.php?page=tablebuilder');
32
33 // Register Settings API
34 new Api\SettingsData();
35
36 add_action('admin_menu', [$this, 'add_admin_menu'], 9);
37 add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
38 }
39
40 public function add_admin_menu()
41 {
42 add_menu_page(
43 esc_html__('Table Builder', 'table-builder-block'),
44 esc_html__('Table Builder', 'table-builder-block'),
45 'manage_options',
46 $this->menu_slug,
47 [$this, 'settings_menu_callback'],
48 TABLE_BUILDER_BLOCK_PLUGIN_URL . 'assets/icons/admin-menu.svg',
49 28
50 );
51
52 add_submenu_page(
53 $this->menu_slug,
54 esc_html__('Welcome', 'table-builder-block'),
55 esc_html__('Welcome', 'table-builder-block'),
56 'manage_options',
57 $this->menu_link_part . '#welcome',
58 ''
59 );
60
61 add_submenu_page(
62 $this->menu_slug,
63 esc_html__('Settings', 'table-builder-block'),
64 esc_html__('Settings', 'table-builder-block'),
65 'manage_options',
66 $this->menu_link_part . '#settings'
67 );
68 }
69
70 /**
71 * Callback for settings submenu
72 */
73 public function settings_menu_callback()
74 {
75 ?>
76 <div class="wrap">
77 <h1><?php esc_html_e('Table Builder Settings', 'table-builder-block'); ?></h1>
78 <p><?php esc_html_e('Configure the settings for Table Builder.', 'table-builder-block'); ?></p>
79 </div>
80 <?php
81 }
82
83 /**
84 * Enqueue admin scripts and styles
85 *
86 * @param string $hook The current admin page.
87 */
88 public function enqueue_admin_scripts($hook)
89 {
90 $screen = get_current_screen();
91
92 if ($screen && isset($screen->post_type) && $screen->post_type === 'tablebuilder') {
93 wp_enqueue_style(
94 'table-builder-admin',
95 TABLE_BUILDER_BLOCK_PLUGIN_URL . 'assets/css/admin.css',
96 [],
97 TABLE_BUILDER_BLOCK_PLUGIN_VERSION
98 );
99
100 wp_localize_script(
101 'wp-block-editor',
102 'tableBuilderBlock',
103 [
104 'plugin_url' => TABLE_BUILDER_BLOCK_PLUGIN_URL,
105 'screen' => $hook,
106 'rootUrl' => esc_url(home_url('/')),
107 'version' => TABLE_BUILDER_BLOCK_PLUGIN_VERSION,
108 'activeTheme' => wp_get_theme()->get('Name'),
109 ]
110 );
111 }
112 }
113
114 }
115