<?php
/**
 * @package Home Shifting Services
 */

/**
 * Footer
 */
if (! function_exists( 'home_shifting_services_footer_copyrights' ) ):
    function home_shifting_services_footer_copyrights() {
        ?>
            <div class="row">
                <div class="copyrights">
                    <p>
                        <?php
                            if("" != esc_html(get_theme_mod( 'home_shifting_services_footer_copyright_text'))) :
                                echo esc_html(get_theme_mod( 'home_shifting_services_footer_copyright_text'));
                                if(get_theme_mod('home_shifting_services_en_footer_credits',true)) :
                                    ?> 
                                    <span class="copyrg-link"><a href="<?php echo esc_url(HOME_SHIFTING_SERVICES_AUT); ?>" target="_blank" rel="nofollow noopener"><?php esc_html_e(' | Home Shifting WordPress Theme','home-shifting-services') ?></a><?php esc_html_e(' by Legacy Themes','home-shifting-services') ?></span>
                                    <?php   
                                endif;
                            else :
                                echo date_i18n(
                                    /* translators: Copyright date format, see https://secure.php.net/date */
                                    _x( 'Y', 'copyright date format', 'home-shifting-services' )
                                );
                                ?>
                                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a>
                                    <span class="copyrg-link"><a href="<?php echo esc_url(HOME_SHIFTING_SERVICES_AUT); ?>" target="_blank" rel="nofollow noopener"><?php esc_html_e(' | Home Shifting WordPress Theme','home-shifting-services') ?></a><?php esc_html_e(' by Legacy Themes','home-shifting-services') ?></span>
                                <?php
                            endif;
                        ?>
                    </p>
                </div>
            </div>
        <?php    
    }
endif;
add_action( 'home_shifting_services_action_footer', 'home_shifting_services_footer_copyrights' );


/**
 * Page Title Settings
 */
if ( ! function_exists( 'home_shifting_services_show_page_title' ) ) :
    function home_shifting_services_show_page_title() {
        if ( ! is_front_page() ) {
            ?>
            <div class="page-title"> 
                <div class="content-section img-overlay">
                    <div class="container">
                        <div class="row text-center">
                            <div class="col-md-12">
                                <div class="section-title"> 
                                    <?php
                                    // WooCommerce Pages
                                    if ( function_exists( 'is_shop' ) && is_shop() ) {
                                        // Shop Page
                                        echo '<h1 class="main-title">' . esc_html__( 'Shop Page', 'home-shifting-services' ) . '</h1>';

                                    } elseif ( function_exists( 'is_product' ) && is_product() ) {
                                        // Single Product Page
                                        echo '<h1 class="main-title">' . esc_html__( 'Single Product Page', 'home-shifting-services' ) . '</h1>';

                                    } elseif ( function_exists( 'is_checkout' ) && is_checkout() ) {
                                        // Checkout Page
                                        echo '<h1 class="main-title">' . esc_html__( 'Checkout', 'home-shifting-services' ) . '</h1>';

                                    } elseif ( function_exists( 'is_account_page' ) && is_account_page() ) {
                                        // My Account Page
                                        echo '<h1 class="main-title">' . esc_html__( 'My Account', 'home-shifting-services' ) . '</h1>';

                                    } elseif ( is_home() ) {
                                        // Blog Index Page
                                        echo '<h1 class="main-title">' . esc_html__( 'Blog Page', 'home-shifting-services' ) . '</h1>';

                                    } elseif ( is_singular( 'post' ) ) {
                                        // Single Blog Post
                                        echo '<h1 class="main-title">' . get_the_title() . '</h1>';

                                    } elseif ( is_category() ) {
                                        echo '<h1 class="main-title">' . single_cat_title( '', false ) . '</h1>';

                                    } elseif ( is_tag() ) {
                                        echo '<h1 class="main-title">' . single_tag_title( '', false ) . '</h1>';

                                    } elseif ( is_author() ) {
                                        echo '<h1 class="main-title">' . get_the_author() . '</h1>';

                                    } elseif ( is_archive() ) {
                                        echo '<h1 class="main-title">' . get_the_archive_title() . '</h1>';

                                    } elseif ( is_search() ) {
                                        echo '<h1 class="main-title">' . esc_html__( 'Search Results', 'home-shifting-services' ) . '</h1>';

                                    } elseif ( is_404() ) {
                                        echo '<h1 class="main-title">' . esc_html__( 'Page Not Found', 'home-shifting-services' ) . '</h1>';

                                    } else {
                                        // Default for all other pages
                                        echo '<h1 class="main-title">' . get_the_title() . '</h1>';
                                    }
                                    ?>
                                </div>                      
                            </div>
                        </div>
                    </div>  
                </div>
            </div>  <!-- End page-title --> 
            <?php
        }
    }
endif;

// Register page title action globally
add_action( 'home_shifting_services_get_page_title', 'home_shifting_services_show_page_title' );

/**
 * Home Banner Section
 */
if (! function_exists( 'home_shifting_services_home_banner_section' ) ):
    function home_shifting_services_home_banner_section() {
        ?>
        <section id="main-banner-wrap">
            <div class="slider-sec">
                <div class="owl-carousel">
                    <?php $home_shifting_services_banner_count = get_theme_mod("home_shifting_services_slider_increase");
                    for ($i = 1; $i <= $home_shifting_services_banner_count; $i++) { ?>
                    <?php
                    $home_shifting_services_banner_image = get_theme_mod( 'home_shifting_services_banner_image'.$i, '' );
                    if ( ! empty( $home_shifting_services_banner_image ) ) { ?>
                        <div class="banner-side-margin position-relative">
                            <div class="overlay-slider"></div>
                            <div class="main-banner-inner-box">
                                <img src="<?php echo esc_url( $home_shifting_services_banner_image ); ?>">
                            </div>
                            <?php
                            $home_shifting_services_alignment_class = get_theme_mod( 'home_shifting_services_slider_content_alignment', 'center' );
                            ?>
                            <div class="main-banner-content-box content-<?php echo esc_attr( $home_shifting_services_alignment_class ); ?>">
                                <?php
                                    $home_shifting_services_banner_heading = get_theme_mod( 'home_shifting_services_banner_heading'.$i, '' );
                                    if ( ! empty( $home_shifting_services_banner_heading ) ) { ?>
                                        <h2 id="banner-heading" class="bnr-hd1 p-0 mb-0 mb-lg-2"><?php echo esc_html( $home_shifting_services_banner_heading ); ?></h2>
                                <?php } ?>
                                <?php
                                    $home_shifting_services_banner_text = get_theme_mod( 'home_shifting_services_banner_text'.$i, '' );
                                    if ( ! empty( $home_shifting_services_banner_text ) ) { ?>
                                        <p class="bnr-txt"><?php echo esc_html( $home_shifting_services_banner_text ); ?></p>
                                <?php } ?> 
                               <div class="btn-box-slid">
                                    <?php
                                    $home_shifting_services_banner_button_link = get_theme_mod( 'home_shifting_services_banner_button_link'.$i, '' );
                                        if ( ! empty( $home_shifting_services_banner_button_link ) ) { ?>
                                        <a class="btn-slid btn mx-2" href="<?php echo esc_url( $home_shifting_services_banner_button_link ); ?>"><?php echo esc_html('GET FREE QUOTE','home-shifting-services'); ?></a>
                                    <?php } ?>
                                    <?php
                                    $home_shifting_services_banner_button_link2 = get_theme_mod( 'home_shifting_services_banner_button_link2'.$i, '' );
                                        if ( ! empty( $home_shifting_services_banner_button_link2 ) ) { ?>
                                        <a class="btn-slid2 btn" href="<?php echo esc_url( $home_shifting_services_banner_button_link2 ); ?>"><?php echo esc_html('OUR SERVICES','home-shifting-services'); ?></a>
                                    <?php } ?>
                                </div>
                            </div>    
                        </div>
                    <?php } } ?>
                </div>
            </div>
        </section>
        <?php
    }
endif;
add_action( 'home_shifting_services_action_home_banner', 'home_shifting_services_home_banner_section' );


/**
 * Home solution Section
 */
if (! function_exists( 'home_shifting_services_home_solution_section' ) ):
    function home_shifting_services_home_solution_section() {
    ?>
    <section id="solution-wrap" class="pb-5">
        <?php 
        $home_shifting_services_solution_section_bg_image = get_theme_mod( 'home_shifting_services_solution_section_bg_image' );

        // Set default image if none is selected in Customizer
        $default_bg_image = get_template_directory_uri() . '/img/solution-bg.png';
        $background_image = !empty($home_shifting_services_solution_section_bg_image) ? $home_shifting_services_solution_section_bg_image : $default_bg_image;
        ?>
        <div class="bg-sect py-5">
            <div class="solu-bg-image" style="background-image: url('<?php echo esc_url($background_image); ?>');">
            </div>
            <div class="container-fluid p-0">
                <div class="inner-wrap pb-4">
                    <div class="solution-head text-center m-auto">
                        <?php
                        $home_shifting_services_solution_main_heading = get_theme_mod( 'home_shifting_services_solution_main_heading', '' );
                        if ( ! empty( $home_shifting_services_solution_main_heading ) ) { ?>
                        <h3 class="soltn-main-hd py-2 mb-0"><?php echo esc_html( $home_shifting_services_solution_main_heading ); ?></h3>
                        <?php } ?>
                        <?php
                        $home_shifting_services_solution_small_heading = get_theme_mod( 'home_shifting_services_solution_small_heading', '' );
                        if ( ! empty( $home_shifting_services_solution_small_heading ) ) { ?>
                        <h6 class="soltn-sm-hd py-2 mb-0"><?php echo esc_html( $home_shifting_services_solution_small_heading ); ?></h6>
                        <?php } ?>
                        <?php
                        $home_shifting_services_solution_text = get_theme_mod( 'home_shifting_services_solution_text', '' );
                        if ( ! empty( $home_shifting_services_solution_text ) ) { ?>
                        <p class="soltn-text py-3"><?php echo esc_html( $home_shifting_services_solution_text ); ?></p>
                        <?php } ?>
                    </div>
                    <div class="solution-box">
                        <div class="owl-carousel">
                            <?php $home_shifting_services_solution_count = get_theme_mod("home_shifting_services_solution_increase");
                            for ($i = 1; $i <= $home_shifting_services_solution_count; $i++) { ?>
                                <div class="solu-detail">
                                    <div class="solu-img-box">
                                       <?php
                                        $home_shifting_services_solution_image = get_theme_mod( 'home_shifting_services_solution_image'.$i, '' );
                                        if( ! empty( $home_shifting_services_solution_image ) ) { ?>  
                                        <div class="solu-inner-box <?php { echo 'solu-overlay'.$i; }?>">
                                            <img src="<?php echo esc_url( $home_shifting_services_solution_image ); ?>">
                                        </div>
                                        <?php } ?>
                                        <div class="solu-title text-start p-lg-5 p-2 p-md-5">
                                            <?php
                                                $home_shifting_services_solution_inner_heading = get_theme_mod( 'home_shifting_services_solution_inner_heading'.$i, '' );
                                                if ( ! empty( $home_shifting_services_solution_inner_heading ) ) { ?>
                                                <h6 class="solu-inn-hd p-0 m-0"><?php echo esc_html( $home_shifting_services_solution_inner_heading ); ?></h6>
                                            <?php } ?>
                                            <?php
                                                $home_shifting_services_solution_inner_txt = get_theme_mod( 'home_shifting_services_solution_inner_txt' . $i, '' );

                                                if ( ! empty( $home_shifting_services_solution_inner_txt ) ) {
                                                    $home_shifting_services_trimmed_text = wp_trim_words( $home_shifting_services_solution_inner_txt, 20, '...' ); 
                                                ?>
                                                    <p class="solu-inn-txt py-lg-4 py-2 py-md-4 m-0"><?php echo esc_html( $home_shifting_services_trimmed_text ); ?></p>
                                            <?php } ?>
                                            <?php
                                                $home_shifting_services_solution_button_link = get_theme_mod( 'home_shifting_services_solution_button_link'.$i, '' );
                                                    if ( ! empty( $home_shifting_services_solution_button_link ) ) { ?>
                                                    <a class="btn-solut btn" href="<?php echo esc_url( $home_shifting_services_solution_button_link ); ?>"><?php echo esc_html('Get Quotation','home-shifting-services'); ?></a>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </div> 
                            <?php } ?>
                        </div>
                    </div>
                </div>                
            </div>
        </div>
    </section>
    <?php    
    }
endif;
add_action( 'home_shifting_services_action_home_solution', 'home_shifting_services_home_solution_section' );

/**
 * Home page another adding Section
 */
if (! function_exists( 'home_shifting_services_home_extra_section' ) ):
    function home_shifting_services_home_extra_section() {
        ?>
        <div id="custom-home-extra-content" class="py-3">
            <div class="container">
              <?php while ( have_posts() ) : the_post(); ?>
                <?php the_content(); ?>
              <?php endwhile; ?>
            </div>
        </div>
        <?php    
    }
endif;
add_action( 'home_shifting_services_action_home_extra', 'home_shifting_services_home_extra_section' );