function nectar_recent_posts($atts, $content = null)
{
    extract(shortcode_atts(array("title_labels" => 'false', 'category' => 'all', 'posts_per_page' => '4', 'columns' => '4'), $atts));
    global $post;
    global $options;
    $posts_page_id = get_option('page_for_posts');
    $posts_page = get_page($posts_page_id);
    $posts_page_title = $posts_page->post_title;
    $posts_page_link = get_page_uri($posts_page_id);
    $title_label_output = null;
    $recent_posts_title_text = !empty($options['recent-posts-title']) ? $options['recent-posts-title'] : 'Recent Posts';
    $recent_posts_link_text = !empty($options['recent-posts-link']) ? $options['recent-posts-link'] : 'View All Posts';
    //incase only all was selected
    if ($category == 'all') {
        $category = null;
    }
    $title_labels == 'true' ? $title_label_output = '<h2 class="uppercase recent-posts-title">' . $recent_posts_title_text . '<a href="' . $posts_page_link . '" class="button"> / ' . $recent_posts_link_text . '</a></h2>' : ($title_label_output = null);
    ob_start();
    echo $title_label_output;
    ?>
		
		<div class="row blog-recent columns-<?php 
    echo $columns;
    ?>
">
			
			<?php 
    $recentBlogPosts = array('showposts' => $posts_per_page, 'category_name' => $category, 'ignore_sticky_posts' => 1, 'tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-link', 'post-format-quote'), 'operator' => 'NOT IN')));
    $recent_posts_query = new WP_Query($recentBlogPosts);
    if ($recent_posts_query->have_posts()) {
        while ($recent_posts_query->have_posts()) {
            $recent_posts_query->the_post();
            if ($columns == '4') {
                $col_num = 'span_3';
            } else {
                if ($columns == '3') {
                    $col_num = 'span_4';
                } else {
                    if ($columns == '2') {
                        $col_num = 'span_6';
                    } else {
                        $col_num = 'span_12';
                    }
                }
            }
            ?>

			<div class="col <?php 
            echo $col_num;
            ?>
">
				
				<?php 
            $wp_version = floatval(get_bloginfo('version'));
            if (get_post_format() == 'video') {
                if ($wp_version < "3.6") {
                    $video_embed = get_post_meta($post->ID, '_nectar_video_embed', true);
                    if (!empty($video_embed)) {
                        echo '<div class="video-wrap">' . stripslashes(htmlspecialchars_decode($video_embed)) . '</div>';
                    } else {
                        nectar_video($post->ID);
                    }
                } else {
                    $video_embed = get_post_meta($post->ID, '_nectar_video_embed', true);
                    $video_m4v = get_post_meta($post->ID, '_nectar_video_m4v', true);
                    $video_ogv = get_post_meta($post->ID, '_nectar_video_ogv', true);
                    $video_poster = get_post_meta($post->ID, '_nectar_video_poster', true);
                    if (!empty($video_embed) || !empty($video_m4v)) {
                        $wp_version = floatval(get_bloginfo('version'));
                        //video embed
                        if (!empty($video_embed)) {
                            echo '<div class="video">' . do_shortcode($video_embed) . '</div>';
                        } else {
                            if (!empty($video_m4v) && $wp_version < "3.6") {
                                echo '<div class="video">';
                                nectar_video($post->ID);
                                echo '</div>';
                            } else {
                                if ($wp_version >= "3.6") {
                                    if (!empty($video_m4v) || !empty($video_ogv)) {
                                        $video_output = '[video ';
                                        if (!empty($video_m4v)) {
                                            $video_output .= 'mp4="' . $video_m4v . '" ';
                                        }
                                        if (!empty($video_ogv)) {
                                            $video_output .= 'ogv="' . $video_ogv . '"';
                                        }
                                        $video_output .= ' poster="' . $video_poster . '"]';
                                        echo '<div class="video">' . do_shortcode($video_output) . '</div>';
                                    }
                                }
                            }
                        }
                    }
                    // endif for if there's a video
                }
                // endif for 3.6
            } else {
                if (get_post_format() == 'audio') {
                    ?>
						<div class="audio-wrap">		
							<?php 
                    if ($wp_version < "3.6") {
                        nectar_audio($post->ID);
                    } else {
                        $audio_mp3 = get_post_meta($post->ID, '_nectar_audio_mp3', true);
                        $audio_ogg = get_post_meta($post->ID, '_nectar_audio_ogg', true);
                        if (!empty($audio_ogg) || !empty($audio_mp3)) {
                            $audio_output = '[audio ';
                            if (!empty($audio_mp3)) {
                                $audio_output .= 'mp3="' . $audio_mp3 . '" ';
                            }
                            if (!empty($audio_ogg)) {
                                $audio_output .= 'ogg="' . $audio_ogg . '"';
                            }
                            $audio_output .= ']';
                            echo do_shortcode($audio_output);
                        }
                    }
                    ?>
						</div><!--/audio-wrap-->
					<?php 
                } else {
                    if (get_post_format() == 'gallery') {
                        if ($wp_version < "3.6") {
                            if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'second-slide')) {
                                nectar_gallery($post->ID);
                            } else {
                                if (has_post_thumbnail()) {
                                    echo get_the_post_thumbnail($post->ID, 'portfolio-thumb', array('title' => ''));
                                }
                            }
                        } else {
                            $gallery_ids = grab_ids_from_gallery();
                            ?>
				
							<div class="flex-gallery"> 
									 <ul class="slides">
									 	<?php 
                            foreach ($gallery_ids as $image_id) {
                                echo '<li>' . wp_get_attachment_image($image_id, 'portfolio-thumb', false) . '</li>';
                            }
                            ?>
							    	</ul>
						   	 </div><!--/gallery-->

				   <?php 
                        }
                    } else {
                        if (has_post_thumbnail()) {
                            echo '<a href="' . get_permalink() . '">' . get_the_post_thumbnail($post->ID, 'portfolio-thumb', array('title' => '')) . '</a>';
                        }
                    }
                }
            }
            ?>

				<div class="post-header">
					<h3 class="title"><a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a></h3>	
					<span class="meta-author"><?php 
            the_author_posts_link();
            ?>
 </span> <span class="meta-category"> | <?php 
            the_category(', ');
            ?>
 </span> <span class="meta-comment-count"> | <a href="<?php 
            comments_link();
            ?>
">
					<?php 
            comments_number(__('No Comments', NECTAR_THEME_NAME), __('One Comment', NECTAR_THEME_NAME), '% ' . __('Comments', NECTAR_THEME_NAME));
            ?>
</a> </span>
				</div><!--/post-header-->
				
				<?php 
            the_excerpt();
            ?>
				
			</div><!--/span_3-->
			
			<?php 
        }
    }
    wp_reset_postdata();
    ?>
	
		</div><!--/blog-recent-->
	
	<?php 
    wp_reset_query();
    $recent_posts_content = ob_get_contents();
    ob_end_clean();
    return $recent_posts_content;
}
Example #2
0
            echo 'span_12';
        }
        ?>
">
						
						<?php 
        if (!post_password_required()) {
            $video_embed = get_post_meta($post->ID, '_nectar_video_embed', true);
            $video_m4v = get_post_meta($post->ID, '_nectar_video_m4v', true);
            $video_ogv = get_post_meta($post->ID, '_nectar_video_ogv', true);
            $video_poster = get_post_meta($post->ID, '_nectar_video_poster', true);
            //Gallery
            if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'second-slide') || !empty($enable_gallery_slider) && $enable_gallery_slider == 'on') {
                if (floatval(get_bloginfo('version')) < "3.6") {
                    if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'second-slide')) {
                        nectar_gallery($post->ID);
                    }
                } else {
                    if (!empty($enable_gallery_slider) && $enable_gallery_slider == 'on') {
                        $gallery_ids = grab_ids_from_gallery();
                        ?>
									
										<div class="flex-gallery"> 
											 <ul class="slides">
											 	<?php 
                        foreach ($gallery_ids as $image_id) {
                            echo '<li>' . wp_get_attachment_image($image_id, '', false) . '</li>';
                        }
                        ?>
									    	</ul>
								   	  </div><!--/gallery-->
function nectar_recent_posts($atts, $content = null)
{
    extract(shortcode_atts(array("title_labels" => 'false', 'category' => 'all', 'slider_size' => '600', 'slider_above_text' => '', 'posts_per_page' => '4', 'columns' => '4', 'style' => 'default', 'post_offset' => '0'), $atts));
    global $post;
    global $options;
    $posts_page_id = get_option('page_for_posts');
    $posts_page = get_page($posts_page_id);
    $posts_page_title = $posts_page->post_title;
    $posts_page_link = get_page_uri($posts_page_id);
    $title_label_output = null;
    $recent_posts_title_text = !empty($options['recent-posts-title']) ? $options['recent-posts-title'] : 'Recent Posts';
    $recent_posts_link_text = !empty($options['recent-posts-link']) ? $options['recent-posts-link'] : 'View All Posts';
    //incase only all was selected
    if ($category == 'all') {
        $category = null;
    }
    if ($style != 'slider') {
        $title_labels == 'true' ? $title_label_output = '<h2 class="uppercase recent-posts-title">' . $recent_posts_title_text . '<a href="' . $posts_page_link . '" class="button"> / ' . $recent_posts_link_text . '</a></h2>' : ($title_label_output = null);
        ob_start();
        echo $title_label_output;
        ?>
			
			<div class="row blog-recent columns-<?php 
        echo $columns;
        ?>
" data-style="<?php 
        echo $style;
        ?>
">
				
				<?php 
        $recentBlogPosts = array('showposts' => $posts_per_page, 'category_name' => $category, 'ignore_sticky_posts' => 1, 'offset' => $post_offset, 'tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-link', 'post-format-quote'), 'operator' => 'NOT IN')));
        $recent_posts_query = new WP_Query($recentBlogPosts);
        if ($recent_posts_query->have_posts()) {
            while ($recent_posts_query->have_posts()) {
                $recent_posts_query->the_post();
                if ($columns == '4') {
                    $col_num = 'span_3';
                } else {
                    if ($columns == '3') {
                        $col_num = 'span_4';
                    } else {
                        if ($columns == '2') {
                            $col_num = 'span_6';
                        } else {
                            $col_num = 'span_12';
                        }
                    }
                }
                ?>

				<div class="col <?php 
                echo $col_num;
                ?>
">
					
					<?php 
                $wp_version = floatval(get_bloginfo('version'));
                if ($style == 'default') {
                    if (get_post_format() == 'video') {
                        if ($wp_version < "3.6") {
                            $video_embed = get_post_meta($post->ID, '_nectar_video_embed', true);
                            if (!empty($video_embed)) {
                                echo '<div class="video-wrap">' . stripslashes(htmlspecialchars_decode($video_embed)) . '</div>';
                            } else {
                                nectar_video($post->ID);
                            }
                        } else {
                            $video_embed = get_post_meta($post->ID, '_nectar_video_embed', true);
                            $video_m4v = get_post_meta($post->ID, '_nectar_video_m4v', true);
                            $video_ogv = get_post_meta($post->ID, '_nectar_video_ogv', true);
                            $video_poster = get_post_meta($post->ID, '_nectar_video_poster', true);
                            if (!empty($video_embed) || !empty($video_m4v)) {
                                $wp_version = floatval(get_bloginfo('version'));
                                //video embed
                                if (!empty($video_embed)) {
                                    echo '<div class="video">' . do_shortcode($video_embed) . '</div>';
                                } else {
                                    if (!empty($video_m4v) && $wp_version < "3.6") {
                                        echo '<div class="video">';
                                        nectar_video($post->ID);
                                        echo '</div>';
                                    } else {
                                        if ($wp_version >= "3.6") {
                                            if (!empty($video_m4v) || !empty($video_ogv)) {
                                                $video_output = '[video ';
                                                if (!empty($video_m4v)) {
                                                    $video_output .= 'mp4="' . $video_m4v . '" ';
                                                }
                                                if (!empty($video_ogv)) {
                                                    $video_output .= 'ogv="' . $video_ogv . '"';
                                                }
                                                $video_output .= ' poster="' . $video_poster . '"]';
                                                echo '<div class="video">' . do_shortcode($video_output) . '</div>';
                                            }
                                        }
                                    }
                                }
                            }
                            // endif for if there's a video
                        }
                        // endif for 3.6
                    } else {
                        if (get_post_format() == 'audio') {
                            ?>
								<div class="audio-wrap">		
									<?php 
                            if ($wp_version < "3.6") {
                                nectar_audio($post->ID);
                            } else {
                                $audio_mp3 = get_post_meta($post->ID, '_nectar_audio_mp3', true);
                                $audio_ogg = get_post_meta($post->ID, '_nectar_audio_ogg', true);
                                if (!empty($audio_ogg) || !empty($audio_mp3)) {
                                    $audio_output = '[audio ';
                                    if (!empty($audio_mp3)) {
                                        $audio_output .= 'mp3="' . $audio_mp3 . '" ';
                                    }
                                    if (!empty($audio_ogg)) {
                                        $audio_output .= 'ogg="' . $audio_ogg . '"';
                                    }
                                    $audio_output .= ']';
                                    echo do_shortcode($audio_output);
                                }
                            }
                            ?>
								</div><!--/audio-wrap-->
							<?php 
                        } else {
                            if (get_post_format() == 'gallery') {
                                if ($wp_version < "3.6") {
                                    if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'second-slide')) {
                                        nectar_gallery($post->ID);
                                    } else {
                                        if (has_post_thumbnail()) {
                                            echo get_the_post_thumbnail($post->ID, 'portfolio-thumb', array('title' => ''));
                                        }
                                    }
                                } else {
                                    $gallery_ids = grab_ids_from_gallery();
                                    ?>
						
									<div class="flex-gallery"> 
											 <ul class="slides">
											 	<?php 
                                    foreach ($gallery_ids as $image_id) {
                                        echo '<li>' . wp_get_attachment_image($image_id, 'portfolio-thumb', false) . '</li>';
                                    }
                                    ?>
									    	</ul>
								   	 </div><!--/gallery-->

						   <?php 
                                }
                            } else {
                                if (has_post_thumbnail()) {
                                    echo '<a href="' . get_permalink() . '">' . get_the_post_thumbnail($post->ID, 'portfolio-thumb', array('title' => '')) . '</a>';
                                }
                            }
                        }
                    }
                    ?>

							<div class="post-header">
								<h3 class="title"><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h3>	
								<span class="meta-author"><?php 
                    the_author_posts_link();
                    ?>
 </span> <span class="meta-category"> | <?php 
                    the_category(', ');
                    ?>
 </span> <span class="meta-comment-count"> | <a href="<?php 
                    comments_link();
                    ?>
">
								<?php 
                    comments_number(__('No Comments', NECTAR_THEME_NAME), __('One Comment', NECTAR_THEME_NAME), '% ' . __('Comments', NECTAR_THEME_NAME));
                    ?>
</a> </span>
							</div><!--/post-header-->
							
							<?php 
                    the_excerpt();
                } else {
                    if ($style == 'minimal') {
                        ?>

							<a href="<?php 
                        the_permalink();
                        ?>
"></a>
							<div class="post-header">
								<span class="meta"> <?php 
                        echo get_the_date() . ' ' . __('in', NECTAR_THEME_NAME);
                        ?>
 <?php 
                        the_category(', ');
                        ?>
 </span> 
								<h3 class="title"><?php 
                        the_title();
                        ?>
</h3>	
							</div><!--/post-header-->
							<?php 
                        the_excerpt();
                        ?>
							<span><?php 
                        echo __('Read More', NECTAR_THEME_NAME);
                        ?>
 <i class="icon-button-arrow"></i></span>

						<?php 
                    } else {
                        if ($style == 'title_only') {
                            ?>

							<a href="<?php 
                            the_permalink();
                            ?>
"></a>
							<div class="post-header">
								<span class="meta"> <?php 
                            echo get_the_date();
                            ?>
 </span> 
								<h2 class="title"><?php 
                            the_title();
                            ?>
</h2>	
							</div><!--/post-header-->

						<?php 
                        }
                    }
                }
                ?>
					
				</div><!--/col-->
				
				<?php 
            }
        }
        wp_reset_postdata();
        ?>
		
			</div><!--/blog-recent-->
		
		<?php 
        wp_reset_query();
        $recent_posts_content = ob_get_contents();
        ob_end_clean();
    } else {
        //slider
        ob_start();
        echo $title_label_output;
        ?>
		
		<?php 
        $recentBlogPosts = array('showposts' => $posts_per_page, 'category_name' => $category, 'ignore_sticky_posts' => 1, 'offset' => $post_offset, 'tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-link', 'post-format-quote'), 'operator' => 'NOT IN')));
        $recent_posts_query = new WP_Query($recentBlogPosts);
        $animate_in_effect = !empty($options['header-animate-in-effect']) ? $options['header-animate-in-effect'] : 'none';
        echo '<div class="nectar-recent-posts-slider" data-height="' . $slider_size . '" data-animate-in-effect="' . $animate_in_effect . '">';
        /*echo '<div class="nectar-recent-post-content"><div class="recent-post-container container"><div class="inner-wrap"><span class="strong">'.$slider_above_text.'</span>';
        		$i = 0;
        		if( $recent_posts_query->have_posts() ) :  while( $recent_posts_query->have_posts() ) : $recent_posts_query->the_post(); global $post; ?>
        
        				<h2 class="post-ref-<?php echo $i; ?>"><a href=" <?php echo get_permalink(); ?>" class="full-slide-link"> <?php echo the_title(); ?> </a></h2>
        				<?php $i++; ?>
        
        		<?php endwhile; endif; 
        		echo '</div></div></div>'; */
        echo '<div class="nectar-recent-posts-slider-inner">';
        $i = 0;
        if ($recent_posts_query->have_posts()) {
            while ($recent_posts_query->have_posts()) {
                $recent_posts_query->the_post();
                global $post;
                ?>

				<?php 
                $bg = get_post_meta($post->ID, '_nectar_header_bg', true);
                $bg_color = get_post_meta($post->ID, '_nectar_header_bg_color', true);
                $bg_image_id = null;
                $featured_img = null;
                if (!empty($bg)) {
                    //page header
                    $featured_img = $bg;
                } elseif (has_post_thumbnail($post->ID)) {
                    $bg_image_id = get_post_thumbnail_id($post->ID);
                    $image_src = wp_get_attachment_image_src($bg_image_id, 'full');
                    $featured_img = $image_src[0];
                }
                ?>

				<div class="nectar-recent-post-slide <?php 
                if ($bg_image_id == null) {
                    echo 'no-bg-img';
                }
                ?>
 post-ref-<?php 
                echo $i;
                ?>
">

					<div class="nectar-recent-post-bg"  style=" <?php 
                if (!empty($bg_color)) {
                    ?>
 background-color: <?php 
                    echo $bg_color;
                    ?>
; <?php 
                }
                ?>
 background-image: url(<?php 
                echo $featured_img;
                ?>
);" > </div>

					<?php 
                echo '<div class="recent-post-container container"><div class="inner-wrap">';
                echo '<span class="strong">';
                $categories = get_the_category();
                if (!empty($categories)) {
                    $output = null;
                    foreach ($categories as $category) {
                        $output .= '<a class="' . $category->slug . '" href="' . esc_url(get_category_link($category->term_id)) . '" alt="' . esc_attr(sprintf(__('View all posts in %s', NECTAR_THEME_NAME), $category->name)) . '"><span class="' . $category->slug . '">' . esc_html($category->name) . '</span></a>';
                    }
                    echo trim($output);
                }
                echo '</span>';
                ?>
					
						<h2 class="post-ref-<?php 
                echo $i;
                ?>
"><a href=" <?php 
                echo get_permalink();
                ?>
" class="full-slide-link"> <?php 
                echo the_title();
                ?>
 </a></h2> 
					</div></div>
						

				</div>

				<?php 
                $i++;
                ?>

		<?php 
            }
        }
        wp_reset_postdata();
        echo '</div></div>';
        wp_reset_query();
        $recent_posts_content = ob_get_contents();
        ob_end_clean();
    }
    return $recent_posts_content;
}