<?php
    $testimonial_title       =party_planner_bell_get_option( 'testimonial_title' );
    $testimonial_subtitle       =party_planner_bell_get_option( 'testimonial_subtitle' );
    $testimonial_side_image       =party_planner_bell_get_option( 'testimonial_side_image' );
    $testimonial_viewall_text       =party_planner_bell_get_option( 'testimonial_viewall_text' );
    $testimonial_btn_url       =party_planner_bell_get_option( 'testimonial_btn_url' );
    $testimonial_content_type     = party_planner_bell_get_option( 'testimonial_content_type' );
    $enable_category     = party_planner_bell_get_option( 'testimonial_category_enable' );
    $enable_content     = party_planner_bell_get_option( 'testimonial_content_enable' );
    $enable_posted_on     = party_planner_bell_get_option( 'testimonial_posted_on_enable' );
    $testimonial_dots  = party_planner_bell_get_option( 'testimonial_dots_enable' );
    $testimonial_arrow  = party_planner_bell_get_option( 'testimonial_arrow_enable' );
    $number_of_testimonial_items  = party_planner_bell_get_option( 'number_of_testimonial_items' );
    $testimonial_category = party_planner_bell_get_option( 'testimonial_category' );
    $testimonial_layout = party_planner_bell_get_option('testimonial_layout_option');
    $testimonial_header_font_size =party_planner_bell_get_option( 'testimonial_title_font_size');
    $testimonial_content_font_size =party_planner_bell_get_option( 'testimonial_content_font_size');
    $testimonial_subtitle_font_size =party_planner_bell_get_option( 'testimonial_subtitle_font_size');
    $testimonial_section_header_font_size =party_planner_bell_get_option( 'testimonial_section_header_font_size');
    $testimonial_section_header_font_size =party_planner_bell_get_option( 'testimonial_section_header_font_size');
    $home_layout = party_planner_bell_get_option( 'homepage_design_layout_options');
    $excerpt_length =party_planner_bell_get_option( 'testimonial_excerpt_length');

    for( $i=1; $i<=$number_of_testimonial_items; $i++ ) :
        $testimonial_page_posts[] = absint(party_planner_bell_get_option( 'testimonial_page_'.$i ) );
        $testimonial_post_posts[] = absint(party_planner_bell_get_option( 'testimonial_post_'.$i ) );
    endfor;
?>
    <style>
        <?php if ($testimonial_subtitle_font_size != 0): ?>
            #testimonial .section-subtitle{
                font-size:<?php echo esc_html($testimonial_subtitle_font_size); ?>px;
            }
        <?php endif ?>
        <?php if ($testimonial_section_header_font_size != 0): ?>
            #testimonial .section-title{
                font-size:<?php echo esc_html($testimonial_section_header_font_size); ?>px;
            }
        <?php endif ?>

        <?php if ($testimonial_header_font_size != 0): ?>
            #testimonial .entry-title{
                font-size:<?php echo esc_html($testimonial_header_font_size); ?>px;
            }
        <?php endif ?>
        <?php if ($testimonial_content_font_size != 0): ?>
            #testimonial .entry-content p{
                font-size:<?php echo esc_html($testimonial_content_font_size); ?>px;
            }
        <?php endif ?>
    </style>
<div class="section-header-wrapper clear">
    <div class="section-header">
        <?php party_planner_bell_leaf_shape(); ?>
        <?php if( !empty($testimonial_title)):?>
            <h2 class="section-title"><?php echo esc_html($testimonial_title);?></h2>
        <?php endif;?>
        <?php if( !empty($testimonial_subtitle)):?>
            <p class="section-subtitle"><?php echo esc_html($testimonial_subtitle);?></p>
        <?php endif;?>
    </div>
</div><!-- .section-header-wrapper -->
<div class="testimonial-slider default-testimonial" data-slick='{"slidesToShow": 1, "slidesToScroll": 1, "infinite": true, "speed": 1200, "dots": <?php if( true== $testimonial_dots){ echo 'true'; } else{ echo 'false'; } ?>, "arrows":<?php if( true== $testimonial_arrow ){ echo 'true'; } else{ echo 'false'; } ?>, "autoplay": true, "fade": true }' >
    <?php if(( $testimonial_content_type == 'testimonial_page') || ( $testimonial_content_type =='testimonial_post') || ( $testimonial_content_type == 'testimonial_category') ) 
        { 
            if( $testimonial_content_type == 'testimonial_page' ) : ?>
                <?php $args = array (
                    'post_type'     => 'page',
                    'post_per_page' => count( $testimonial_page_posts ),
                    'post__in'      => $testimonial_page_posts,
                    'orderby'       =>'post__in', 
                ); 
            endif; 
            if( $testimonial_content_type == 'testimonial_post' ) :
                $args = array (
                    'post_type'     => 'post',
                    'post_per_page' => count( $testimonial_post_posts ),
                    'post__in'      => $testimonial_post_posts,
                    'orderby'       =>'post__in', 
                    'ignore_sticky_posts' => true, 
                ); 
            endif;

            if( $testimonial_content_type == 'testimonial_category' ) :
                $args = array (

                'posts_per_page' =>absint( $number_of_testimonial_items ),              
                'post_type' => 'post',
                'post_status' => 'publish',
                'paged' => 1,
                'ignore_sticky_posts' => true, 
                );
                if ( absint( $testimonial_category ) > 0 ) {
                    $args['cat'] = absint( $testimonial_category );
                }
        endif;
        $loop = new WP_Query($args);                        
        if ( $loop->have_posts() ) :
            $i=0;  
            while ($loop->have_posts()) : $loop->the_post(); $i++;?>  
                <?php $testimonial_post_bg_color = party_planner_bell_get_option( 'testimonial_post_background_color_'.$i ); ?>
                <article style="background-color: <?php echo esc_attr($testimonial_post_bg_color) ?>" >                        
                    <div class="testimonial-items">
                        <div class="featured-image">
                            <img src="<?php the_post_thumbnail_url( 'full');?>">
                        </div><!-- .featured-image --> 
                        <div class="entry-container">
                            <?php if ( ($enable_content==true)): ?>
                                <div class="entry-content">
                                    <?php 
                                        $excerpt = party_planner_bell_the_excerpt( $excerpt_length );
                                        echo wp_kses_post( wpautop( $excerpt ) );
                                    ?>
                                </div><!-- .entry-content -->
                            <?php endif; ?>
                            <header class="entry-header">
                                <h2 class="entry-title"><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
                            </header>
                            <?php $testimonial_position = party_planner_bell_get_option('testimonial_position_'.$i) ?>
                            <?php if (!empty($testimonial_position)): ?>
                                <span class="position"><?php echo esc_html($testimonial_position); ?></span>
                            <?php endif ?>
                        </div><!-- .entry-container -->
                    </div>
                </article>         
            <?php endwhile;?>
        <?php endif; ?>
    <?php wp_reset_postdata(); ?>
<?php  }?>
</div>