Use wp_title() proper in Twenty Ten, and move the janky stuff to a filter. see #13751.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9e65c710fe
commit
4c53975440
|
@ -191,35 +191,71 @@ function twentyten_admin_header_style() {
|
|||
<style type="text/css">
|
||||
/* Shows the same border as on front end */
|
||||
#headimg {
|
||||
border-bottom: 1px solid #000000;
|
||||
border-top: 4px solid #000000;
|
||||
}
|
||||
|
||||
/* If NO_HEADER_TEXT is false, you can style here the header text preview */
|
||||
#headimg #name {
|
||||
}
|
||||
|
||||
#headimg #desc {
|
||||
border-bottom: 1px solid #000;
|
||||
border-top: 4px solid #000;
|
||||
}
|
||||
/* If NO_HEADER_TEXT is false, you would style the text with these selectors:
|
||||
#headimg #name { }
|
||||
#headimg #desc { }
|
||||
*/
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'twentyten_the_page_number' ) ) :
|
||||
/**
|
||||
* Prints the page number currently being browsed, with a vertical bar before it.
|
||||
* Makes some changes to the <title> tag, by filtering the output of wp_title().
|
||||
*
|
||||
* Used in Twenty Ten's header.php to add the page number to the <title> HTML tag.
|
||||
* If we have a site description and we're viewing the home page or a blog posts
|
||||
* page (when using a static front page), then we will add the site description.
|
||||
*
|
||||
* If we're viewing a search result, then we're going to recreate the title entirely.
|
||||
* We're going to add page numbers to all titles as well, to the middle of a search
|
||||
* result title and the end of all other titles.
|
||||
*
|
||||
* The site title also gets added to all titles.
|
||||
*
|
||||
* @since Twenty Ten 1.0
|
||||
*
|
||||
* @param string $title Title generated by wp_title()
|
||||
* @param string $separator The separator passed to wp_title(). Twenty Ten uses a
|
||||
* vertical bar, "|", as a separator in header.php.
|
||||
* @return string The new title, ready for the <title> tag.
|
||||
*/
|
||||
function twentyten_the_page_number() {
|
||||
global $paged; // Contains page number.
|
||||
function twentyten_filter_wp_title( $title, $separator ) {
|
||||
// The $paged global variable contains the page number of a listing of posts.
|
||||
// The $page global variable contains the page number of a single post that is paged.
|
||||
// We'll display whichever one applies, if we're not looking at the first page.
|
||||
global $paged, $page;
|
||||
|
||||
if ( is_search() ) {
|
||||
// If we're a search, let's start over:
|
||||
$title = sprintf( __( 'Search results for %s', 'twentyten' ), '"' . get_search_query() . '"' );
|
||||
// Add a page number if we're on page 2 or more:
|
||||
if ( $paged >= 2 )
|
||||
echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), $paged );
|
||||
$title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), $paged );
|
||||
// Add the site name to the end:
|
||||
$title .= " $separator " . get_bloginfo( 'name', 'display' );
|
||||
// We're done. Let's send the new title back to wp_title():
|
||||
return $title;
|
||||
}
|
||||
|
||||
// Otherwise, let's start by adding the site name to the end:
|
||||
$title .= get_bloginfo( 'name', 'display' );
|
||||
|
||||
// If we have a site description and we're on the home/front page, add the description:
|
||||
$site_description = get_bloginfo( 'description', 'display' );
|
||||
if ( $site_description && ( is_home() || is_front_page() ) )
|
||||
$title .= " $separator " . $site_description;
|
||||
|
||||
// Add a page number if necessary:
|
||||
if ( $paged >= 2 || $page >= 2 )
|
||||
$title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
|
||||
|
||||
// Return the new title to wp_title():
|
||||
return $title;
|
||||
}
|
||||
endif;
|
||||
add_filter( 'wp_title', 'twentyten_filter_wp_title', 10, 2 );
|
||||
|
||||
/**
|
||||
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
|
||||
|
|
|
@ -11,31 +11,19 @@
|
|||
?><!DOCTYPE html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>" />
|
||||
<title>
|
||||
<?php // Returns the title based on what is being viewed
|
||||
if ( is_single() ) { // single posts
|
||||
single_post_title(); echo ' | '; bloginfo( 'name' );
|
||||
// The home page or, if using a static front page, the blog posts page.
|
||||
} elseif ( is_home() || is_front_page() ) {
|
||||
bloginfo( 'name' );
|
||||
if( get_bloginfo( 'description' ) )
|
||||
echo ' | ' ; bloginfo( 'description' );
|
||||
twentyten_the_page_number();
|
||||
} elseif ( is_page() ) { // WordPress Pages
|
||||
single_post_title( '' ); echo ' | '; bloginfo( 'name' );
|
||||
} elseif ( is_search() ) { // Search results
|
||||
printf( __( 'Search results for %s', 'twentyten' ), '"'.get_search_query().'"' ); twentyten_the_page_number(); echo ' | '; bloginfo( 'name' );
|
||||
} elseif ( is_404() ) { // 404 (Not Found)
|
||||
_e( 'Not Found', 'twentyten' ); echo ' | '; bloginfo( 'name' );
|
||||
} else { // Otherwise:
|
||||
wp_title( '' ); echo ' | '; bloginfo( 'name' ); twentyten_the_page_number();
|
||||
}
|
||||
?>
|
||||
</title>
|
||||
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
||||
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
|
||||
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>" />
|
||||
<title><?php
|
||||
/*
|
||||
* Print the <title> tag based on what is being viewed.
|
||||
* We filter the output of wp_title() a bit -- see
|
||||
* twentyten_filter_wp_title() in functions.php.
|
||||
*/
|
||||
wp_title( '|', true, 'right' );
|
||||
|
||||
?></title>
|
||||
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
||||
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
|
||||
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
|
||||
<?php
|
||||
/* We add some JavaScript to pages with the comment form
|
||||
* to support sites with threaded comments (when in use).
|
||||
|
@ -48,7 +36,6 @@
|
|||
* generally use this hook to add elements to <head> such
|
||||
* as styles, scripts, and meta tags.
|
||||
*/
|
||||
|
||||
wp_head();
|
||||
?>
|
||||
</head>
|
||||
|
|
Loading…
Reference in New Issue