/** * Render the shortcode * @param array $args Shortcode paramters * @param string $content Content between shortcode * @return string HTML output */ function render($args, $content = '') { global $smof_data; $defaults = T4PCore_Plugin::set_shortcode_defaults(array('class' => '', 'id' => '', 'blog_grid_columns' => '3', 'cat_slug' => '', 'excerpt' => 'yes', 'excerpt_length' => '', 'excerpt_words' => '50', 'exclude_cats' => '', 'layout' => 'large', 'meta_all' => 'yes', 'meta_author' => 'yes', 'meta_categories' => 'yes', 'meta_comments' => 'yes', 'meta_date' => 'yes', 'meta_link' => 'yes', 'meta_read' => 'yes', 'meta_tags' => 'no', 'number_posts' => '', 'order' => 'DESC', 'paging' => 'yes', 'scrolling' => 'infinite', 'strip_html' => 'yes', 'thumbnail' => 'yes', 'show_title' => 'yes', 'title_link' => 'yes', 'nopaging' => false, 'posts_per_page' => '-1', 'taxonomy' => 'category'), $args); extract($defaults); 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; } $defaults['paged'] = $paged; // covert all attributes to correct values for WP query if ($defaults['number_posts']) { $defaults['posts_per_page'] = $defaults['number_posts']; } if ($defaults['posts_per_page'] == -1) { $defaults['nopaging'] = true; } $defaults['excerpt'] == "yes" ? $defaults['excerpt'] = true : ($defaults['excerpt'] = false); $defaults['meta_all'] == "yes" ? $defaults['meta_all'] = true : ($defaults['meta_all'] = false); $defaults['meta_author'] == "yes" ? $defaults['meta_author'] = true : ($defaults['meta_author'] = false); $defaults['meta_categories'] == "yes" ? $defaults['meta_categories'] = true : ($defaults['meta_categories'] = false); $defaults['meta_comments'] == "yes" ? $defaults['meta_comments'] = true : ($defaults['meta_comments'] = false); $defaults['meta_date'] == "yes" ? $defaults['meta_date'] = true : ($defaults['meta_date'] = false); $defaults['meta_link'] == "yes" ? $defaults['meta_link'] = true : ($defaults['meta_link'] = false); $defaults['meta_tags'] == "yes" ? $defaults['meta_tags'] = true : ($defaults['meta_tags'] = false); $defaults['paging'] == "yes" ? $defaults['paging'] = true : ($defaults['paging'] = false); $defaults['scrolling'] == "infinite" ? $defaults['paging'] = true : ($defaults['paging'] = $defaults['paging']); $defaults['strip_html'] == "yes" ? $defaults['strip_html'] = true : ($defaults['strip_html'] = false); $defaults['thumbnail'] == "yes" ? $defaults['thumbnail'] = true : ($defaults['thumbnail'] = false); $defaults['show_title'] == "yes" ? $defaults['show_title'] = true : ($defaults['show_title'] = false); $defaults['title_link'] == "yes" ? $defaults['title_link'] = true : ($defaults['title_link'] = false); if ($defaults['excerpt_length'] || $defaults['excerpt_length'] === '0') { $defaults['excerpt_words'] = $defaults['excerpt_length']; } //check for cats to exclude; needs to be checked via exclude_cats param and '-' prefixed cats on cats param //exclution via exclude_cats param $cats_to_exclude = explode(',', $defaults['exclude_cats']); $cats_id_to_exclude = array(); if ($cats_to_exclude) { foreach ($cats_to_exclude as $cat_to_exclude) { $id_obj = get_category_by_slug($cat_to_exclude); if ($id_obj) { $cats_id_to_exclude[] = $id_obj->term_id; } } if ($cats_id_to_exclude) { $defaults['category__not_in'] = $cats_id_to_exclude; } } //setting up cats to be used and exclution using '-' prefix on cats param; transform slugs to ids $cat_ids = ''; $categories = explode(',', $defaults['cat_slug']); if (isset($categories) && $categories) { foreach ($categories as $category) { $id_obj = get_category_by_slug($category); if ($id_obj) { if (strpos($category, '-') === 0) { $cat_ids .= '-' . $id_obj->cat_ID . ','; } else { $cat_ids .= $id_obj->cat_ID . ','; } } } } $defaults['cat'] = substr($cat_ids, 0, -1); self::$args = $defaults; $t4p_query = new WP_Query($defaults); $this->query = $t4p_query; //prepare needed wrapping containers $html = ''; $html .= sprintf('<div %s>', T4PCore_Plugin::attributes('blog-shortcode')); $html .= sprintf('<div %s>', T4PCore_Plugin::attributes('blog-shortcode-posts-container')); ob_start(); do_action('t4p_blog_shortcode_wrap_loop_open'); $wrap_loop_open = ob_get_contents(); ob_get_clean(); $html .= $wrap_loop_open; if (self::$args['layout'] == 'timeline') { $this->post_count = 1; $prev_post_timestamp = null; $prev_post_month = null; $first_timeline_loop = false; } //do the loop if ($t4p_query->have_posts()) { while ($t4p_query->have_posts()) { $t4p_query->the_post(); $this->post_id = get_the_ID(); if (self::$args['layout'] == 'timeline') { $post_timestamp = strtotime(get_the_date()); $this->post_month = date('n', $post_timestamp); $post_year = get_the_date('o'); $current_date = get_the_date('o-n'); $date_params['prev_post_month'] = $prev_post_month; $date_params['post_month'] = $this->post_month; ob_start(); do_action('t4p_blog_shortcode_timeline_date', $date_params); do_action('t4p_blog_shortcode_before_loop_timeline'); $before_loop_timeline_action = ob_get_contents(); ob_get_clean(); $html .= $before_loop_timeline_action; } else { ob_start(); do_action('t4p_blog_shortcode_before_loop'); $before_loop_action = ob_get_contents(); ob_get_clean(); $html .= $before_loop_action; } if (self::$args['layout'] == 'grid' || self::$args['layout'] == 'timeline') { $html .= sprintf('<div %s>', T4PCore_Plugin::attributes('post-content-wrapper')); } $this->header = array('title_link' => true); ob_start(); do_action('t4p_blog_shortcode_loop_header'); do_action('t4p_blog_shortcode_loop_content'); do_action('t4p_blog_shortcode_loop_footer'); do_action('t4p_blog_shortcode_after_loop'); $loop_actions = ob_get_contents(); ob_get_clean(); $html .= $loop_actions; if (self::$args['layout'] == 'grid' || self::$args['layout'] == 'timeline') { $html .= '</div>'; } if (self::$args['layout'] == 'timeline') { $prev_post_timestamp = $post_timestamp; $prev_post_month = $this->post_month; $this->post_count++; } } } else { } wp_reset_query(); ob_start(); do_action('t4p_blog_shortcode_wrap_loop_close'); $wrap_loop_close_action = ob_get_contents(); ob_get_clean(); $html .= $wrap_loop_close_action; $html .= '</div>'; if (self::$args['paging']) { ob_start(); t4p_pagination($this->query->max_num_pages, $range = 2, $this->query); $pagination = ob_get_contents(); ob_get_clean(); $html .= $pagination; } $html .= '</div>'; return $html; }
echo get_post_meta($post->ID, 'pyre_video', true); ?> </div> <?php } ?> </div> <?php } } ?> </div> <div class="text-center"> <?php t4p_pagination($gallery->max_num_pages, $range = 2); ?> </div> <?php } ?> </div> <?php if ($sidebar_exists == true) { ?> <?php wp_reset_query(); ?> <div id="sidebar" style="<?php
</div> </div> <?php } ?> </div> <?php } } ?> </div> <div class="text-center"> <?php t4p_pagination($pages = '', $range = 2); ?> </div> </div> <?php if ($sidebar_exists == true) { ?> <?php wp_reset_query(); ?> <div id="sidebar" style="<?php echo $sidebar_css; ?> " class="<?php