Better title handling for WordPress 4.1. See #644.

This commit is contained in:
Philip Arthur Moore 2014-11-14 08:46:20 +07:00
parent 83792b8566
commit 648a5467e9
1 changed files with 13 additions and 10 deletions

View File

@ -35,14 +35,14 @@ function _s_body_classes( $classes ) {
} }
add_filter( 'body_class', '_s_body_classes' ); add_filter( 'body_class', '_s_body_classes' );
/** if ( ! function_exists( '_wp_render_title_tag' ) ) :
/**
* Filters wp_title to print a neat <title> tag based on what is being viewed. * Filters wp_title to print a neat <title> tag based on what is being viewed.
* *
* @param string $title Default title text for current view. * @param string $title Default title text for current view.
* @param string $sep Optional separator. * @param string $sep Optional separator.
* @return string The filtered title. * @return string The filtered title.
*/ */
if ( ! function_exists( '_wp_render_title_tag' ) ) :
function _s_wp_title( $title, $sep ) { function _s_wp_title( $title, $sep ) {
if ( is_feed() ) { if ( is_feed() ) {
return $title; return $title;
@ -69,10 +69,13 @@ if ( ! function_exists( '_wp_render_title_tag' ) ) :
add_filter( 'wp_title', '_s_wp_title', 10, 2 ); add_filter( 'wp_title', '_s_wp_title', 10, 2 );
endif; endif;
/**
* Title shiv for blogs older than WordPress 4.1
*/
if ( ! function_exists( '_wp_render_title_tag' ) ) : if ( ! function_exists( '_wp_render_title_tag' ) ) :
/**
* Title shim for sites older than WordPress 4.1.
*
* @link https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/
* @todo Remove this function when WordPress 4.4 is released.
*/
function _s_render_title() { function _s_render_title() {
echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n"; echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
} }