* 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', 'blog_info_excerpt_length' );
* ...
* }
*
*
* For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
*
*
*/
/**
* 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 = 630;
/** Tell WordPress to run blog_info_setup() when the 'after_setup_theme' hook is run. */
add_action( 'after_setup_theme', 'blog_info_setup' );
if ( ! function_exists( 'blog_info_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 blog_info_setup() in a child theme, add your own blog_info_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.
* @uses add_editor_style() To style the visual editor.
* @uses load_theme_textdomain() For translation/localization support.
* @uses add_custom_image_header() To add support for a custom header.
* @uses register_default_headers() To register the default custom header images provided with the theme.
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
*
* @since Blog info 1.0
*/
function blog_info_setup() {
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style('editor-style.css?=' . time());
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
add_theme_support( "post-thumbnails" );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded
tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'blog_info_custom_background_args', array(
'default-color' => 'f3f3f3',
'default-image' => '',
) ) );
add_theme_support( 'custom-header', apply_filters( 'blog_info_custom_header_args', array(
'default-image' => '',
'default-text-color' => '000000',
'width' => 1000,
'height' => 250,
'flex-height' => true,
'wp-head-callback' => 'blog_info_header_style',
) ) );
// Make theme available for translation
// Translations can be filed in the /languages/ directory
load_theme_textdomain( 'blog-info', get_template_directory_uri() . '/languages' );
$locale = get_locale();
$locale_file = get_template_directory_uri() . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
require_once( $locale_file );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary Navigation', 'blog-info' ),
) );
// Don't support text inside the header image.
//define( 'NO_HEADER_TEXT', true );
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
register_default_headers( array(
'berries' => array(
'url' => '%s/images/headers/berries.jpg',
'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
'description' => esc_html__( 'Berries', 'blog-info' )
),
'cherryblossom' => array(
'url' => '%s/images/headers/cherryblossoms.jpg',
'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
'description' => esc_html__( 'Cherry Blossoms', 'blog-info' )
),
'concave' => array(
'url' => '%s/images/headers/concave.jpg',
'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
'description' => esc_html__( 'Concave', 'blog-info' )
),
'fern' => array(
'url' => '%s/images/headers/fern.jpg',
'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
'description' => esc_html__( 'Fern', 'blog-info' )
),
'forestfloor' => array(
'url' => '%s/images/headers/forestfloor.jpg',
'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
'description' => esc_html__( 'Forest Floor', 'blog-info' )
),
'inkwell' => array(
'url' => '%s/images/headers/inkwell.jpg',
'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
'description' => esc_html__( 'Inkwell', 'blog-info' )
),
'path' => array(
'url' => '%s/images/headers/path.jpg',
'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
'description' => esc_html__( 'Path', 'blog-info' )
),
'sunset' => array(
'url' => '%s/images/headers/sunset.jpg',
'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
'description' => esc_html__( 'Sunset', 'blog-info' )
)
) );
}
endif;
if ( ! function_exists( 'blog_info_header_style' ) ) :
/**
* Styles the header image and text displayed on the blog.
*
* @see blog_info_custom_header_setup().
*/
function blog_info_header_style() {
$header_text_color = get_header_textcolor();
// If we get this far, we have custom styles. Let's do this.
?>
' . __( 'Continue reading →', 'blog-info' ) . '';
}
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and blog_info_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 Blog info 1.0
* @return string An ellipsis
*/
function blog_info_auto_excerpt_more( $more ) {
return ' …' . blog_info_continue_reading_link();
}
add_filter( 'excerpt_more', 'blog_info_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 Blog info 1.0
* @return string Excerpt with a pretty "Continue Reading" link
*/
function blog_info_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= blog_info_continue_reading_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'blog_info_custom_excerpt_more' );
/**
* Remove inline styles printed when the gallery shortcode is used.
*
* Galleries are styled by the theme in Blog info's style.css.
*
* @since Blog info 1.0
* @return string The gallery style filter, with the styles themselves removed.
*/
function blog_info_remove_gallery_css( $css ) {
return preg_replace( "##s", '', $css );
}
add_filter( 'gallery_style', 'blog_info_remove_gallery_css' );
if ( ! function_exists( 'blog_info_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own blog_info_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* @since Blog info 1.0
*/
function blog_info_comment( $comment, $args, $depth ) {
switch ( $comment->comment_type ) :
case '' :
?>
id="li-comment-">
esc_html__( 'Primary Widget Area', 'blog-info' ),
'id' => 'primary-widget-area',
'description' => esc_html__( 'The primary widget area', 'blog-info' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
// Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
register_sidebar( array(
'name' => esc_html__( 'Secondary Widget Area', 'blog-info' ),
'id' => 'secondary-widget-area',
'description' => esc_html__( 'The secondary widget area', 'blog-info' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
// Area 3, located in the footer. Empty by default.
register_sidebar( array(
'name' => esc_html__( 'First Footer Widget Area', 'blog-info' ),
'id' => 'first-footer-widget-area',
'description' => esc_html__( 'The first footer widget area', 'blog-info' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
// Area 4, located in the footer. Empty by default.
register_sidebar( array(
'name' => esc_html__( 'Second Footer Widget Area', 'blog-info' ),
'id' => 'second-footer-widget-area',
'description' => esc_html__( 'The second footer widget area', 'blog-info' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
// Area 5, located in the footer. Empty by default.
register_sidebar( array(
'name' => esc_html__( 'Third Footer Widget Area', 'blog-info' ),
'id' => 'third-footer-widget-area',
'description' => esc_html__( 'The third footer widget area', 'blog-info' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
// Area 6, located in the footer. Empty by default.
register_sidebar( array(
'name' => esc_html__( 'Fourth Footer Widget Area', 'blog-info' ),
'id' => 'fourth-footer-widget-area',
'description' => esc_html__( 'The fourth footer widget area', 'blog-info' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
}
/** Register sidebars by running blog_info_widgets_init() on the widgets_init hook. */
add_action( 'widgets_init', 'blog_info_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.
*
* @since Blog info 1.0
*/
function blog_info_remove_recent_comments_style() {
global $wp_widget_factory;
remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
}
add_action( 'widgets_init', 'blog_info_remove_recent_comments_style' );
if ( ! function_exists( 'blog_info_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post—date/time and author.
*
* @since Blog info 1.0
*/
function blog_info_posted_on() {
printf( __( 'Posted on %2$s by %3$s', 'blog-info' ),
'meta-prep meta-prep-author',
sprintf( '%3$s',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
get_the_date()
),
sprintf( '%3$s',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
sprintf( esc_attr__( 'View all posts by %s', 'blog-info' ), get_the_author() ),
get_the_author()
)
);
}
endif;
if ( ! function_exists( 'blog_info_posted_in' ) ) :
/**
* Prints HTML with meta information for the current post (category, tags and permalink).
*
* @since Blog info 1.0
*/
function blog_info_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
$posted_in = esc_html__( 'This entry was posted in %1$s and tagged %2$s. Bookmark the permalink.', 'blog-info' );
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = esc_html__( 'This entry was posted in %1$s. Bookmark the permalink.', 'blog-info' );
} else {
$posted_in = esc_html__( 'Bookmark the permalink.', 'blog-info' );
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( esc_html__( ', ', 'blog-info' ) ),
$tag_list,
esc_url( get_permalink() ),
the_title_attribute( 'echo=0' )
);
}
endif;
/**
* By default, if a widget doesn't have a title, Wordpress doesn't show the widget header
* To fix this, this function adds a space if no title is set.
*
*
*/
function blog_info_fix_widget_title ($title){
if (!$title) $title = ' ';
return $title;
}
add_filter('widget_title','blog_info_fix_widget_title');
/**
* Enqueue scripts and styles.
*/
function blog_info_scripts() {
wp_enqueue_style( 'blog_info-style', get_stylesheet_uri() );
$fonts_url='http://fonts.googleapis.com/css?family=Arimo|Armata';
if(!empty($fonts_url)){
wp_enqueue_style('blog_info-font-name',esc_url_raw($fonts_url),array(),null);
}
}
add_action( 'wp_enqueue_scripts', 'blog_info_scripts' );