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

if ( ! function_exists( 'broilda_styles' ) ) :

	/**
	 * Enqueue styles.
	 *
	 * @since Broilda 1.0
	 *
	 * @return void
	 */
	function broilda_styles() {
		// Register custom stylesheet.
		$broilda_theme_version = wp_get_theme()->get( 'Version' );

		$broilda_version_string = is_string( $broilda_theme_version ) ? $broilda_theme_version : false;

		wp_register_style(
			'broilda-block-style',
			get_template_directory_uri() . '/assets/css/block-style.css',
			array(),
			$broilda_version_string
		);

		wp_register_style(
			'broilda-custom-core',
			get_template_directory_uri() . '/assets/css/custom-core.css',
			array(),
			$broilda_version_string
		);

		wp_register_style(
			'broilda-animate-style',
			get_template_directory_uri() . '/assets/css/animate.css',
			array(),
			$broilda_version_string
		);

		wp_register_style(
			'broilda-admin-page',
			get_template_directory_uri() . '/assets/css/admin.css',
			array(),
			$broilda_version_string
		);

		// Enqueue custom stylesheet.
		wp_enqueue_style( 'broilda-block-style' );
		wp_enqueue_style( 'broilda-custom-core' );
		wp_enqueue_style( 'broilda-animate-style' );
		wp_enqueue_style( 'broilda-admin-page' );
		
		wp_enqueue_script('jquery');
		wp_enqueue_script('jquery-ui-accordion');
		wp_enqueue_script('broilda-custom-core', get_template_directory_uri() . '/assets/js/custom-core.js', array(), $broilda_version_string, true);
	}

endif;

add_action( 'init', 'broilda_styles' );

 /**
 * Load Block Function.
 */
require_once get_template_directory() . '/inc/init.php';

/**
 * Register pattern categories.
 */

if ( ! function_exists( 'broilda_pattern_categories' ) ) :
	/**
	 * Register pattern categories
	 *
	 * @since Broilda 1.0
	 * @return void
	 */
	function broilda_pattern_categories() {

		register_block_pattern_category(
			'broilda_page',
			array(
				'label'       => _x( 'Broilda Pages', 'Block pattern category', 'broilda' ),
				'description' => __( 'A collection of full page layouts.', 'broilda' ),
			)
		);

		register_block_pattern_category(
			'broilda_theme',
			array(
				'label'       => _x( 'Broilda Theme Layout', 'Block pattern category', 'broilda' ),
				'description' => __( 'A collection of pattern theme layout.', 'broilda' ),
			)
		);
	}
endif;

add_action( 'init', 'broilda_pattern_categories' );

// Patterns Custom Conditional

function broilda_register_block_patterns() {

	$block_patterns = array(		
		'site-logo',
	);

	/**
	 * Filters the theme block patterns.
	 *
	 * @since 1.0
	 *
	 * @param array $block_patterns List of block patterns by name.
	 */
	$block_patterns = apply_filters( 'broilda_block_patterns', $block_patterns );

	foreach ( $block_patterns as $block_pattern ) {
		$pattern_file = get_parent_theme_file_path( '/inc/patterns/' . $block_pattern . '.php' );

		register_block_pattern(
			'broilda/' . $block_pattern,
			require $pattern_file
		); // register_block_pattern( string $pattern_name, array $pattern_properties )
	}

}

add_action( 'init', 'broilda_register_block_patterns', 9 );