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 #18548.
Deprecates `wp_title()`.

Fixes #31078.



git-svn-id: https://develop.svn.wordpress.org/trunk@35294 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Konstantin Obenland
2015-10-20 16:20:04 +00:00
parent 1940317385
commit d625bd2428
12 changed files with 557 additions and 229 deletions
+21 -21
View File
@@ -91,53 +91,53 @@ function get_default_feed() {
* Retrieve the blog title for the feed title.
*
* @since 2.2.0
* @since 4.4.0 Deprecated argument.
*
* @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.
* @param string $deprecated Deprecated.
* @return string The document title.
*/
function get_wp_title_rss( $sep = '»' ) {
$title = wp_title( $sep, false );
if ( is_wp_error( $title ) ) {
return $title->get_error_message();
}
if ( $title && $sep && ' ' !== substr( $title, 0, 1 ) ) {
$title = " $sep " . $title;
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>' ) );
}
/**
* Filter the blog title for use as the feed title.
*
* @since 2.2.0
* @since 4.4.0 Deprecated argument.
*
* @param string $title The current blog title.
* @param string $sep Separator used by wp_title().
* @param string $title The current blog title.
* @param string $deprecated Deprecated.
*/
$title = apply_filters( 'get_wp_title_rss', $title, $sep );
return $title;
return apply_filters( 'get_wp_title_rss', wp_get_document_title(), $deprecated );
}
/**
* Display the blog title for display of the feed title.
*
* @since 2.2.0
* @see wp_title() $sep parameter usage.
* @since 4.4.0 Deprecated argument.
*
* @param string $sep Optional.
* @param string $deprecated Optional.
*/
function wp_title_rss( $sep = '&#187;' ) {
function wp_title_rss( $deprecated = '&#8211;' ) {
if ( '&#8211;' !== $deprecated ) {
_deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), '<code>document_title_separator</code>' ) );
}
/**
* Filter the blog title for display of the feed title.
*
* @since 2.2.0
* @since 4.4.0 Deprecated argument.
*
* @see get_wp_title_rss()
*
* @param string $wp_title The current blog title.
* @param string $sep Separator used by wp_title().
* @param string $wp_title_rss The current blog title.
* @param string $deprecated Deprecated.
*/
echo apply_filters( 'wp_title_rss', get_wp_title_rss( $sep ), $sep );
echo apply_filters( 'wp_title_rss', get_wp_title_rss(), $deprecated );
}
/**