WordPress.org

Make WordPress Core

Ticket #21233: 21233.2.diff

File 21233.2.diff, 1.8 KB (added by obenland, 11 months ago)

Beef up the wp_title callback - and don't mess up ticket numbers

  • wp-content/themes/twentytwelve/header.php

     
    1313<head> 
    1414<meta charset="<?php bloginfo( 'charset' ); ?>" /> 
    1515<meta name="viewport" content="width=device-width, initial-scale=1.0" /> 
    16 <title><?php wp_title( '|', true, 'right' ); ?><?php echo bloginfo( 'name' ); ?></title> 
     16<title><?php wp_title( '|', true, 'right' ); ?></title> 
    1717<link rel="profile" href="http://gmpg.org/xfn/11" /> 
    1818<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> 
    1919<!--[if lt IE 9]> 
  • wp-content/themes/twentytwelve/functions.php

     
    131131add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' ); 
    132132 
    133133/** 
     134 * Returns the <title> tag based on what is being viewed. 
     135 * 
     136 * @since Twenty Twelve 1.0 
     137 */ 
     138function twentytwelve_wp_title( $title, $sep ) { 
     139        global $paged, $page; 
     140 
     141        // Add the blog name. 
     142        $title .= get_bloginfo( 'name' ); 
     143 
     144        // Add the blog description for the home/front page. 
     145        $site_description = get_bloginfo( 'description', 'display' ); 
     146        if ( $site_description && ( is_home() || is_front_page() ) ) 
     147                $title = "$title $sep $site_description"; 
     148 
     149        // Add a page number if necessary: 
     150        if ( $paged >= 2 || $page >= 2 ) 
     151                $title =  "$title $sep " . sprintf( __( 'Page %s', 'twentytwelve' ), max( $paged, $page ) ); 
     152         
     153        return $title; 
     154} 
     155add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 ); 
     156 
     157/** 
    134158 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. 
    135159 * 
    136160 * @since Twenty Twelve 1.0