<?php
/**
 * NewsNation Admin Class.
 *
 * @package NewsNation
 * @since   1.0.0
 */
if (!defined('ABSPATH')) {
    exit;
}
if (!class_exists('NewsNation_Admin')):
    /**
     * NewsNation_Admin Class.
     */
    class NewsNation_Admin
    {
        /**
         * Constructor.
         */
        public function __construct()
        {
            add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
        }

        /**
         * Localize array for import button AJAX request.
         */
        public function enqueue_scripts()
        {

            $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';

            $file_name = is_rtl() ? 'admin-rtl' . $suffix . '.css' : 'admin' . $suffix . '.css';

            wp_enqueue_style(
                'newsnation-admin-style',
                get_template_directory_uri() . '/inc/dashboard/css/' . $file_name,
                array(),
                NEWSNATION_VERSION
            );


            wp_enqueue_script('newsnation-plugin-install-helper', get_template_directory_uri() . '/inc/dashboard/js/admin.js', array('jquery'), NEWSNATION_VERSION, true);
            $welcome_data = array(
                'uri' => esc_url(admin_url('/themes.php?page=newsnation&tab=starter-templates')),
                'btn_text' => esc_html__('Processing...', 'newsnation'),
                'nonce' => wp_create_nonce('newsnation_demo_import_nonce'),
                'plugin_nonce' => wp_create_nonce('newsnation_install_plugin_nonce'),
                'admin_url' => esc_url(admin_url()),
                'ajaxurl' => admin_url('admin-ajax.php'), // Include this line for using admin-ajax.php
            );
            wp_localize_script('newsnation-plugin-install-helper', 'newsnationRedirectDemoPage', $welcome_data);
        }
    }
endif;
return new NewsNation_Admin();
