for posts and comments.
*/
add_theme_support( 'automatic-feed-links' );
/**
* 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' );
/**
* Adds support for post thumbnails
*/
add_theme_support( 'post-thumbnails' );
/*
* Switches default core markup for search form to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
) );
/**
* Set theme image sizes
*/
add_image_size( 'baskerville-post-image', 1400, 9999 );
add_image_size( 'baskerville-post-thumbnail', 600, 9999 );
add_image_size( 'baskerville-site-logo', 300, 300, 9999 );
/**
* Add support for post formats
*/
add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) );
/**
* Add support for custom backgrounds
*/
add_theme_support( 'custom-background', apply_filters( 'baskerville_custom_background_args', array(
'default-color' => 'f1f1f1',
'default-image' => '',
) ) );
/**
* Add support for styles in WYSIWYG editor
*/
add_editor_style( array( 'editor-style.css', baskerville_fonts_url() ) );
/**
* Add navigation menu
*/
register_nav_menu( 'primary', 'Primary Menu' );
/**
* Make the theme translation-ready
*/
load_theme_textdomain( 'baskerville', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'baskerville_setup' );
endif;
if ( ! function_exists( 'baskerville_fonts_url' ) ) :
/**
* Define Google Fonts
*/
function baskerville_fonts_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Roboto, translate this to 'off'. Do not translate
* into your own language.
*/
$roboto = esc_html_x( 'on', 'Roboto font: on or off', 'baskerville' );
/* Translators: If there are characters in your language that are not
* supported by Roboto Slab, translate this to 'off'. Do not translate
* into your own language.
*/
$robotoslab = esc_html_x( 'on', 'Roboto Slab font: on or off', 'baskerville' );
/* Translators: If there are characters in your language that are not
* supported by Pacifico, translate this to 'off'. Do not translate
* into your own language.
*/
$pacifico = esc_html_x( 'on', 'Pacifico font: on or off', 'baskerville' );
if ( 'off' !== $roboto || 'off' !== $robotoslab || 'off' !== $pacifico ) {
$font_families = array();
if ( 'off' !== $robotoslab ) {
$font_families[] = 'Roboto Slab:400,700';
}
if ( 'off' !== $roboto ) {
$font_families[] = 'Roboto:400,400italic,700,700italic,300';
}
if ( 'off' !== $pacifico ) {
$font_families[] = 'Pacifico:400';
}
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
return $fonts_url;
}
endif;
if ( ! function_exists( 'baskerville_scripts' ) ) :
/**
* Enqueue scripts and styles.
*/
function baskerville_scripts() {
wp_enqueue_style( 'baskerville-style', get_stylesheet_uri() );
wp_enqueue_style( 'baskerville-fonts', baskerville_fonts_url(), array(), null );
wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/fontawesome/font-awesome.css', array(), '4.3.0' );
wp_enqueue_script( 'baskerville-imagesloaded', get_template_directory_uri() . '/js/imagesloaded.pkgd.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'baskerville-flexslider', get_template_directory_uri() . '/js/flexslider.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'baskerville-global', get_template_directory_uri() . '/js/global.js', array( 'jquery', 'masonry' ), '', true );
if ( is_singular() ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'baskerville_scripts' );
endif;
if ( ! function_exists( 'baskerville_sidebar_reg' ) ) :
/**
* Add Widget Areas to footer and sidebar
*/
function baskerville_sidebar_reg() {
register_sidebar( array(
'name' => esc_html__( 'Footer A', 'baskerville' ),
'id' => 'footer-a',
'description' => esc_html__( 'Widgets in this area will be shown in the left column in the footer.', 'baskerville' ),
'before_title' => '',
'before_widget' => '',
));
register_sidebar( array(
'name' => esc_html__( 'Footer B', 'baskerville' ),
'id' => 'footer-b',
'description' => esc_html__( 'Widgets in this area will be shown in the middle column in the footer.', 'baskerville' ),
'before_title' => '',
'before_widget' => '',
));
register_sidebar( array(
'name' => esc_html__( 'Footer C', 'baskerville' ),
'id' => 'footer-c',
'description' => esc_html__( 'Widgets in this area will be shown in the right column in the footer.', 'baskerville' ),
'before_title' => '',
'before_widget' => '',
));
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'baskerville' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Widgets in this area will be shown in the sidebar.', 'baskerville' ),
'before_title' => '',
'before_widget' => '',
));
}
add_action( 'widgets_init', 'baskerville_sidebar_reg' );
endif;
if ( ! function_exists( 'baskerville_posts_link_attributes_1' ) ) :
/**
* Add classes to next_posts_link and previous_posts_link
*/
function baskerville_posts_link_attributes_1() {
return 'class="post-nav-older fleft"';
}
add_filter( 'next_posts_link_attributes', 'baskerville_posts_link_attributes_1' );
endif;
if ( ! function_exists( 'baskerville_posts_link_attributes_2' ) ) :
function baskerville_posts_link_attributes_2() {
return 'class="post-nav-newer fright"';
}
add_filter( 'previous_posts_link_attributes', 'baskerville_posts_link_attributes_2' );
endif;
if ( ! function_exists( 'baskerville_body_classes' ) ) :
/**
* Adding classes to body tag under certain circumstances
*/
function baskerville_body_classes( $classes ) {
global $post;
// Add class to body if the post/page has a featured image
if ( isset( $post ) && has_post_thumbnail() ) {
$classes[] = 'has-featured-image';
} else {
$classes[] = 'no-featured-image';
}
// Add class to body if it's a single page
if ( is_page() || is_404() || is_attachment() ) {
$classes[] = 'single single-post';
}
return $classes;
}
add_action( 'body_class', 'baskerville_body_classes' );
endif;
if ( ! function_exists( 'baskerville_clearfix_class' ) ) :
/**
* Add class to posts for clearfix
*/
function baskerville_clearfix_class( $classes ) {
$classes[] = 'clear';
return $classes;
}
add_filter( 'post_class', 'baskerville_clearfix_class', 10, 3 );
endif;
if ( ! function_exists( 'baskerville_custom_excerpt_length' ) ) :
/**
* Change length of excerpts
*/
function baskerville_custom_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'baskerville_custom_excerpt_length', 999 );
endif;
if ( ! function_exists( 'baskerville_new_excerpt_more' ) ) :
/**
* Add more link text to excerpt
*/
function baskerville_new_excerpt_more( $more ) {
return '... ' . esc_html__( 'Continue Reading', 'baskerville' ) . ' →';
}
add_filter( 'excerpt_more', 'baskerville_new_excerpt_more' );
endif;
if ( ! function_exists( 'baskerville_url_to_domain' ) ) :
/**
* Get domain name from URL
*/
function baskerville_url_to_domain( $url ) {
$host = parse_url( $url, PHP_URL_HOST );
if ( ! $host ) {
$host = $url;
}
if ( 'www.' == substr( $host, 0, 4 ) ) {
$host = substr( $host, 0 );
}
return $host;
}
endif;
/**
* Return the post URL.
*
* @uses get_url_in_content() to get the URL in the post meta (if it exists) or
* the first link found in the post content.
*
* Falls back to the post permalink if no URL is found in the post.
*
* Borrowed from Twenty Thirteen.
*/
function baskerville_get_link_url() {
$content = get_the_content();
$has_url = get_url_in_content( $content );
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}
if ( ! function_exists( 'baskerville_setup_author' ) ) :
/**
* Sets the authordata global when viewing an author archive.
*
* This provides backwards compatibility with
* http://core.trac.wordpress.org/changeset/25574
*
* It removes the need to call the_post() and rewind_posts() in an author
* template to print information about the author.
*
* @global WP_Query $wp_query WordPress Query object.
* @return void
*/
function baskerville_setup_author() {
global $wp_query;
if ( $wp_query->is_author() && isset( $wp_query->post ) ) {
$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
}
}
add_action( 'wp', 'baskerville_setup_author' );
endif;
/**
* Includes & required files:
*/
// Custom header functions for this theme
require get_template_directory() . '/inc/custom-header.php';
// Jetpack functions for this theme
require get_template_directory() . '/inc/jetpack.php';
// Custom template tags for this theme
require get_template_directory() . '/inc/template-tags.php';
// Add Baskerville widgets
require_once( get_template_directory() . '/widgets/dribbble-widget.php' );