<?php
/**
 * Template part for breadcrumb.
 *
 * @package Ogma
 */

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

$site_breadcrumb_enable = ogma_get_customizer_option_value( 'site_breadcrumb_enable' );

if ( false === $site_breadcrumb_enable ) {
    return;
}

$site_breadcrumb_types = ogma_get_customizer_option_value( 'site_breadcrumb_types' );

if ( ! function_exists( 'ogma_breadcrumb_trail' ) ) :

    /**
     *  function to manage the breadcrumb trail
     * 
     * @since 1.0.0
     */
    function ogma_breadcrumb_trail() {

        $ogma_body_classes = get_body_class();
        if ( in_array( 'woocommerce', $ogma_body_classes ) ) {
            woocommerce_breadcrumb();
            return;
        }

        if ( ! function_exists( 'breadcrumb_trail' ) ) {
            // load class file
            require_once get_template_directory() . '/inc/ogma-class-breadcrumb.php';
        }

        $ogma_breadcrumb_args = array(
            'container'   => 'div',
            'show_browse' => false,
        );

        breadcrumb_trail( $ogma_breadcrumb_args );
    }
    
endif;

?>
<div class="ogma-breadcrumb-wrapper">
    <div class="ogma-container">
        <?php
            switch ( $site_breadcrumb_types ) {
                case 'navxt':
                    if ( function_exists( 'bcn_display' ) ) {
                        echo '<nav id="breadcrumb" class="ogma-breadcrumb">';
                            bcn_display();
                        echo '</nav>';
                    }
                    break;

                case 'yoast':
                    if ( function_exists( 'yoast_breadcrumb' ) && true === WPSEO_Options::get( 'breadcrumbs-enable', false ) ) {
                        yoast_breadcrumb( '<nav id="breadcrumb" class="ogma-breadcrumb">', '</nav>' );
                    }
                    break;

                case 'rankmath':
                    if ( function_exists( 'rank_math_the_breadcrumbs' ) && RankMath\Helper::get_settings( 'general.breadcrumbs' ) ) {
                        rank_math_the_breadcrumbs();
                    }
                    break;
                
                default:
                    ogma_breadcrumb_trail();
                    break;
            }
        ?>
    </div><!-- .ogma-container -->
</div><!-- .ogma-breadcrumb-wrapper -->