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

if ( ! function_exists( 'muskrat_support' ) ) {

	// Sets up theme defaults and registers support for various WordPress features.
	function muskrat_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', 'muskrat_support' );

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

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

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

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

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


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

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

// Add admin page
if ( ! function_exists( 'muskrat_create_menu' ) ) {
	add_action( 'admin_menu', 'muskrat_create_menu' );
	// Adds our dashboard menu item
	function muskrat_create_menu() {
		add_theme_page( 'Muskrat WordPress Theme', 'Muskrat', 'edit_theme_options', 'muskrat', 'muskrat_admin_theme_page' );
	}
}