<?php

/**
 * functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package relax_spa
 */
// Freemius integration start
if ( !function_exists( 'fs_relax_spa' ) ) {
    // Create a helper function for easy SDK access.
    function fs_relax_spa() {
        global $fs_relax_spa;
        if ( !isset( $fs_relax_spa ) ) {
            // Include Freemius SDK.
            require_once dirname( __FILE__ ) . '/freemius/start.php';
            $fs_relax_spa = fs_dynamic_init( array(
                'id'             => '8610',
                'slug'           => 'relax-spa',
                'premium_slug'   => 'relax-spa-pro',
                'type'           => 'theme',
                'public_key'     => 'pk_4e76d446fd8d6c8aee7bf20047eed',
                'is_premium'     => false,
                'premium_suffix' => 'Pro',
                'has_addons'     => false,
                'has_paid_plans' => true,
                'navigation'     => 'tabs',
                'menu'           => array(
                    'slug'        => 'relax-spa',
                    'parent'      => array(
                        'slug' => 'themes.php',
                    ),
                    'first-path'  => 'themes.php?page=relax-spa',
                    'contact'     => true,
                    'account'     => true,
                    'support'     => false,
                    'addons'      => false,
                    'affiliation' => false,
                    'pricing'     => false,
                ),
                'is_live'        => true,
            ) );
        }
        return $fs_relax_spa;
    }

    // Init Freemius.
    fs_relax_spa();
    // Signal that SDK was initiated.
    do_action( 'fs_relax_spa_loaded' );
}
// Freemius integration end
if ( !defined( 'RELAX_SPA_VERSION' ) ) {
    // Replace the version number of the theme on each release.
    define( 'RELAX_SPA_VERSION', '1.8.2' );
}
if ( !function_exists( 'relax_spa_setup' ) ) {
    define( 'RELAX_SPA_DIR', dirname( __FILE__ ) );
    /**
     * Sets up theme defaults and registers support for various WordPress features.
     *
     * Note that this function is hooked into the after_setup_theme hook, which
     * runs before the init hook. The init hook is too late for some features, such
     * as indicating support for post thumbnails.
     */
    function relax_spa_setup() {
        /*
         * Make theme available for translation.
         * Translations can be filed in the /languages/ directory.
         * If you're building a theme based on relax spa, use a find and replace
         * to change 'relax-spa' to the name of your theme in all the template files.
         */
        load_theme_textdomain( 'relax-spa', get_template_directory() . '/languages' );
        // Add default posts and comments RSS feed links to head.
        add_theme_support( 'automatic-feed-links' );
        /*
         * Let WordPress manage the document title.
         * By adding theme support, we declare that this theme does not use a
         * hard-coded <title> tag in the document head, and expect WordPress to
         * provide it for us.
         */
        add_theme_support( 'title-tag' );
        /*
         * Enable support for Post Thumbnails on posts and pages.
         *
         * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
         */
        add_theme_support( 'post-thumbnails' );
        // This theme uses wp_nav_menu() in one location.
        register_nav_menus( array(
            'main-menu' => esc_html__( 'Main Menu', 'relax-spa' ),
        ) );
        /*
         * Switch default core markup for search form, comment form, and comments
         * to output valid HTML5.
         */
        add_theme_support( 'html5', array(
            'search-form',
            'comment-form',
            'comment-list',
            'gallery',
            'caption',
            'style',
            'script'
        ) );
        // Set up the WordPress core custom background feature.
        add_theme_support( 'custom-background', apply_filters( 'relax_spa_custom_background_args', array(
            'default-color' => 'ffffff',
            'default-image' => '',
        ) ) );
        // Add theme support for selective refresh for widgets.
        add_theme_support( 'customize-selective-refresh-widgets' );
        /**
         * Add support for core custom logo.
         *
         * @link https://codex.wordpress.org/Theme_Logo
         */
        add_theme_support( 'custom-logo', array(
            'height'      => 250,
            'width'       => 250,
            'flex-width'  => true,
            'flex-height' => true,
        ) );
        add_editor_style();
        add_theme_support( 'register_block_style' );
        add_theme_support( 'register_block_pattern' );
        add_theme_support( "wp-block-styles" );
        add_theme_support( "responsive-embeds" );
        add_theme_support( "align-wide" );
        require get_template_directory() . '/inc/starter-content.php';
        $starter_content = relax_spa_starter_content();
        add_theme_support( 'starter-content', $starter_content );
    }

}
add_action( 'after_setup_theme', 'relax_spa_setup' );
/**
 * Set the content width in pixels, based on the theme's design and stylesheet.
 *
 * Priority 0 to make it available to lower priority callbacks.
 *
 * @global int $content_width
 */
function relax_spa_content_width() {
    $GLOBALS['content_width'] = apply_filters( 'relax_spa_content_width', 640 );
}

add_action( 'after_setup_theme', 'relax_spa_content_width', 0 );
/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
require get_template_directory() . '/inc/widgets/widgets.php';
/**
 * Enqueue scripts and styles.
 */
function relax_spa_scripts() {
    $body_font_family = get_theme_mod( 'body_font_family', 'Mulish' );
    $heading_font_family = get_theme_mod( 'heading_font_family', 'Poppins' );
    $topheading_font_family = get_theme_mod( 'topheading_font_family', 'Caveat' );
    $site_identity_font_family = esc_attr( get_theme_mod( 'site_identity_font_family', 'Dancing Script' ) );
    wp_enqueue_style( 'relax-spa-bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css' );
    wp_enqueue_style( 'fontello', get_template_directory_uri() . '/css/fontello.css' );
    wp_enqueue_style( 'owl', get_template_directory_uri() . '/css/owl.carousel.min.css' );
    wp_enqueue_style(
        'relax-spa-style',
        get_stylesheet_uri(),
        array(),
        RELAX_SPA_VERSION
    );
    wp_style_add_data( 'relax-spa-style', 'rtl', 'replace' );
    wp_enqueue_style( 'relax-spa-googlefonts', 'https://fonts.googleapis.com/css?family=' . esc_attr( $body_font_family ) . ':200,300,400,500,600,700,800,900|' . esc_attr( $heading_font_family ) . ':200,300,400,500,600,700,800,900|' . esc_attr( $topheading_font_family ) . ':200,300,400,500,600,700,800,900|' . esc_attr( $site_identity_font_family ) . ':200,300,400,500,600,700,800,900|' );
    wp_enqueue_script( 'relax-spa-bootstrap', get_template_directory_uri() . '/js/bootstrap.bundle.min.js', array('jquery') );
    wp_enqueue_script( 'owl', get_template_directory_uri() . '/js/owl.carousel.min.js', array('jquery') );
    wp_enqueue_script(
        'relax-spa-navigation',
        get_template_directory_uri() . '/js/navigation.js',
        array(),
        RELAX_SPA_VERSION,
        true
    );
    wp_enqueue_script(
        'relax-spa-script',
        get_template_directory_uri() . '/js/script.js',
        array('jquery'),
        '',
        true
    );
    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }
}

add_action( 'wp_enqueue_scripts', 'relax_spa_scripts' );
/**
 * Required Plugins
 */
add_theme_support( 'required-plugins', array(array(
    'slug'            => 'tbthemes-demo-import',
    'name'            => 'TBThemes Theme Import',
    'active_filename' => 'tbthemes-demo-import/tbthemes-demo-import.php',
), array(
    'slug'            => 'the-bootstrap-themes-companion',
    'name'            => 'The Bootstrap Theme Companion',
    'active_filename' => 'the-bootstrap-themes-companion/tbthemes-companion.php',
)) );
/**
 * Implement the Custom Header feature.
 */
require get_template_directory() . '/inc/custom-header.php';
/**
 * Custom template tags for this theme.
 */
require get_template_directory() . '/inc/template-tags.php';
/**
 * Functions which enhance the theme by hooking into WordPress.
 */
require get_template_directory() . '/inc/template-functions.php';
/**
 * Custom contrl
 */
require get_template_directory() . '/inc/custom-controls/custom-control.php';
/**
 * Customizer additions.
 */
require get_template_directory() . '/inc/customizer.php';
/**
 * Shortcode hooks
 */
require get_template_directory() . '/inc/shortcode-hooks.php';
/**
 * Load Jetpack compatibility file.
 */
if ( defined( 'JETPACK__VERSION' ) ) {
    require get_template_directory() . '/inc/jetpack.php';
}
/**
 * Customizer changes css
 */
require get_template_directory() . '/inc/dynamic-css.php';
/**
 * Theme Admin Dashboard
 */
require get_template_directory() . '/inc/admin/dashboard.php';
/**
 * Sidebar panel
 */
require get_template_directory() . '/inc/gutenberg/sidebar/sidebar_panel.php';
/**
 * Block Editor Typography
 */
require get_template_directory() . '/inc/gutenberg/typography/typography.php';