<?php

/**
 * The admin-specific functionality of the plugin.
 *
 * @link       https://www.56degrees.co.uk/
 * @since      1.0.0
 *
 * @package    Fsdsb_Simple_Banner
 * @subpackage Fsdsb_Simple_Banner/admin
 */

/**
 * The admin-specific functionality of the plugin.
 *
 * Defines the plugin name, version, and two examples hooks for how to
 * enqueue the admin-specific stylesheet and JavaScript.
 *
 * @package    Fsdsb_Simple_Banner
 * @subpackage Fsdsb_Simple_Banner/admin
 * @author     56 Degrees <tech@degrees.co.uk>
 */
use Carbon_Fields\Container;
use Carbon_Fields\Field;
class Fsdsb_Simple_Banner_Admin {

	/**
	 * The ID of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $plugin_name    The ID of this plugin.
	 */
	private $plugin_name;

	/**
	 * The version of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $version    The current version of this plugin.
	 */
	private $version;

	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 * @param      string    $plugin_name       The name of this plugin.
	 * @param      string    $version    The version of this plugin.
	 */
	public function __construct( $plugin_name, $version ) {

        add_action( 'after_setup_theme', array( $this , 'crb_load' ) );
        add_action( 'carbon_fields_register_fields', array( $this, 'crb_attach_theme_options') );

		$this->plugin_name = $plugin_name;
		$this->version = $version;

	}

    public function crb_load()
    {
        require_once( __DIR__ .  '/../vendor/autoload.php' );
        \Carbon_Fields\Carbon_Fields::boot();
    }

    public function crb_attach_theme_options()
    {

        $general_tab_content = include plugin_dir_path(__DIR__) . 'admin/fields/fsd-simple-banner-general.php';
        $settings_tab_content = include plugin_dir_path(__DIR__) . 'admin/fields/fsd-simple-banner-settings.php';
        $design_tab_content = include plugin_dir_path(__DIR__) . 'admin/fields/fsd-simple-banner-design.php';
        $cta_tab_content = include plugin_dir_path(__DIR__) . 'admin/fields/fsd-simple-banner-cta.php';
        $customcss_tab_content = include plugin_dir_path(__DIR__) . 'admin/fields/fsd-simple-banner-customcss.php';

        Container::make('theme_options', 'fsd-sb', __('Simple banner', 'fsd-simple-banner'))
            ->set_classes('disabled')
            // General Tab
            ->add_tab(__('General <span class="material-symbols-outlined">home</span>', 'fsd-simple-banner'), $general_tab_content)
            // Design tab
            ->add_tab(__('Design <span class="material-symbols-outlined">design_services</span>', 'fsd-simple-banner'), $design_tab_content)
            // CTA Tab
            ->add_tab(__('Button <span class="material-symbols-outlined">link</span>', 'fsd-simple-banner'), $cta_tab_content)
            // Settings Tab
            ->add_tab(__('Settings <span class="material-symbols-outlined">settings</span>', 'fsd-simple-banner'), $settings_tab_content)
            // Custom css tab
            ->add_tab(__('Custom css <span class="material-symbols-outlined">empty_dashboard</span>', 'fsd-simple-banner'), $customcss_tab_content);

        add_action('crb_attach_theme_options', 'add_custom_content_after_tabs');

        function add_custom_content_after_tabs() {
            // Output your custom content here
            echo '<div>Your custom content goes here</div>';
        }

    }


	/**
	 * Register the stylesheets for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_styles() {

		/**
		 * This function is provided for demonstration purposes only.
		 *
		 * An instance of this class should be passed to the run() function
		 * defined in Fsdsb_Simple_Banner_Loader as all of the hooks are defined
		 * in that particular class.
		 *
		 * The Fsdsb_Simple_Banner_Loader will then create the relationship
		 * between the defined hooks and the functions defined in this
		 * class.
		 */


		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/fsd-simple-banner-admin.css', array(), $this->version, 'all' );

	}

	/**
	 * Register the JavaScript for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_scripts() {

		/**
		 * This function is provided for demonstration purposes only.
		 *
		 * An instance of this class should be passed to the run() function
		 * defined in Fsdsb_Simple_Banner_Loader as all of the hooks are defined
		 * in that particular class.
		 *
		 * The Fsdsb_Simple_Banner_Loader will then create the relationship
		 * between the defined hooks and the functions defined in this
		 * class.
		 */

		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/fsd-simple-banner-admin.js', array( 'jquery' ), $this->version, false );

	}

}
