mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-30 23:30:05 +00:00
Introduce a new means of outputting a <title> tag in the theme head. Requires a theme to add support by calling add_theme_support( 'title-tag' ). This is the first step in adding a more robust means of generating and outputting the title tag.
See #18548. Props obenland, chrisbliss18, joostdevalk. git-svn-id: https://develop.svn.wordpress.org/trunk@30074 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -730,6 +730,25 @@ function get_bloginfo( $show = '', $filter = 'raw' ) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display <title> tag with contents.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @access private
|
||||
*/
|
||||
function _wp_render_title_tag() {
|
||||
if ( ! current_theme_supports( 'title-tag' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This can only work internally on wp_head.
|
||||
if ( ! did_action( 'wp_head' ) && ! doing_action( 'wp_head' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Display or retrieve page title for all areas of blog.
|
||||
*
|
||||
@@ -753,7 +772,7 @@ function get_bloginfo( $show = '', $filter = 'raw' ) {
|
||||
* @return string|null String on retrieve, null when displaying.
|
||||
*/
|
||||
function wp_title($sep = '»', $display = true, $seplocation = '') {
|
||||
global $wp_locale;
|
||||
global $wp_locale, $page, $paged;
|
||||
|
||||
$m = get_query_var('m');
|
||||
$year = get_query_var('year');
|
||||
@@ -853,6 +872,19 @@ function wp_title($sep = '»', $display = true, $seplocation = '') {
|
||||
$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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the text of the page title.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user