<?php 
/**
 * Template part for displaying Featured Classes Section
 *
 * @package Prime Fashion
 */

$prime_fashion_classes = get_theme_mod( 'prime_fashion_classes_setting',false );
$prime_fashion_service_title = get_theme_mod( 'prime_fashion_service_title' );
$prime_fashion_service_text = get_theme_mod( 'prime_fashion_service_text' );

?>
<?php if ( $prime_fashion_classes ){?>
<div class="our-classes">
    <div class="container">
        <div class="service">
            <div class="side-border">
                <?php if ( $prime_fashion_service_title ){?>
                    <h3><?php echo esc_html( $prime_fashion_service_title );?></h3>
                <?php } ?> 
                <?php if ( $prime_fashion_service_text ){?>
                    <p class="title-text mb-5"><?php echo esc_html( $prime_fashion_service_text );?></p>
                <?php } ?>                       
            </div>
            <div class="owl-carousel">
                <?php 
                    $prime_fashion_catergory_name = get_theme_mod('prime_fashion_blog_args_');
                    $args = array(
                        'post_type'           => 'post',
                        'category_name'       => $prime_fashion_catergory_name,
                        'orderby'             => 'post__in',
                        'ignore_sticky_posts' => true,
                    );
                    ?>
                    <?php
                    $loop = new WP_Query($args);
                    if ( $loop->have_posts() ) :
                        $i=1;
                        while ($loop->have_posts()) : $loop->the_post(); ?>
                            <div class=" align-self-center px-0 position-relative">
                                <div class="box wow zoomIn delay-1000" data-wow-duration="2s">
                                    <?php
                                        if ( has_post_thumbnail() ) : ?>
                                        <div class="image-blog">
                                          <?php the_post_thumbnail();?>
                                            <ul class="social">
                                                <?php 
                                                $prime_fashion_social_link1 = get_theme_mod( 'prime_fashion_social_link_1' . $i );
                                                $prime_fashion_social_link2 = get_theme_mod( 'prime_fashion_social_link_2' . $i );
                                                $prime_fashion_social_link3 = get_theme_mod( 'prime_fashion_social_link_3' . $i );
                                                $prime_fashion_social_link4 = get_theme_mod( 'prime_fashion_social_link_4' . $i );

                                                if ( ! empty( $prime_fashion_social_link1 ) ) {
                                                    echo '<li><a class="social1" href="' . esc_url( $prime_fashion_social_link1 ) . '" target="_blank"><i class="fab fa-facebook-f"></i></a></li>';
                                                }
                                                if ( ! empty( $prime_fashion_social_link3 ) ) {
                                                    echo '<li><a class="social3" href="' . esc_url( $prime_fashion_social_link3 ) . '" target="_blank"><i class="fab fa-instagram"></i></a></li>';
                                                }
                                                if ( ! empty( $prime_fashion_social_link2 ) ) {
                                                    echo '<li><a class="social2" href="' . esc_url( $prime_fashion_social_link2 ) . '" target="_blank"><i class="fab fa-twitter"></i></a></li>';
                                                } 
                                                if ( ! empty( $prime_fashion_social_link4 ) ) {
                                                    echo '<li><a class="social4" href="' . esc_url( $prime_fashion_social_link4 ) . '" target="_blank"><i class="fab fa-linkedin-in"></i></a></li>';
                                                }
                                                ?>
                                            </ul>
                                        </div>
                                        <?php else:
                                          ?>
                                          <div class="image-blog">
                                            <img src="<?php echo get_stylesheet_directory_uri() . '/images/default-header.png'; ?>">
                                            <ul class="social">
                                                <?php 
                                                $prime_fashion_social_link1 = get_theme_mod( 'prime_fashion_social_link_1' . $i );
                                                $prime_fashion_social_link2 = get_theme_mod( 'prime_fashion_social_link_2' . $i );
                                                $prime_fashion_social_link3 = get_theme_mod( 'prime_fashion_social_link_3' . $i );
                                                $prime_fashion_social_link4 = get_theme_mod( 'prime_fashion_social_link_4' . $i );

                                                if ( ! empty( $prime_fashion_social_link1 ) ) {
                                                    echo '<li><a class="social1" href="' . esc_url( $prime_fashion_social_link1 ) . '" target="_blank"><i class="fab fa-facebook-f"></i></a></li>';
                                                }
                                                if ( ! empty( $prime_fashion_social_link3 ) ) {
                                                    echo '<li><a class="social3" href="' . esc_url( $prime_fashion_social_link3 ) . '" target="_blank"><i class="fab fa-instagram"></i></a></li>';
                                                }
                                                if ( ! empty( $prime_fashion_social_link2 ) ) {
                                                    echo '<li><a class="social2" href="' . esc_url( $prime_fashion_social_link2 ) . '" target="_blank"><i class="fab fa-twitter"></i></a></li>';
                                                } 
                                                if ( ! empty( $prime_fashion_social_link4 ) ) {
                                                    echo '<li><a class="social4" href="' . esc_url( $prime_fashion_social_link4 ) . '" target="_blank"><i class="fab fa-linkedin-in"></i></a></li>';
                                                }
                                                ?>
                                            </ul>
                                          </div>
                                          <?php
                                        endif;
                                      ?>
                                    <div class="box-content mt-3">
                                        <h4 class="title mb-2"><?php the_title();?></h4>
                                        <?php if( get_theme_mod( 'prime_fashion_category_designation'.$i ) != '' ) { ?>
                                            <span><?php echo esc_html(get_theme_mod('prime_fashion_category_designation'.$i)); ?></span>
                                        <?php } ?>
                                        <p class="mb-0"><?php echo wp_trim_words( get_the_content(), 8 ); ?></p>
                                    </div>
                                </div>
                            </div>
                        <?php  $i++; endwhile;
                    endif;
                ?>
            </div>
        </div>
    </div>
</div>
<?php } ?>