Make WordPress Core


Ignore:
Timestamp:
07/12/2010 07:40:21 PM (16 years ago)
Author:
nacin
Message:

Update to Twenty Ten 1.0.3 from theme dir. see #14284.

File:
1 edited

Legend:

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

    r15261 r15392  
    203203}
    204204endif;
    205 
    206 /**
    207  * Makes some changes to the <title> tag, by filtering the output of wp_title().
    208  *
    209  * If we have a site description and we're viewing the home page or a blog posts
    210  * page (when using a static front page), then we will add the site description.
    211  *
    212  * If we're viewing a search result, then we're going to recreate the title entirely.
    213  * We're going to add page numbers to all titles as well, to the middle of a search
    214  * result title and the end of all other titles.
    215  *
    216  * The site title also gets added to all titles.
    217  *
    218  * @since Twenty Ten 1.0
    219  *
    220  * @param string $title Title generated by wp_title()
    221  * @param string $separator The separator passed to wp_title(). Twenty Ten uses a
    222  *      vertical bar, "|", as a separator in header.php.
    223  * @return string The new title, ready for the <title> tag.
    224  */
    225 function twentyten_filter_wp_title( $title, $separator ) {
    226         // Don't affect wp_title() calls in feeds.
    227         if ( is_feed() )
    228                 return $title;
    229 
    230         // The $paged global variable contains the page number of a listing of posts.
    231         // The $page global variable contains the page number of a single post that is paged.
    232         // We'll display whichever one applies, if we're not looking at the first page.
    233         global $paged, $page;
    234 
    235         if ( is_search() ) {
    236                 // If we're a search, let's start over:
    237                 $title = sprintf( __( 'Search results for %s', 'twentyten' ), '"' . get_search_query() . '"' );
    238                 // Add a page number if we're on page 2 or more:
    239                 if ( $paged >= 2 )
    240                         $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), $paged );
    241                 // Add the site name to the end:
    242                 $title .= " $separator " . get_bloginfo( 'name', 'display' );
    243                 // We're done. Let's send the new title back to wp_title():
    244                 return $title;
    245         }
    246 
    247         // Otherwise, let's start by adding the site name to the end:
    248         $title .= get_bloginfo( 'name', 'display' );
    249 
    250         // If we have a site description and we're on the home/front page, add the description:
    251         $site_description = get_bloginfo( 'description', 'display' );
    252         if ( $site_description && ( is_home() || is_front_page() ) )
    253                 $title .= " $separator " . $site_description;
    254 
    255         // Add a page number if necessary:
    256         if ( $paged >= 2 || $page >= 2 )
    257                 $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
    258 
    259         // Return the new title to wp_title():
    260         return $title;
    261 }
    262 add_filter( 'wp_title', 'twentyten_filter_wp_title', 10, 2 );
    263205
    264206/**
Note: See TracChangeset for help on using the changeset viewer.