<?php
/**
 * This file is used for your testimonials post and entries
 * @package Ultra WordPress Theme
 * @since 1.0
 * @author AJ Clarke : http://wpexplorer.com
 * @copyright Copyright (c) 2012, AJ Clarke
 * @link http://wpexplorer.com
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

/******************************************************
 * Single Posts
 * @since 1.0
*****************************************************/
if ( is_singular('testimonials') && is_main_query() ) {
	
	// Show heading area unless disabled
	if ( get_post_meta( get_the_ID(), 'wpex_page_disable_heading', true ) !== 'yes' ) {
	$posttype_obj = get_post_type_object( get_post_type( ) ); ?>
        <header id="page-heading">
            <div class="boxed">
                <span id="main-title">
                    <?php
                    // Display post tybe label
                    $wpex_current_post_type = get_post_type_object( get_post_type($post) );
                    echo $wpex_current_post_type->label; ?>
                </span>	
                <?php
                // Yoast Breadcrumbs Support
                if( function_exists('yoast_breadcrumb') ) yoast_breadcrumb('<div id="breadcrumbs"><span class="icon-home"></span>','</div>'); ?>
                <ul id="post-pagination" class="clearfix">
                    <?php next_post_link('<li class="post-prev">%link</li>', '<span class="icon-arrow-left"></span>', false); ?>
                    <li class="postype-main"><a href="<?php echo get_post_type_archive_link( $post->post_type ); ?>" title="<?php echo $posttype_obj->label; ?>"><span class="icon-th-large"></span></a></li>
                    <?php previous_post_link('<li class="post-next">%link</li>', '<span class="icon-arrow-right"></span>', false); ?>
                </ul><!-- #post-pagination -->
            </div><!-- /boxed -->
        </header><!-- /page-heading -->
    <?php } ?>
    
	<div id="single-post-wrap" class="container boxed clearfix">
        <div id="post">
            <article class="testimonial clearfix">
                <?php if( has_post_thumbnail() ) { ?>
                    <div class="testimonial-post-thumbnail">
                        <img src="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id() ),  wpex_img( 'testimonial_post_width' ), wpex_img( 'testimonial_post_height' ), wpex_img( 'testimonial_post_crop' ) ); ?>" alt="<?php echo the_title(); ?>" />
                    </div><!-- .testimonial-post-thumbnail -->
                <?php } ?>
                <div class="testimonial-content entry">
                    <h1><?php the_title(); ?></h1>
                    <?php the_content(); ?>
                     <?php
                    // Show meta if testimonial custom fields aren't blank
                    if ( get_post_meta( get_the_ID(), 'wpex_testimonial_by', true) !== '' ) { ?>
                        <footer class="testimonial-author">
                            <span class="icon-double-angle-right"></span>
                                <?php
                                _e('Testimonial by','wpex');
                                // Show testimonial author with URL
                                if ( get_post_meta( get_the_ID(), 'wpex_testimonial_url', true ) !== '' ) { ?>
                                    <a href="<?php echo get_post_meta( get_the_ID(), 'wpex_testimonial_url', true); ?>" title="<?php echo get_post_meta( get_the_ID(), 'wpex_testimonial_by', true); ?>" target="_blank">
                                        <?php echo get_post_meta( get_the_ID(), 'wpex_testimonial_by', true ); ?>
                                    </a>
                            <?php } else {
                            // Show testimonial author without URL
                                echo ' '. get_post_meta( get_the_ID(), 'wpex_testimonial_by', true);
                            } ?>
                        </footer><!-- .post-meta -->
                    <?php } ?>
                    <span class="icon-quote-right"></span>
                </div><!-- .testimonial-content .entry -->
			</article><!-- .testimonial .clearfix -->
			<?php
            // Show comments
            if ( of_get_option('testimonials_comments','') == '1' ) {
            comments_template();
            } ?>
			</div><!-- #post -->
			<?php
            // Load sidebar if post isn't full-width
            if( get_post_meta(get_the_ID(), 'wpex_post_layout', true ) !== 'Full Width' ) {
                get_sidebar();
            } ?>
	</div><!-- #single-post-wrap -->

<?php
/******************************************************
 * Entries
 * @since 1.0
*****************************************************/
} else { ?>
     <article class="testimonial testimonial-entry clearfix <?php if( !has_post_thumbnail() ) echo 'no-thumbnail'; ?> ?>">
                <?php if( has_post_thumbnail() ) { ?>
                    <div class="testimonial-post-thumbnail">
                        <img src="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id() ),  wpex_img( 'testimonial_post_width' ), wpex_img( 'testimonial_post_height' ), wpex_img( 'testimonial_post_crop' ) ); ?>" alt="<?php echo get_post_meta( get_the_ID(), 'wpex_testimonial_by', true ); ?>" />
                    </div><!-- .testimonial-post-thumbnail -->
                <?php } ?>
                <div class="testimonial-content entry">
                    <h1><?php the_title(); ?></h1>
                    <?php
					// Display the testimonial content
                    the_content();
                    // Show meta if testimonial custom fields aren't blank
                    if ( get_post_meta( get_the_ID(), 'wpex_testimonial_by', true) !== '' ) { ?>
                        <footer class="testimonial-author">
                            <span class="icon-double-angle-right"></span>
                                <?php
                                _e('Testimonial by','wpex');
                                // Show testimonial author with URL
                                if ( get_post_meta( get_the_ID(), 'wpex_testimonial_url', true ) !== '' ) { ?>
                                    <a href="<?php echo get_post_meta( get_the_ID(), 'wpex_testimonial_url', true); ?>" title="<?php echo get_post_meta( get_the_ID(), 'wpex_testimonial_by', true); ?>" target="_blank"><?php echo get_post_meta( get_the_ID(), 'wpex_testimonial_by', true ); ?></a>
                            <?php } else {
                            // Show testimonial author without URL
                                echo ' '. get_post_meta( get_the_ID(), 'wpex_testimonial_by', true);
                            } ?>
                        </footer><!-- .post-meta -->
                    <?php } ?>
                    <span class="icon-quote-right"></span>
                </div><!-- .testimonial-content .entry -->
            </article><!-- .testimonial .clearfix -->
<?php } ?>