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

if ( ! function_exists( 'skinclub_support' ) ) :
	/**
	 * Sets up theme defaults and registers support for various WordPress features.
	 *
	 * @since 1.0.0
	 *
	 * @return void
	 */

	function skinclub_support() {

		add_editor_style( get_template_directory_uri().'/assets/css/editor.css' );

		load_theme_textdomain( 'skinclub', get_template_directory() . '/languages' );

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

		// Add support for post thumbnails
		add_theme_support( 'post-thumbnails' );

	}

endif;
add_action( 'after_setup_theme', 'skinclub_support' );

add_action( 'init', 'skinclub_register_block_styles' );

function skinclub_register_block_styles() {
	register_block_style(
	    'core/button',
	    array(
	        'name' => 'shadow-button',
	        'label' => __( 'Shadow Button', 'skinclub' ),
	        'inline_style' => '
	        	.wp-block-button.is-style-shadow-button>.wp-block-button__link {
			    background-color: var(--wp--preset--color--white);
			    color: var(--wp--preset--color--black)
			}

			.wp-block-button.is-style-shadow-button>.wp-block-button__link:hover {
			    background-color: var(--wp--preset--color--contrast);
			    color: var(--wp--preset--color--white)
			}',
		)
	);
	
	register_block_style(
	    'core/list',
	    array(
	        'name' => 'styled-list',
	        'label' => __( 'Styled List', 'skinclub' ),
			'inline_style' => '
				ul.is-style-styled-list {
					display: flex;
					flex-direction: column;
					justify-items: center;
					align-items: center;
				}
				ul.is-style-styled-list li {
					margin: 25px;
					background-color: var(--wp--preset--color--white);
					padding: 20px;
					margin-left: unset;
					list-style: none;
				}
				ol.is-style-styled-list li {
					margin: 25px;
					background-color: var(--wp--preset--color--white);
					padding: 20px;
					margin-left: unset;
					list-style: none;
				}',
		)
	);

	register_block_style(
	    'woocommerce/product-image',
	    array(
	        'name' => 'rounded-image',
	        'label' => __( 'Rounded Image', 'skinclub' ),
	        'inline_style' => '
	        	.is-style-rounded-image.wc-block-components-product-image img {
				    border-top-right-radius: 5px !important;
				    border-top-left-radius: 5px !important;
			}',
		)
	);

	register_block_style(
		'core/paragraph',
		array(
			'name'         => 'admin-icon',
			'label'        => __( 'Admin Icon', 'skinclub' ),
			'inline_style' => '
			.is-style-admin-icon:before {
				content: "\f110";
				font-family: "Dashicons";
			}
			.is-style-admin-icon span{
				display: none;
			}',
		)
	);

	register_block_style(
		'core/paragraph',
		array(
			'name'         => 'mini-cart-icon',
			'label'        => __( 'Mini Cart Icon', 'skinclub' ),
			'inline_style' => '
			.is-style-mini-cart-icon:before {
				content: "\f174";
				font-family: "Dashicons";
			}
			.is-style-mini-cart-icon span{
				display: none;
			}',
		)
	);
}


function enqueue_skinclub_styles() {
    // Register and enqueue your stylesheet
    wp_enqueue_style( 
    	'skinclub-style', 
    	get_template_directory_uri() . '/style.css', 
    	array(), 
    	'1.0.0', 
    	'all'
    );

    wp_enqueue_script( 
    	'skinclub-script', 
    	get_template_directory_uri() . '/assets/js/script.js', 
    	array('jquery'), 
    	'1.0.0', 
    	true
    );

    wp_enqueue_script( 
    	'matchHeight', 
    	get_template_directory_uri() . '/assets/js/matchHeight/jquery.matchHeight.js', 
    	array('jquery'), 
    	'1.0', 
    	true
    );

    wp_enqueue_style( 'dashicons' );
}
// Hook the function to the 'wp_enqueue_scripts' action
add_action( 'wp_enqueue_scripts', 'enqueue_skinclub_styles' );

add_action( 'enqueue_block_assets', function (): void {
	wp_enqueue_style( 'dashicons' );
});

// admin style
function skinclub_admin_styles() {
	wp_enqueue_style(
		'wc-shop-admin-style',
		get_template_directory_uri() . '/assets/css/theme-info.css',
		[],
		wp_get_theme()->get( 'Version' )
	);
}
add_action( 'admin_enqueue_scripts', 'skinclub_admin_styles' );

require get_template_directory() . '/inc/pattern-category.php';

// tgm-plugin
require get_template_directory() . '/inc/tgm-plugin/tgmpa-hook.php';

// admin Info
require get_template_directory() . '/class/admin-info.php';