<?php

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

if ( ! class_exists( 'REACTIFY_Block_Admin' ) ) :

    class REACTIFY_Block_Admin {

        private static $_instance = null;

        public static function instance() {
            if (is_null(self::$_instance)) {
                self::$_instance = new self();
            }
            return self::$_instance;
        }

        public function __construct() {
            add_action( 'admin_menu', array( $this, 'add_admin_menu_register' ) );
        }

        public function add_admin_menu_register() {
            add_menu_page(
                'reactify-dashboard',
                esc_html__( 'Reactify', 'reactify' ),
                'manage_options',
                'reactify-dashboard',
                array( $this, 'dashboard_html_callback' ),
                'dashicons-smiley',
                20
            );

            add_submenu_page(
                'reactify-dashboard',
                esc_html__( 'Dashboard', 'reactify' ),
                esc_html__( 'Dashboard', 'reactify' ),
                'manage_options',
                'reactify-dashboard',
                array( $this, 'dashboard_html_callback' )
            );

            add_submenu_page(
                'reactify-dashboard',
                esc_html__( 'Reaction Settings', 'reactify' ),
                esc_html__( 'Reaction Settings', 'reactify' ),
                'manage_options',
                'reactify-reaction-settings',
                array( $this, 'settings_html_callback' )
            );
        }

        public function dashboard_html_callback() {

            require_once REACTIFY_BLOCK_INCLUDES_PATH . '/view/dashboard.php';
        }

        public function settings_html_callback() {

            require_once REACTIFY_BLOCK_INCLUDES_PATH . '/view/settings.php';
        }
    }

    REACTIFY_Block_Admin::instance();

endif;
