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

if ( ! doctor_physician_has_page_header() ) {
    return;
}

$doctor_physician_classes = array( 'page-header' );
$doctor_physician_style = doctor_physician_page_header_style();

if ( $doctor_physician_style ) {
    $doctor_physician_classes[] = $doctor_physician_style . '-page-header';
}

$doctor_physician_visibility = get_theme_mod( 'doctor_physician_page_header_visibility', 'all-devices' );

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

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

$doctor_physician_PAGE_TITLE_background_color = get_theme_mod('doctor_physician_page_title_background_color_setting', '');

// Get the toggle switch value
$doctor_physician_background_image_enabled = get_theme_mod('doctor_physician_page_header_style', true);

// Add background image to the header if enabled
$doctor_physician_background_image = get_theme_mod( 'doctor_physician_page_header_background_image', '' );
$doctor_physician_background_height = get_theme_mod( 'doctor_physician_page_header_image_height', '200' );
$doctor_physician_inline_style = '';

if ( $doctor_physician_background_image_enabled && ! empty( $doctor_physician_background_image ) ) {
    $doctor_physician_inline_style .= 'background-image: url(' . esc_url( $doctor_physician_background_image ) . '); ';
    $doctor_physician_inline_style .= 'height: ' . esc_attr( $doctor_physician_background_height ) . 'px; ';
    $doctor_physician_inline_style .= 'background-size: cover; ';
    $doctor_physician_inline_style .= 'background-position: center center; ';

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

$doctor_physician_classes = implode( ' ', $doctor_physician_classes );
$doctor_physician_heading = get_theme_mod( 'doctor_physician_page_header_heading_tag', 'h1' );
$doctor_physician_heading = apply_filters( 'doctor_physician_page_header_heading', $doctor_physician_heading );

?>

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

<header class="<?php echo esc_attr( $doctor_physician_classes ); ?>" style="<?php echo esc_attr( $doctor_physician_inline_style ); ?> background-color: <?php echo esc_attr($doctor_physician_PAGE_TITLE_background_color); ?>;">

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

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

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

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

        <?php endif; ?>

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

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

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

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

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