<?php
/**
 * Shop breadcrumb
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see         https://docs.woocommerce.com/document/template-structure/
 * @package     WooCommerce/Templates
 * @version     2.3.0
 * @see         woocommerce_breadcrumb()
 *
 * @var string $wrap_before
 * @var string $before
 * @var string $after
 * @var string $delimiter
 * @var string $wrap_after
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! empty( $breadcrumb ) ) {
	if ( ! empty( $wrap_before ) ) {
		echo trim($wrap_before);//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	}

	foreach ( $breadcrumb as $key => $crumb ) {
		if ( ! empty( $before ) ) {
			echo trim($before);//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		}

		if ( ! empty( $crumb[1] ) && count( $breadcrumb ) !== $key + 1 ) {
			if ( 0 === $key ) {
				echo '<a href="' . esc_url( $crumb[1] ) . '"><i class="fa-solid fa-house"></i></a>';
			} else {
				echo '<a href="' . esc_url( $crumb[1] ) . '">' . esc_html( $crumb[0] ) . '</a>';
			}
		} else {
			echo esc_html( $crumb[0] );
		}

		if ( ! empty( $after ) ) {
			echo trim($after);//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		}

		if ( count( $breadcrumb ) !== $key + 1 ) {
			echo trim($delimiter);//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		}
	}

	if ( ! empty( $wrap_after ) ) {
		echo trim($wrap_after);//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	}
}
