__( 'Main Navigation', 'the-bootstrap' ), 'header-menu' => __( 'Header Menu', 'the-bootstrap' ), 'footer-menu' => __( 'Footer Menu', 'the-bootstrap' ) ) ); } // the_bootstrap_setup endif; add_action( 'after_setup_theme', 'the_bootstrap_setup' ); /** * Register the sidebars. * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function the_bootstrap_widgets_init() { register_sidebar( array( 'name' => __( 'Main Sidebar', 'the-bootstrap' ), 'id' => 'main', 'before_widget' => '", 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Image Sidebar', 'the-bootstrap' ), 'description' => __( 'Shown on image attchment pages.', 'the-bootstrap' ), 'id' => 'image', 'before_widget' => '", 'before_title' => '

', 'after_title' => '

', ) ); include_once( 'inc/the-bootstrap-image-meta-widget.php' ); register_widget( 'The_Bootstrap_Image_Meta_Widget' ); } add_action( 'widgets_init', 'the_bootstrap_widgets_init' ); /** * Registration of theme scripts and styles * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function the_bootstrap_register_scripts_styles() { if ( ! is_admin() ) { $theme_data = get_theme_data( get_template_directory() . '/style.css' ); $suffix = ( defined('SCRIPT_DEBUG') AND SCRIPT_DEBUG ) ? '' : '.min'; /** * Scripts */ wp_register_script( 'tw-bootstrap', get_template_directory_uri() . "/js/bootstrap{$suffix}.js", array('jquery'), '2.0.2', true ); wp_register_script( 'the-bootstrap', get_template_directory_uri() . "/js/the-bootstrap{$suffix}.js", array('jquery'), $theme_data['Version'], true ); /** * Styles */ wp_register_style( 'tw-bootstrap', get_template_directory_uri() . "/css/bootstrap{$suffix}.css", array(), '2.0.2' ); wp_register_style( 'the-bootstrap', get_template_directory_uri() . "/style{$suffix}.css", array('tw-bootstrap'), $theme_data['Version'] ); } } add_action( 'init', 'the_bootstrap_register_scripts_styles' ); /** * Properly enqueue frontend scripts * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function the_bootstrap_print_scripts() { wp_enqueue_script( 'tw-bootstrap' ); wp_enqueue_script( 'the-bootstrap' ); if ( is_singular() AND comments_open() AND get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'the_bootstrap_print_scripts' ); /** * Properly enqueue frontend styles * * Since 'tw-bootstrap' was registered as a dependency, it'll get enqueued * automatically * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function the_bootstrap_print_styles() { wp_enqueue_style( 'the-bootstrap' ); } add_action( 'wp_enqueue_scripts', 'the_bootstrap_print_styles' ); /** * Display navigation to next/previous pages when applicable * * To be honest - I'm pretty proud of this function. Through a lot of trial and * error, I was able to user a core WordPress function (paginate_links()) and * adjust it in a way, that the end result is a legitimate pagination. * A pagination many developers buy (code) expensively with Plugins like * WP Pagenavi. No need! WordPress has it all! * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function the_bootstrap_content_nav() { global $wp_query; $paged = ( get_query_var( 'paged' ) ) ? intval( get_query_var( 'paged' ) ) : 1; $pagenum_link = get_pagenum_link(); $url_parts = parse_url( $pagenum_link ); $format = ( get_option('permalink_structure') ) ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; if ( isset($url_parts['query']) ) { $pagenum_link = "{$url_parts['scheme']}://{$url_parts['host']}{$url_parts['path']}%_%?{$url_parts['query']}"; } else { $pagenum_link .= '%_%'; } $links = paginate_links( array( 'base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'list' ) ); if ( $links ) { echo ""; } } if ( ! function_exists( 'the_bootstrap_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author, * comment and edit link * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @return void */ function the_bootstrap_posted_on() { printf( __( 'Posted on by ', 'the-bootstrap' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'the-bootstrap' ), get_the_author() ) ), get_the_author() ); if ( comments_open() AND ! post_password_required() ) { ?> | ' . __( 'Leave a reply', 'the-bootstrap' ) . '', __( '1 Reply', 'the-bootstrap' ), __( '% Replies', 'the-bootstrap' ) ); ?>  ', '' ); } endif; if ( ! function_exists( 'the_bootstrap_link_pages' ) ) : /** * Displays page links for paginated posts * * It's basically the wp_link_pages() function, altered to fit to the Bootstrap * markup needs for paginations (unordered list). * @see wp_link_pages() * * @author Konstantin Obenland * @since 1.1.0 - 09.03.2012 * * @param array $args * * @return string */ function the_bootstrap_link_pages( $args = array() ) { wp_link_pages( array( 'echo' => 0 )); $defaults = array( 'next_or_number' => 'number', 'nextpagelink' => __('Next page', 'the-bootstrap'), 'previouspagelink' => __('Previous page', 'the-bootstrap'), 'pagelink' => '%', 'echo' => true ); $r = wp_parse_args( $args, $defaults ); $r = apply_filters( 'the_bootstrap_link_pages_args', $r ); extract( $r, EXTR_SKIP ); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ( $multipage ) { if ( 'number' == $next_or_number ) { $output .= ''; } else { if ( $more ) { $output .= ''; } } } if ( $echo ) echo $output; return $output; } endif; if ( ! function_exists( 'the_bootstrap_credits' ) ) : /** * Prints HTML with meta information for the current post-date/time and author, * comment and edit link * * @author Konstantin Obenland * @since 1.2.2 - 07.04.2012 * * @return void */ function the_bootstrap_credits() { printf( __('© %1$s %3$s, all rights reserved.', 'the-bootstrap'), date( 'Y' ), home_url( '/' ), get_bloginfo( 'name' ) ); } endif; /** * Returns the blogname if no title was set. * * @author Konstantin Obenland * @since 1.1.0 - 18.03.2012 * * @param string $title * * @return string */ function the_bootstrap_wp_title( $title, $sep ) { $title .= get_bloginfo( 'name' ); if ( is_front_page() ) { $title .= " {$sep} " . get_bloginfo( 'description' ); } return $title; } add_filter( 'wp_title', 'the_bootstrap_wp_title', 1, 2 ); /** * Returns a "Continue Reading" link for excerpts * * @author WordPress.org * @since 1.0.0 - 05.02.2012 * * @param string $more * * @return string */ function the_bootstrap_continue_reading_link() { return ' ' . __( 'Continue reading ', 'the-bootstrap' ) . ''; } /** * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and the_bootstrap_continue_reading_link(). * * To override this in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. * * @author WordPress.org * @since 1.0.0 - 05.02.2012 * * @param string $more * * @return string */ function the_bootstrap_auto_excerpt_more( $more ) { return '…' . the_bootstrap_continue_reading_link(); } add_filter( 'excerpt_more', 'the_bootstrap_auto_excerpt_more' ); /** * Adds a pretty "Continue Reading" link to custom post excerpts. * * To override this link in a child theme, remove the filter and add your own * function tied to the get_the_excerpt filter hook. * * @author WordPress.org * @since 1.0.0 - 05.02.2012 * * @param string $output * * @return string */ function the_bootstrap_custom_excerpt_more( $output ) { if ( has_excerpt() AND ! is_attachment() ) { $output .= the_bootstrap_continue_reading_link(); } return $output; } add_filter( 'get_the_excerpt', 'the_bootstrap_custom_excerpt_more' ); /** * Get the wp_nav_menu() fallback, wp_page_menu(), to show a home link. * * @author WordPress.org * @since 1.0.0 - 05.02.2012 * * @param array $args * * @return array */ function the_bootstrap_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'the_bootstrap_page_menu_args' ); /** * Filter in a link to a content ID attribute for the next/previous image links on image attachment pages * * @author Automattic * @since 1.0.0 - 05.02.2012 * * @param string $url * @param int $id * * @return string */ function the_bootstrap_enhanced_image_navigation( $url, $id ) { if ( ! is_attachment() AND ! wp_attachment_is_image( $id ) ) return $url; $image = get_post( $id ); if ( $image->post_parent AND $image->post_parent != $id ) $url .= '#primary'; return $url; } add_filter( 'attachment_link', 'the_bootstrap_enhanced_image_navigation', 10, 2 ); if ( ! function_exists( 'the_bootstrap_comment' ) ) : /** * Template for comments and pingbacks. * * To override this walker in a child theme without modifying the comments template * simply create your own the_bootstrap_comment(), and that function will be used instead. * * Used as a callback by wp_list_comments() for displaying the comments. * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param object $comment Comment data object. * @param array $args * @param int $depth Depth of comment in reference to parents. * * @return void */ function the_bootstrap_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : ?>
  •  ', '' ); ?>

  • id="li-comment-">
    ">
    said on %2$s:', 'the-bootstrap' ), sprintf( '%s', get_comment_author_link() ), sprintf( '', esc_url( get_comment_link( $comment->comment_ID ) ), get_comment_time( 'c' ), /* translators: 1: date, 2: time */ sprintf( __( '%1$s at %2$s', 'the-bootstrap' ), get_comment_date(), get_comment_time() ) ) ); edit_comment_link( __( 'Edit', 'the-bootstrap' ), ' ', '' ); ?>
    comment_approved ) : ?>
    __( 'Reply ', 'the-bootstrap' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    '; } add_action( 'comment_form_top', 'the_bootstrap_comment_form_top' ); /** * Adds markup to the comment form which is needed to make it work with Bootstrap * needs * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $html * * @return string */ function the_bootstrap_comment_form() { echo ''; } add_action( 'comment_form', 'the_bootstrap_comment_form' ); /** * Custom author form field for the comments form * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $html * * @return string */ function the_bootstrap_comment_form_field_author( $html ) { $commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); return '
    ' . ( $req ? '

    ' . __('required', 'the-bootstrap') . '

    ' : '' ) . '
    '; } add_filter( 'comment_form_field_author', 'the_bootstrap_comment_form_field_author'); /** * Custom HTML5 email form field for the comments form * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $html * * @return string */ function the_bootstrap_comment_form_field_email( $html ) { $commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); return '

    ' . ( $req ? '' . __('required', 'the-bootstrap') . ', ' : '' ) . __( 'will not be published', 'the-bootstrap' ) . '

    '; } add_filter( 'comment_form_field_email', 'the_bootstrap_comment_form_field_email'); /** * Custom HTML5 url form field for the comments form * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $html * * @return string */ function the_bootstrap_comment_form_field_url( $html ) { $commenter = wp_get_current_commenter(); return '
    '; } add_filter( 'comment_form_field_url', 'the_bootstrap_comment_form_field_url'); /** * Adjusts an attechment link to hold the class of 'thumbnail' and make it look * pretty * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $link * @param int $id Post ID. * @param string $size Default is 'thumbnail'. Size of image, either array or string. * @param bool $permalink Default is false. Whether to add permalink to image. * @param bool $icon Default is false. Whether to include icon. * @param string $text Default is false. If string, then will be link text. * * @return string */ function the_bootstrap_get_attachment_link( $link, $id, $size, $permalink, $icon, $text) { if ( ! $text ) { $link = str_replace( ' 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'figure', 'icontag' => 'div', 'captiontag' => 'figcaption', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '' ), $attr)); $id = intval($id); if ( 'RAND' == $order ) $orderby = 'none'; if ( !empty($include) ) { $include = preg_replace( '/[^0-9,]+/', '', $include ); $_attachments = get_posts( array( 'include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); $attachments = array(); foreach ( $_attachments as $key => $val ) { $attachments[$val->ID] = $_attachments[$key]; } } elseif ( !empty($exclude) ) { $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); } else { $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); } if ( empty($attachments) ) return ''; if ( is_feed() ) { $output = "\n"; foreach ( $attachments as $att_id => $attachment ) $output .= wp_get_attachment_link( $att_id, $size, true ) . "\n"; return $output; } $itemtag = tag_escape( $itemtag ); $captiontag = tag_escape( $captiontag ); $columns = intval( $columns ); $itemwidth = ($columns > 0) ? floor( 100/$columns ) : 100; $float = (is_rtl())? 'right' : 'left'; $selector = "gallery-{$instance}"; $size_class = sanitize_html_class( $size ); $output = "\n"; return $output; } add_filter( 'post_gallery', 'the_bootstrap_post_gallery', 10, 2 ); /** * HTML 5 caption for pictures * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $empty * @param array $attr * @param string $content * * @return string */ function the_bootstrap_img_caption_shortcode( $empty, $attr, $content ) { extract( shortcode_atts( array( 'id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '' ), $attr) ); if ( 1 > (int) $width OR empty($caption) ) { return $content; } if ( $id ) { $id = 'id="' . $id . '" '; } return '
    ' . do_shortcode( $content ) . '
    ' . $caption . '
    '; } add_filter( 'img_caption_shortcode', 'the_bootstrap_img_caption_shortcode', 10, 3 ); /** * Returns a password form which dispalys nicely with Bootstrap * * @author Konstantin Obenland * @since 1.0.0 - 05.02.2012 * * @param string $form * * @return string The Bootstrap password form */ function the_bootstrap_the_password_form( $form ) { return '
    '. __( 'This post is password protected. To view it please enter your password below:', 'the-bootstrap' ) . '
    '; } add_filter( 'the_password_form', 'the_bootstrap_the_password_form' ); /* End of file functions.php */ /* Location: ./wp-content/themes/the-bootstrap/functions.php */