<?php

use Hecate\Components\ComponentsRepository;
use Hecate\Controls\Components\BaseControl;
use Hecate\Customizer\CustomizerJsData;
use Hecate\LodashSimple;
use Hecate\Theme;

define( 'HECATE_ROOT', __DIR__ );

function hecate_dir( $path ) {
	return get_template_directory() . '/' . $path;
}//end hecate_dir()


function hecate_url( $path ) {
	return get_template_directory_uri() . '/' . $path;
}//end hecate_url()


function hecate_in_customizer() {
	global $wp_customize;
	return isset( $wp_customize );
}//end hecate_in_customizer()


require_once hecate_dir( 'inc/functions.php' );


function hecate_is_local() {
	return defined( LIMITLESS_THEMES_DEBUG ) || ! ! LIMITLESS_THEMES_DEBUG;
}//end hecate_is_dev()


function hecate_load_assets() {
	// $isDev = hecate_is_dev();
	// style
	wp_enqueue_style( 'style', get_stylesheet_uri() );

	wp_enqueue_style( 'bootstrap', hecate_url( '/assets/css/bootstrap.min.css' ), false, '1.1' );
	wp_enqueue_style( 'hecate-preview-style', hecate_url( '/dist/preview.min.css' ), false, '1.1' );


	// scripts
	wp_enqueue_script( 'bootstrap', hecate_url( '/assets/js/bootstrap.min.js' ), array( 'jquery' ), 1.1, true );
	wp_enqueue_script( 'hecate-preview-scripts', hecate_url( '/dist/preview.min.js' ), array( 'jquery' ), 1.1, true );

	if ( is_singular() ) {
		wp_enqueue_script( 'comment-reply' );
	}
}//end hecate_load_assets()


function hecate_load_customizer_assets() {
	// style
	wp_enqueue_style( 'hecate-customizer-style', hecate_url( '/dist/customizer.min.css' ), false, '1.1' );

	// scripts
	wp_enqueue_script( 'hecate-customizer-scripts', hecate_url( '/dist/customizer.min.js' ), array( 'jquery' ), 1.1, true );
}//end hecate_load_customizer_assets()


add_action( 'wp_enqueue_scripts', 'hecate_load_assets' );
add_action( 'customize_controls_enqueue_scripts', 'hecate_load_customizer_assets' );


function hecate_register_nav_menu() {
	register_nav_menus(
		array(
			'primary_menu' => __( 'Primary Menu', 'hecate' ),
			'footer_menu'  => __( 'Footer Menu', 'hecate' ),
		)
	);
}//end hecate_register_nav_menu()


add_action( 'after_setup_theme', 'hecate_register_nav_menu', 0 );


function hecate_the_posts_navigation() {
	the_posts_pagination(
		array(
			'before_page_number' => esc_html__( 'Page', 'hecate' ) . ' ',
			'mid_size'           => 0,
			'prev_text'          => sprintf(
				'<span class="nav-prev-text">%s</span>',
				wp_kses(
					__( 'Newer <span class="nav-short">posts</span>', 'hecate' ),
					array(
						'span' => array(
							'class' => array(),
						),
					)
				)
			),
			'next_text'          => sprintf(
				'<span class="nav-next-text">%s</span>',
				wp_kses(
					__( 'Older <span class="nav-short">posts</span>', 'hecate' ),
					array(
						'span' => array(
							'class' => array(),
						),
					)
				)
			),
		)
	);
}//end hecate_the_posts_navigation()


function hecate_init() {
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'customize-selective-refresh-widgets' );
	add_theme_support( 'title-tag' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support(
		'custom-logo',
		array(
			'flex-height' => true,
			'flex-width'  => true,
			'width'       => 150,
			'height'      => 70,
		)
	);

	global $content_width;
	$content_width = 1200;

	Theme::init();

}//end hecate_init()


hecate_init();


