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

if ( ! florist_bouquet_has_page_header() ) {
    return;
}

$florist_bouquet_classes = array( 'page-header' );
$florist_bouquet_style = florist_bouquet_page_header_style();

if ( $florist_bouquet_style ) {
    $florist_bouquet_classes[] = $florist_bouquet_style . '-page-header';
}

$florist_bouquet_visibility = get_theme_mod( 'florist_bouquet_page_header_visibility', 'all-devices' );

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

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

$florist_bouquet_PAGE_TITLE_background_color = get_theme_mod('florist_bouquet_page_title_background_color_setting', '');

// Get the toggle switch value
$florist_bouquet_background_image_enabled = get_theme_mod('florist_bouquet_page_header_style', true);

// Add background image to the header if enabled
$florist_bouquet_background_image = get_theme_mod( 'florist_bouquet_page_header_background_image', '' );
$florist_bouquet_background_height = get_theme_mod( 'florist_bouquet_page_header_image_height', '200' );
$florist_bouquet_inline_style = '';

if ( $florist_bouquet_background_image_enabled && ! empty( $florist_bouquet_background_image ) ) {
    $florist_bouquet_inline_style .= 'background-image: url(' . esc_url( $florist_bouquet_background_image ) . '); ';
    $florist_bouquet_inline_style .= 'height: ' . esc_attr( $florist_bouquet_background_height ) . 'px; ';
    $florist_bouquet_inline_style .= 'background-size: cover; ';
    $florist_bouquet_inline_style .= 'background-position: center center; ';

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

$florist_bouquet_classes = implode( ' ', $florist_bouquet_classes );
$florist_bouquet_heading = get_theme_mod( 'florist_bouquet_page_header_heading_tag', 'h1' );
$florist_bouquet_heading = apply_filters( 'florist_bouquet_page_header_heading', $florist_bouquet_heading );

?>

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

<header class="<?php echo esc_attr( $florist_bouquet_classes ); ?>" style="<?php echo esc_attr( $florist_bouquet_inline_style ); ?> background-color: <?php echo esc_attr($florist_bouquet_PAGE_TITLE_background_color); ?>;">

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

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

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

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

        <?php endif; ?>

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

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

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

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

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