<?php 
/**
 * Breadcrumb init file
 * @since 1.0
 * @package evaWp
 */
evawp_file_loader( array(
	'breadcrumb/class-breadcrumb',
));

if( !function_exists( 'evawp_breadcrumb_trail' ) ){	
	/**
	 * Shows a breadcrumb for all types of pages.  This is a wrapper function for the Breadcrumb_Trail class,
	 * which should be used in theme templates.
	 *
	 * @since  0.1.0
	 * @access public
	 * @param  array $args Arguments to pass to Breadcrumb_Trail.
	 * @return void
	 */
	function evawp_breadcrumb_trail( $args = array() ) {
		$breadcrumb = apply_filters( 'evawp_breadcrumb_trail_object', null, $args );

		if ( ! is_object( $breadcrumb ) )
			$breadcrumb = new EVAWP_Breadcrumb_Trail( $args );

		return $breadcrumb->trail();
	}
}

if( !function_exists( 'evawp_the_breadcrumb' ) ){
	/**
	 * Calling the main breadcrumb
	 * @since 1.0
	 * @package evaWp
	 */
	function evawp_the_breadcrumb(){
		if( !evawp_customizer_get( 'enable_bc', true ) ){
			return;
		}
		if( is_home() || is_front_page() || is_404() ){
			return;
		}
		$args = array(
		    'container'   => 'div',
		    'show_browse' => false,
		);
		$args = apply_filters( 'evawp-breadcrumb-args', $args );
		echo '<div class="evawp-breadcrumb-wrapper">';
			evawp_breadcrumb_trail( $args );
		echo '</div>';
	}
}

/**
 * Change home to icon
 * @since 1.0
 * @package evaWp
 */
function evawp_change_home_title( $defaults ){
	$defaults[ 'home' ] = '<i class="fas fa-home"></i>';
	return $defaults;
}
add_filter( 'evawp_breadcrumb_trail_labels', 'evawp_change_home_title' );