<?php

/**
 * Update Elementor Options
 */
function ultimate_hotel_booking_load_elementor_options() {  
    update_option( 'elementor_disable_color_schemes', 'yes' );
    update_option( 'elementor_disable_typography_schemes', 'yes' );
    update_option( 'elementor_global_image_lightbox', '' );
}
add_action( 'elementor/loaded', 'ultimate_hotel_booking_load_elementor_options' );

/**
 * Disable Getting Start - Elementor 
 */
function ultimate_hotel_booking_elementor_loaded_function() {
    if ( did_action( 'elementor/loaded' ) ) {
        remove_action( 'admin_init', [ \Elementor\Plugin::$instance->admin, 'maybe_redirect_to_getting_started' ] );
    }
};
add_action( 'admin_init', 'ultimate_hotel_booking_elementor_loaded_function', 1 );

/**
 * Posts Paginations
 */
if ( !function_exists('ultimate_hotel_booking_posts_pagination') ) {
    function ultimate_hotel_booking_posts_pagination(){
        the_posts_pagination( array(
            'mid_size'  => 1,
            'prev_text'          => '<i class="fas fa-arrow-left"></i>',
            'next_text'          => '<i class="fas fa-arrow-right"></i>',
            'before_page_number' => '<span class="meta-nav screen-reader-text">' . esc_html__( 'Page', 'ultimate-hotel-booking' ) . ' </span>',
        ) );
    } 
}

if ( ! function_exists( 'ultimate_hotel_booking_archive_page_banner' ) ) {
    function ultimate_hotel_booking_archive_page_banner(){
        $ultimate_hotel_booking_prefix = 'travelfic_customizer_settings_';
        $ultimate_hotel_booking_ImageUrl = get_theme_mod($ultimate_hotel_booking_prefix.'tf_archive_header_img' , get_template_directory_uri() . '/assets/img/page_header.jpg');
        
        $ultimate_hotel_booking_banner = get_theme_mod($ultimate_hotel_booking_prefix . 'archive_banner', 'banner');
        $ultimate_hotel_booking_disable_banner = get_post_meta( get_the_ID(), 'ultimate-hotel-booking-pmb-banner', true );
        
        if( $ultimate_hotel_booking_disable_banner != 1 && $ultimate_hotel_booking_banner == 'banner' ){
            ?>
                <div class="tf-page-header-inner ultimate-hotel-booking-page-banner blog" style="background-image:url('<?php echo esc_url( $ultimate_hotel_booking_ImageUrl ); ?>');">
                    <div class="<?php echo esc_attr( apply_filters( 'ultimate_hotel_booking_page_tftcontainer', $ultimate_hotel_booking_container = '') ); ?>">
                        <?php  
                            the_archive_title( '<h1 class="page-title">', '</h1>' );
                            the_archive_description( '<div class="archive-description">', '</div>' );
                        ?>
                    </div>
                </div>
            <?php
        }elseif( $ultimate_hotel_booking_banner == 'title'){
            ?>
                <div class="<?php echo esc_attr( apply_filters( 'ultimate_hotel_booking_page_tftcontainer', $ultimate_hotel_booking_container = '') ); ?>">
                    <div class="ultimate-hotel-booking-blog-header">
                        <header class="entry-header">
                            <?php  
                                the_archive_title( '<h1 class="page-title">', '</h1>' );
                                the_archive_description( '<div class="archive-description">', '</div>' );
                            ?>
                        </header><!-- .entry-header -->
                    </div>
                </div>
            <?php
        }
    }
}

if ( ! function_exists( 'ultimate_hotel_booking_blog_page_banner' ) ) {
    function ultimate_hotel_booking_blog_page_banner(){
        $ultimate_hotel_booking_prefix = 'travelfic_customizer_settings_';
        $ultimate_hotel_booking_ImageUrl = get_theme_mod($ultimate_hotel_booking_prefix.'tf_archive_header_img' , get_template_directory_uri() . '/assets/img/page_header.jpg');
        
        $ultimate_hotel_booking_banner = get_theme_mod($ultimate_hotel_booking_prefix . 'blog_banner', 'banner');
        $ultimate_hotel_booking_disable_banner = get_post_meta( get_the_ID(), 'ultimate-hotel-booking-pmb-banner', true );
        
        if( $ultimate_hotel_booking_disable_banner != 1 && $ultimate_hotel_booking_banner == 'banner' ){
            ?>
                <div class="tf-page-header-inner ultimate-hotel-booking-page-banner blog" style="background-image:url('<?php echo esc_url( $ultimate_hotel_booking_ImageUrl ); ?>');">
                    <h1 class="entry-title"><?php echo esc_html( get_bloginfo( 'name' ) ); ?></h1>
                </div>
            <?php
        }elseif( $ultimate_hotel_booking_banner == 'title' || $ultimate_hotel_booking_banner != 'empty' ){
            ?>
                <div class="<?php echo esc_attr( apply_filters( 'ultimate_hotel_booking_page_tftcontainer', $ultimate_hotel_booking_container = '') ); ?>">
                    <div class="ultimate-hotel-booking-blog-header">
                        <header class="entry-header">
                            <h1 class="entry-title"><?php echo esc_html( get_bloginfo( 'name' ) ); ?></h1>
                        </header><!-- .entry-header -->
                    </div>
                </div>
            <?php
        }
    }
}