<?php
/**
 * This file is used for your standard post entry
 * @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() && is_main_query() ) {
	
	// Load flexslider script
	wp_enqueue_script('gallery-format-flexslider');
               
	// Get image attachments
	$wpex_gallery_imgs = get_posts(
		array(
			'orderby' => 'menu_order',
			'order' => 'ASC',
			'post_type' => 'attachment',
			'post_parent' => get_the_ID(),
			'post_mime_type' => 'image',
			'post_status' => null,
			'posts_per_page' => -1
		)
	); ?>
    <div id="blog-post-slider" class="gallery-format-slider flexslider-container flex-loading">
        <div class="flexslider">
            <ul class="slides">
            <?php foreach ( $wpex_gallery_imgs as $wpex_gallery_img ) : ?>
                <li class="slide">
                    <img src="<?php echo aq_resize( wp_get_attachment_url( $wpex_gallery_img->ID ),  wpex_img( 'recent_posts_entry_width' ), wpex_img( 'recent_posts_entry_height' ), wpex_img( 'recent_posts_entry_crop' ) ); ?>" alt="<?php echo the_title(); ?>" />
                </li>
            <?php endforeach; wp_reset_postdata(); ?>
            </ul><!-- .slides -->
        </div><!-- .flexslider -->
	</div><!-- .gallery-format-slider -->
    
    <?php $wpex_gallery_imgs = NULL; // Reset var

			
/******************************************************
 * Entries
 * @since 1.0
*****************************************************/
} else { ?>
<article <?php post_class('blog-entry blog-entry-with-icon clearfix '. of_get_option('blog_entry_style','large_image') ); ?>>

	<div class="blog-entry-media">
		<?php
        // Load flexslider script
        wp_enqueue_script('gallery-format-flexslider');
                   
        // Get image attachments
        $wpex_gallery_imgs = get_posts(
            array(
                'orderby' => 'menu_order',
                'order' => 'ASC',
                'post_type' => 'attachment',
                'post_parent' => get_the_ID(),
                'post_mime_type' => 'image',
                'post_status' => null,
                'posts_per_page' => -1
            )
        ); ?>
        <div class="gallery-format-slider flexslider-container flex-loading">
            <div class="flexslider">
                <ul class="slides">
                <?php foreach ( $wpex_gallery_imgs as $wpex_gallery_img ) : ?>
                    <li class="slide">
                        <img src="<?php echo aq_resize( wp_get_attachment_url( $wpex_gallery_img->ID ),  wpex_img( 'recent_posts_entry_width' ), wpex_img( 'recent_posts_entry_height' ), wpex_img( 'recent_posts_entry_crop' ) ); ?>" alt="<?php echo the_title(); ?>" />
                    </li>
                <?php endforeach; wp_reset_postdata(); $wpex_gallery_imgs = NULL; ?>
                </ul><!-- .slides -->
            </div><!-- .flexslider -->
        </div><!-- .gallery-format-slider -->
	</div><!-- .blog-entry-media -->
	
	<div class="blog-entry-details clearfix <?php if( !has_post_thumbnail() ) echo 'full-width-blog-entry'; ?>">
		<header class="blog-entry-title">
			<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
			<ul class="entry-meta clearfix">
                <li class="meta-date"><span class="icon-time"></span><?php echo get_the_date(); ?></li>
                <li class="meta-author"><span class="icon-user"></span><?php the_author_posts_link(); ?></li>
                <?php if(comments_open()) { ?><li class="meta-comments"><span class="icon-comments"></span><?php comments_popup_link(__('0 Comments', 'wpex'), __('1 Comment', 'wpex'), __('% Comments', 'wpex'), 'comments-link' ); ?></li><?php } ?>
            </ul><!-- .post-meta -->
            <div class="blog-entry-icon"><span class="icon-picture"></span></div>
		</header><!-- .blog-entry-title -->
        
        <div class="blog-entry-excerpt">
			<?php
            // Excerpt
            if( of_get_option( 'blog_entry_excerpt', '1' ) == '1' ) {
                    echo wp_trim_words( strip_shortcodes( get_the_content() ), of_get_option( 'blog_entry_excerpt_trim', '15' ) );
					// Read more link 
					if ( of_get_option('blog_entry_readmore','1' ) == '1' ) { ?>
						<br />
						<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="blog-entry-readmore"><?php _e('read more','wpex'); ?> &rarr;</a>
					<?php }
                } else {
                    the_content('');
            } ?>
		</div><!-- .blog-entry-excerpt -->
	</div><!-- .blog-entry-details -->
</article><!-- .blog-entry -->
<?php } ?>