<?php
/**
 * Load CSS and JavaScripts.
 *
 * @package brahma
 * @since 1.0.0
 */

namespace Brahma;

/**
 * Enqueue block variation script.
 */
function brahma_enqueue_block_variations() {
	wp_enqueue_script(
		BRAHMA_SLUG . '-enqueue-block-variations',
		get_template_directory_uri() . '/assets/js/variations.js',
		array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ),
		BRAHMA_VERSION
	);
}
add_action( 'enqueue_block_editor_assets', BRAHMA_NS . 'brahma_enqueue_block_variations' );

/**
 * Redirecting and loading style.css for the editor.
 */
function brahma_add_editor_scripts() {
	add_editor_style( '/assets/css/style.css' );
}
add_action( 'after_setup_theme', BRAHMA_NS . 'brahma_add_editor_scripts' );

/**
 * Loading style . css for the editor
 */
function brahma_front_end_scripts() {
	wp_enqueue_style(
		'main-styles',
		get_template_directory_uri() . '/assets/css/style.css',
		array(),
		BRAHMA_VERSION
	);
}
add_action( 'wp_enqueue_scripts', BRAHMA_NS . 'brahma_front_end_scripts' );


/**
 * Editor
 */

if ( ! function_exists( 'brahma_theme_setup' ) ) {
	/**
	 * Redirecting and loading style.css for the editor.
	 * Remove core block patterns.
	 */
	function brahma_theme_setup() {
		// Add support for editor styles.
		add_editor_style( '/assets/css/style.css' );

		// Remove default core block patterns.
		remove_theme_support( 'core-block-patterns' );
	}
}
add_action( 'after_setup_theme', BRAHMA_NS . 'brahma_theme_setup' );
