<?php $uniq_id = uniqid(); ?>
<div class="widget testimonials">

    <?php if (!empty($instance['title'])): ?>
        <h3 class="widget-title"><?php echo $instance['title'] ?></h3>
    <?php endif; ?>

    <div class="testimonials_<?php echo $uniq_id ?>">
        <?php
        $query = new WP_Query(array(
                    'post_type' => 'testimonials',
                    'orderby' => 'rand',
                        )
        );


        if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
                ?>
                <div class="quote-text">
                    <?php the_content(); ?>
                    <div class="quote-author"><p>-<?php the_title(); ?>-</p></div>
                </div>
                <?php
            endwhile;
        endif;
        ?>
    </div>
</div>


<script type="text/javascript">
    
    jQuery(document).ready(function() {
        /* Testimonials --> Begin */
        function onAfter(curr, next, opts, fwd) {
            var $ht = jQuery(this).height();
            jQuery(this).parent().animate({height: $ht});
        }
        jQuery('.testimonials_<?php echo $uniq_id ?>').cycle({
            fx: 'fade',
            timeout: <?php echo $instance['pause']; ?>,
            height: 'auto',
            pause: 1,
            pager: '.testimonial-pager',
            before: onAfter,
            cleartypeNoBg: true
        });
        
    });
    
</script>

