<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( ! jeweler_shop_has_page_header() ) {
    return;
}

$jeweler_shop_classes = array( 'page-header' );
$jeweler_shop_style = jeweler_shop_page_header_style();

if ( $jeweler_shop_style ) {
    $jeweler_shop_classes[] = $jeweler_shop_style . '-page-header';
}

$jeweler_shop_visibility = get_theme_mod( 'jeweler_shop_page_header_visibility', 'all-devices' );

if ( 'hide-all-devices' === $jeweler_shop_visibility ) {
    // Don't show the header at all
    return;
}

if ( 'hide-tablet' === $jeweler_shop_visibility ) {
    $jeweler_shop_classes[] = 'hide-on-tablet';
} elseif ( 'hide-mobile' === $jeweler_shop_visibility ) {
    $jeweler_shop_classes[] = 'hide-on-mobile';
} elseif ( 'hide-tablet-mobile' === $jeweler_shop_visibility ) {
    $jeweler_shop_classes[] = 'hide-on-tablet-mobile';
}

$jeweler_shop_PAGE_TITLE_background_color = get_theme_mod('jeweler_shop_page_title_background_color_setting', '');

// Get the toggle switch value
$jeweler_shop_background_image_enabled = get_theme_mod('jeweler_shop_page_header_style', true);

// Add background image to the header if enabled
$jeweler_shop_background_image = get_theme_mod( 'jeweler_shop_page_header_background_image', '' );
$jeweler_shop_background_height = get_theme_mod( 'jeweler_shop_page_header_image_height', '200' );
$jeweler_shop_inline_style = '';

if ( $jeweler_shop_background_image_enabled && ! empty( $jeweler_shop_background_image ) ) {
    $jeweler_shop_inline_style .= 'background-image: url(' . esc_url( $jeweler_shop_background_image ) . '); ';
    $jeweler_shop_inline_style .= 'height: ' . esc_attr( $jeweler_shop_background_height ) . 'px; ';
    $jeweler_shop_inline_style .= 'background-size: cover; ';
    $jeweler_shop_inline_style .= 'background-position: center center; ';

    // Add the unique class if the background image is set
    $jeweler_shop_classes[] = 'has-background-image';
}

$jeweler_shop_classes = implode( ' ', $jeweler_shop_classes );
$jeweler_shop_heading = get_theme_mod( 'jeweler_shop_page_header_heading_tag', 'h1' );
$jeweler_shop_heading = apply_filters( 'jeweler_shop_page_header_heading', $jeweler_shop_heading );

?>

<?php do_action( 'jeweler_shop_before_page_header' ); ?>

<header class="<?php echo esc_attr( $jeweler_shop_classes ); ?>" style="<?php echo esc_attr( $jeweler_shop_inline_style ); ?> background-color: <?php echo esc_attr($jeweler_shop_PAGE_TITLE_background_color); ?>;">

    <?php do_action( 'jeweler_shop_before_page_header_inner' ); ?>

    <div class="asterthemes-wrapper page-header-inner">

        <?php if ( jeweler_shop_has_page_header() ) : ?>

            <<?php echo esc_attr( $jeweler_shop_heading ); ?> class="page-header-title">
                <?php echo wp_kses_post( jeweler_shop_get_page_title() ); ?>
            </<?php echo esc_attr( $jeweler_shop_heading ); ?>>

        <?php endif; ?>

        <?php if ( function_exists( 'jeweler_shop_breadcrumb' ) ) : ?>
            <?php jeweler_shop_breadcrumb(); ?>
        <?php endif; ?>

    </div><!-- .page-header-inner -->

    <?php do_action( 'jeweler_shop_after_page_header_inner' ); ?>

</header><!-- .page-header -->

<?php do_action( 'jeweler_shop_after_page_header' ); ?>