2013-07-28 18:55:10 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Twenty Fourteen functions and definitions
|
2013-08-14 23:13:44 -04:00
|
|
|
*
|
2013-10-11 18:02:11 -04:00
|
|
|
* Set up the theme and provides some helper functions, which are used in the
|
2013-08-14 23:13:44 -04:00
|
|
|
* theme as custom template tags. Others are attached to action and filter
|
|
|
|
* hooks in WordPress to change core functionality.
|
|
|
|
*
|
|
|
|
* When using a child theme (see http://codex.wordpress.org/Theme_Development
|
|
|
|
* and http://codex.wordpress.org/Child_Themes), you can override certain
|
|
|
|
* functions (those wrapped in a function_exists() call) by defining them first
|
|
|
|
* in your child theme's functions.php file. The child theme's functions.php
|
|
|
|
* file is included before the parent theme's file, so the child theme
|
|
|
|
* functions would be used.
|
|
|
|
*
|
|
|
|
* Functions that are not pluggable (not wrapped in function_exists()) are
|
|
|
|
* instead attached to a filter or action hook.
|
|
|
|
*
|
|
|
|
* For more information on hooks, actions, and filters,
|
2013-10-11 18:02:11 -04:00
|
|
|
* @link http://codex.wordpress.org/Plugin_API
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Twenty_Fourteen
|
2013-10-11 18:02:11 -04:00
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Set up the content width value based on the theme's design.
|
|
|
|
*
|
|
|
|
* @link twentyfourteen_content_width()
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
if ( ! isset( $content_width ) )
|
2013-08-14 23:13:44 -04:00
|
|
|
$content_width = 474;
|
2013-07-28 18:55:10 -04:00
|
|
|
|
|
|
|
if ( ! function_exists( 'twentyfourteen_setup' ) ) :
|
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Twenty Fourteen setup.
|
|
|
|
*
|
|
|
|
* Set up theme defaults and registers support for various WordPress features.
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
2013-08-14 23:13:44 -04:00
|
|
|
* 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.
|
2013-10-11 18:02:11 -04:00
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
function twentyfourteen_setup() {
|
|
|
|
|
2013-08-14 23:13:44 -04:00
|
|
|
/*
|
2013-10-11 18:02:11 -04:00
|
|
|
* Make Twenty Fourteen available for translation.
|
2013-08-14 23:13:44 -04:00
|
|
|
*
|
|
|
|
* Translations can be added to the /languages/ directory.
|
|
|
|
* If you're building a theme based on Twenty Fourteen, use a find and
|
|
|
|
* replace to change 'twentyfourteen' to the name of your theme in all
|
|
|
|
* template files.
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
load_theme_textdomain( 'twentyfourteen', get_template_directory() . '/languages' );
|
|
|
|
|
2013-10-11 18:02:11 -04:00
|
|
|
// This theme styles the visual editor to resemble the theme style.
|
2013-09-02 19:03:09 -04:00
|
|
|
add_editor_style( array( 'editor-style.css', twentyfourteen_font_url() ) );
|
|
|
|
|
2013-10-11 18:02:11 -04:00
|
|
|
// Add RSS feed links to <head> for posts and comments.
|
2013-07-28 18:55:10 -04:00
|
|
|
add_theme_support( 'automatic-feed-links' );
|
|
|
|
|
2013-08-14 23:13:44 -04:00
|
|
|
// Enable support for Post Thumbnails.
|
2013-10-08 17:22:10 -04:00
|
|
|
add_theme_support( 'post-thumbnails' );
|
2013-07-28 18:55:10 -04:00
|
|
|
|
2013-10-11 18:02:11 -04:00
|
|
|
// Add several sizes for Post Thumbnails.
|
2013-10-30 10:39:10 -04:00
|
|
|
add_image_size( 'post-thumbnail-slider', 1038, 576, true );
|
|
|
|
add_image_size( 'post-thumbnail-grid', 672, 372, true );
|
|
|
|
add_image_size( 'post-thumbnail', 672, 0 );
|
2013-07-28 18:55:10 -04:00
|
|
|
|
2013-08-14 23:13:44 -04:00
|
|
|
// This theme uses wp_nav_menu() in two locations.
|
2013-07-28 18:55:10 -04:00
|
|
|
register_nav_menus( array(
|
2013-08-14 23:13:44 -04:00
|
|
|
'primary' => __( 'Top primary menu', 'twentyfourteen' ),
|
|
|
|
'secondary' => __( 'Secondary menu in left sidebar', 'twentyfourteen' ),
|
2013-07-28 18:55:10 -04:00
|
|
|
) );
|
|
|
|
|
2013-08-22 13:01:08 -04:00
|
|
|
/*
|
2013-10-11 18:02:11 -04:00
|
|
|
* Switch default core markup for search form, comment form, and comments
|
2013-08-22 13:01:08 -04:00
|
|
|
* to output valid HTML5.
|
|
|
|
*/
|
|
|
|
add_theme_support( 'html5', array(
|
|
|
|
'search-form', 'comment-form', 'comment-list',
|
|
|
|
) );
|
|
|
|
|
2013-08-14 23:13:44 -04:00
|
|
|
/*
|
|
|
|
* Enable support for Post Formats.
|
|
|
|
* See http://codex.wordpress.org/Post_Formats
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
2013-08-14 23:13:44 -04:00
|
|
|
add_theme_support( 'post-formats', array(
|
2013-11-05 16:52:09 -05:00
|
|
|
'aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery',
|
2013-08-14 23:13:44 -04:00
|
|
|
) );
|
2013-07-28 18:55:10 -04:00
|
|
|
|
2013-08-14 23:13:44 -04:00
|
|
|
/*
|
2013-07-28 18:55:10 -04:00
|
|
|
* This theme allows users to set a custom background.
|
|
|
|
*/
|
2013-08-14 23:13:29 -04:00
|
|
|
add_theme_support( 'custom-background', apply_filters( 'twentyfourteen_custom_background_args', array(
|
|
|
|
'default-color' => 'f5f5f5',
|
|
|
|
) ) );
|
2013-10-15 12:46:09 -04:00
|
|
|
|
2013-10-16 00:22:09 -04:00
|
|
|
/*
|
|
|
|
* Add support for featured content.
|
|
|
|
*/
|
|
|
|
add_theme_support( 'featured-content', array(
|
|
|
|
'featured_content_filter' => 'twentyfourteen_get_featured_posts',
|
|
|
|
'max_posts' => 6,
|
|
|
|
) );
|
|
|
|
|
2013-10-15 12:46:09 -04:00
|
|
|
/*
|
|
|
|
* This theme uses its own gallery styles.
|
|
|
|
*/
|
|
|
|
add_filter( 'use_default_gallery_style', '__return_false' );
|
2013-07-28 18:55:10 -04:00
|
|
|
}
|
|
|
|
endif; // twentyfourteen_setup
|
|
|
|
add_action( 'after_setup_theme', 'twentyfourteen_setup' );
|
|
|
|
|
|
|
|
/**
|
2013-10-24 18:57:34 -04:00
|
|
|
* Adjust content_width value for image attachment template.
|
2013-10-11 18:02:11 -04:00
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
2013-08-14 23:13:44 -04:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function twentyfourteen_content_width() {
|
2013-10-24 18:57:34 -04:00
|
|
|
if ( is_attachment() && wp_attachment_is_image() )
|
2013-09-20 14:22:09 -04:00
|
|
|
$GLOBALS['content_width'] = 810;
|
2013-08-14 23:13:44 -04:00
|
|
|
}
|
|
|
|
add_action( 'template_redirect', 'twentyfourteen_content_width' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Getter function for Featured Content Plugin.
|
2013-10-11 18:02:11 -04:00
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-10-16 00:22:09 -04:00
|
|
|
*
|
|
|
|
* @return array An array of WP_Post objects.
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
function twentyfourteen_get_featured_posts() {
|
2013-10-16 00:22:09 -04:00
|
|
|
return apply_filters( 'twentyfourteen_get_featured_posts', array() );
|
2013-07-28 18:55:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-10-16 00:22:09 -04:00
|
|
|
* A helper conditional function that returns a boolean value.
|
2013-10-11 18:02:11 -04:00
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-10-16 00:22:09 -04:00
|
|
|
*
|
|
|
|
* @return bool Whether there are featured posts.
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
2013-10-16 00:22:09 -04:00
|
|
|
function twentyfourteen_has_featured_posts() {
|
|
|
|
return ! is_paged() && (bool) apply_filters( 'twentyfourteen_get_featured_posts', false );
|
2013-07-28 18:55:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Register two widget areas.
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
2013-08-14 23:13:44 -04:00
|
|
|
* @return void
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
function twentyfourteen_widgets_init() {
|
2013-08-22 14:06:09 -04:00
|
|
|
require get_template_directory() . '/inc/widgets.php';
|
|
|
|
register_widget( 'Twenty_Fourteen_Ephemera_Widget' );
|
|
|
|
|
|
|
|
register_sidebar( array(
|
|
|
|
'name' => __( 'Primary Sidebar', 'twentyfourteen' ),
|
|
|
|
'id' => 'sidebar-1',
|
|
|
|
'description' => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ),
|
|
|
|
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
|
|
|
'after_widget' => '</aside>',
|
|
|
|
'before_title' => '<h1 class="widget-title">',
|
|
|
|
'after_title' => '</h1>',
|
|
|
|
) );
|
2013-07-28 18:55:10 -04:00
|
|
|
register_sidebar( array(
|
2013-08-22 14:06:09 -04:00
|
|
|
'name' => __( 'Content Sidebar', 'twentyfourteen' ),
|
2013-10-10 23:17:11 -04:00
|
|
|
'id' => 'sidebar-2',
|
|
|
|
'description' => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ),
|
2013-07-28 18:55:10 -04:00
|
|
|
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
2013-08-22 14:06:09 -04:00
|
|
|
'after_widget' => '</aside>',
|
|
|
|
'before_title' => '<h1 class="widget-title">',
|
|
|
|
'after_title' => '</h1>',
|
2013-07-28 18:55:10 -04:00
|
|
|
) );
|
|
|
|
register_sidebar( array(
|
2013-08-22 14:06:09 -04:00
|
|
|
'name' => __( 'Footer Widget Area', 'twentyfourteen' ),
|
2013-10-10 23:17:11 -04:00
|
|
|
'id' => 'sidebar-3',
|
2013-08-22 14:06:09 -04:00
|
|
|
'description' => __( 'Appears in the footer section of the site.', 'twentyfourteen' ),
|
2013-07-28 18:55:10 -04:00
|
|
|
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
2013-08-22 14:06:09 -04:00
|
|
|
'after_widget' => '</aside>',
|
|
|
|
'before_title' => '<h1 class="widget-title">',
|
|
|
|
'after_title' => '</h1>',
|
2013-07-28 18:55:10 -04:00
|
|
|
) );
|
|
|
|
}
|
|
|
|
add_action( 'widgets_init', 'twentyfourteen_widgets_init' );
|
|
|
|
|
|
|
|
/**
|
2013-09-02 19:03:09 -04:00
|
|
|
* Register Lato Google font for Twenty Fourteen.
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
2013-10-11 18:02:11 -04:00
|
|
|
* @since Twenty Fourteen 1.0
|
|
|
|
*
|
2013-08-14 23:13:44 -04:00
|
|
|
* @return void
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
2013-09-02 19:03:09 -04:00
|
|
|
function twentyfourteen_font_url() {
|
|
|
|
$font_url = '';
|
|
|
|
/*
|
|
|
|
* Translators: If there are characters in your language that are not supported
|
|
|
|
* by Lato, translate this to 'off'. Do not translate into your own language.
|
|
|
|
*/
|
2013-08-14 23:13:29 -04:00
|
|
|
if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) )
|
2013-09-02 19:03:09 -04:00
|
|
|
$font_url = add_query_arg( 'family', urlencode( 'Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic' ), "//fonts.googleapis.com/css" );
|
|
|
|
|
|
|
|
return $font_url;
|
2013-07-28 18:55:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Enqueue scripts and styles for front end.
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
2013-08-14 23:13:44 -04:00
|
|
|
* @return void
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
function twentyfourteen_scripts() {
|
2013-08-20 14:10:08 -04:00
|
|
|
// Add Lato font, used in the main stylesheet.
|
2013-10-30 10:39:10 -04:00
|
|
|
wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null );
|
2013-07-28 18:55:10 -04:00
|
|
|
|
2013-08-20 14:10:08 -04:00
|
|
|
// Add Genericons font, used in the main stylesheet.
|
2013-11-04 13:08:10 -05:00
|
|
|
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/fonts/genericons.css', array(), '3.0.2' );
|
2013-08-20 14:10:08 -04:00
|
|
|
|
|
|
|
// Loads our main stylesheet.
|
|
|
|
wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri() );
|
|
|
|
|
2013-08-14 23:13:29 -04:00
|
|
|
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
|
2013-07-28 18:55:10 -04:00
|
|
|
wp_enqueue_script( 'comment-reply' );
|
|
|
|
|
2013-08-14 23:13:29 -04:00
|
|
|
if ( is_singular() && wp_attachment_is_image() )
|
2013-07-28 18:55:10 -04:00
|
|
|
wp_enqueue_script( 'twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20130402' );
|
|
|
|
|
2013-08-20 13:53:09 -04:00
|
|
|
if ( is_active_sidebar( 'sidebar-3' ) )
|
|
|
|
wp_enqueue_script( 'jquery-masonry' );
|
|
|
|
|
2013-10-30 10:39:10 -04:00
|
|
|
if ( 'slider' == get_theme_mod( 'featured_content_layout' ) )
|
|
|
|
wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131028', true );
|
2013-09-02 19:03:09 -04:00
|
|
|
|
2013-11-02 00:36:12 -04:00
|
|
|
wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20131102', true );
|
2013-07-28 18:55:10 -04:00
|
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enqueue Google fonts style to admin screen for custom header display.
|
|
|
|
*
|
2013-10-11 18:02:11 -04:00
|
|
|
* @since Twenty Fourteen 1.0
|
|
|
|
*
|
2013-08-14 23:13:44 -04:00
|
|
|
* @return void
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
2013-08-14 23:13:29 -04:00
|
|
|
function twentyfourteen_admin_fonts() {
|
2013-07-28 18:55:10 -04:00
|
|
|
wp_enqueue_style( 'twentyfourteen-lato' );
|
|
|
|
}
|
2013-08-14 23:13:29 -04:00
|
|
|
add_action( 'admin_print_scripts-appearance_page_custom-header', 'twentyfourteen_admin_fonts' );
|
2013-07-28 18:55:10 -04:00
|
|
|
|
2013-08-14 23:13:29 -04:00
|
|
|
if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) :
|
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Print the attached image with a link to the next attached image.
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-08-14 23:13:29 -04:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function twentyfourteen_the_attached_image() {
|
|
|
|
$post = get_post();
|
|
|
|
$attachment_size = apply_filters( 'twentyfourteen_attachment_size', array( 1200, 1200 ) );
|
|
|
|
$next_attachment_url = wp_get_attachment_url();
|
|
|
|
|
2013-10-11 18:02:11 -04:00
|
|
|
/*
|
2013-08-14 23:13:29 -04:00
|
|
|
* Grab the IDs of all the image attachments in a gallery so we can get the URL
|
|
|
|
* of the next adjacent image in a gallery, or the first image (if we're
|
|
|
|
* looking at the last image in a gallery), or, in a gallery of one, just the
|
|
|
|
* link to that image file.
|
|
|
|
*/
|
|
|
|
$attachment_ids = get_posts( array(
|
|
|
|
'post_parent' => $post->post_parent,
|
|
|
|
'fields' => 'ids',
|
|
|
|
'numberposts' => -1,
|
|
|
|
'post_status' => 'inherit',
|
|
|
|
'post_type' => 'attachment',
|
|
|
|
'post_mime_type' => 'image',
|
|
|
|
'order' => 'ASC',
|
2013-08-14 23:13:44 -04:00
|
|
|
'orderby' => 'menu_order ID',
|
2013-08-14 23:13:29 -04:00
|
|
|
) );
|
|
|
|
|
|
|
|
// If there is more than 1 attachment in a gallery...
|
|
|
|
if ( count( $attachment_ids ) > 1 ) {
|
|
|
|
foreach ( $attachment_ids as $attachment_id ) {
|
|
|
|
if ( $attachment_id == $post->ID ) {
|
|
|
|
$next_id = current( $attachment_ids );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the URL of the next image attachment...
|
|
|
|
if ( $next_id )
|
|
|
|
$next_attachment_url = get_attachment_link( $next_id );
|
|
|
|
|
|
|
|
// or get the URL of the first image attachment.
|
|
|
|
else
|
|
|
|
$next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) );
|
|
|
|
}
|
|
|
|
|
2013-10-09 15:07:09 -04:00
|
|
|
printf( '<a href="%1$s" rel="attachment">%2$s</a>',
|
2013-08-14 23:13:29 -04:00
|
|
|
esc_url( $next_attachment_url ),
|
|
|
|
wp_get_attachment_image( $post->ID, $attachment_size )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2013-09-19 17:33:09 -04:00
|
|
|
if ( ! function_exists( 'twentyfourteen_list_authors' ) ) :
|
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Print a list of all site contributors who published at least one post.
|
|
|
|
*
|
|
|
|
* @since Twenty Fourteen 1.0
|
2013-09-19 17:33:09 -04:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function twentyfourteen_list_authors() {
|
|
|
|
$contributor_ids = get_users( array(
|
|
|
|
'fields' => 'ID',
|
|
|
|
'orderby' => 'post_count',
|
|
|
|
'who' => 'authors',
|
|
|
|
) );
|
|
|
|
|
|
|
|
foreach ( $contributor_ids as $contributor_id ) :
|
|
|
|
$post_count = count_user_posts( $contributor_id );
|
|
|
|
|
|
|
|
// Move on if user has not published a post (yet).
|
|
|
|
if ( ! $post_count )
|
|
|
|
continue;
|
|
|
|
?>
|
|
|
|
|
2013-09-20 14:22:09 -04:00
|
|
|
<div class="contributor">
|
2013-10-30 10:39:10 -04:00
|
|
|
<div class="contributor-info">
|
2013-09-20 14:22:09 -04:00
|
|
|
<div class="contributor-avatar"><?php echo get_avatar( $contributor_id, 132 ); ?></div>
|
|
|
|
<div class="contributor-summary">
|
|
|
|
<h2 class="contributor-name"><?php echo get_the_author_meta( 'display_name', $contributor_id ); ?></h2>
|
|
|
|
<p class="contributor-bio">
|
|
|
|
<?php echo get_the_author_meta( 'description', $contributor_id ); ?>
|
|
|
|
</p>
|
|
|
|
<a class="contributor-posts-link" href="<?php echo esc_url( get_author_posts_url( $contributor_id ) ); ?>">
|
|
|
|
<?php printf( _n( '%d Article', '%d Articles', $post_count, 'twentyfourteen' ), $post_count ); ?>
|
|
|
|
</a>
|
|
|
|
</div><!-- .contributor-summary -->
|
|
|
|
</div><!-- .contributor-info -->
|
2013-09-19 17:33:09 -04:00
|
|
|
</div><!-- .contributor -->
|
|
|
|
|
|
|
|
<?php
|
|
|
|
endforeach;
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
2013-07-28 18:55:10 -04:00
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Extend the default WordPress body classes.
|
2013-08-14 23:13:44 -04:00
|
|
|
*
|
|
|
|
* Adds body classes to denote:
|
|
|
|
* 1. Single or multiple authors.
|
2013-10-30 10:39:10 -04:00
|
|
|
* 2. Presense of header image.
|
|
|
|
* 3. Index views.
|
|
|
|
* 4. Full-width content layout.
|
|
|
|
* 5. Presence of footer widgets.
|
|
|
|
* 6. Single views.
|
|
|
|
* 7. Featured content layout.
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
2013-10-11 18:02:11 -04:00
|
|
|
* @since Twenty Fourteen 1.0
|
|
|
|
*
|
2013-08-14 23:13:44 -04:00
|
|
|
* @param array $classes A list of existing body class values.
|
|
|
|
* @return array The filtered body class list.
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
function twentyfourteen_body_classes( $classes ) {
|
2013-09-20 14:22:09 -04:00
|
|
|
if ( is_multi_author() )
|
2013-07-28 18:55:10 -04:00
|
|
|
$classes[] = 'group-blog';
|
2013-09-20 14:22:09 -04:00
|
|
|
|
2013-10-24 18:58:48 -04:00
|
|
|
if ( get_header_image() )
|
|
|
|
$classes[] = 'header-image';
|
|
|
|
else
|
|
|
|
$classes[] = 'masthead-fixed';
|
|
|
|
|
2013-09-20 14:22:09 -04:00
|
|
|
if ( is_archive() || is_search() || is_home() )
|
2013-07-28 18:55:10 -04:00
|
|
|
$classes[] = 'list-view';
|
2013-09-20 14:22:09 -04:00
|
|
|
|
2013-10-10 23:17:11 -04:00
|
|
|
if ( ( ! is_active_sidebar( 'sidebar-2' ) )
|
2013-09-25 12:36:09 -04:00
|
|
|
|| is_page_template( 'full-width-page.php' )
|
|
|
|
|| is_page_template( 'contributor-page.php' )
|
|
|
|
|| is_attachment() )
|
2013-09-20 14:22:09 -04:00
|
|
|
$classes[] = 'full-width';
|
2013-07-28 18:55:10 -04:00
|
|
|
|
2013-10-10 23:17:11 -04:00
|
|
|
if ( is_active_sidebar( 'sidebar-3' ) )
|
2013-10-08 17:37:09 -04:00
|
|
|
$classes[] = 'footer-widgets';
|
|
|
|
|
2013-10-30 10:39:10 -04:00
|
|
|
if ( is_singular() )
|
|
|
|
$classes[] = 'singular';
|
|
|
|
|
|
|
|
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) )
|
|
|
|
$classes[] = 'slider';
|
|
|
|
elseif ( is_front_page() )
|
|
|
|
$classes[] = 'grid';
|
|
|
|
|
2013-07-28 18:55:10 -04:00
|
|
|
return $classes;
|
|
|
|
}
|
|
|
|
add_filter( 'body_class', 'twentyfourteen_body_classes' );
|
|
|
|
|
2013-10-08 17:22:10 -04:00
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Extend the default WordPress post classes.
|
2013-10-08 17:22:10 -04:00
|
|
|
*
|
|
|
|
* Adds a post class to denote:
|
2013-10-30 10:39:10 -04:00
|
|
|
* Non-password protected page with a post thumbnail.
|
2013-10-08 17:22:10 -04:00
|
|
|
*
|
2013-10-11 18:02:11 -04:00
|
|
|
* @since Twenty Fourteen 1.0
|
|
|
|
*
|
2013-10-08 17:22:10 -04:00
|
|
|
* @param array $classes A list of existing post class values.
|
|
|
|
* @return array The filtered post class list.
|
|
|
|
*/
|
|
|
|
function twentyfourteen_post_classes( $classes ) {
|
|
|
|
if ( ! post_password_required() && has_post_thumbnail() )
|
2013-10-30 10:39:10 -04:00
|
|
|
$classes[] = 'has-post-thumbnail';
|
|
|
|
else
|
|
|
|
$classes[] = 'no-post-thumbnail';
|
2013-10-08 17:22:10 -04:00
|
|
|
|
|
|
|
return $classes;
|
|
|
|
}
|
|
|
|
add_filter( 'post_class', 'twentyfourteen_post_classes' );
|
|
|
|
|
2013-07-28 18:55:10 -04:00
|
|
|
/**
|
2013-10-11 18:02:11 -04:00
|
|
|
* Create a nicely formatted and more specific title element text for output
|
2013-08-14 23:13:44 -04:00
|
|
|
* in head of document, based on current view.
|
2013-07-28 18:55:10 -04:00
|
|
|
*
|
2013-10-11 18:02:11 -04:00
|
|
|
* @since Twenty Fourteen 1.0
|
|
|
|
*
|
2013-08-14 23:13:44 -04:00
|
|
|
* @param string $title Default title text for current view.
|
|
|
|
* @param string $sep Optional separator.
|
|
|
|
* @return string The filtered title.
|
2013-07-28 18:55:10 -04:00
|
|
|
*/
|
|
|
|
function twentyfourteen_wp_title( $title, $sep ) {
|
2013-08-14 23:13:44 -04:00
|
|
|
global $paged, $page;
|
2013-07-28 18:55:10 -04:00
|
|
|
|
|
|
|
if ( is_feed() )
|
|
|
|
return $title;
|
|
|
|
|
2013-08-14 23:13:44 -04:00
|
|
|
// Add the site name.
|
2013-07-28 18:55:10 -04:00
|
|
|
$title .= get_bloginfo( 'name' );
|
|
|
|
|
2013-08-14 23:13:44 -04:00
|
|
|
// Add the site description for the home/front page.
|
2013-07-28 18:55:10 -04:00
|
|
|
$site_description = get_bloginfo( 'description', 'display' );
|
|
|
|
if ( $site_description && ( is_home() || is_front_page() ) )
|
2013-08-14 23:13:44 -04:00
|
|
|
$title = "$title $sep $site_description";
|
2013-07-28 18:55:10 -04:00
|
|
|
|
2013-08-14 23:13:44 -04:00
|
|
|
// Add a page number if necessary.
|
2013-07-28 18:55:10 -04:00
|
|
|
if ( $paged >= 2 || $page >= 2 )
|
2013-08-14 23:13:44 -04:00
|
|
|
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentyfourteen' ), max( $paged, $page ) );
|
2013-07-28 18:55:10 -04:00
|
|
|
|
|
|
|
return $title;
|
|
|
|
}
|
2013-08-14 23:13:29 -04:00
|
|
|
add_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2 );
|
|
|
|
|
2013-10-11 18:02:11 -04:00
|
|
|
// Implement Custom Header features.
|
2013-08-14 23:13:44 -04:00
|
|
|
require get_template_directory() . '/inc/custom-header.php';
|
|
|
|
|
2013-10-11 18:02:11 -04:00
|
|
|
// Custom template tags for this theme.
|
2013-08-14 23:13:29 -04:00
|
|
|
require get_template_directory() . '/inc/template-tags.php';
|
|
|
|
|
2013-10-11 18:02:11 -04:00
|
|
|
// Add Theme Customizer functionality.
|
2013-08-14 23:13:29 -04:00
|
|
|
require get_template_directory() . '/inc/customizer.php';
|
2013-10-16 00:22:09 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add Featured Content functionality.
|
|
|
|
*
|
|
|
|
* To overwrite in a plugin, define your own Featured_Content class on or
|
|
|
|
* before the 'setup_theme' hook.
|
|
|
|
*/
|
|
|
|
if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] )
|
|
|
|
require get_template_directory() . '/inc/featured-content.php';
|