<?php
/**
 * Barbel functions and definitions
 */

if ( ! function_exists( 'barbel_support' ) ) {

	// Sets up theme defaults and registers support for various WordPress features.
	function barbel_support() {

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

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

	}
}
add_action( 'after_setup_theme', 'barbel_support' );

if ( ! function_exists( 'barbel_styles' ) ) {
	// Enqueue styles.
	function barbel_styles() {

		// Register theme stylesheet.
		wp_register_style(
			'barbel-style',
			get_template_directory_uri() . '/assets/css/theme.min.css',
			array(),
			wp_get_theme()->get( 'Version' )
		);

		// Enqueue theme stylesheet.
		wp_enqueue_style( 'barbel-style' );

	}
}
add_action( 'wp_enqueue_scripts', 'barbel_styles' );

if ( ! function_exists( 'barbel_editor_styles' ) ) {
	// Enqueue editor styles.
	function barbel_editor_styles() {
		add_editor_style(
			get_template_directory_uri() . '/assets/css/theme.min.css'
		);
	}
}
add_action( 'admin_init', 'barbel_editor_styles' );


// Add script to Editor
if ( ! function_exists( 'barbel_admin_add_scripts' ) ) {
	function barbel_admin_add_scripts( $hook ){
		if ( 'appearance_page_barbel' != $hook ) {
			return;
		}
		
		wp_register_style( 'barbel-settings-css',  get_template_directory_uri() . '/assets/css/admin.min.css' , '1.0.0' );
		wp_enqueue_style( 'barbel-settings-css');
	
	}
}
add_action( 'admin_enqueue_scripts', 'barbel_admin_add_scripts');

// Add admin page content
get_template_part( 'inc/theme' );

// Add admin page
if ( ! function_exists( 'barbel_create_menu' ) ) {
	add_action( 'admin_menu', 'barbel_create_menu' );
	// Adds our dashboard menu item
	function barbel_create_menu() {
		add_theme_page( 'Barbel WordPress Theme', 'Barbel', 'edit_theme_options', 'barbel', 'barbel_admin_theme_page' );
	}
}