<?php
/**
 * Euphony Blocks functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Euphony_Blocks
 * @since 1.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! function_exists( 'euphony_blocks_support' ) ) :

	/**
	 * Sets up theme defaults and registers support for various WordPress features.
	 *
	 * Translations are not loaded here: WordPress loads them automatically for themes
	 * hosted on WordPress.org, so load_theme_textdomain() is unnecessary.
	 *
	 * @since 1.0
	 *
	 * @return void
	 */
	function euphony_blocks_support() {

		// Add support for block styles.
		add_theme_support( 'wp-block-styles' );

		// Enqueue editor styles.
		add_editor_style( 'style.css' );

	}

endif;

add_action( 'after_setup_theme', 'euphony_blocks_support' );

if ( ! function_exists( 'euphony_blocks_styles' ) ) :

	/**
	 * Enqueue styles and scripts.
	 *
	 * @since 1.0
	 *
	 * @return void
	 */
	function euphony_blocks_styles() {
		/*
		 * Version the assets with the theme version rather than filemtime(). filemtime()
		 * resolves against the child theme when one is active, while the URLs below always
		 * point at the parent, and it produces a different version on every server.
		 */
		$theme_version = wp_get_theme( get_template() )->get( 'Version' );
		$version       = is_string( $theme_version ) ? $theme_version : false;

		// Enqueue theme stylesheet.
		wp_enqueue_style(
			'euphony-blocks-style',
			get_template_directory_uri() . '/style.css',
			array(),
			$version
		);

		wp_enqueue_script(
			'euphony-blocks-script',
			get_template_directory_uri() . '/assets/js/custom.js',
			array(),
			$version,
			true
		);
	}

endif;

add_action( 'wp_enqueue_scripts', 'euphony_blocks_styles' );

// Add block patterns.
require get_template_directory() . '/inc/block-patterns.php';

// Add block styles.
require get_template_directory() . '/inc/block-styles.php';

// Block Filters.
require get_template_directory() . '/inc/block-filters.php';

// Svg icons.
require get_template_directory() . '/inc/icon-function.php';

// Admin Notice Dismissal.
require get_template_directory() . '/inc/persist-admin-notices-dismissal.php';

// Theme About Page.
require get_template_directory() . '/inc/about.php';
