Ejemplo n.º 1
0
        <?php endif; ?>
        <div id="posts-container" class="<?php echo $container_class; ?> clearfix">
            <?php
            $post_count = 1;

            $prev_post_timestamp = null;
            $prev_post_month = null;
            $first_timeline_loop = false;

            while(have_posts()): the_post();
                $post_timestamp = strtotime($post->post_date);
                $post_month = date('n', $post_timestamp);
                $post_year = get_the_date('o');
                $current_date = get_the_date('o-n');
            ?>
            <div id="post-<?php the_ID(); ?>" <?php post_class($post_class.getClassAlign($post_count).' clearfix'); ?>>
                <?php if($data['blog_layout'] == 'Timeline'): ?>
                <?php if(is_null($prev_post_month )): ?>
                    <h3 class="timeline-title"><?php echo get_the_date('F Y'); ?></h3>
                <?php elseif($prev_post_month != $post_month): ?>
                    <h3 class="timeline-title"><?php echo get_the_date('F Y'); ?></h3>
                <?php endif; ?>
                <?php endif; ?>

                <?php if($data['blog_layout'] == 'Medium Alternate'): ?>
                <div class="date-and-formats">
                    <div class="date-box">
                        <span class="date"><?php the_time('j'); ?></span>
                        <span class="month-year"><?php the_time('m, Y'); ?></span>
                    </div>
                    <div class="format-box">
Ejemplo n.º 2
0
    ?>
			<?php 
    if (get_post_meta(get_the_ID(), 'pyre_video', true)) {
        ?>
			<?php 
        $thumb_class = ' has-post-thumbnail';
        ?>
			<?php 
    }
    ?>
		
			<div id="post-<?php 
    the_ID();
    ?>
" <?php 
    post_class('post ' . $post_class . getClassAlign($post_count) . $thumb_class . ' clearfix');
    ?>
>
				<div class="post-wrapper">
					<?php 
    if ($smof_data['blog_archive_layout'] == 'Medium Alternate') {
        ?>
					<?php 
        echo avada_post_date_and_format_box();
        ?>
					<?php 
    }
    ?>
					<?php 
    if ($smof_data['featured_images']) {
        get_template_part('new-slideshow');
Ejemplo n.º 3
0
            ?>
				<div class="timeline-date"><h3 class="timeline-title"><?php 
            echo get_the_date($data['timeline_date_format']);
            ?>
</h3></div>
			<?php 
        }
        ?>
			<?php 
    }
    ?>
			<div id="post-<?php 
    the_ID();
    ?>
" <?php 
    post_class($post_class . getClassAlign($post_count) . ' clearfix');
    ?>
>
				<?php 
    if ($data['blog_archive_layout'] == 'Medium Alternate') {
        ?>
				<div class="date-and-formats">
					<div class="date-box">
						<span class="date"><?php 
        the_time($data['alternate_date_format_day']);
        ?>
</span>
						<span class="month-year"><?php 
        the_time($data['alternate_date_format_month_year']);
        ?>
</span>
Ejemplo n.º 4
0
function blog_shortcode($atts) {
	global $data;
	global $post;

	wp_enqueue_script( '/js/jquery.flexslider-min' );

	if((is_front_page() || is_home() ) ) {
		$paged = (get_query_var('paged')) ?get_query_var('paged') : ((get_query_var('page')) ? get_query_var('page') : 1);
	} else {
		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
	}

	// get specified number of posts per page
	if (isset($atts['number_posts']) && $atts['number_posts']) {
		$atts['number_posts'] = (int) $atts['number_posts'];

		$atts = shortcode_atts( array(
				'author'              => '',
				'author_name'		  => '',
				'category_name'       => '',
				'cat'      			  => '',
				'id'                  => false,
				'p'					  => false,
				'post__in'			  => false,
				'order'               => 'DESC',
				'orderby'             => 'date',
				'post_status'         => 'publish',
				'post_type'           => 'post',
				'posts_per_page'	  => (int) $atts['number_posts'],
				'nopaging'			  => false,
				'paged'				  => $paged,
				'tag'                 => '',
				'tax_operator'        => 'IN',
				'tax_term'            => false,
				'taxonomy'            => 'category',
				'title_meta'		  => '',
				'include_shortcodes'  => false,
				'layout' 			  => 'large',

				'cat_slug'			  => '',
				'title'				  => true,
				'meta_all'			  => true,
				'meta_author' 		  => true,
				'meta_date' 		  => true,
				'meta_categories'  	  => true,
				'meta_comments'  	  => true,
				'meta_link'  	  	  => true,
				'thumbnail'			  => true,
				'excerpt'			  => true,
				'excerpt_words'		  => '50',
				'strip_html'		  => true,
				'paging'			  => true,
				'scrolling'		      => 'infinite',
				'blog_grid_columns'   => '3'
			), $atts );

	} else {
		// get all posts, i.e. default
		$atts = shortcode_atts( array(
				'author'              => '',
				'author_name'		  => '',
				'category_name'       => '',
				'cat'   		   	  => '',
				'id'                  => false,
				'p'					  => false,
				'post__in'			  => false,
				'order'               => 'DESC',
				'orderby'             => 'date',
				'post_status'         => 'publish',
				'post_type'           => 'post',
				'nopaging'			  => false,
				'paged'				  => $paged,
				'tag'                 => '',
				'tax_operator'        => 'IN',
				'tax_term'            => false,
				'taxonomy'            => 'category',
				'title_meta'		  => false,
				'include_shortcodes'  => false,
				'layout' 			  => 'large',

				'cat_slug'			  => '',
				'title'				  => true,
				'meta_all'			  => true,
				'meta_author' 		  => true,
				'meta_date' 		  => true,
				'meta_categories'  	  => true,
				'meta_comments'  	  => true,
				'meta_link'  	  	  => true,
				'thumbnail'			  => true,
				'excerpt'			  => true,
				'excerpt_words'		  => '50',
				'strip_html'		  => true,
				'paging'			  => true,
				'scrolling'		      => 'infinite',
				'blog_grid_columns'   => '3'
			), $atts );
	}

	if(isset($atts['posts_per_page']) && $atts['posts_per_page'] == -1) {
		$atts['nopaging'] = true;
	}

	// setting attributes right for the php script
	($atts['title'] == "yes") ? ($atts['title'] = true) : ($atts['title'] = false);
	($atts['meta_all'] == "yes") ? ($atts['meta_all'] = true) : ($atts['meta_all'] = false);
	($atts['meta_author'] == "yes") ? ($atts['meta_author'] = true) : ($atts['meta_author'] = false);
	($atts['meta_date'] == "yes") ? ($atts['meta_date'] = true) : ($atts['meta_date'] = false);
	($atts['meta_categories'] == "yes") ? ($atts['meta_categories'] = true) : ($atts['meta_categories'] = false);
	($atts['meta_comments'] == "yes") ? ($atts['meta_comments'] = true) : ($atts['meta_comments'] = false);
	($atts['meta_link'] == "yes") ? ($atts['meta_link'] = true) : ($atts['meta_link'] = false);

	//checking if there are categories that are excluded using "-"; transform slugs to ids
	$cat_ids ='';
	$categories = explode(',', $atts['cat_slug']);
	if ( isset($categories) && $categories) {
		foreach ($categories as $category) {
			if(strpos($category, '-') === 0) {
				$cat_ids .= '-' .get_category_by_slug( $category )->cat_ID .',';
			} else {
				$cat_ids .= get_category_by_slug( $category )->cat_ID .',';
			}
		}
	}
	$atts['cat'] = substr($cat_ids, 0, -1);

	($atts['thumbnail'] == "yes") ? ($atts['thumbnail'] = true) : ($atts['thumbnail'] = false);
	($atts['thumbnail'] == "yes") ? ($atts['thumbnail'] = true) : ($atts['thumbnail'] = false);
	($atts['excerpt'] == "yes") ? ($atts['excerpt'] = true) : ($atts['excerpt'] = false);
	($atts['strip_html'] == "yes") ? ($atts['strip_html'] = 1) : ($atts['strip_html'] = 0);
	($atts['paging'] == "yes") ? ($atts['paging'] = true) : ($atts['paging'] = false);
	($atts['scrolling'] == "infinite") ? ($atts['paging'] = true) : ($atts['paging'] = $atts['paging']);

	$container_class = '';
	$post_class = '';
	if($atts['layout'] == 'large alternate') {
		$post_class = 'large-alternate';
	} elseif($atts['layout'] == 'medium alternate') {
		$post_class = 'medium-alternate';
	} elseif($atts['layout'] == 'grid') {
		$post_class = 'grid-post';
		$container_class = 'grid-layout';
		if(get_post_meta($post->ID, 'pyre_full_width', true) == 'yes' || basename( get_page_template() ) == "full-width.php" || basename( get_page_template() ) == "100-width.php") {
			if($atts['blog_grid_columns'] == '3') {
				$container_class = 'grid-layout grid-full-layout-3';
			} else {
				$container_class = 'grid-layout grid-full-layout-4';
			}
		}
	} elseif($atts['layout'] == 'timeline') {
		$post_class = 'timeline-post';
		$container_class = 'timeline-layout';
		if(get_post_meta($post->ID, 'pyre_full_width', true) == 'no' && basename( get_page_template() ) != "full-width.php" || basename( get_page_template() ) == "100-width.php") {
			$container_class = 'timeline-layout timeline-sidebar-layout';
		}
	}

	$ml_query = new WP_Query($atts);

	$html = '';

	if ($atts['scrolling'] == "infinite") {
		$html .= '<div id="blog-infinite" class="blog-shortcode">';
		$posts_container_id = 'posts-container-infinite';
	} else {
		$html .= '<div id="blog" class="blog-shortcode">';
		$posts_container_id = 'posts-container-pagination';
	}
	if($atts['layout'] == 'timeline') {
		$html .= '<div class="timeline-icon"><i class="icon-comments-alt"></i></div>';
	}

	$html .= '<div id="'.$posts_container_id.'" class="' .$container_class .' clearfix">';

	$post_count = 1;

	$prev_post_timestamp = null;
	$prev_post_month = null;
	$first_timeline_loop = false;

	while( $ml_query->have_posts() ) :
		$ml_query->the_post();

		$post_timestamp = strtotime($post->post_date);
		$post_month = date('n', $post_timestamp);
		$post_year = get_the_date('o');
		$current_date = get_the_date('o-n');

		if($atts['layout'] == 'timeline') {
			if($prev_post_month != $post_month) {
				$html.= '<div class="timeline-date"><h3 class="timeline-title">' . get_the_date($data['timeline_date_format']) .'</h3></div>';
			}
		}
		$html .= '<div id="post-' .get_the_ID().'"';
		ob_start();
		post_class($post_class.getClassAlign($post_count).' clearfix');
		$html .= ob_get_clean() .'>';
			if($atts['layout'] == 'medium alternate') {
				$html.= '<div class="date-and-formats">
					<div class="date-box updated">
						<span class="date">' . get_the_time($data['alternate_date_format_day']) .'</span>
						<span class="month-year">' .get_the_time($data['alternate_date_format_month_year']) .'</span>
					</div>
					<div class="format-box">';

					switch(get_post_format()) {
						case 'gallery':
							$format_class = 'camera-retro';
							break;
						case 'link':
							$format_class = 'link';
							break;
						case 'image':
							$format_class = 'picture';
							break;
						case 'quote':
							$format_class = 'quote-left';
							break;
						case 'video':
							$format_class = 'film';
							break;
						case 'audio':
							$format_class = 'headphones';
							break;
						case 'chat':
							$format_class = 'comments-alt';
							break;
						default:
							$format_class = 'book';
							break;
					}

						$html.= '<i class="icon-' . $format_class .'"></i>
					</div>
				</div>';
			}

			if($atts['thumbnail']) {
				if($data['legacy_posts_slideshow']) {
					ob_start();
					include(locate_template('legacy-slideshow-blog-shortcode.php', false));
					//get_template_part('legacy-slideshow');
					$html .= ob_get_clean();
				} else {
					ob_start();
					include(locate_template('new-slideshow-blog-shortcode.php', false));
					//get_template_part('new-slideshow-blog-shortcode');
					$html .= ob_get_clean();

				}
			}

			$html.= '<div class="post-content-container">';
			if($atts['layout'] == 'timeline') {
				$html.= '<div class="timeline-circle"></div>
				<div class="timeline-arrow"></div>';
			}
			if($atts['layout'] != 'large alternate' && $atts['layout'] != 'medium alternate' && $atts['layout'] != 'grid'  && $atts['layout'] != 'timeline') {
				if($atts['title']) {
					$html.= '<h2 class="entry-title"><a href="' . get_permalink() .'">' .get_the_title() .'</a></h2>';
				}
			}
			if($atts['layout'] == 'large alternate') {
				$html.= '<div class="date-and-formats">
					<div class="date-box updated">
						<span class="date">' .get_the_time($data['alternate_date_format_day']) .'</span>
						<span class="month-year">' .get_the_time($data['alternate_date_format_month_year']) .'</span>
					</div>
					<div class="format-box">';

						switch(get_post_format()) {
							case 'gallery':
								$format_class = 'camera-retro';
								break;
							case 'link':
								$format_class = 'link';
								break;
							case 'image':
								$format_class = 'picture';
								break;
							case 'quote':
								$format_class = 'quote-left';
								break;
							case 'video':
								$format_class = 'film';
								break;
							case 'audio':
								$format_class = 'headphones';
								break;
							case 'chat':
								$format_class = 'comments-alt';
								break;
							default:
								$format_class = 'book';
								break;
						}

						$html.= '<i class="icon-' .$format_class .'"></i>
					</div>
				</div>';
			}


			$html.= '<div class="post-content">';
				if($atts['layout'] == 'large alternate' || $atts['layout'] == 'medium alternate'  || $atts['layout'] == 'grid' || $atts['layout'] == 'timeline') {
					if($atts['title']) {
						$html.= '<h2 class="post-title entry-title"><a href="' . get_permalink() .'">' . get_the_title() .'</a></h2>';
					}
					if($atts['meta_all']) {
						if($atts['layout'] == 'grid' || $atts['layout'] == 'timeline') {
							$html.= '<p class="single-line-meta vcard">';
							if($atts['meta_author']) {
								$html .= __('By', 'Avada') .' ';
								ob_start();
								the_author_posts_link();
								$html .= '<span class="fn">'.ob_get_clean().'</span><span class="sep">|</span>';
							}
							if($atts['meta_date']) {
								$html .= '<span class="updated">'.get_the_time($data["date_format"]).'</span><span class="sep">|</span>';
							}
							$html.= '</p>';
						} else {
							$html.= '<p class="single-line-meta vcard">';
							if($atts['meta_author']) {
								$html .= __('By', 'Avada') .' ';
								ob_start();
								the_author_posts_link();
								$html .= '<span class="fn">'.ob_get_clean().'</span><span class="sep">|</span>';
							}
							if($atts['meta_date']) {
								$html .= '<span class="updated">'.get_the_time($data["date_format"]).'</span><span class="sep">|</span>';
							}
							if($atts['meta_categories']) {
								ob_start();
								the_category(', ');
								$html .= ob_get_clean().'<span class="sep">|</span>';
							}
							if($atts['meta_comments']) {
								ob_start();
								comments_popup_link(__('0 Comments', 'Avada'), __('1 Comment', 'Avada'), '% '.__('Comments', 'Avada'));
								$html .= ob_get_clean().'<span class="sep">|</span>';
							}
							$html .= '</p>';
						}
					}
				}
				$html .= '<div class="content-sep"></div>';

				// get the post content according to the chosen kind of delivery
				if($atts['excerpt']) {
					// content of shortcodes should be displayed
					if (isset($atts['include_shortcodes']) && $atts['include_shortcodes'] == true) {
						$html .= avada_custom_excerpt();
					} else {
						// content of shortcodes will be cut out, i.e. standard
						$stripped_content = tf_content( $atts['excerpt_words'], $atts['strip_html'] );
						$html .= $stripped_content;
					}
				} else {
					global $more; $more = 0;
					$content = get_the_content('');
					$content = apply_filters('the_content', $content);
					$content = str_replace(']]>', ']]&gt;', $content);
					$html .= $content;
				}

			$html .= '</div>
			<div style="clear:both;"></div>';

			if($atts['meta_all']) {
				$html .= '<div class="meta-info">';
					if($atts['layout'] == 'grid' || $atts['layout'] == 'timeline') {
						if($atts['layout'] != 'large alternate' && $atts['layout'] != 'medium alternate') {
							$html .= '<div class="alignleft">';
								if($atts['meta_link']) {
									$html .= '<a href="' .get_permalink() .'" class="read-more">' .__("Read More", "Avada") .'</a>';
								}
							$html .= '</div>';
						}
						$html .= '<div class="alignright">';
							if($atts['meta_comments']) {
								ob_start();
								comments_popup_link('<i class="icon-comments"></i>&nbsp;'.__('0', 'Avada'), '<i class="icon-comments"></i>&nbsp;'.__('1', 'Avada'), '<i class="icon-comments"></i>&nbsp;'.'%');
								$html .= ob_get_clean();
							}
						$html .= '</div>';
					} else {
						if($atts['layout'] != 'large alternate' && $atts['layout'] != 'medium alternate') {
							$html .= '<div class="alignleft vcard">';
								if($atts['meta_author']) {
									$html .= __('By', 'Avada') .' ';
									ob_start();
									the_author_posts_link();
									$html .= '<span class="fn">'.ob_get_clean().'</span><span class="sep">|</span>';
								}
								if($atts['meta_date']) {
									$html .= '<span class="updated">'.get_the_time($data["date_format"]).'</span><span class="sep">|</span>';
								}
								if($atts['meta_categories']) {
									ob_start();
									the_category(', ');
									$html .= ob_get_clean().'<span class="sep">|</span>';
								}
								if($atts['meta_comments']) {
									ob_start();
									comments_popup_link(__('0 Comments', 'Avada'), __('1 Comment', 'Avada'), '% '.__('Comments', 'Avada'));
									$html .= ob_get_clean().'<span class="sep">|</span>';
								}
							$html .= '</div>';
						}
						$html .= '<div class="alignright">';
							if($atts['meta_link']) {
								$html .= '<a href="' .get_permalink() .'" class="read-more">' .__("Read More", "Avada") .'</a>';
							}
						$html .= '</div>';
					}
				$html .= '</div>';
			}
			$html .= '</div>
		</div>';

		$prev_post_timestamp = $post_timestamp;
		$prev_post_month = $post_month;
		$post_count++;
	endwhile;

	$html .= '</div></div>';

	//no paging if only the latest posts are shown
	if ($atts['paging']) {
		$html .= avada_blog_shortcode_pagination($ml_query, $pages = '', $range = 2, $atts['scrolling']);
	}
	wp_reset_query();
	return $html;
}