/** * Render the metabox - used via callback * * @param array $post * @param array $args */ public function render($post = null, $args = null) { if (!$args['id']) { return false; } // add nonce for security if (!isset($this->cache['nonce'])) { wp_nonce_field('meta_save', '_nonce_' . $this->prefix . 'meta', false); } Bunyad::factory('admin/option-renderer'); // load $file = sanitize_file_name(str_replace($this->prefix, '', $args['id'])) . '.php'; $meta = Bunyad::factory('admin/meta-renderer', true); /* @var $meta Bunyad_Admin_MetaRenderer */ // render the template $meta->set_prefix($this->option_prefix)->template(array(), locate_template('admin/meta/' . $file), Bunyad::posts()->meta(null, $post->ID), array('post' => $post, 'box' => $this->get_box($args['id']), 'box_id' => $args['id'])); }
/** * Set a default or selected sidebar for WooCommerce pages and archives */ public function set_sidebar() { if (!(is_woocommerce() || is_checkout() || is_cart() || is_account_page())) { return; } $layout = ''; // archives and single if (is_woocommerce() && !is_product()) { $layout = Bunyad::posts()->meta('layout_style', wc_get_page_id('shop')); } // checkout, cart, account and single product pages (not enabled atm) if (is_checkout() || is_cart() || is_account_page() || is_product()) { // set layout $layout = Bunyad::posts()->meta('layout_style'); } // have a layout setting? if ($layout) { Bunyad::core()->set_sidebar($layout == 'full' ? 'none' : $layout); } else { // use default sidebar setting for WooCommerce Bunyad::core()->set_sidebar(Bunyad::options()->woocommerce_sidebar); } }
<?php /** * The single post template is selected based on your global Theem Settings or the post * setting. * * Template files for the post layouts are as follows: * * Classic: Located below in the code conditional * Post Cover: partials/single/layout-cover.php */ $template = Bunyad::posts()->meta('layout_template'); if (!$template or strstr($template, 'classic')) { $template = 'classic'; } if ($template != 'classic') { Bunyad::core()->add_body_class('post-layout-' . $template); } ?> <?php get_header(); ?> <div class="main wrap cf"> <?php if ($template != 'classic') { // not the default layout? ?>
<?php /** * Fields to show for posts meta box */ $options = array(array('label' => __('Featured Slider Post?', 'bunyad-admin'), 'name' => 'featured_post', 'type' => 'checkbox', 'value' => 0), array('label' => __('Post Layout', 'bunyad-admin'), 'name' => 'layout_template', 'type' => 'select', 'options' => array('' => __('Default (from Theme Settings)', 'bunyad-admin'), 'classic' => __('Classic', 'bunyad-admin'), 'cover' => __('Post Cover', 'bunyad-admin'), 'classic-above' => __('Classic - Title First', 'bunyad-admin')), 'value' => ''), array('label' => __('Layout Style', 'bunyad-admin'), 'name' => 'layout_style', 'type' => 'radio', 'options' => array('' => __('Default', 'bunyad-admin'), 'right' => __('Right Sidebar', 'bunyad-admin'), 'full' => __('Full Width', 'bunyad-admin')), 'value' => ''), array('label' => __('Category Label Overlay', 'bunyad-admin'), 'name' => 'cat_label', 'type' => 'html', 'html' => wp_dropdown_categories(array('show_option_all' => __('-- Auto Detect--', 'bunyad-admin'), 'hierarchical' => 1, 'order_by' => 'name', 'class' => '', 'name' => '_bunyad_cat_label', 'echo' => false, 'selected' => Bunyad::posts()->meta('cat_label'))), 'desc' => __('When you have multiple categories for a post, auto detection chooses one in alphabetical order. These labels are shown above image in category listings.', 'bunyad-admin')), array('label' => __('Multi-page Content Slideshow?', 'bunyad-admin'), 'desc' => __('You can use <!--nextpage--> to split a page into multi-page content slideshow.', 'bunyad-admin'), 'name' => 'content_slider', 'type' => 'select', 'value' => 0, 'options' => array('' => __('Disabled', 'bunyad-admin'), 'ajax' => __('AJAX - No Refresh', 'bunyad-admin'), 'refresh' => __('Multi-page - Refresh for next page', 'bunyad-admin'))), array('label_left' => __('Disable Featured?', 'bunyad-admin'), 'label' => __('Do not show featured Image, Video, or Gallery at the top for this post, on post page.', 'bunyad-admin'), 'name' => 'featured_disable', 'type' => 'checkbox', 'value' => 0), array('label' => __('Featured Video Code', 'bunyad-admin'), 'name' => 'featured_video', 'type' => 'textarea', 'options' => array('rows' => 7, 'cols' => 90), 'value' => '', 'allowed_html' => array('iframe' => array('scrolling' => true, 'src' => true, 'width' => true, 'height' => true, 'frameborder' => true)))); if (Bunyad::options()->layout_style == 'boxed') { $options[] = array('label' => __('Custom Background Image', 'bunyad-admin'), 'name' => 'bg_image', 'type' => 'upload', 'options' => array('type' => 'image', 'title' => __('Upload This Picture', 'bunyad-admin'), 'button_label' => __('Upload', 'bunyad-admin'), 'insert_label' => __('Use as Background', 'bunyad-admin')), 'value' => '', 'bg_type' => array('value' => 'cover')); }
// init the grid query if (is_array($grid_query)) { $grid_query = new WP_Query(apply_filters('bunyad_block_query_args', $grid_query, 'slider_grid')); } if (!empty($grid_query) && $grid_query->have_posts()) { ?> <?php while ($grid_query->have_posts()) { $grid_query->the_post(); $z++; if (!has_post_thumbnail()) { continue; } // custom label selected? if ($cat_label = Bunyad::posts()->meta('cat_label')) { $category = get_category($cat_label); } else { $category = current(get_the_category()); } ?> <article class="<?php echo $z == 1 ? 'large' : ($z == 2 ? 'small' : 'small last'); ?> "> <?php if ($z == 1) { ?> <span class="cat cat-title cat-<?php
?> </div> </section> <div class="row"> <div class="col-8 main-content"> <article> <div class="post-container cf"> <div class="post-content description <?php echo Bunyad::posts()->meta('content_slider') ? 'post-slideshow' : ''; ?> " itemprop="articleBody"> <?php // get post body content get_template_part('partials/single/post-content'); ?> </div><!-- .post-content --> </div> <?php // add social share get_template_part('partials/single/social-share');
<?php } ?> </div> <?php if (!Bunyad::options()->blog_no_pagination) { // pagination can be disabled ?> <div class="main-pagination"> <?php echo Bunyad::posts()->paginate(array(), $bunyad_loop); ?> </div> <?php } ?> <?php } elseif (is_archive() or is_search()) { // show error on archive only ?> <article id="post-0" class="page no-results not-found"> <div class="post-content">
"><?php the_title(); ?> </a></h2> <?php echo Bunyad::blocks()->meta('below', 'highlights'); ?> <?php if ($type == 'thumb') { ?> <div class="excerpt"> <?php echo Bunyad::posts()->excerpt(null, Bunyad::options()->excerpt_length_highlights, array('add_more' => false)); ?> </div> <?php } ?> </article> <?php if ($query->post_count > 1) { ?> <ul class="block <?php echo $type == 'thumb' ? 'posts-list thumb' : 'posts';
/** * Custom CSS for pages and posts that shouldn't be cached through css-compiler.php because * the size will increase exponentially. * */ public function add_per_page($return = false) { if (!is_admin() && is_singular() && Bunyad::posts()->meta('bg_image')) { $bg_type = Bunyad::posts()->meta('bg_image_bg_type'); $the_css = 'background: url("' . esc_attr(Bunyad::posts()->meta('bg_image')) . '");'; if (!empty($bg_type)) { if ($bg_type == 'cover') { $the_css .= 'background-repeat: no-repeat; background-attachment: fixed; background-position: center center; ' . '-webkit-background-size: cover; -moz-background-size: cover;-o-background-size: cover; background-size: cover;'; } else { $the_css .= 'background-repeat: ' . esc_attr($bg_type) . ';'; } } $the_css = 'body.boxed { ' . $the_css . ' }'; // return the css? if ($return) { return $the_css; } // or enqueue it for inline css Bunyad::core()->enqueue_css(wp_style_is('custom-css', 'enqueued') ? 'custom-css' : 'smartmag-core', $the_css); } }
<?php /** * Partial: Pagination used in multi-page content slideshows */ ?> <div class="post-pagination-next" data-type="<?php echo esc_attr(Bunyad::posts()->meta('content_slider')); ?> "> <?php global $page, $numpages; // get multi-page numbers ?> <span class="info"><?php printf(__('Showing %s of %s', 'bunyad'), '<strong>' . $page . '</strong>', '<strong>' . $numpages . '</strong>'); ?> </span> <?php wp_link_pages(array('before' => '<div class="links">', 'after' => '</div>', 'link_before' => '<span class="button">', 'next_or_number' => 'next', 'nextpagelink' => __('Next', 'bunyad') . ' <i class="next fa fa-chevron-right"></i>', 'previouspagelink' => '<i class="prev fa fa-chevron-left"></i> ' . __('Prev', 'bunyad'), 'link_after' => '</span>')); ?> </div>
the_title_attribute(); ?> "><?php the_title(); ?> </a></h2> <?php echo Bunyad::blocks()->meta('below'); ?> <div class="excerpt"> <?php // Excerpt option key for news focus is excerpt_length_news_focus $excerpt = 'excerpt_length_' . ($the_block == 'news-focus' ? 'news_focus' : 'focus_grid'); echo Bunyad::posts()->excerpt(null, Bunyad::options()->{$excerpt}, array('add_more' => false)); ?> </div> </article> <?php if ($count == $highlights) { break; } ?> <?php } ?>
/** * Callback: Set the relevant header options for the theme such as sidebar */ public function _set_header_options() { // posts, pages, attachments etc. if (is_singular()) { wp_enqueue_script('comment-reply', null, null, null, true); // set layout $layout = Bunyad::posts()->meta('layout_style'); if ($layout) { $this->set_sidebar($layout == 'full' ? 'none' : $layout); } } }
</div> <h2 itemprop="name"><a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?> "><?php the_title(); ?> </a></h2> <div class="excerpt"> <?php echo Bunyad::posts()->excerpt(null, Bunyad::options()->excerpt_length_news_focus, array('add_more' => false)); ?> </div> </article> <?php if ($count == $highlights) { break; } ?> <?php } ?>
<div class="section-head"><?php _e('Author', 'bunyad'); ?></div> <?php get_template_part('partial-author'); ?> <?php endif; else: if (is_single() && Bunyad::options()->author_box) : // author box? ?> <div class="section-head"><?php _e('Author', 'bunyad'); ?></div> <?php get_template_part('partial-author'); endif; endif; */ ?> <?php if (is_single() && Bunyad::options()->related_posts && ($related = Bunyad::posts()->get_related(Bunyad::core()->get_sidebar() == 'none' ? 3 : 3))) { // && Bunyad::options()->related_posts != false): ?> <section class="related-posts"> <h2 class="section-head"><?php _e('Related Posts', 'bunyad'); ?> </h2> <ul class="highlights-box three-col related-posts"> <?php foreach ($related as $post) { setup_postdata($post); ?>
echo '<hr class="separator" />'; } ?> </div> </article> <?php if ($pages > 1) { $query = (object) array('max_num_pages' => $pages); ?> <div class="main-pagination"> <?php echo Bunyad::posts()->paginate(array(), $query); ?> </div> <?php } ?> </div> <?php Bunyad::core()->theme_sidebar(); ?> </div> <!-- .row --> </main> <!-- .main -->
<div class="gallery-slider slider-arrows"> <div class="frame flexslider"> <ul class="slides"> <?php foreach ($images as $attachment) { ?> <li> <a href="<?php echo wp_get_attachment_url($attachment->ID); ?> "> <?php if (!in_the_loop() && Bunyad::posts()->meta('layout_style') == 'full' or Bunyad::core()->get_sidebar() == 'none') { // largest images - no sidebar? ?> <?php echo wp_get_attachment_image($attachment->ID, 'main-full'); ?> <?php } else { ?> <?php echo wp_get_attachment_image($attachment->ID, 'main-slider'); ?>
<?php /** * Pagination - Show numbered pagination for catalog pages. * * @version 2.2.2 */ ?> <div class="main-pagination"> <?php echo Bunyad::posts()->paginate(); ?> </div>
/** * Filter callback: Add a wrapper to the content slideshow wrapper * * @param string $content */ public function add_post_slideshow_wrap($content) { if (is_single() && Bunyad::posts()->meta('content_slider') == 'ajax') { return '<div class="content-page">' . $content . '</div>'; } return $content; }
* Note: supports microformat schema. Add hreview, reviewer, dtreviewed * relevant fields in content.php */ $meta = Bunyad::posts()->meta(); $ratings = array(); foreach ($meta as $key => $value) { if (preg_match('/criteria_rating_([0-9]+)$/', $key, $match)) { $ratings[] = array('number' => $match[1], 'rating' => $value, 'label' => $meta['_bunyad_criteria_label_' . $match[1]]); } } $overall = Bunyad::posts()->meta('review_overall'); $heading = Bunyad::posts()->meta('review_heading'); $type = Bunyad::posts()->meta('review_type'); // add verdict text $verdict = Bunyad::posts()->meta('review_verdict'); $verdict_text = Bunyad::posts()->meta('review_verdict_text'); // container classes $classes[] = 'review-box'; if ($position == 'top-left') { array_push($classes, 'alignleft', 'column', 'half'); } // add stars class if ($type == 'stars') { array_push($classes, 'stars'); } ?> <section class="<?php echo implode(' ', $classes); ?> ">
if (Bunyad::posts()->meta('content_slider')) { get_template_part('partials/pagination-next'); } ?> <?php // excerpts or main content? if (!is_page() && is_singular() or !Bunyad::options()->show_excerpts_classic or Bunyad::posts()->meta('content_slider')) { Bunyad::posts()->the_content(); } else { echo Bunyad::posts()->excerpt(null, Bunyad::options()->excerpt_length_classic, array('force_more' => true)); } ?> <?php // multi-page post - add numbered pagination if (!Bunyad::posts()->meta('content_slider')) { wp_link_pages(array('before' => '<div class="main-pagination post-pagination">', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>')); } ?> <?php if (is_single() && Bunyad::options()->show_tags) { ?> <div class="tagcloud"><?php the_tags('', ' '); ?> </div> <?php }
/** * Get primary category of the current post in loop (if selected) * * Note: If no primary category is selected, it will return one category * using the default alphabetical sorting of WordPress. * * @see get_the_category() * @return object */ public function get_primary_cat() { // Custom label selected? if ($cat_label = Bunyad::posts()->meta('cat_label')) { $cat = get_category($cat_label); } else { $cat = current(get_the_category()); } return apply_filters('bunyad_get_primary_cat', $cat); }
/** * Get overall user rating for a post * * @param integer|null $post_id * @param string $type empty for overall number or 'percent' for rounded percent */ public function get_user_rating($post_id = null, $type = '') { $rating = Bunyad::posts()->meta('user_rating', $post_id); if (!empty($rating['overall'])) { // return percent? if ($type == 'percent') { return $this->decimal_to_percent($rating['overall']); } return round($rating['overall'], 1); } return 0; }
<h1 class="main-heading"><?php the_title(); ?> </h1> </header><!-- .post-header --> <?php //endif; ?> <div> <?php Bunyad::posts()->the_content(); ?> </div> </div> </div> <?php Bunyad::core()->theme_sidebar(); ?> </div> <!-- .row --> </main> <!-- .main -->
$meta = Bunyad::options()->get('cat_meta_' . $cat); // slider not enabled? quit! if (empty($meta['slider'])) { return; } $args['cat'] = $cat; // latest posts? if ($meta['slider'] == 'latest') { unset($args['meta_key'], $args['meta_value']); } } /* * Main slider posts query */ // use latest posts? if (Bunyad::posts()->meta('featured_slider') == 'default-latest') { unset($args['meta_key'], $args['meta_value']); } $query = new WP_Query($args); if (!$query->have_posts()) { return; } // Use rest of the 3 posts for grid if not post grid is not using // any category or tag. Create reference for to main query. if (empty($grid_query) && $query->found_posts > 5) { $grid_query =& $query; } $i = $z = 0; // loop counters ?> <div class="main-featured">
<?php /** * Partial Template for related posts on single pages */ ?> <?php if (is_single() && Bunyad::options()->related_posts) { $related = Bunyad::posts()->get_related(Bunyad::core()->get_sidebar() == 'none' ? 3 : 3); if (!$related) { return; } ?> <section class="related-posts"> <h3 class="section-head"><?php _e('Related Posts', 'bunyad'); ?> </h3> <ul class="highlights-box three-col related-posts"> <?php foreach ($related as $post) { setup_postdata($post); ?> <li class="highlights column one-third"> <article>
?> <div class="post"> <a href="<?php the_permalink(); ?> "><?php the_post_thumbnail('post-thumbnail', array('title' => strip_tags(get_the_title()))); ?> <?php if (class_exists('Bunyad') && Bunyad::options()->review_show_widgets && Bunyad::posts()->meta('reviews')) { ?> <div class="review rate-number"><span class="progress"></span> <span><?php echo Bunyad::posts()->meta('review_overall'); ?> </span></div> <?php } ?> </a> <div class="content"> <?php echo Bunyad::blocks()->meta('above', 'mega-menu', array('type' => 'widget')); ?> <a href="<?php