<?php
/**
 * Breadcrumbs for this theme
 *
 * The file loading under functions.php
 *
 * @package RB_Themes
 * @subpackage RB_Blog_Two
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/*
============================================
Table of Breadcrumbs Functions List Start Here
==============================================
	01. Breadcrumbs Description
	02. Breadcrumbs Title
	03. Breadcrumbs Navbar
*/

if ( ! function_exists( 'rb_blog_two_archive_description_custom' ) ) {
	/**
	 * Breadcrumbs Description.
	 */
	function rb_blog_two_archive_description_custom() {
		$description = get_the_archive_description();
		if ( $description ) {
			if ( is_author() ) {
				?>
				<div class="breadcrumbs-description">
					<?php echo esc_html( $description ); ?>
				</div>
				<?php
			} elseif ( is_category() ) {
				?>
				<div class="breadcrumbs-description">
					<?php echo esc_html( $description ); ?>
				</div>
				<?php
			} elseif ( is_tag() ) {
				?>
				<div class="breadcrumbs-description">
					<?php echo esc_html( $description ); ?>
				</div>
				<?php
			} elseif ( is_tax() ) {
				?>
				<div class="breadcrumbs-description">
					<?php echo esc_html( $description ); ?>
				</div>
				<?php
			}
		}
	}
	add_action( 'rb_blog_two_archive_description', 'rb_blog_two_archive_description_custom' );
}

if ( ! function_exists( 'rb_blog_two_breadcrumbs_title_custom' ) ) {
	/**
	 * Breadcrumbs Title.
	 */
	function rb_blog_two_breadcrumbs_title_custom() {
		if ( is_front_page() || is_home() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( 'Blog Page', 'rb-blog-two' )
			);
		} elseif ( is_singular() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html( get_the_title() )
			);
		} elseif ( is_search() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( 'Search Page', 'rb-blog-two' )
			);
		} elseif ( is_404() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( '404 Page', 'rb-blog-two' )
			);
		} elseif ( is_year() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( 'Year Archive', 'rb-blog-two' )
			);
		} elseif ( is_month() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( 'Month Archive', 'rb-blog-two' )
			);
		} elseif ( is_day() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( 'Day Archive', 'rb-blog-two' )
			);
		} elseif ( is_author() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( 'Author Page', 'rb-blog-two' )
			);
		} elseif ( is_category() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( 'Category Page', 'rb-blog-two' )
			);
		} elseif ( is_tag() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( 'Tag Page', 'rb-blog-two' )
			);
		} elseif ( is_tax() ) {
			printf(
				/* translators: Breadcrumbs Title. */
				'<h2 class="breadcrumbs-title">%s</h2>',
				esc_html__( 'Taxonomy Page', 'rb-blog-two' )
			);
		}
	}
	add_action( 'rb_blog_two_breadcrumbs_title', 'rb_blog_two_breadcrumbs_title_custom' );
}

if ( ! function_exists( 'rb_blog_two_breadcrumbs_nav_custom' ) ) {
	/**
	 * Breadcrumbs Navbar.
	 */
	function rb_blog_two_breadcrumbs_nav_custom() {
		if ( function_exists( 'bcn_display' ) ) {
			?>
			<nav class="breadcrumbs-nav">
				<ul>
					<?php bcn_display(); ?>
				</ul>
			</nav>
			<?php
		}
	}
	add_action( 'rb_blog_two_breadcrumbs_nav', 'rb_blog_two_breadcrumbs_nav_custom' );
}