Version ) ); define( 'BAVOTASAN_THEME_NAME', $bavotasan_theme_data->Name ); define( 'BAVOTASAN_THEME_FILE', get_option( 'template' ) ); /** * Includes * * @since 1.0.0 */ require( BAVOTASAN_THEME_TEMPLATE . '/library/customizer.php' ); // Functions for theme options page require( BAVOTASAN_THEME_TEMPLATE . '/library/about.php' ); // Functions for about page require( BAVOTASAN_THEME_TEMPLATE . '/library/preview-pro.php' ); // Functions for preview pro page require( BAVOTASAN_THEME_TEMPLATE . '/library/custom-metaboxes.php' ); // Functions for home page alignment /** * Prepare the content width * * @since 1.0.2 */ function bavotasan_content_width() { $bavotasan_theme_options = bavotasan_theme_options(); $bavotasan_array_content = array( 'col-md-2' => .1666, 'col-md-3' => .25, 'col-md-4' => .3333, 'col-md-5' => .4166, 'col-md-6' => .5, 'col-md-7' => .5833, 'col-md-8' => .6666, 'col-md-9' => .75, 'col-md-10' => .8333, 'col-md-12' => 1 ); $bavotasan_main_content = $bavotasan_array_content[$bavotasan_theme_options['primary']] * $bavotasan_theme_options['width'] - 30; return round( $bavotasan_array_content[$bavotasan_theme_options['primary']] * $bavotasan_theme_options['width'] - 30 ); } if ( ! isset( $content_width ) ) $content_width = bavotasan_content_width(); add_action( 'template_redirect', 'bavotasan_content_width_adjust' ); /** * Adjust content_width value for image attachment template. * @ since 1.0.3 */ function bavotasan_content_width_adjust() { if ( is_home() || is_search() || is_archive() ) { $bavotasan_theme_options = bavotasan_theme_options(); $GLOBALS['content_width'] = $bavotasan_theme_options['width'] - 30; } } add_action( 'after_setup_theme', 'bavotasan_setup' ); if ( ! function_exists( 'bavotasan_setup' ) ) : /** * Initial setup * * This function is attached to the 'after_setup_theme' action hook. * * @uses load_theme_textdomain() * @uses get_locale() * @uses BAVOTASAN_THEME_TEMPLATE * @uses add_theme_support() * @uses add_editor_style() * @uses add_custom_background() * @uses add_custom_image_header() * @uses register_default_headers() * * @since 1.0.0 */ function bavotasan_setup() { load_theme_textdomain( 'matheson', BAVOTASAN_THEME_TEMPLATE . '/library/languages' ); // Add default posts and comments RSS feed links to . add_theme_support( 'automatic-feed-links' ); // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style( array( 'library/css/admin/editor-style.css', bavotasan_font_url() ) ); // This theme uses wp_nav_menu() in two location. register_nav_menu( 'primary', __( 'Primary Menu', 'matheson' ) ); // Add support for a variety of post formats add_theme_support( 'post-formats', array( 'gallery', 'image', 'video', 'audio', 'quote', 'link', 'status', 'aside' ) ); // This theme uses Featured Images (also known as post thumbnails) for archive pages add_theme_support( 'post-thumbnails' ); add_image_size( 'teaser', 300, 300, true ); // Add a filter to bavotasan_header_image_width and bavotasan_header_image_height to change the width and height of your custom header. add_theme_support( 'custom-header', array( 'default-text-color' => '282828', 'flex-height' => true, 'flex-width' => true, 'random-default' => true, 'width' => apply_filters( 'bavotasan_header_image_width', 1200 ), 'height' => apply_filters( 'bavotasan_header_image_height', 600 ), 'wp-head-callback' => 'bavotasan_header_style', 'admin-head-callback' => 'bavotasan_admin_header_style', 'admin-preview-callback' => 'bavotasan_admin_header_image' ) ); // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. register_default_headers( array( 'header01' => array( 'url' => '%s/library/images/header01.jpg', 'thumbnail_url' => '%s/library/images/header01-thumbnail.jpg', 'description' => __( 'Default Header 1', 'matheson' ) ), ) ); // Add support for custom backgrounds add_theme_support( 'custom-background' ); add_theme_support( 'title-tag' ); // Add HTML5 elements add_theme_support( 'html5', array( 'comment-list', 'search-form', 'comment-form', ) ); // Infinite scroll add_theme_support( 'infinite-scroll', array( 'type' => 'scroll', 'container' => 'primary', 'wrapper' => false, 'footer' => false, ) ); // Remove default gallery styles add_filter( 'use_default_gallery_style', '__return_false' ); } endif; // bavotasan_setup add_action( 'wp_head', 'bavotasan_styles' ); /** * Add a style block to the theme for the current link color. * * This function is attached to the 'wp_head' action hook. * * @since 1.0.0 */ function bavotasan_styles() { $bavotasan_theme_options = bavotasan_theme_options(); ?> Header admin panel. * * Referenced via add_custom_image_header() in bavotasan_setup(). * * @since 1.0.0 */ function bavotasan_admin_header_style() { $text_color = get_header_textcolor(); $styles = ( 'blank' == $text_color ) ? 'display:none' : 'color:#' . $text_color . ' !important'; ?> Header admin panel. * * Referenced via add_custom_image_header() in bavotasan_setup(). * * @uses bloginfo() * @uses get_header_image() * * @since 1.0.0 */ function bavotasan_admin_header_image() { ?>

__( 'First Sidebar', 'matheson' ), 'id' => 'sidebar', 'description' => __( 'This sidebar only appears on single posts and pages. All defaults widgets work great here.', 'matheson' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Home Page Top Area', 'matheson' ), 'id' => 'home-page-top-area', 'description' => __( 'Area on the home page above the main content. Specifically designed for 3 Image & Text widgets.', 'matheson' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } endif; // bavotasan_widgets_init /** * Add pagination * * @uses paginate_links() * @uses add_query_arg() * * @since 1.0.0 */ function bavotasan_pagination() { global $wp_query, $paged, $bavotasan_grid_query; $wp_query = ( $bavotasan_grid_query ) ? $bavotasan_grid_query : $wp_query; // Don't print empty markup if there's only one page. if ( $wp_query->max_num_pages < 2 && 0 == $paged ) return; ?> comment_type ) : case '' : ?>
  • >
    comment_approved ) { echo '' . __( 'Your comment is awaiting moderation.', 'matheson' ) . ''; } ?>
    comment_type ) { ?>
    $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  • ' . $text . '

    '; } endif; // bavotasan_excerpt_more add_filter( 'the_content_more_link', 'bavotasan_content_more_link', 10, 2 ); if ( ! function_exists( 'bavotasan_content_more_link' ) ) : /** * Customize read more link for content * * This function is attached to the 'the_content_more_link' filter hook. * * @param string $link * @param string $text * * @return Custom read more link * * @since 1.0.0 */ function bavotasan_content_more_link( $link, $text ) { return ''; } endif; // bavotasan_content_more_link add_filter( 'excerpt_length', 'bavotasan_excerpt_length', 999 ); if ( ! function_exists( 'bavotasan_excerpt_length' ) ) : /** * Custom excerpt length * * This function is attached to the 'excerpt_length' filter hook. * * @param int $length * * @return Custom excerpt length * * @since 1.0.0 */ function bavotasan_excerpt_length( $length ) { global $bavotasan_custom_excerpt_length; if ( $bavotasan_custom_excerpt_length ) return $bavotasan_custom_excerpt_length; return 60; } endif; // bavotasan_excerpt_length /** * Print the attached image with a link to the next attached image. * * @since 1.0.9 */ function bavotasan_the_attached_image() { $post = get_post(); $attachment_size = apply_filters( 'bavotasan_attachment_size', array( 810, 810 ) ); $next_attachment_url = wp_get_attachment_url(); $attachment_ids = get_posts( array( 'post_parent' => $post->post_parent, 'fields' => 'ids', 'numberposts' => -1, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', ) ); if ( count( $attachment_ids ) > 1 ) { foreach ( $attachment_ids as $attachment_id ) { if ( $attachment_id == $post->ID ) { $next_id = current( $attachment_ids ); break; } } if ( $next_id ) $next_attachment_url = get_attachment_link( $next_id ); else $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) ); } printf( '%2$s', esc_url( $next_attachment_url ), wp_get_attachment_image( $post->ID, $attachment_size ) ); } /** * Create the required attributes for the #primary container * * @since 1.0.0 */ function bavotasan_primary_attr() { $bavotasan_theme_options = bavotasan_theme_options(); $primary = str_replace( 'col-md-', '', $bavotasan_theme_options['primary'] ); $secondary = ( is_active_sidebar( 'second-sidebar' ) ) ? str_replace( 'col-md-', '', $bavotasan_theme_options['secondary'] ) : 12 - $primary; $tertiary = 12 - $primary - $secondary; $class = $bavotasan_theme_options['primary']; $class = ( is_singular() || is_404() || ( function_exists( 'is_bbpress' ) && is_bbpress() ) ) ? $class : 'col-sm-12'; $push = ''; $class = ( 'left' == $bavotasan_theme_options['layout'] ) ? $class . ' pull-right' : $class; echo 'class="' . esc_attr( $class ) . esc_attr( $push ) . '"'; } /** * Create the required classes for the #secondary sidebar container * * @since 1.0.0 */ function bavotasan_sidebar_class() { $bavotasan_theme_options = bavotasan_theme_options(); $primary = str_replace( 'col-md-', '', $bavotasan_theme_options['primary'] ); $pull = ''; if ( is_active_sidebar( 'second-sidebar' ) ) { $class = $bavotasan_theme_options['secondary']; $pull = ( 'right' != $bavotasan_theme_options['layout'] ) ? ' col-md-pull-' . $primary : ''; } else { $end = ( 'right' == $bavotasan_theme_options['layout'] ) ? ' end' : ''; $class = 'col-md-' . ( 12 - $primary ) . $end; } echo 'class="' . esc_attr( $class ) . esc_attr( $pull ) . '"'; } /** * Default menu * * Referenced via wp_nav_menu() in header.php. * * @since 1.0.0 */ function bavotasan_default_menu( $args ) { extract( $args ); $output = wp_list_categories( array( 'title_li' => '', 'echo' => 0, 'number' => 5, 'depth' => 1, ) ); echo "<$container class='$container_class'>"; } /** * Add bootstrap classes to menu items * * @since 1.0.0 */ class Bavotasan_Page_Navigation_Walker extends Walker_Nav_Menu { function check_current( $classes ) { return preg_match( '/(current[-_])|active|dropdown/', $classes ); } function start_lvl( &$output, $depth = 0, $args = array() ) { $output .= "\n