<?php
/**
 * Functions which enhance the theme by hooking into WordPress
 *
 * @package Blog Bee
 */
use BBE\Customizer\Theme_Defaults as Theme_Defaults;
/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function blog_bee_body_classes( $classes ) {
	// Adds a class of hfeed to non-singular pages.
	if ( ! is_singular() ) {
		$classes[] = 'hfeed';
	}

	// Adds a class of no-sidebar when there is no sidebar present.
	if ( ! is_active_sidebar( 'sidebar-1' ) ) {
		$classes[] = 'no-sidebar';
	}

	$classes[] = 'bbe-light';
	$classes[] = 'block-title--' . Theme_Defaults::get_theme_option( 'block_title_layouts' );
	$classes[] = 'block-align--' . Theme_Defaults::get_theme_option( 'block_title_alignment' );
	$classes[] = 'meta-seperator--' . Theme_Defaults::get_theme_option( 'meta_seperator_icon' );
	$classes[] = 'post-title--' . Theme_Defaults::get_theme_option( 'hover_effects_post_title_hover' );
	$classes[] = 'image-hover--' . Theme_Defaults::get_theme_option( 'hover_effects_image_hover' );
	$classes[] = 'show-date--' . Theme_Defaults::get_theme_option( 'seo_misc_date_to_display' );
	$classes[] = 'card--' . Theme_Defaults::get_theme_option( 'card_settings_container' );
	$classes[] = 'background--' . Theme_Defaults::get_theme_option( 'background_animation' );
	$classes[] = 'width-layout--' . Theme_Defaults::get_theme_option( 'site_container_width' );

	$cat_style = Theme_Defaults::get_theme_option( 'category_colors_style' );
	if( $cat_style ) {
		$cat_classes = 'cat-' . str_replace( ' ', ' cat-', $cat_style );
		$classes[] = $cat_classes;
	}
	
	$card = Theme_Defaults::get_theme_option( 'card_settings_container' );
	if( $card == 'boxed' ) {
		if( Theme_Defaults::get_theme_option( 'card_settings_animation' ) ) $classes[] = 'card-animation--on';
	}

	return $classes;
}
add_filter( 'body_class', 'blog_bee_body_classes' );

/**
 * Add a pingback url auto-discovery header for single posts, pages, or attachments.
 */
function blog_bee_pingback_header() {
	if ( is_singular() && pings_open() ) {
		printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
	}
}
add_action( 'wp_head', 'blog_bee_pingback_header' );

/**
 * Customizer Defaults
 * 
 * @since 1.0.0
 */
require_once get_template_directory() . '/inc/customizer/theme-starter.php';

/**
 * Enqueue files
 * 
 * @since 1.0.0
 */
require_once get_template_directory() . '/inc/enqueue.php';

/**
 * Customizer Sanitize Function
 * 
 * @since 1.0.0
 */
require_once get_template_directory() . '/inc/customizer/sanitize-functions.php';

/**
 * Helper Functions
 * 
 * @since 1.0.0
 */
require_once get_template_directory() . '/inc/helpers.php';