Make WordPress Core

Changeset 21276


Ignore:
Timestamp:
07/18/2012 05:07:15 PM (12 years ago)
Author:
lancewillett
Message:

Twenty Twelve: make title truly pluggable by moving output from header.php to a function. Props obenland, fixes #21233.

Location:
trunk/wp-content/themes/twentytwelve
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentytwelve/functions.php

    r21275 r21276  
    130130}
    131131add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' );
     132
     133/**
     134 * Creates a nicely formatted and more specific title element text
     135 * for output in head of document, based on current view.
     136 *
     137 * @since Twenty Twelve 1.0
     138 */
     139function twentytwelve_wp_title( $title, $sep ) {
     140    global $paged, $page;
     141
     142    // Add the blog name.
     143    $title .= get_bloginfo( 'name' );
     144
     145    // Add the blog description for the home/front page.
     146    $site_description = get_bloginfo( 'description', 'display' );
     147    if ( $site_description && ( is_home() || is_front_page() ) )
     148        $title = "$title $sep $site_description";
     149
     150    // Add a page number if necessary.
     151    if ( $paged >= 2 || $page >= 2 )
     152        $title =  "$title $sep " . sprintf( __( 'Page %s', 'twentytwelve' ), max( $paged, $page ) );
     153
     154    return $title;
     155}
     156add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );
    132157
    133158/**
  • trunk/wp-content/themes/twentytwelve/header.php

    r21261 r21276  
    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' ); ?>" />
Note: See TracChangeset for help on using the changeset viewer.