update_option('show_on_front', 'page'); update_option('page_on_front', $home->ID); } } } /** * Action callback: Fix menu on sample import * * @param object $import */ public function import_fix_menu($import) { // remove an item from menu $item = get_page_by_title('Shop With Sidebar', OBJECT, 'nav_menu_item'); if (is_object($item)) { wp_delete_post($item->ID); } } /** * Custom Menu fields for the sample menu * * @param array $values */ public function import_menu_fields($values = array()) { return array('mega_menu' => array('Entertainment' => 'category', 'Tidbits' => 'category', 'Features' => 'normal'), 'url' => array('Forums' => home_url('/forums/'))); } } // init and make available in Bunyad::get('admin_import') Bunyad::register('admin_import', array('class' => 'Bunyad_Theme_Admin_Import', 'init' => true));
"><?php echo esc_html($category->name); ?> </a></span> <?php return apply_filters('bunyad_blocks_cat_label', ob_get_clean()); } /** * 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); } } // init and make available in Bunyad::get('blocks') Bunyad::register('blocks', array('class' => 'Bunyad_Theme_Blocks', 'init' => true));
} /** * Filter callback: Add a search icon the navigation */ public function add_navigation_search($items, $args) { return $items; if (!Bunyad::options()->nav_search or $args->theme_location != 'main') { return $items; } ob_start(); // nav search flag used by search.php $in_nav = true; ?> <li class="search-icon"> <a href="#" title="<?php esc_attr_e('Search', 'bunyad'); ?> "><i class="fa fa-search"></i></a> <?php include locate_template('partials/header/search.php'); ?> </li> <?php $items .= ob_get_clean(); return $items; } } // init and make available in Bunyad::get('navigation') Bunyad::register('navigation', array('class' => 'Bunyad_Theme_Navigation', 'init' => true));
add_theme_support('bbpress'); // Add modal to footer add_action('wp_footer', array($this, 'auth_modal')); // Navigation login icon add_filter('nav_menu_css_class', array($this, 'nav_login'), 10, 2); } /** * Action callback: Add login/register modal if bbPress is active */ public function auth_modal() { get_template_part('bbpress/auth-modal'); } /** * Filter callback: Add user login class to the correct menu item. * * Mainly used for bbPress! * * @param array $classes */ public function nav_login($classes, $item) { if (strstr($item->url, '#user-login')) { $classes[] = 'user-login'; } return $classes; } } // init and make available in Bunyad::get('blocks') Bunyad::register('bbpress', array('class' => 'Bunyad_Theme_BBPress', 'init' => true));
* top-level / and in partials/ folder. * */ // Already initialized? some buggy plugin call? if (class_exists('Bunyad_Core')) { return; } /** * Initialize Framework * * Include the Bunyad_Base and extend it using our theme-specific class. */ locate_template('lib/bunyad.php', true, true); locate_template('inc/bunyad.php', true, true); // Fire up the theme - make available in Bunyad::get('smart_mag') Bunyad::register('smart_mag', array('class' => 'Bunyad_Theme_SmartMag', 'init' => true)); /** * Main Framework Configuration */ $bunyad = Bunyad::core()->init(apply_filters('bunyad_init_config', array('theme_name' => 'smartmag', 'meta_prefix' => '_bunyad', 'theme_version' => '2.6.1', 'widgets' => array('about', 'latest-posts', 'popular-posts', 'tabbed-recent', 'flickr', 'ads', 'latest-reviews', 'bbp-login', 'tabber', 'blocks'), 'post_formats' => array('gallery', 'image', 'video', 'audio'), 'shortcode_config' => array('font_icons' => true, 'social_font' => true, 'button_colors' => array('default', 'red', 'orange', 'yellow', 'blue', 'black')), 'meta_boxes' => array(array('id' => 'post-options', 'title' => __('Post Options', 'bunyad-admin'), 'priority' => 'high', 'page' => array('post')), array('id' => 'post-reviews', 'title' => __('Review', 'bunyad-admin'), 'priority' => 'high', 'page' => array('post')), array('id' => 'page-options', 'title' => __('Page Options', 'bunyad-admin'), 'priority' => 'high', 'page' => array('page'))), 'page_builder_blocks' => array('highlights' => 'Bunyad_PageBuilder_Highlights', 'news-focus' => 'Bunyad_PageBuilder_NewsFocus', 'focus-grid' => 'Bunyad_PageBuilder_FocusGrid', 'blog' => 'Bunyad_PageBuilder_Blog', 'latest-gallery' => 'Bunyad_PageBuilder_LatestGallery', 'separator' => 'Bunyad_PbBasic_Separator', 'rich-text' => 'Bunyad_PbBasic_RichText', 'text' => 'WP_Widget_Text', 'latest-posts' => array('class' => 'Bunyad_LatestPosts_Widget', 'name' => __('Latest Posts', 'bunyad-admin')), 'flickr' => array('class' => 'Bunyad_Flickr_Widget', 'name' => __('Flickr Images', 'bunyad-admin')), 'ads' => array('class' => 'Bunyad_Ads_Widget', 'name' => __('Advertisement', 'bunyad-admin')), 'latest-reviews' => array('class' => 'Bunyad_LatestReviews_Widget', 'name' => __('Latest Reviews', 'bunyad-admin')))))); /** * SmartMag Theme! * * Anything theme-specific that won't go into the core framework goes here. * * Also see: inc/admin.php for the admin bootstrap. */ class Bunyad_Theme_SmartMag { public $woocommerce; public $registry = array();
} /** * 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); } } } // init and make available in Bunyad::get('custom_css') Bunyad::register('custom_css', array('class' => 'Bunyad_Theme_CustomCss', 'init' => true));
// change main-block for default slider if ($id == 'main-block' && $place == 'slider-right') { $id = 'slider-right-large'; } return $id; } /** * Filter callback: Adjust number of posts in the mega menu */ public function mega_menu_number($query, $type = '') { if ($type == 'category-recent') { $query['posts_per_page'] = 4; } return $query; } /** * Add to dynamic Custom CSS generator */ public function add_dynamic_css($css) { $css .= <<<EOF EOF; return $css; } } // init and make available in Bunyad::get('skin_tech') Bunyad::register('skin_tech', array('class' => 'Bunyad_Skin_Tech', 'init' => true));