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

if ( ! function_exists( 'cichlid_support' ) ) {

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

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

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

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

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

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


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

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

// Add admin page
if ( ! function_exists( 'cichlid_create_menu' ) ) {
	add_action( 'admin_menu', 'cichlid_create_menu' );
	// Adds our dashboard menu item
	function cichlid_create_menu() {
		add_theme_page( 'Cichlid WordPress Theme', 'Cichlid', 'edit_theme_options', 'cichlid', 'cichlid_admin_theme_page' );
	}
}