Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r14955 r15222  
    6262 * functions.php file.
    6363 *
    64  * @uses add_theme_support() To add support for post thumbnails, navigation menus, and automatic feed links.
     64 * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
     65 * @uses register_nav_menus() To add support for navigation menus.
    6566 * @uses add_custom_background() To add support for a custom background.
    6667 * @uses add_editor_style() To style the visual editor.
     
    191192/* Shows the same border as on front end */
    192193#headimg {
    193     border-bottom: 1px solid #000000;
    194     border-top: 4px solid #000000;
    195 }
    196 
    197 /* If NO_HEADER_TEXT is false, you can style here the header text preview */
    198 #headimg #name {
    199 }
    200 
    201 #headimg #desc {
    202 }
     194    border-bottom: 1px solid #000;
     195    border-top: 4px solid #000;
     196}
     197/* If NO_HEADER_TEXT is false, you would style the text with these selectors:
     198    #headimg #name { }
     199    #headimg #desc { }
     200*/
    203201</style>
    204202<?php
     
    206204endif;
    207205
    208 if ( ! function_exists( 'twentyten_the_page_number' ) ) :
    209 /**
    210  * Prints the page number currently being browsed, with a vertical bar before it.
    211  *
    212  * Used in Twenty Ten's header.php to add the page number to the <title> HTML tag.
    213  *
    214  * @since Twenty Ten 1.0
    215  */
    216 function twentyten_the_page_number() {
    217     global $paged; // Contains page number.
    218     if ( $paged >= 2 )
    219         echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), $paged );
    220 }
    221 endif;
     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 */
     225function twentyten_filter_wp_title( $title, $separator ) {
     226    // The $paged global variable contains the page number of a listing of posts.
     227    // The $page global variable contains the page number of a single post that is paged.
     228    // We'll display whichever one applies, if we're not looking at the first page.
     229    global $paged, $page;
     230
     231    if ( is_search() ) {
     232        // If we're a search, let's start over:
     233        $title = sprintf( __( 'Search results for %s', 'twentyten' ), '"' . get_search_query() . '"' );
     234        // Add a page number if we're on page 2 or more:
     235        if ( $paged >= 2 )
     236            $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), $paged );
     237        // Add the site name to the end:
     238        $title .= " $separator " . get_bloginfo( 'name', 'display' );
     239        // We're done. Let's send the new title back to wp_title():
     240        return $title;
     241    }
     242
     243    // Otherwise, let's start by adding the site name to the end:
     244    $title .= get_bloginfo( 'name', 'display' );
     245
     246    // If we have a site description and we're on the home/front page, add the description:
     247    $site_description = get_bloginfo( 'description', 'display' );
     248    if ( $site_description && ( is_home() || is_front_page() ) )
     249        $title .= " $separator " . $site_description;
     250
     251    // Add a page number if necessary:
     252    if ( $paged >= 2 || $page >= 2 )
     253        $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
     254
     255    // Return the new title to wp_title():
     256    return $title;
     257}
     258add_filter( 'wp_title', 'twentyten_filter_wp_title', 10, 2 );
    222259
    223260/**
     
    250287
    251288/**
    252  * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis.
     289 * Returns a "Continue Reading" link for excerpts
     290 *
     291 * @since Twenty Ten 1.0
     292 * @return string "Continue Reading" link
     293 */
     294function twentyten_continue_reading_link() {
     295    return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
     296}
     297
     298/**
     299 * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
    253300 *
    254301 * To override this in a child theme, remove the filter and add your own
     
    259306 */
    260307function twentyten_auto_excerpt_more( $more ) {
    261     return ' &hellip;';
     308    return ' &hellip;' . twentyten_continue_reading_link();
    262309}
    263310add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
    264311
    265312/**
    266  * Adds a pretty "Continue Reading" link to post excerpts.
     313 * Adds a pretty "Continue Reading" link to custom post excerpts.
    267314 *
    268315 * To override this link in a child theme, remove the filter and add your own
     
    273320 */
    274321function twentyten_custom_excerpt_more( $output ) {
    275     return $output . ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
     322    if ( has_excerpt() && ! is_attachment() ) {
     323        $output .= twentyten_continue_reading_link();
     324    }
     325    return $output;
    276326}
    277327add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
     
    302352 */
    303353function twentyten_comment( $comment, $args, $depth ) {
    304     $GLOBALS['comment'] = $comment; ?>
    305     <?php if ( '' == $comment->comment_type ) : ?>
     354    $GLOBALS['comment'] = $comment;
     355    switch ( $comment->comment_type ) :
     356        case '' :
     357    ?>
    306358    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
    307359        <div id="comment-<?php comment_ID(); ?>">
     
    329381    </div><!-- #comment-##  -->
    330382
    331     <?php else : ?>
     383    <?php
     384            break;
     385        case 'pingback'  :
     386        case 'trackback' :
     387    ?>
    332388    <li class="post pingback">
    333389        <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'twentyten'), ' ' ); ?></p>
    334     <?php endif;
     390    <?php
     391            break;
     392    endswitch;
    335393}
    336394endif;
     
    436494 */
    437495function twentyten_posted_on() {
    438     printf( __( '<span %1$s>Posted on</span> %2$s by %3$s', 'twentyten' ),
    439         'class="meta-prep meta-prep-author"',
    440         sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">',
     496    printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
     497        'meta-prep meta-prep-author',
     498        sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
    441499            get_permalink(),
    442500            esc_attr( get_the_time() ),
    443501            get_the_date()
    444502        ),
    445         sprintf( '</span> <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
     503        sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
    446504            get_author_posts_url( get_the_author_meta( 'ID' ) ),
    447505            sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
Note: See TracChangeset for help on using the changeset viewer.