Make WordPress Core

Changeset 23719


Ignore:
Timestamp:
03/15/2013 06:16:47 PM (13 years ago)
Author:
lancewillett
Message:

Twenty Ten: use a filter to modify the output of wp_title(). Props obenland, closes #23774.

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

Legend:

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

    r23477 r23719  
    515515}
    516516endif;
     517
     518/**
     519 * Creates a nicely formatted and more specific title element text
     520 * for output in head of document, based on current view.
     521 *
     522 * @since Twenty Ten 1.6
     523 *
     524 * @param string $title Default title text for current view.
     525 * @param string $sep Optional separator.
     526 * @return string Filtered title.
     527 */
     528function twentyten_wp_title( $title, $sep ) {
     529    global $paged, $page;
     530
     531    if ( is_feed() )
     532        return $title;
     533
     534    // Add the site name.
     535    $title .= get_bloginfo( 'name' );
     536
     537    // Add the site description for the home/front page.
     538    $site_description = get_bloginfo( 'description', 'display' );
     539    if ( $site_description && ( is_home() || is_front_page() ) )
     540        $title = "$title $sep $site_description";
     541
     542    // Add a page number if necessary.
     543    if ( $paged >= 2 || $page >= 2 )
     544        $title = "$title $sep " . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
     545
     546    return $title;
     547}
     548add_filter( 'wp_title', 'twentyten_wp_title', 10, 2 );
  • trunk/wp-content/themes/twentyten/header.php

    r20983 r23719  
    1313<head>
    1414<meta charset="<?php bloginfo( 'charset' ); ?>" />
    15 <title><?php
    16     /*
    17      * Print the <title> tag based on what is being viewed.
    18      */
    19     global $page, $paged;
    20 
    21     wp_title( '|', true, 'right' );
    22 
    23     // Add the blog name.
    24     bloginfo( 'name' );
    25 
    26     // Add the blog description for the home/front page.
    27     $site_description = get_bloginfo( 'description', 'display' );
    28     if ( $site_description && ( is_home() || is_front_page() ) )
    29         echo " | $site_description";
    30 
    31     // Add a page number if necessary:
    32     if ( $paged >= 2 || $page >= 2 )
    33         echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
    34 
    35     ?></title>
     15<title><?php wp_title( '|', true, 'right' ); ?></title>
    3616<link rel="profile" href="http://gmpg.org/xfn/11" />
    3717<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
Note: See TracChangeset for help on using the changeset viewer.