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

if ( ! jewelry_accessories_has_page_header() ) {
    return;
}

$jewelry_accessories_classes = array( 'page-header' );
$jewelry_accessories_style = jewelry_accessories_page_header_style();

if ( $jewelry_accessories_style ) {
    $jewelry_accessories_classes[] = $jewelry_accessories_style . '-page-header';
}

$jewelry_accessories_visibility = get_theme_mod( 'jewelry_accessories_page_header_visibility', 'all-devices' );

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

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

$jewelry_accessories_PAGE_TITLE_background_color = get_theme_mod('jewelry_accessories_page_title_background_color_setting', '');

// Get the toggle switch value
$jewelry_accessories_background_image_enabled = get_theme_mod('jewelry_accessories_page_header_style', true);

// Add background image to the header if enabled
$jewelry_accessories_background_image = get_theme_mod( 'jewelry_accessories_page_header_background_image', '' );
$jewelry_accessories_background_height = get_theme_mod( 'jewelry_accessories_page_header_image_height', '200' );
$jewelry_accessories_inline_style = '';

if ( $jewelry_accessories_background_image_enabled && ! empty( $jewelry_accessories_background_image ) ) {
    $jewelry_accessories_inline_style .= 'background-image: url(' . esc_url( $jewelry_accessories_background_image ) . '); ';
    $jewelry_accessories_inline_style .= 'height: ' . esc_attr( $jewelry_accessories_background_height ) . 'px; ';
    $jewelry_accessories_inline_style .= 'background-size: cover; ';
    $jewelry_accessories_inline_style .= 'background-position: center center; ';

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

$jewelry_accessories_classes = implode( ' ', $jewelry_accessories_classes );
$jewelry_accessories_heading = get_theme_mod( 'jewelry_accessories_page_header_heading_tag', 'h1' );
$jewelry_accessories_heading = apply_filters( 'jewelry_accessories_page_header_heading', $jewelry_accessories_heading );

?>

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

<header class="<?php echo esc_attr( $jewelry_accessories_classes ); ?>" style="<?php echo esc_attr( $jewelry_accessories_inline_style ); ?> background-color: <?php echo esc_attr($jewelry_accessories_PAGE_TITLE_background_color); ?>;">

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

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

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

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

        <?php endif; ?>

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

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

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

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

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