# table-builder-block/2.0.0/includes/Admin/Admin.php

TableKit – WordPress Table Builder for Data Tables, WooCommerce Product Tables &amp; Post Tables, version 2.0.0. 115 lines.

- Page: https://pluginprobe.com/plugins/table-builder-block/2.0.0/code/includes/Admin/Admin.php
- Raw: https://pluginprobe.com/plugins/table-builder-block/2.0.0/raw/includes/Admin/Admin.php
- Modified: 2025-04-24T06:10:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/table-builder-block/2.0.0/code/includes/Admin/Admin.php#L10-L20`.

```php
<?php

namespace TableBuilder\Admin;
use TableBuilder\Traits\PluginHelper;

defined('ABSPATH') || exit;

/**
 * The admin class for TableBuilder
 */
class Admin
{
    use \TableBuilder\Traits\Singleton;
    use PluginHelper;

    /**
     * @var string slug of the admin menu
     */
    private $menu_slug = 'tablebuilder';

    /**
     * @var string $menu_link_part Part of the menu link used in the admin panel.
     */
    private $menu_link_part;

    /**
     * Initialize the class
     */
    public function __construct()
    {
        $this->menu_link_part = admin_url('admin.php?page=tablebuilder');

        // Register Settings API
        new Api\SettingsData();

        add_action('admin_menu', [$this, 'add_admin_menu'], 9);
        add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
    }

    public function add_admin_menu()
    {
        add_menu_page(
            esc_html__('Table Builder', 'table-builder-block'),
            esc_html__('Table Builder', 'table-builder-block'),
            'manage_options',
            $this->menu_slug,
            [$this, 'settings_menu_callback'],
            TABLE_BUILDER_BLOCK_PLUGIN_URL . 'assets/icons/admin-menu.svg',
            28
        );

        add_submenu_page(
            $this->menu_slug,
            esc_html__('Welcome', 'table-builder-block'),
            esc_html__('Welcome', 'table-builder-block'),
            'manage_options',
            $this->menu_link_part . '#welcome',
            ''
        );

        add_submenu_page(
            $this->menu_slug,
            esc_html__('Settings', 'table-builder-block'),
            esc_html__('Settings', 'table-builder-block'),
            'manage_options',
            $this->menu_link_part . '#settings'
        );
    }

    /**
     * Callback for settings submenu
     */
    public function settings_menu_callback()
    {
        ?>
        <div class="wrap">
            <h1><?php esc_html_e('Table Builder Settings', 'table-builder-block'); ?></h1>
            <p><?php esc_html_e('Configure the settings for Table Builder.', 'table-builder-block'); ?></p>
        </div>
        <?php
    }

    /**
     * Enqueue admin scripts and styles
     *
     * @param string $hook The current admin page.
     */
    public function enqueue_admin_scripts($hook)
    {
        $screen = get_current_screen();

        if ($screen && isset($screen->post_type) && $screen->post_type === 'tablebuilder') {
            wp_enqueue_style(
                'table-builder-admin',
                TABLE_BUILDER_BLOCK_PLUGIN_URL . 'assets/css/admin.css',
                [],
                TABLE_BUILDER_BLOCK_PLUGIN_VERSION
            );

            wp_localize_script(
                'wp-block-editor',
                'tableBuilderBlock',
                [
                    'plugin_url'  => TABLE_BUILDER_BLOCK_PLUGIN_URL,
                    'screen'      => $hook,
                    'rootUrl'     => esc_url(home_url('/')),
                    'version'     => TABLE_BUILDER_BLOCK_PLUGIN_VERSION,
                    'activeTheme' => wp_get_theme()->get('Name'),
                ]
            );
        }
    }

}

```
