* add_action( 'after_setup_theme', 'my_child_theme_setup' ); * function my_child_theme_setup() { * // We are providing our own filter for excerpt_length (or using the unfiltered value) * remove_filter( 'excerpt_length', 'vanillabloom_excerpt_length' ); * ... * } * * * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API. * * @package WordPress * @subpackage Vanilla Bloom * @since Vanilla Bloom 1.0 */ /** * Set the content width based on the theme's design and stylesheet. * * Used to set the width of images and content. Should be equal to the width the theme * is designed for, generally via the style.css stylesheet. */ if ( ! isset( $content_width ) ) $content_width = 730; /** Tell WordPress to run vanillabloom_setup() when the 'after_setup_theme' hook is run. */ add_action( 'after_setup_theme', 'vanillabloom_setup' ); if ( ! function_exists( 'vanillabloom_setup' ) ): /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which runs * before the init hook. The init hook is too late for some features, such as indicating * support post thumbnails. * * To override vanillabloom_setup() in a child theme, add your own vanillabloom_setup to your child theme's * functions.php file. * * @uses add_theme_support() To add support for post thumbnails and automatic feed links. * @uses register_nav_menus() To add support for navigation menus. * * @since Vanilla Bloom 1.0 */ function vanillabloom_setup() { // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); // This theme uses post thumbnails add_theme_support( 'post-thumbnails' ); // Add default posts and comments RSS feed links to head add_theme_support( 'automatic-feed-links' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => __( 'Primary Navigation', 'vanillabloom' ), ) ); } endif; /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. * * To override this in a child theme, remove the filter and optionally add * your own function tied to the wp_page_menu_args filter hook. * * @since Vanilla Bloom 1.0 */ function vanillabloom_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'vanillabloom_page_menu_args' ); /** * Sets the post excerpt length to 40 characters. * * To override this length in a child theme, remove the filter and add your own * function tied to the excerpt_length filter hook. * * @since Vanilla Bloom 1.0 * @return int */ function vanillabloom_excerpt_length( $length ) { return 50; } add_filter( 'excerpt_length', 'vanillabloom_excerpt_length' ); /** * Returns a "Continue Reading" link for excerpts * * @since Vanilla Bloom 1.0 * @return string "Continue Reading" link */ function vanillabloom_continue_reading_link() { return ' ' . __( 'Continue reading ', 'vanillabloom' ) . ''; } /** * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and vanillabloom_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. * * @since Vanilla Bloom 1.0 * @return string An ellipsis */ function vanillabloom_auto_excerpt_more( $more ) { return '…'; } add_filter( 'excerpt_more', 'vanillabloom_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. * * @since Vanilla Bloom 1.0 * @return string Excerpt with a pretty "Continue Reading" link */ function vanillabloom_custom_excerpt_more( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output .= vanillabloom_continue_reading_link(); } return $output; } add_filter( 'get_the_excerpt', 'vanillabloom_custom_excerpt_more' ); if ( ! function_exists( 'vanillabloom_comment' ) ) : /** * Template for comments and pingbacks. * * To override this walker in a child theme without modifying the comments template * simply create your own vanillabloom_comment(), and that function will be used instead. * * Used as a callback by wp_list_comments() for displaying the comments. * * @since Vanilla Bloom 1.0 */ function vanillabloom_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case '' : ?>
  • id="li-comment-">
    says:', 'vanillabloom' ), sprintf( '%s', get_comment_author_link() ) ); ?>
    comment_approved == '0' ) : ?>
    $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  • __( 'Primary Widget Area', 'vanillabloom' ), 'id' => 'primary-widget-area', 'description' => __( 'The primary widget area', 'vanillabloom' ), 'before_widget' => '
    ', 'after_widget' => '
     ', 'before_title' => '

    ', 'after_title' => '

    ', ) ); } /** Register sidebars by running vanillabloom_widgets_init() on the widgets_init hook. */ add_action( 'widgets_init', 'vanillabloom_widgets_init' ); /** * Removes the default styles that are packaged with the Recent Comments widget. * * To override this in a child theme, remove the filter and optionally add your own * function tied to the widgets_init action hook. * * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1 * to remove the default style. * * @since Vanilla Bloom 1.0 */ function vanillabloom_remove_recent_comments_style() { add_filter( 'show_recent_comments_widget_style', '__return_false' ); } add_action( 'widgets_init', 'vanillabloom_remove_recent_comments_style' ); /** * Retrieve category parents for breadcrumb, copied and adapted from WP source. * * @since Vanilla Bloom 1.0 * * by VanillaBloom * * * @param int $id Category ID. * @param bool $link Optional, default is false. Whether to format with link. * @param string $separator Optional, default is '/'. How to separate categories. * @param bool $nicename Optional, default is false. Whether to use nice name for display. * @param array $visited Optional. Already linked to categories to prevent duplicates. * @return string */ function vanillabloom_get_category_parents_li( $id, $link = false, $separator = '/', $paged = '0', $page = '0', $nicename = false, $visited = array() ) { $chain = ''; $parent = &get_category( $id ); if ( is_wp_error( $parent ) ) return $parent; if ( $nicename ) $name = $parent->slug; else $name = $parent->name; if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) { $visited[] = $parent->parent; $chain .= vanillabloom_get_category_parents_li( $parent->parent, $link, $separator, $nicename, $visited ); } if ( $link ){ if ( in_array( $id, $visited ) ) { $chain .= '
  • '.$name.'
  • ' . $separator; } elseif ( $paged >= 2 || $page >= 2 ){ $chain .= '
  • '.$name.'
  • '.$separator.'
  • Page '.$paged.'
  • '; } else { $chain .= '
  • '.$name.'
  • ' . $separator; } } else { $chain .= $name.$separator; } return $chain; } /** * Retrieve single post parent categories for breadcrumb, copied and adapted from WP source. * * @since Vanilla Bloom 1.0 * * by VanillaBloom * * @param int $id Category ID. * @param bool $link Optional, default is false. Whether to format with link. * @param string $separator Optional, default is '/'. How to separate categories. * @param bool $nicename Optional, default is false. Whether to use nice name for display. * @param array $visited Optional. Already linked to categories to prevent duplicates. * @return string */ function vanillabloom_get_category_parents_li_single( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) { $chain = ''; $parent = &get_category( $id ); if ( is_wp_error( $parent ) ) return $parent; if ( $nicename ) $name = $parent->slug; else $name = $parent->name; if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) { $visited[] = $parent->parent; $chain .= vanillabloom_get_category_parents_li( $parent->parent, $link, $separator, $nicename, $visited ); } if ( $link ) $chain .= '
  • '.$name.'
  • ' . $separator; else $chain .= $name.$separator; return $chain; } /** * Retrieve page parents for breadcrumb. * * @since Vanilla Bloom 1.0 * * by VanillaBloom * * @param int $id Category ID. * * @return string */ function vanillabloom_get_page_parents_li( $id ) { $chain = ''; $parent_ids = get_ancestors($id, 'page'); $parent_ids = array_reverse($parent_ids); foreach ($parent_ids as $ids){ $chain .= '
  • '.get_the_title($ids).'
  • ';} return $chain; } /** * Adds class to default menu. * * @since Vanilla Bloom 1.0 * * by VanillaBloom */ function vanillabloom_wp_page_menu_args( $args = '' ) { $args['menu_class'] = 'menu menu-navigation'; return $args; } // function add_filter( 'wp_page_menu_args', 'vanillabloom_wp_page_menu_args' ); /** * Removes menu_class and menu_id from custom menu. * * @since Vanilla Bloom 1.0 * * by VanillaBloom */ function vanillabloom_wp_nav_menu_args( $args = '' ) { $args['menu_class'] = false; $args['menu_id'] = false; return $args; } // function add_filter( 'wp_nav_menu_args', 'vanillabloom_wp_nav_menu_args' ); /** * Categories widget class replacemant. * Replaces default WP_Widget_Categories with Vanilla Bloom's version * @since Vanilla Bloom 1.0 * by VanillaBloom */ function vanillabloom_categories_widgets_init() { unregister_widget('WP_Widget_Categories'); } add_action( 'widgets_init', 'vanillabloom_categories_widgets_init' ); class Vanilla_Bloom_Widget_Categories extends WP_Widget { function Vanilla_Bloom_Widget_Categories() { $widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories", 'vanillabloom' ) ); $this->WP_Widget('categories', __('Categories', 'vanillabloom'), $widget_ops); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories', 'vanillabloom' ) : $instance['title'], $instance, $this->id_base); $c = $instance['count'] ? '1' : '0'; $h = $instance['hierarchical'] ? '1' : '1'; $d = $instance['dropdown'] ? '1' : '0'; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); if ( $d ) { $cat_args['show_option_none'] = __('Select Category', 'vanillabloom'); wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)); ?> '') ); $title = esc_attr( $instance['title'] ); $count = isset($instance['count']) ? (bool) $instance['count'] :true; $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; $dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false; ?>

    />
    '

    ' . ' ' . ( $req ? '*' : '' ) . '

    ', 'email' => '

    ' . ( $req ? '*' : '' ) . '

    ', 'url' => '

    ' . '

    ', ); apply_filters( 'comment_form_default_fields', $field ); /** * Categories widget class replacemant. * Replaces default WP_Widget_Categories with Vanilla Bloom's version * @since Vanilla Bloom 1.0 * by VanillaBloom */ function vanillabloom_search_widgets_init() { unregister_widget('WP_Widget_Search'); } add_action( 'widgets_init', 'vanillabloom_search_widgets_init' ); remove_action( 'wp_head', 'rsd_link'); remove_action( 'wp_head', 'wlwmanifest_link'); remove_action( 'wp_head', 'wp_generator'); remove_action( 'wp_head', 'index_rel_link'); remove_action( 'wp_head', 'wp_shortlink_wp_head'); remove_action( 'wp_head', 'feed_links'); ?>