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

if ( ! lawyer_consultant_firm_has_page_header() ) {
    return;
}

$lawyer_consultant_firm_classes = array( 'page-header' );
$lawyer_consultant_firm_style = lawyer_consultant_firm_page_header_style();

if ( $lawyer_consultant_firm_style ) {
    $lawyer_consultant_firm_classes[] = $lawyer_consultant_firm_style . '-page-header';
}

$lawyer_consultant_firm_visibility = get_theme_mod( 'lawyer_consultant_firm_page_header_visibility', 'all-devices' );

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

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

$lawyer_consultant_firm_PAGE_TITLE_background_color = get_theme_mod('lawyer_consultant_firm_page_title_background_color_setting', '');

// Get the toggle switch value
$lawyer_consultant_firm_background_image_enabled = get_theme_mod('lawyer_consultant_firm_page_header_style', true);

// Add background image to the header if enabled
$lawyer_consultant_firm_background_image = get_theme_mod( 'lawyer_consultant_firm_page_header_background_image', '' );
$lawyer_consultant_firm_background_height = get_theme_mod( 'lawyer_consultant_firm_page_header_image_height', '200' );
$lawyer_consultant_firm_inline_style = '';

if ( $lawyer_consultant_firm_background_image_enabled && ! empty( $lawyer_consultant_firm_background_image ) ) {
    $lawyer_consultant_firm_inline_style .= 'background-image: url(' . esc_url( $lawyer_consultant_firm_background_image ) . '); ';
    $lawyer_consultant_firm_inline_style .= 'height: ' . esc_attr( $lawyer_consultant_firm_background_height ) . 'px; ';
    $lawyer_consultant_firm_inline_style .= 'background-size: cover; ';
    $lawyer_consultant_firm_inline_style .= 'background-position: center center; ';

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

$lawyer_consultant_firm_classes = implode( ' ', $lawyer_consultant_firm_classes );
$lawyer_consultant_firm_heading = get_theme_mod( 'lawyer_consultant_firm_page_header_heading_tag', 'h1' );
$lawyer_consultant_firm_heading = apply_filters( 'lawyer_consultant_firm_page_header_heading', $lawyer_consultant_firm_heading );

?>

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

<header class="<?php echo esc_attr( $lawyer_consultant_firm_classes ); ?>" style="<?php echo esc_attr( $lawyer_consultant_firm_inline_style ); ?> background-color: <?php echo esc_attr($lawyer_consultant_firm_PAGE_TITLE_background_color); ?>;">

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

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

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

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

        <?php endif; ?>

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

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

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

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

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