Twenty Eleven Functions.php comments cleanup, merge the 2 body class functions. Props jorbin. See #17748
git-svn-id: http://svn.automattic.com/wordpress/trunk@18272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
aa4dd50d7b
commit
7c16b8d1dd
|
@ -100,39 +100,35 @@ function twentyeleven_setup() {
|
||||||
// This theme uses wp_nav_menu() in one location.
|
// This theme uses wp_nav_menu() in one location.
|
||||||
register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
|
register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
|
||||||
|
|
||||||
/**
|
// Add support for a variety of post formats
|
||||||
* Add support for an Aside Post Format
|
|
||||||
*/
|
|
||||||
add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
|
add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
|
||||||
|
|
||||||
/**
|
// Add support for custom backgrounds
|
||||||
* Add support for custom backgrounds
|
|
||||||
*/
|
|
||||||
add_custom_background();
|
add_custom_background();
|
||||||
|
|
||||||
// This theme uses Feature Images for per-post/per-page Custom Header images
|
// This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
|
||||||
add_theme_support( 'post-thumbnails' );
|
add_theme_support( 'post-thumbnails' );
|
||||||
|
|
||||||
/**
|
// The next four constants set how twentyeleven supports custom headers
|
||||||
* Add support for Custom Headers
|
|
||||||
*/
|
// The default header text color
|
||||||
define( 'HEADER_TEXTCOLOR', '000' );
|
define( 'HEADER_TEXTCOLOR', '000' );
|
||||||
|
|
||||||
// No CSS, just an IMG call. The %s is a placeholder for the theme template directory URI.
|
// By leaving empty, we default to random image rotation
|
||||||
define( 'HEADER_IMAGE', '' ); // Leaving empty for random image rotation.
|
define( 'HEADER_IMAGE', '' );
|
||||||
|
|
||||||
// The height and width of your custom header. You can hook into the theme's own filters to change these values.
|
// The height and width of your custom header.
|
||||||
// Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values.
|
// Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values.
|
||||||
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) );
|
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) );
|
||||||
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) );
|
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) );
|
||||||
|
|
||||||
// We'll be using post thumbnails for custom header images on posts and pages.
|
// We'll be using post thumbnails for custom header images on posts and pages.
|
||||||
// We want them to be 1000 pixels wide by 288 pixels tall.
|
// We want them to be the size of the header image that we just defined
|
||||||
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
|
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
|
||||||
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
|
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
|
||||||
|
|
||||||
// Add Twenty Eleven's custom image sizes
|
// Add Twenty Eleven's custom image sizes
|
||||||
add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature images
|
add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images
|
||||||
add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist
|
add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist
|
||||||
|
|
||||||
// Add a way for the custom header to be styled in the admin panel that controls
|
// Add a way for the custom header to be styled in the admin panel that controls
|
||||||
|
@ -353,17 +349,6 @@ function twentyeleven_custom_excerpt_more( $output ) {
|
||||||
}
|
}
|
||||||
add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
|
add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
|
||||||
|
|
||||||
/**
|
|
||||||
* Add custom body classes
|
|
||||||
*/
|
|
||||||
function twentyeleven_singular_class( $classes ) {
|
|
||||||
if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
|
|
||||||
$classes[] = 'singular';
|
|
||||||
|
|
||||||
return $classes;
|
|
||||||
}
|
|
||||||
add_filter( 'body_class', 'twentyeleven_singular_class' );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
|
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
|
||||||
*/
|
*/
|
||||||
|
@ -563,6 +548,7 @@ endif; // ends check for twentyeleven_comment()
|
||||||
if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
|
if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
|
||||||
/**
|
/**
|
||||||
* Prints HTML with meta information for the current post-date/time and author.
|
* Prints HTML with meta information for the current post-date/time and author.
|
||||||
|
* Create your own twentyeleven_posted_on to override in a child theme
|
||||||
*
|
*
|
||||||
* @since Twenty Eleven 1.0
|
* @since Twenty Eleven 1.0
|
||||||
*/
|
*/
|
||||||
|
@ -580,16 +566,22 @@ function twentyeleven_posted_on() {
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds Twenty Eleven author class to the array of body classes.
|
* Adds two classes to the array of body classes.
|
||||||
|
* The first is if the site has only had one author with published posts.
|
||||||
|
* The second is if a singular post being displayed
|
||||||
*
|
*
|
||||||
* @since Twenty Eleven 1.0
|
* @since Twenty Eleven 1.0
|
||||||
*/
|
*/
|
||||||
function twentyeleven_author_class( $classes ) {
|
function twentyeleven_body_classes( $classes ) {
|
||||||
|
|
||||||
if ( ! is_multi_author() ) {
|
if ( ! is_multi_author() ) {
|
||||||
$classes[] = 'single-author';
|
$classes[] = 'single-author';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
|
||||||
|
$classes[] = 'singular';
|
||||||
|
|
||||||
return $classes;
|
return $classes;
|
||||||
}
|
}
|
||||||
add_filter( 'body_class', 'twentyeleven_author_class' );
|
add_filter( 'body_class', 'twentyeleven_body_classes' );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue