<?php
if ( ! function_exists( 'amazing_blog_single_featured_post' ) ) :
    /**
     * Featured Slider
     *
     * @since Amazing Blog 1.0.0
     *
     * @param null
     * @return null
     *
     */
    function amazing_blog_single_featured_post() {
        global $amazing_blog_customizer_all_values;

        $amazing_blog_fp_enable = $amazing_blog_customizer_all_values['amazing-blog-fp-enable'];
        $amazing_blog_fp = absint($amazing_blog_customizer_all_values['amazing-blog-fp']);

        if( 1 != $amazing_blog_fp_enable ){
            return null;
        }
        ?>
        <section class="wrapper block-section large-feature-post">
            <div class="container">
                <div class="row">
                    <div class="column-md-12">
                    <?php
                    if( !empty( $amazing_blog_fp )){
                        $amazing_blog_feature_post_args =    array(
                            'post_type' => 'post',
                            'p' => $amazing_blog_fp,
                            'posts_per_page' => 1

                        );
                        $amazing_blog_feature_post_query = new WP_Query( $amazing_blog_feature_post_args );
                        if ( $amazing_blog_feature_post_query->have_posts() ) :
                        while ( $amazing_blog_feature_post_query->have_posts() ) : $amazing_blog_feature_post_query->the_post(); ?>
                        <div class="block-holder block-container">
                            <div class="thumb-holder">
                            <?php
                                if(has_post_thumbnail()){
                                    $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'amazing-blog-header-image' );
                                }
                                else{
                                    $thumb[0] = get_template_directory_uri() .'/assets/img/no-image-126_530.png';
                                } ?>
                                <img src="<?php echo esc_url($thumb[0]); ?>">
                            </div>
                            <div class="block-overlay-content">
                                <div class="vmiddle-holder">
                                    <div class="vmiddle">
                                        <span class="cat-list-holder">
                                                <?php echo get_the_category_list( ",", "", $amazing_blog_fp ); ?>
                                            </span>
                                        <h1>
                                            <a href="<?php echo the_permalink(); ?>"><?php the_title(); ?></a>
                                        </h1>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php 
                        wp_reset_postdata();
                        endwhile;
                    endif;
                    }
                    ?>
                    </div>
                </div>
            </div>
        </section>
        <?php
    }
endif;
add_action( 'homepage_slider', 'amazing_blog_single_featured_post', 10 );