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 /** * Prepare the content width * * @since 1.0.0 */ $bavotasan_theme_options = bavotasan_theme_options(); $array_width = array( '' => 1200, 'w960' => 960, 'w640' => 640, 'w320' => 320, 'wfull' => 1200 ); $array_content = array( 'c2' => .17, 'c3' => .25, 'c4' => .34, 'c5' => .42, 'c6' => .5, 'c7' => .58, 'c8' => .66, 'c9' => .75, 'c10' => .83, 'c12' => 1 ); $bavotasan_main_content = $array_content[$bavotasan_theme_options['primary']] * $array_width[$bavotasan_theme_options['width']] - 40; if ( ! isset( $content_width ) ) $content_width = $bavotasan_main_content; 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( 'tonic', 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(); // This theme uses wp_nav_menu() in one location. register_nav_menu( 'primary', __( 'Primary Menu', 'tonic' ) ); // 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 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' => 'fff', 'flex-height' => true, 'flex-width' => true, 'random-default' => true, 'width' => apply_filters( 'bavotasan_header_image_width', 1500 ), 'height' => apply_filters( 'bavotasan_header_image_height', 550 ), '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', 'tonic' ) ), ) ); // Add support for custom backgrounds add_theme_support( 'custom-background' ); // Add title tag support add_theme_support( 'title-tag' ); // Add HTML5 elements add_theme_support( 'html5', array( 'comment-list', 'search-form', 'comment-form', ) ); // 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(); $text_color = get_header_textcolor(); $styles = ( 'blank' == $text_color ) ? 'position:absolute !important;clip:rect(1px 1px 1px 1px);clip:rect(1px, 1px, 1px, 1px)' : 'color:#' . $text_color . ' !important'; ?> add_node( array( 'id' => 'bavotasan_toolbar', 'title' => BAVOTASAN_THEME_NAME, 'href' => esc_url( admin_url( 'customize.php' ) ) ) ); } if ( ! function_exists( 'bavotasan_admin_header_style' ) ) : /** * Styles the header image displayed on the Appearance > 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', 'tonic' ), 'id' => 'sidebar', 'description' => __( 'This is the first sidebar widgetized area. All defaults widgets work great here.', 'tonic' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Home Page Top Area', 'tonic' ), 'id' => 'home-page-top-area', 'description' => __( 'Widgetized area on the home page directly below the navigation menu. Add at least one widget to make it appear.', 'tonic' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } if ( !function_exists( 'bavotasan_pagination' ) ) : /** * Add pagination * * @uses paginate_links() * @uses add_query_arg() * * @since 1.0.0 */ function bavotasan_pagination() { global $wp_query; $current = max( 1, get_query_var('paged') ); $big = 999999999; // need an unlikely integer $pagination_return = paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => $current, 'total' => $wp_query->max_num_pages, 'next_text' => '»', 'prev_text' => '«' ) ); if ( ! empty( $pagination_return ) ) { echo ''; } } endif; // bavotasan_pagination if ( ! function_exists( 'bavotasan_comment' ) ) : /** * Callback function for comments * * Referenced via wp_list_comments() in comments.php. * * @uses get_avatar() * @uses get_comment_author_link() * @uses get_comment_date() * @uses get_comment_time() * @uses edit_comment_link() * @uses comment_text() * @uses comments_open() * @uses comment_reply_link() * * @since 1.0.0 */ function bavotasan_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case '' : ?>
  • >
    comment_approved ) { echo '' . __( 'Your comment is awaiting moderation.', 'tonic' ) . ''; } ?>
    comment_type ) { ?>
    $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  • ' . __( 'Read more →' , 'tonic' ) . '

    '; } 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 ) { return 55; } endif; // bavotasan_excerpt_length /** * Create the required attributes for the #primary container * * @since 1.0.0 */ function bavotasan_primary_attr() { $bavotasan_theme_options = bavotasan_theme_options(); $layout = $bavotasan_theme_options['layout']; $column = $bavotasan_theme_options['primary']; $class = ( 6 == $layout ) ? $column . ' centered' : $column; $class = ( 1 == $layout ) ? $class . ' fr"' : $class; echo 'class="' . $class . '"'; } /** * Create the required classes for the #secondary sidebar container * * @since 1.0.0 */ function bavotasan_sidebar_class() { $bavotasan_theme_options = bavotasan_theme_options(); $class = 'c' . ( 12 - str_replace( 'c', '', $bavotasan_theme_options['primary'] ) ); echo 'class="' . $class . '"'; } add_filter( 'body_class','bavotasan_custom_body_class' ); /** * Adds class if first sidebar located on left side * * @since Gridiculous Pro 1.0.7 */ function bavotasan_custom_body_class( $classes ) { $bavotasan_theme_options = bavotasan_theme_options(); if ( 1 == $bavotasan_theme_options['layout'] ) { $classes[] = 'left-sidebar'; } $classes[] = 'basic'; return $classes; } add_filter( 'next_post_link', 'bavotasan_add_class' ); add_filter( 'previous_post_link', 'bavotasan_add_class' ); add_filter( 'next_image_link', 'bavotasan_add_class' ); add_filter( 'previous_image_link', 'bavotasan_add_class' ); /** * Add 'btn' class to previous and next post links * * This function is attached to the 'next_post_link' and 'previous_post_link' filter hook. * * @param string $format * * @return Modified string * * @since 1.0.0 */ function bavotasan_add_class( $format ){ return str_replace( 'href=', 'class="btn" href=', $format ); } /** * 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 class to sub-menu parent items * * @author Kirk Wight * @since 1.0.0 */ class Bavotasan_Page_Navigation_Walker extends Walker_Nav_Menu { function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { $id_field = $this->db_fields['id']; if ( !empty( $children_elements[ $element->$id_field ] ) ) $element->classes[] = 'sub-menu-parent'; Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } } add_filter( 'wp_nav_menu_args', 'bavotasan_nav_menu_args' ); /** * Set our new walker only if a menu is assigned and a child theme hasn't modified it to one level deep * * This function is attached to the 'wp_nav_menu_args' filter hook. * * @author Kirk Wight * @since 1.0.0 */ function bavotasan_nav_menu_args( $args ) { if ( 1 !== $args[ 'depth' ] && has_nav_menu( 'primary' ) && 'primary' == $args[ 'theme_location' ] ) $args[ 'walker' ] = new Bavotasan_Page_Navigation_Walker; return $args; } /** * Create the jumbo headline section on the home page * * @since 1.0.0 */ function bavotasan_jumbotron() { $bavotasan_theme_options = bavotasan_theme_options(); if ( ! empty( $bavotasan_theme_options['jumbo_headline_title'] ) ) { ?>

    'ids', 'numberposts' => 999, 'order' => 'ASC', 'orderby' => 'menu_order', 'post_mime_type' => 'image', 'post_parent' => get_the_ID(), 'post_type' => 'attachment', ) ); } return $images; }