Template: Use template-loader.php as cononical source of truth for conditional ordering.

Reverts [35700] which didn't account for author archives without posts.
Determination of the correct title is now based on the same order of
conditionals that template loader uses to select the right template.

H/t ocean90.
Fixes #34516.


Built from https://develop.svn.wordpress.org/trunk@35706


git-svn-id: http://core.svn.wordpress.org/trunk@35670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Konstantin Obenland 2015-11-19 17:09:26 +00:00
parent c98359ddcf
commit 595ade87f9
2 changed files with 23 additions and 19 deletions

View File

@ -847,10 +847,27 @@ function wp_get_document_title() {
'title' => '',
);
// If it's a 404 page, use a "Page not found" title.
if ( is_404() ) {
$title['title'] = __( 'Page not found' );
// If it's a search, use a dynamic search results title.
} elseif ( is_search() ) {
/* translators: %s: search phrase */
$title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() );
// If on the home or front page, use the site title.
if ( is_home() && is_front_page() ) {
} elseif ( is_home() && is_front_page() ) {
$title['title'] = get_bloginfo( 'name', 'display' );
// If on a post type archive, use the post type archive title.
} elseif ( is_post_type_archive() ) {
$title['title'] = post_type_archive_title( '', false );
// If on a taxonomy archive, use the term title.
} elseif ( is_tax() ) {
$title['title'] = single_term_title( '', false );
/*
* If we're on the blog page and that page is not the homepage or a single
* page that is designated as the homepage, use the container page's title.
@ -862,22 +879,13 @@ function wp_get_document_title() {
} elseif ( is_singular() ) {
$title['title'] = single_post_title( '', false );
// If on a category or tag or taxonomy archive, use the archive title.
} elseif ( is_category() || is_tag() || is_tax() ) {
// If on a category or tag archive, use the term title.
} elseif ( is_category() || is_tag() ) {
$title['title'] = single_term_title( '', false );
// If it's a search, use a dynamic search results title.
} elseif ( is_search() ) {
/* translators: %s: search phrase */
$title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() );
// If on an author archive, use the author's display name.
} elseif ( is_author() ) {
$title['title'] = get_the_author();
// If on a post type archive, use the post type archive title.
} elseif ( is_post_type_archive() ) {
$title['title'] = post_type_archive_title( '', false );
} elseif ( is_author() && $author = get_queried_object() ) {
$title['title'] = $author->display_name;
// If it's a date archive, use the date as the title.
} elseif ( is_year() ) {
@ -888,10 +896,6 @@ function wp_get_document_title() {
} elseif ( is_day() ) {
$title['title'] = get_the_date();
// If it's a 404 page, use a "Page not found" title.
} elseif ( is_404() ) {
$title['title'] = __( 'Page not found' );
}
// Add a page number if necessary.

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-beta4-35705';
$wp_version = '4.4-beta4-35706';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.