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

if ( ! moving_truck_rental_has_page_header() ) {
    return;
}

$moving_truck_rental_classes = array( 'page-header' );
$moving_truck_rental_style = moving_truck_rental_page_header_style();

if ( $moving_truck_rental_style ) {
    $moving_truck_rental_classes[] = $moving_truck_rental_style . '-page-header';
}

$moving_truck_rental_visibility = get_theme_mod( 'moving_truck_rental_page_header_visibility', 'all-devices' );

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

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

$moving_truck_rental_PAGE_TITLE_background_color = get_theme_mod('moving_truck_rental_page_title_background_color_setting', '#eaeaea');

// Get the toggle switch value
$moving_truck_rental_background_image_enabled = get_theme_mod('moving_truck_rental_page_header_style', true);

// Add background image to the header if enabled
$moving_truck_rental_background_image = get_theme_mod( 'moving_truck_rental_page_header_background_image', '' );
$moving_truck_rental_background_height = get_theme_mod( 'moving_truck_rental_page_header_image_height', '200' );
$moving_truck_rental_inline_style = '';

if ( $moving_truck_rental_background_image_enabled && ! empty( $moving_truck_rental_background_image ) ) {
    $moving_truck_rental_inline_style .= 'background-image: url(' . esc_url( $moving_truck_rental_background_image ) . '); ';
    $moving_truck_rental_inline_style .= 'height: ' . esc_attr( $moving_truck_rental_background_height ) . 'px; ';
    $moving_truck_rental_inline_style .= 'background-size: cover; ';
    $moving_truck_rental_inline_style .= 'background-position: center center; ';

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

$moving_truck_rental_classes = implode( ' ', $moving_truck_rental_classes );
$moving_truck_rental_heading = get_theme_mod( 'moving_truck_rental_page_header_heading_tag', 'h1' );
$moving_truck_rental_heading = apply_filters( 'moving_truck_rental_page_header_heading', $moving_truck_rental_heading );

?>

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

<header class="<?php echo esc_attr( $moving_truck_rental_classes ); ?>" style="<?php echo esc_attr( $moving_truck_rental_inline_style ); ?> background-color: <?php echo esc_attr($moving_truck_rental_PAGE_TITLE_background_color); ?>;">

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

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

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

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

        <?php endif; ?>

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

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

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

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

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