<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[35294] trunk: Themes: Improve document title output.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/35294">35294</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/35294","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>obenland</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-10-20 16:20:04 +0000 (Tue, 20 Oct 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Themes: Improve document title output.
Introduces more flexibility in filtering all parts of the document title,the
separator, and a way to short-circuit title generation. Plugins can now also
check for theme support and reliably filter the entire output. See <a href="https://core.trac.wordpress.org/ticket/18548">#18548</a>.
Deprecates `wp_title()`.
Fixes <a href="https://core.trac.wordpress.org/ticket/31078">#31078</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesdeprecatedphp">trunk/src/wp-includes/deprecated.php</a></li>
<li><a href="#trunksrcwpincludesfeedatomcommentsphp">trunk/src/wp-includes/feed-atom-comments.php</a></li>
<li><a href="#trunksrcwpincludesfeedatomphp">trunk/src/wp-includes/feed-atom.php</a></li>
<li><a href="#trunksrcwpincludesfeedrdfphp">trunk/src/wp-includes/feed-rdf.php</a></li>
<li><a href="#trunksrcwpincludesfeedrssphp">trunk/src/wp-includes/feed-rss.php</a></li>
<li><a href="#trunksrcwpincludesfeedrss2commentsphp">trunk/src/wp-includes/feed-rss2-comments.php</a></li>
<li><a href="#trunksrcwpincludesfeedrss2php">trunk/src/wp-includes/feed-rss2.php</a></li>
<li><a href="#trunksrcwpincludesfeedphp">trunk/src/wp-includes/feed.php</a></li>
<li><a href="#trunksrcwpincludesgeneraltemplatephp">trunk/src/wp-includes/general-template.php</a></li>
<li><a href="#trunksrcwpincludesthemecompatheaderphp">trunk/src/wp-includes/theme-compat/header.php</a></li>
<li><a href="#trunksrcwpincludesthemephp">trunk/src/wp-includes/theme.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsgeneraldocumenttitlephp">trunk/tests/phpunit/tests/general/document-title.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesdeprecatedphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/deprecated.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/deprecated.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/deprecated.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3635,3 +3635,156 @@
</span><span class="cx" style="display: block; padding: 0 10px"> _deprecated_function( __FUNCTION__, '4.4', 'force_ssl_admin()' );
</span><span class="cx" style="display: block; padding: 0 10px"> return force_ssl_admin( $force );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Formerly used to display or retrieve page title for all areas of blog.
+ *
+ * By default, the page title will display the separator before the page title,
+ * so that the blog title will be before the page title. This is not good for
+ * title display, since the blog title shows up on most tabs and not what is
+ * important, which is the page that the user is looking at.
+ *
+ * There are also SEO benefits to having the blog title after or to the 'right'
+ * or the page title. However, it is mostly common sense to have the blog title
+ * to the right with most browsers supporting tabs. You can achieve this by
+ * using the seplocation parameter and setting the value to 'right'. This change
+ * was introduced around 2.5.0, in case backwards compatibility of themes is
+ * important.
+ *
+ * @since 1.0.0
+ * @deprecated 4.4.0
+ * @deprecated Use add_theme_support( 'title-tag' );
+ *
+ * @param string $sep Optional, default is '»'. How to separate the various items within the page title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @param string $seplocation Optional. Direction to display title, 'right'.
+ * @return string|null String on retrieve, null when displaying.
+ */
+function wp_title( $sep = '»', $display = true, $seplocation = '' ) {
+ _deprecated_function( __FUNCTION__, '4.4', 'add_theme_support( \'title-tag\' )' );
+
+ global $wp_locale;
+
+ $m = get_query_var( 'm' );
+ $year = get_query_var( 'year' );
+ $monthnum = get_query_var( 'monthnum' );
+ $day = get_query_var( 'day' );
+ $search = get_query_var( 's' );
+ $title = '';
+
+ $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
+
+ // If there is a post
+ if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {
+ $title = single_post_title( '', false );
+ }
+
+ // If there's a post type archive
+ if ( is_post_type_archive() ) {
+ $post_type = get_query_var( 'post_type' );
+ if ( is_array( $post_type ) ) {
+ $post_type = reset( $post_type );
+ }
+ $post_type_object = get_post_type_object( $post_type );
+ if ( ! $post_type_object->has_archive ) {
+ $title = post_type_archive_title( '', false );
+ }
+ }
+
+ // If there's a category or tag
+ if ( is_category() || is_tag() ) {
+ $title = single_term_title( '', false );
+ }
+
+ // If there's a taxonomy
+ if ( is_tax() ) {
+ $term = get_queried_object();
+ if ( $term ) {
+ $tax = get_taxonomy( $term->taxonomy );
+ $title = single_term_title( $tax->labels->name . $t_sep, false );
+ }
+ }
+
+ // If there's an author
+ if ( is_author() && ! is_post_type_archive() ) {
+ $author = get_queried_object();
+ if ( $author ) {
+ $title = $author->display_name;
+ }
+ }
+
+ // Post type archives with has_archive should override terms.
+ if ( is_post_type_archive() && $post_type_object->has_archive ) {
+ $title = post_type_archive_title( '', false );
+ }
+
+ // If there's a month
+ if ( is_archive() && ! empty( $m ) ) {
+ $my_year = substr( $m, 0, 4 );
+ $my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
+ $my_day = intval( substr( $m, 6, 2 ) );
+ $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
+ }
+
+ // If there's a year
+ if ( is_archive() && ! empty( $year ) ) {
+ $title = $year;
+ if ( ! empty( $monthnum ) ) {
+ $title .= $t_sep . $wp_locale->get_month( $monthnum );
+ }
+ if ( ! empty( $day ) ) {
+ $title .= $t_sep . zeroise( $day, 2 );
+ }
+ }
+
+ // If it's a search
+ if ( is_search() ) {
+ /* translators: 1: separator, 2: search phrase */
+ $title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) );
+ }
+
+ // If it's a 404 page
+ if ( is_404() ) {
+ $title = __( 'Page not found' );
+ }
+
+ $prefix = '';
+ if ( ! empty( $title ) ) {
+ $prefix = " $sep ";
+ }
+
+ /**
+ * Filter the parts of the page title.
+ *
+ * @since 4.0.0
+ *
+ * @param array $title_array Parts of the page title.
+ */
+ $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
+
+ // Determines position of the separator and direction of the breadcrumb
+ if ( 'right' == $seplocation ) { // sep on right, so reverse the order
+ $title_array = array_reverse( $title_array );
+ $title = implode( " $sep ", $title_array ) . $prefix;
+ } else {
+ $title = $prefix . implode( " $sep ", $title_array );
+ }
+
+ /**
+ * Filter the text of the page title.
+ *
+ * @since 2.0.0
+ *
+ * @param string $title Page title.
+ * @param string $sep Title separator.
+ * @param string $seplocation Location of the separator (left or right).
+ */
+ $title = apply_filters( 'wp_title', $title, $sep, $seplocation );
+
+ // Send it out
+ if ( $display ) {
+ echo $title;
+ } else {
+ return $title;
+ }
+}
</ins></span></pre></div>
<a id="trunksrcwpincludesfeedatomcommentsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/feed-atom-comments.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/feed-atom-comments.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/feed-atom-comments.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,7 +33,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> elseif ( is_search() )
</span><span class="cx" style="display: block; padding: 0 10px"> printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
</span><span class="cx" style="display: block; padding: 0 10px"> else
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( ent2ncr( __( 'Comments for %s' ) ), get_bloginfo_rss( 'name' ) . get_wp_title_rss() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
</ins><span class="cx" style="display: block; padding: 0 10px"> ?></title>
</span><span class="cx" style="display: block; padding: 0 10px"> <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesfeedatomphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/feed-atom.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/feed-atom.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/feed-atom.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -27,7 +27,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'atom_ns' );
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> >
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <title type="text"><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <title type="text"><?php wp_title_rss(); ?></title>
</ins><span class="cx" style="display: block; padding: 0 10px"> <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
</span></span></pre></div>
<a id="trunksrcwpincludesfeedrdfphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/feed-rdf.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/feed-rdf.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/feed-rdf.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -30,7 +30,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> >
</span><span class="cx" style="display: block; padding: 0 10px"> <channel rdf:about="<?php bloginfo_rss("url") ?>">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <title><?php wp_title_rss(); ?></title>
</ins><span class="cx" style="display: block; padding: 0 10px"> <link><?php bloginfo_rss('url') ?></link>
</span><span class="cx" style="display: block; padding: 0 10px"> <description><?php bloginfo_rss('description') ?></description>
</span><span class="cx" style="display: block; padding: 0 10px"> <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
</span></span></pre></div>
<a id="trunksrcwpincludesfeedrssphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/feed-rss.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/feed-rss.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/feed-rss.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,7 +11,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <rss version="0.92">
</span><span class="cx" style="display: block; padding: 0 10px"> <channel>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <title><?php wp_title_rss(); ?></title>
</ins><span class="cx" style="display: block; padding: 0 10px"> <link><?php bloginfo_rss('url') ?></link>
</span><span class="cx" style="display: block; padding: 0 10px"> <description><?php bloginfo_rss('description') ?></description>
</span><span class="cx" style="display: block; padding: 0 10px"> <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
</span></span></pre></div>
<a id="trunksrcwpincludesfeedrss2commentsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/feed-rss2-comments.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/feed-rss2-comments.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/feed-rss2-comments.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -38,7 +38,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> elseif ( is_search() )
</span><span class="cx" style="display: block; padding: 0 10px"> printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
</span><span class="cx" style="display: block; padding: 0 10px"> else
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( ent2ncr( __( 'Comments for %s' ) ), get_bloginfo_rss( 'name' ) . get_wp_title_rss() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
</ins><span class="cx" style="display: block; padding: 0 10px"> ?></title>
</span><span class="cx" style="display: block; padding: 0 10px"> <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
</span><span class="cx" style="display: block; padding: 0 10px"> <link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
</span></span></pre></div>
<a id="trunksrcwpincludesfeedrss2php"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/feed-rss2.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/feed-rss2.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/feed-rss2.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -38,7 +38,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> >
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <channel>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <title><?php wp_title_rss(); ?></title>
</ins><span class="cx" style="display: block; padding: 0 10px"> <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
</span><span class="cx" style="display: block; padding: 0 10px"> <link><?php bloginfo_rss('url') ?></link>
</span><span class="cx" style="display: block; padding: 0 10px"> <description><?php bloginfo_rss("description") ?></description>
</span></span></pre></div>
<a id="trunksrcwpincludesfeedphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/feed.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/feed.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/feed.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -91,53 +91,53 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieve the blog title for the feed title.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.2.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.4.0 Deprecated argument.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $sep Optional. How to separate the title. See wp_title() for more info.
- * @return string Error message on failure or blog title on success.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $deprecated Deprecated.
+ * @return string The document title.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function get_wp_title_rss( $sep = '»' ) {
- $title = wp_title( $sep, false );
-
- if ( is_wp_error( $title ) ) {
- return $title->get_error_message();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function get_wp_title_rss( $deprecated = '–' ) {
+ if ( '–' !== $deprecated ) {
+ _deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), '<code>document_title_separator</code>' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $title && $sep && ' ' !== substr( $title, 0, 1 ) ) {
- $title = " $sep " . $title;
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filter the blog title for use as the feed title.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.2.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.4.0 Deprecated argument.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $title The current blog title.
- * @param string $sep Separator used by wp_title().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $title The current blog title.
+ * @param string $deprecated Deprecated.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $title = apply_filters( 'get_wp_title_rss', $title, $sep );
- return $title;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return apply_filters( 'get_wp_title_rss', wp_get_document_title(), $deprecated );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Display the blog title for display of the feed title.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.2.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @see wp_title() $sep parameter usage.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.4.0 Deprecated argument.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $sep Optional.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $deprecated Optional.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function wp_title_rss( $sep = '»' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wp_title_rss( $deprecated = '–' ) {
+ if ( '–' !== $deprecated ) {
+ _deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), '<code>document_title_separator</code>' ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filter the blog title for display of the feed title.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.2.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.4.0 Deprecated argument.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see get_wp_title_rss()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $wp_title The current blog title.
- * @param string $sep Separator used by wp_title().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $wp_title_rss The current blog title.
+ * @param string $deprecated Deprecated.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo apply_filters( 'wp_title_rss', get_wp_title_rss( $sep ), $sep );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo apply_filters( 'wp_title_rss', get_wp_title_rss(), $deprecated );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/general-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/general-template.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/general-template.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -781,187 +781,144 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Display title tag with contents.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns document title for the current page.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @ignore
- * @since 4.1.0
- * @access private
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.4.0
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @see wp_title()
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @global int $page Page number of a single post.
+ * @global int $paged Page number of a list of posts.
+ *
+ * @return string Tag with the document title.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function _wp_render_title_tag() {
- if ( ! current_theme_supports( 'title-tag' ) ) {
- return;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wp_get_document_title() {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // This can only work internally on wp_head.
- if ( ! did_action( 'wp_head' ) && ! doing_action( 'wp_head' ) ) {
- return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Allows to short-circuit the title generation.
+ *
+ * @since 4.4.0
+ *
+ * @param string $title The document title. Default empty string.
+ */
+ $title = apply_filters( 'pre_get_document_title', '' );
+ if ( ! empty( $title ) ) {
+ return $title;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
-}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $page, $paged;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * Display or retrieve page title for all areas of blog.
- *
- * By default, the page title will display the separator before the page title,
- * so that the blog title will be before the page title. This is not good for
- * title display, since the blog title shows up on most tabs and not what is
- * important, which is the page that the user is looking at.
- *
- * There are also SEO benefits to having the blog title after or to the 'right'
- * or the page title. However, it is mostly common sense to have the blog title
- * to the right with most browsers supporting tabs. You can achieve this by
- * using the seplocation parameter and setting the value to 'right'. This change
- * was introduced around 2.5.0, in case backwards compatibility of themes is
- * important.
- *
- * @since 1.0.0
- *
- * @global WP_Locale $wp_locale
- * @global int $page
- * @global int $paged
- *
- * @param string $sep Optional, default is '»'. How to separate the various items within the page title.
- * @param bool $display Optional, default is true. Whether to display or retrieve title.
- * @param string $seplocation Optional. Direction to display title, 'right'.
- * @return string|void String on retrieve.
- */
-function wp_title( $sep = '»', $display = true, $seplocation = '' ) {
- global $wp_locale, $page, $paged;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $title = array(
+ 'title' => '',
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $m = get_query_var('m');
- $year = get_query_var('year');
- $monthnum = get_query_var('monthnum');
- $day = get_query_var('day');
- $search = get_query_var('s');
- $title = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_home() && is_front_page() ) {
+ $title['title'] = get_bloginfo( 'name', 'display' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * 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.
+ */
+ } elseif ( ( is_home() && ! is_front_page() ) || ( ! is_home() && is_front_page() ) ) {
+ $title['title'] = single_post_title( '', false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If there is a post
- if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
- $title = single_post_title( '', false );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If we're on a post / page.
+ } elseif ( is_singular() ) {
+ $title['title'] = single_post_title( '', false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If there's a post type archive
- if ( is_post_type_archive() ) {
- $post_type = get_query_var( 'post_type' );
- if ( is_array( $post_type ) )
- $post_type = reset( $post_type );
- $post_type_object = get_post_type_object( $post_type );
- if ( ! $post_type_object->has_archive )
- $title = post_type_archive_title( '', false );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If we're on a category or tag or taxonomy archive.
+ } elseif ( is_category() || is_tag() || is_tax() ) {
+ $title['title'] = single_term_title( '', false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If there's a category or tag
- if ( is_category() || is_tag() ) {
- $title = single_term_title( '', false );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If it's a search.
+ } elseif ( is_search() ) {
+ /* translators: %s: search phrase */
+ $title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If there's a taxonomy
- if ( is_tax() ) {
- $term = get_queried_object();
- if ( $term ) {
- $tax = get_taxonomy( $term->taxonomy );
- $title = single_term_title( $tax->labels->name . $t_sep, false );
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If we're on an author archive.
+ } elseif ( is_author() && $author = get_queried_object() ) {
+ $title['title'] = $author->display_name;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If there's an author
- if ( is_author() && ! is_post_type_archive() ) {
- $author = get_queried_object();
- if ( $author )
- $title = $author->display_name;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If we're on a post type archive.
+ } elseif ( is_post_type_archive() ) {
+ $title['title'] = post_type_archive_title( '', false );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Post type archives with has_archive should override terms.
- if ( is_post_type_archive() && $post_type_object->has_archive )
- $title = post_type_archive_title( '', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If it's a date archive.
+ } elseif ( is_year() ) {
+ $title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If there's a month
- if ( is_archive() && !empty($m) ) {
- $my_year = substr($m, 0, 4);
- $my_month = $wp_locale->get_month(substr($m, 4, 2));
- $my_day = intval(substr($m, 6, 2));
- $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( is_month() ) {
+ $title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If there's a year
- if ( is_archive() && !empty($year) ) {
- $title = $year;
- if ( !empty($monthnum) )
- $title .= $t_sep . $wp_locale->get_month($monthnum);
- if ( !empty($day) )
- $title .= $t_sep . zeroise($day, 2);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( is_day() ) {
+ $title['title'] = get_the_date();
+
+ // If it's a 404 page.
+ } elseif ( is_404() ) {
+ $title['title'] = __( 'Page not found' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If it's a search
- if ( is_search() ) {
- /* translators: 1: separator, 2: search phrase */
- $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add a page number if necessary.
+ if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
+ $title['page'] = sprintf( __( 'Page %s' ), max( $paged, $page ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If it's a 404 page
- if ( is_404() ) {
- $title = __('Page not found');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Append the description or site title to give context.
+ if ( is_home() && is_front_page() ) {
+ $title['tagline'] = get_bloginfo( 'description', 'display' );
+ } else {
+ $title['site'] = get_bloginfo( 'name', 'display' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $prefix = '';
- if ( !empty($title) )
- $prefix = " $sep ";
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Filter the parts of the page title.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Filters the separator for the document title.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 4.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.4.0
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $title_array Parts of the page title.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $sep The separator. Default '-'.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $sep = apply_filters( 'document_title_separator', '-' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Determines position of the separator and direction of the breadcrumb
- if ( 'right' == $seplocation ) { // sep on right, so reverse the order
- $title_array = array_reverse( $title_array );
- $title = implode( " $sep ", $title_array ) . $prefix;
- } else {
- $title = $prefix . implode( " $sep ", $title_array );
- }
-
- if ( current_theme_supports( 'title-tag' ) && ! is_feed() ) {
- $title .= get_bloginfo( 'name', 'display' );
-
- $site_description = get_bloginfo( 'description', 'display' );
- if ( $site_description && ( is_home() || is_front_page() ) ) {
- $title .= " $sep $site_description";
- }
-
- if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
- $title .= " $sep " . sprintf( __( 'Page %s' ), max( $paged, $page ) );
- }
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Filter the text of the page title.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Filters the parts of the document title.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 2.0.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.4.0
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $title Page title.
- * @param string $sep Title separator.
- * @param string $seplocation Location of the separator (left or right).
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $title {
+ * The document title parts.
+ *
+ * @type string $title Title of the viewed page.
+ * @type string $page Optional. Page number if paginated.
+ * @type string $tagline Optional. Site description when on home page.
+ * @type string $site Optional. Site title when not on home page.
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $title = apply_filters( 'wp_title', $title, $sep, $seplocation );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $title = apply_filters( 'document_title_parts', $title );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Send it out
- if ( $display )
- echo $title;
- else
- return $title;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $title = implode( " $sep ", array_filter( $title ) );
+ $title = wptexturize( $title );
+ $title = convert_chars( $title );
+ $title = esc_html( $title );
+ $title = capital_P_dangit( $title );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $title;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Displays title tag with content.
+ *
+ * @ignore
+ * @since 4.1.0
+ * @since 4.4.0 Improved title output replaced `wp_title()`.
+ * @access private
+ */
+function _wp_render_title_tag() {
+ if ( ! current_theme_supports( 'title-tag' ) ) {
+ return;
+ }
+
+ echo '<title>' . wp_get_document_title() . '</title>' . "\n";
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Display or retrieve page title for post.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * This is optimized for single.php template file for displaying the post title.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1039,14 +996,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Display or retrieve page title for category archive.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * This is useful for category template file or files, because it is optimized
- * for category page title and with less overhead than {@link wp_title()}.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Useful for category template files for displaying the category page title.
+ * The prefix does not automatically place a space between the prefix, so if
+ * there should be a space, the parameter value will need to have it at the end.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * It does not support placing the separator after the title, but by leaving the
- * prefix parameter empty, you can set the title separator manually. The prefix
- * does not automatically place a space between the prefix, so if there should
- * be a space, the parameter value will need to have it at the end.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @since 0.71
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $prefix Optional. What to display before the title.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1060,11 +1013,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Display or retrieve page title for tag post archive.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Useful for tag template files for displaying the tag page title. It has less
- * overhead than {@link wp_title()}, because of its limited implementation.
- *
- * It does not support placing the separator after the title, but by leaving the
- * prefix parameter empty, you can set the title separator manually. The prefix
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Useful for tag template files for displaying the tag page title. The prefix
</ins><span class="cx" style="display: block; padding: 0 10px"> * does not automatically place a space between the prefix, so if there should
</span><span class="cx" style="display: block; padding: 0 10px"> * be a space, the parameter value will need to have it at the end.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1082,11 +1031,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Display or retrieve page title for taxonomy term archive.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Useful for taxonomy term template files for displaying the taxonomy term page title.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * It has less overhead than {@link wp_title()}, because of its limited implementation.
- *
- * It does not support placing the separator after the title, but by leaving the
- * prefix parameter empty, you can set the title separator manually. The prefix
- * does not automatically place a space between the prefix, so if there should
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The prefix does not automatically place a space between the prefix, so if there should
</ins><span class="cx" style="display: block; padding: 0 10px"> * be a space, the parameter value will need to have it at the end.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1144,15 +1089,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Display or retrieve page title for post archive based on date.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Useful for when the template only needs to display the month and year, if
- * either are available. Optimized for just this purpose, so if it is all that
- * is needed, should be better than {@link wp_title()}.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Useful for when the template only needs to display the month and year,
+ * if either are available. The prefix does not automatically place a space
+ * between the prefix, so if there should be a space, the parameter value
+ * will need to have it at the end.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * It does not support placing the separator after the title, but by leaving the
- * prefix parameter empty, you can set the title separator manually. The prefix
- * does not automatically place a space between the prefix, so if there should
- * be a space, the parameter value will need to have it at the end.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @since 0.71
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @global WP_Locale $wp_locale
</span></span></pre></div>
<a id="trunksrcwpincludesthemecompatheaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/theme-compat/header.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/theme-compat/header.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/theme-compat/header.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,7 +15,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <link rel="profile" href="http://gmpg.org/xfn/11" />
</span><span class="cx" style="display: block; padding: 0 10px"> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<title><?php echo wp_get_document_title(); ?></title>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
</span><span class="cx" style="display: block; padding: 0 10px"> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
</span></span></pre></div>
<a id="trunksrcwpincludesthemephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/theme.php 2015-10-20 16:12:21 UTC (rev 35293)
+++ trunk/src/wp-includes/theme.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1752,14 +1752,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !isset( $_wp_theme_features[$feature] ) )
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'title-tag' == $feature ) {
- // Don't confirm support unless called internally.
- $trace = debug_backtrace();
- if ( ! in_array( $trace[1]['function'], array( '_wp_render_title_tag', 'wp_title' ) ) ) {
- return false;
- }
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> // If no args passed then no extra checks need be performed
</span><span class="cx" style="display: block; padding: 0 10px"> if ( func_num_args() <= 1 )
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span></span></pre></div>
<a id="trunktestsphpunittestsgeneraldocumenttitlephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/general/document-title.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/general/document-title.php (rev 0)
+++ trunk/tests/phpunit/tests/general/document-title.php 2015-10-20 16:20:04 UTC (rev 35294)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,242 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * A set of unit tests for functions in wp-includes/general-template.php
+ *
+ * @group template
+ * @group document-title
+ */
+class Tests_Document_Title extends WP_UnitTestCase {
+
+ function setUp() {
+ parent::setUp();
+
+ add_action( 'after_setup_theme', array( $this, '_add_title_tag_support' ) );
+
+ $this->category_id = $this->factory->category->create( array(
+ 'name' => 'test_category',
+ ) );
+
+ $this->author_id = $this->factory->user->create( array(
+ 'role' => 'author',
+ 'user_login' => 'test_author',
+ 'description' => 'test_author',
+ ) );
+
+ $this->post_id = $this->factory->post->create( array(
+ 'post_author' => $this->author_id,
+ 'post_status' => 'publish',
+ 'post_content' => rand_str(),
+ 'post_title' => 'test_title',
+ 'post_type' => 'post',
+ 'post_date' => '2015-09-22 18:52:17',
+ 'category' => $this->category_id,
+ ) );
+
+ setup_postdata( get_post( $this->post_id ) );
+ }
+
+ function tearDown() {
+ wp_reset_postdata();
+ parent::tearDown();
+ }
+
+ function _add_title_tag_support() {
+ add_theme_support( 'title-tag' );
+ }
+
+ function test_short_circuiting_title() {
+ $this->go_to( '/' );
+
+ add_filter( 'title_tag_pre', array( $this, '_short_circuit_title' ) );
+
+ $this->expectOutputString( "<title>A Wild Title</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function _short_circuit_title( $title ) {
+ return 'A Wild Title';
+ }
+
+ function test_front_page_title() {
+ update_option( 'show_on_front', 'page' );
+ update_option( 'page_for_posts', $this->factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
+ update_option( 'page_on_front', $this->factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
+
+ $this->go_to( '/' );
+
+ $this->expectOutputString( "<title>front-page – Test Blog</title>\n" );
+ _wp_render_title_tag();
+
+ update_option( 'show_on_front', 'posts' );
+ }
+
+ function test_home_title() {
+ $this->go_to( '/' );
+
+ add_filter( 'title_tag_parts', array( $this, '_home_title_parts' ) );
+
+ $this->expectOutputString( "<title>Test Blog – Just another WordPress site</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function _home_title_parts( $parts ) {
+ $this->assertArrayHasKey( 'title', $parts );
+ $this->assertArrayHasKey( 'tagline', $parts );
+ $this->assertArrayNotHasKey( 'site', $parts );
+
+ return $parts;
+ }
+
+ function test_paged_title() {
+ $this->go_to( '?page=4' );
+
+ add_filter( 'title_tag_parts', array( $this, '_paged_title_parts' ) );
+
+ $this->expectOutputString( "<title>Test Blog – Page 4 – Just another WordPress site</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function _paged_title_parts( $parts ) {
+ $this->assertArrayHasKey( 'page', $parts );
+ $this->assertArrayHasKey( 'title', $parts );
+ $this->assertArrayHasKey( 'tagline', $parts );
+ $this->assertArrayNotHasKey( 'site', $parts );
+
+ return $parts;
+ }
+
+ function test_singular_title() {
+ $this->go_to( '?p=' . $this->post_id );
+
+ add_filter( 'title_tag_parts', array( $this, '_singular_title_parts' ) );
+
+ $this->expectOutputString( "<title>test_title – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function _singular_title_parts( $parts ) {
+ $this->assertArrayHasKey( 'site', $parts );
+ $this->assertArrayHasKey( 'title', $parts );
+ $this->assertArrayNotHasKey( 'tagline', $parts );
+
+ return $parts;
+ }
+
+ function test_category_title() {
+ $this->go_to( '?cat=' . $this->category_id );
+
+ $this->expectOutputString( "<title>test_category – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function test_search_title() {
+ $this->go_to( '?s=test_title' );
+
+ $this->expectOutputString( "<title>Search Results for “test_title” – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function test_author_title() {
+ $this->go_to( '?author=' . $this->author_id );
+
+ $this->expectOutputString( "<title>test_author – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function test_post_type_archive_title() {
+ register_post_type( 'cpt', array(
+ 'public' => true,
+ 'has_archive' => true,
+ 'labels' => array(
+ 'name' => 'test_cpt',
+ ),
+ ) );
+
+ $this->factory->post->create( array(
+ 'post_type' => 'cpt',
+ ) );
+
+ $this->go_to( '?post_type=cpt' );
+
+ $this->expectOutputString( "<title>test_cpt – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function test_year_title() {
+ $this->go_to( '?year=2015' );
+
+ $this->expectOutputString( "<title>2015 – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function test_month_title() {
+ $this->go_to( '?monthnum=09' );
+
+ $this->expectOutputString( "<title>September 2015 – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function test_day_title() {
+ $this->go_to( '?day=22' );
+
+ $this->expectOutputString( "<title>September 22, 2015 – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function test_404_title() {
+ $this->go_to( '?m=404' );
+
+ $this->expectOutputString( "<title>Page not found – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function test_paged_post_title() {
+ $this->go_to( '?paged=4&p=' . $this->post_id );
+
+ add_filter( 'title_tag_parts', array( $this, '_paged_post_title_parts' ) );
+
+ $this->expectOutputString( "<title>test_title – Page 4 – Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function _paged_post_title_parts( $parts ) {
+ $this->assertArrayHasKey( 'page', $parts );
+ $this->assertArrayHasKey( 'site', $parts );
+ $this->assertArrayHasKey( 'title', $parts );
+ $this->assertArrayNotHasKey( 'tagline', $parts );
+
+ return $parts;
+ }
+
+ function test_rearrange_title_parts() {
+ $this->go_to( '?p=' . $this->post_id );
+
+ add_filter( 'title_tag_parts', array( $this, '_rearrange_title_parts' ) );
+
+ $this->expectOutputString( "<title>Test Blog – test_title</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function _rearrange_title_parts( $parts ) {
+ $parts = array(
+ $parts['site'],
+ $parts['title'],
+ );
+
+ return $parts;
+ }
+
+ function test_change_title_separator() {
+ $this->go_to( '?p=' . $this->post_id );
+
+ add_filter( 'title_tag_separator', array( $this, '_change_title_separator' ) );
+
+ $this->expectOutputString( "<title>test_title %% Test Blog</title>\n" );
+ _wp_render_title_tag();
+ }
+
+ function _change_title_separator( $sep ) {
+ return '%%';
+ }
+}
</ins></span></pre>
</div>
</div>
</body>
</html>