<?php
    
    $catlist_title    = sophi_blog_get_option( 'catlist_title' );
    $catlist_subtitle    = sophi_blog_get_option( 'catlist_subtitle' );
    $enable_small_category     = sophi_blog_get_option( 'catlist_small_category_enable' );
    $enable_category     = sophi_blog_get_option( 'catlist_category_enable' );
    $view_more_txt     = sophi_blog_get_option( 'catlist_see_all_txt' );
    $enable_content     = sophi_blog_get_option( 'catlist_content_enable' );
    $enable_author     = sophi_blog_get_option( 'catlist_author_enable' );
    $enable_posted_on     = sophi_blog_get_option( 'catlist_posted_on_enable' );
    $number_of_catlist_items  = sophi_blog_get_option( 'number_of_catlist_items' );
    $catlist_category = sophi_blog_get_option( 'catlist_category' ); 
    $catlist_header_font_size =sophi_blog_get_option( 'catlist_section_header_font_size');
    $catlist_subtitle_font_size =sophi_blog_get_option( 'catlist_subtitle_font_size');
    $header_font_size = sophi_blog_get_option( 'catlist_font_size');
    $catlist_layout = sophi_blog_get_option('catlist_layout_option');
    $excerpt_length =sophi_blog_get_option( 'catlist_excerpt_length');
    $home_layout = sophi_blog_get_option( 'homepage_design_layout_options');
    $no_of_column     = sophi_blog_get_option( 'number_of_catlist_column' );
    $catlist_content_type     = sophi_blog_get_option( 'catlist_content_type' );
    $number_of_catlist_items  = sophi_blog_get_option( 'number_of_catlist_items' );
    for( $i=1; $i<=$number_of_catlist_items; $i++ ) :
        $catlist_product_category[] = absint(sophi_blog_get_option( 'catlist_product_category_'.$i ) );
    endfor;
    $small_category ='';
    if (function_exists('z_taxonomy_image_url') && !empty(z_taxonomy_image_url())){
          $catlist_image = z_taxonomy_image_url(); 
        }
?>
<style> 
        <?php if ($catlist_subtitle_font_size != 0): ?>
            #catlist .section-subtitle{
                font-size:<?php echo esc_html($catlist_subtitle_font_size); ?>px;
            }
        <?php endif ?>
        <?php if ($catlist_header_font_size != 0): ?>
            #catlist .section-title{
                font-size:<?php echo esc_html($catlist_header_font_size); ?>px;
            }
        <?php endif ?>

        <?php if ($header_font_size != 0): ?>
            #catlist .entry-title{
                font-size:<?php echo esc_html($header_font_size); ?>px;
            }
        <?php endif ?>
    </style>
    
        <div class="section-header">
            <?php if( !empty($catlist_title)):?>
                <h2 class="section-title"><?php echo esc_html($catlist_title);?></h2>
            <?php endif;?>
            <?php if ($home_layout=='home-main'): ?>
                <?php if (!empty($catlist_subtitle)): ?>
                    <h3 class="section-subtitle"><?php echo esc_html($catlist_subtitle);?></h3>
                <?php endif; ?>
            <?php endif ?>
        </div>
    
<?php if (!empty($catlist_category)): ?>
    <?php if ($enable_small_category==false) {
        $small_category='small-category';
    } ?>
   <div class="catlist-slider" data-slick='{"slidesToShow": <?php echo esc_attr($no_of_column); ?>, "slidesToScroll": 1, "infinite": true, "speed": 600, "dots": false, "arrows":true, "autoplay": true, "fade": false }'>
            <?php foreach ( $catlist_category as $category ) : ?>
                <article class="catlist-wrapper">
                    <div class="catlist-items">
                        <?php $category_id = get_cat_ID($category); 
                        if (function_exists('z_taxonomy_image_url') && !empty(z_taxonomy_image_url($category))){ ?>
                            <div class="post-featured-image">
                                <div class="catlist-featured-image" style="background-image: url('<?php echo z_taxonomy_image_url($category); ?>');">  
                                    <a href="<?php echo esc_url(get_category_link($category)); ?>" class="post-thumbnail-link"></a>
                                </div>
                            </div>
                        <?php } ?>
                        <div class="catlist-category-header">
                            <div class="catlist-category-title">
                                <h2 class="entry-title">
                                    <a href="<?php echo esc_url(get_category_link($category)); ?>">
                                        <?php echo esc_html( get_cat_name($category)); ?>   
                                    </a>
                                </h2>
                            </div>
                        </div>
                    </div>
                </article><!-- .section-content -->
            <?php endforeach; ?> 
    </div><!-- .content-wrapper -->
<?php endif; ?>

