<?php
if (!defined('WALKER_NEWS_TEMPLATE_VERSION')) {
    // Replace the version number of the theme on each release.
    define('WALKER_NEWS_TEMPLATE_VERSION', wp_get_theme()->get('Version'));
}
define('WALKER_NEWS_TEMPLATE_DEBUG', defined('WP_DEBUG') && WP_DEBUG === true);
define('WALKER_NEWS_TEMPLATE_DIR', trailingslashit(get_template_directory()));
define('WALKER_NEWS_TEMPLATE_URL', trailingslashit(get_template_directory_uri()));

if (!function_exists('walker_news_template_support')) :

    /**
     * Sets up theme defaults and registers support for various WordPress features.
     *
     * @since walker_fse 1.0.0
     *
     * @return void
     */
    function walker_news_template_support()
    {
        // Add default posts and comments RSS feed links to head.
        add_theme_support('automatic-feed-links');
        // Add support for block styles.
        add_theme_support('wp-block-styles');
        add_theme_support('post-thumbnails');
        // Enqueue editor styles.
        add_editor_style('style.css');
    }

endif;
add_action('after_setup_theme', 'walker_news_template_support');

/*----------------------------------------------------------------------------------
Enqueue Styles
-----------------------------------------------------------------------------------*/
if (!function_exists('walker_news_template_styles')) :
    function walker_news_template_styles()
    {
        // registering style for theme
        wp_enqueue_style('walker-news-template-style', get_stylesheet_uri(), array(), WALKER_NEWS_TEMPLATE_VERSION);
        if (is_rtl()) {
            wp_enqueue_style('rtl-css', get_template_directory_uri() . '/assets/css/rtl.css', 'rtl_css');
        }
        // registering js for theme
        wp_enqueue_script('jquery');
    }
endif;

add_action('wp_enqueue_scripts', 'walker_news_template_styles');

/**
 * Enqueue scripts for admin area
 */
function walker_news_template_admin_style()
{
    wp_enqueue_style('admin-style', get_template_directory_uri() . '/assets/css/admin-style.css', array(), WALKER_NEWS_TEMPLATE_VERSION, 'all');
}
add_action('admin_enqueue_scripts', 'walker_news_template_admin_style');

/**
 * Enqueue assets scripts for both backend and frontend
 */
function walker_news_template_block_assets()
{
    wp_enqueue_style('walker-news-template-blocks-style', get_template_directory_uri() . '/assets/css/blocks.css');
    wp_enqueue_style('walker-news-template-swiper-bundle-style', get_template_directory_uri() . '/assets/css/swiper-bundle.css');
    wp_enqueue_script('walker-news-template-swiper-bundle-js', get_template_directory_uri() . '/assets/js/swiper-bundle.js', array('jquery'), WALKER_NEWS_TEMPLATE_VERSION, true);
    wp_enqueue_script('walker-news-template-scripts', get_template_directory_uri() . '/assets/js/newsify-scripts.js', array('jquery'), WALKER_NEWS_TEMPLATE_VERSION, true);
}
add_action('enqueue_block_assets', 'walker_news_template_block_assets');

/**
 * Load core file.
 */
require_once get_template_directory() . '/inc/core/init.php';

/**
 * Load welcome page file.
 */
require_once get_template_directory() . '/inc/admin/welcome-notice.php';
