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

if ( ! online_school_courses_has_page_header() ) {
    return;
}

$online_school_courses_classes = array( 'page-header' );
$online_school_courses_style = online_school_courses_page_header_style();

if ( $online_school_courses_style ) {
    $online_school_courses_classes[] = $online_school_courses_style . '-page-header';
}

$online_school_courses_visibility = get_theme_mod( 'online_school_courses_page_header_visibility', 'all-devices' );

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

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

$online_school_courses_PAGE_TITLE_background_color = get_theme_mod('online_school_courses_page_title_background_color_setting', '');

// Get the toggle switch value
$online_school_courses_background_image_enabled = get_theme_mod('online_school_courses_page_header_style', true);

// Add background image to the header if enabled
$online_school_courses_background_image = get_theme_mod( 'online_school_courses_page_header_background_image', '' );
$online_school_courses_background_height = get_theme_mod( 'online_school_courses_page_header_image_height', '200' );
$online_school_courses_inline_style = '';

if ( $online_school_courses_background_image_enabled && ! empty( $online_school_courses_background_image ) ) {
    $online_school_courses_inline_style .= 'background-image: url(' . esc_url( $online_school_courses_background_image ) . '); ';
    $online_school_courses_inline_style .= 'height: ' . esc_attr( $online_school_courses_background_height ) . 'px; ';
    $online_school_courses_inline_style .= 'background-size: cover; ';
    $online_school_courses_inline_style .= 'background-position: center center; ';

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

$online_school_courses_classes = implode( ' ', $online_school_courses_classes );
$online_school_courses_heading = get_theme_mod( 'online_school_courses_page_header_heading_tag', 'h1' );
$online_school_courses_heading = apply_filters( 'online_school_courses_page_header_heading', $online_school_courses_heading );

?>

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

<header class="<?php echo esc_attr( $online_school_courses_classes ); ?>" style="<?php echo esc_attr( $online_school_courses_inline_style ); ?> background-color: <?php echo esc_attr($online_school_courses_PAGE_TITLE_background_color); ?>;">

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

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

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

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

        <?php endif; ?>

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

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

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

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

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