<?php
/**
 * Enqueue scripts and styles.
 */

function author_personal_blog_scripts() {
	$isMasonryActivated = get_theme_mod('active_masonry_layout', true);
	$isBookSliderActivated = get_theme_mod('books_slider_on_off', false);
	if ( (is_home() && true == $isBookSliderActivated) || class_exists('WooCommerce') && is_product()) {
		wp_enqueue_style( 'slick', esc_url(get_theme_file_uri( 'assets/css/slick.css' )) );
	}
	if ( function_exists( 'is_woocommerce' ) && ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) ) {
		wp_enqueue_style( 'author-personal-blog-woocommerce', esc_url(get_theme_file_uri( 'assets/css/woocommerce.css' )) );
	}
	if (class_exists('Rswpbs') && true == $isBookSliderActivated ) {
		wp_enqueue_style( 'author-personal-blog-rswpbs', esc_url(get_theme_file_uri( 'assets/css/rswpbs.css' )) );
	}
	wp_enqueue_style( 'author-personal-blog-style', get_stylesheet_uri() );
	if ( (is_home() || is_archive()) && true == $isMasonryActivated) :
		wp_enqueue_script( 'imagesloaded', esc_url( get_template_directory_uri() ) . '/assets/js/imagesloaded.pkgd.min.js', array( 'jquery' ), '1.0', true );
		wp_enqueue_script( 'masonry' );
	endif;
	wp_enqueue_script( 'author-personal-blog-menu', esc_url( get_template_directory_uri() ) . '/assets/js/menu.js', array( 'jquery' ), '1.0', true );
	$is_home_slider = is_home() && $isBookSliderActivated;
	$is_product_page = class_exists('WooCommerce') && is_product();

	if ( $is_home_slider || $is_product_page ) {
	    wp_enqueue_script( 'slick', get_template_directory_uri() . '/assets/js/slick.js', array( 'jquery' ), '1.0', true );

	}
	wp_enqueue_script( 'author-personal-blog-active', esc_url( get_template_directory_uri() ) . '/assets/js/active.js', array( 'jquery' ), '1.0', true );
	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}
}
add_action( 'wp_enqueue_scripts', 'author_personal_blog_scripts' );

add_action('customize_controls_enqueue_scripts', 'author_personal_blog_customizer_scripts');
function author_personal_blog_customizer_scripts(){
	wp_enqueue_style('customizer-style', esc_url(get_theme_file_uri('assets/customizer/customizer-style.css')));
}

add_action('enqueue_block_editor_assets', 'author_personal_blog_global_scripts');
add_action('wp_enqueue_scripts', 'author_personal_blog_global_scripts');

function author_personal_blog_global_scripts(){
	wp_enqueue_style( 'bootstrap-grid', esc_url(get_theme_file_uri( 'assets/css/bootstrap-grid.css' )) );
	// wp_enqueue_style( 'fontawesome-v4', esc_url(get_theme_file_uri( 'assets/css/fontawesome.css' )) );
	wp_enqueue_style( 'rswpthemes-icons', esc_url(get_theme_file_uri( 'assets/icons/icons.css' )) );
	wp_enqueue_style( 'block-style', esc_url(get_theme_file_uri( 'assets/blocks-style/block-styles.css' )) );
}
