WordPress.org

Make WordPress Core

Changeset 14698


Ignore:
Timestamp:
05/16/10 20:53:36 (4 years ago)
Author:
nacin
Message:

Twenty Ten documentation and functions.php improvements. see #12695.

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

Legend:

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

    r14692 r14698  
    5959                    <div class="entry-content"> 
    6060                        <div class="entry-attachment"> 
    61 <?php if ( wp_attachment_is_image() ) : ?> 
    62                         <p class="attachment"><a href="<?php echo twentyten_get_next_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php 
     61<?php if ( wp_attachment_is_image() ) : 
     62    $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) ); 
     63    foreach ( $attachments as $k => $attachment ) { 
     64        if ( $attachment->ID == $post->ID ) 
     65            break; 
     66    } 
     67    $k++; 
     68    if ( isset( $attachments[ $k ] ) ) 
     69        $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 
     70    else 
     71        $next_attachment_url = get_permalink( $post->post_parent ); 
     72?> 
     73                        <p class="attachment"><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php 
    6374                            $attachment_size = apply_filters( 'twentyten_attachment_size', 900 ); 
    6475                            echo wp_get_attachment_image( $post->ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height. 
     
    8192 
    8293                    <div class="entry-utility"> 
    83                         <?php echo twentyten_posted_in(); ?> 
     94                        <?php twentyten_posted_in(); ?> 
    8495                        <?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?> 
    8596                    </div><!-- .entry-utility --> 
  • trunk/wp-content/themes/twentyten/functions.php

    r14692 r14698  
    1010 * for various features in WordPress, such as post thumbnails, navigation menus, and the like. 
    1111 * 
    12  * When using a child theme (see http://codex.wordpress.org/Theme_Development), you can 
    13  * override certain functions (those wrapped in a function_exists() call) by defining 
    14  * them first in your child theme's functions.php file. The child theme's functions.php 
    15  * file is included before the parent theme's file, so the child theme functions would 
    16  * be used. 
     12 * When using a child theme (see http://codex.wordpress.org/Theme_Development and 
     13 * http://codex.wordpress.org/Theme_Development), you can override certain functions 
     14 * (those wrapped in a function_exists() call) by defining them first in your child theme's 
     15 * functions.php file. The child theme's functions.php file is included before the parent 
     16 * theme's file, so the child theme functions would be used. 
    1717 * 
    1818 * Functions that are not pluggable (not wrapped in function_exists()) are instead attached 
     
    3636 * @package WordPress 
    3737 * @subpackage Twenty_Ten 
    38  * @since 3.0.0 
     38 * @since Twenty Ten 1.0 
    3939 */ 
    4040 
     
    7070 * @uses set_post_thumbnail_size() To set a custom post thumbnail size. 
    7171 * 
    72  * @since 3.0.0 
     72 * @since Twenty Ten 1.0 
    7373 */ 
    7474function twentyten_setup() { 
     
    183183 * Referenced via add_custom_image_header() in twentyten_setup(). 
    184184 * 
    185  * @since 3.0.0 
     185 * @since Twenty Ten 1.0 
    186186 */ 
    187187function twentyten_admin_header_style() { 
     
    206206 * Used in Twenty Ten's header.php to add the page number to the <title> HTML tag. 
    207207 * 
    208  * @since 3.0.0 
     208 * @since Twenty Ten 1.0 
    209209 */ 
    210210function twentyten_the_page_number() { 
     
    215215endif; 
    216216 
    217 if ( ! function_exists( 'twentyten_page_menu_args' ) ) : 
    218217/** 
    219218 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. 
    220  */ 
    221 function twentyten_page_menu_args($args) { 
     219 * 
     220 * To override this in a child theme, remove the filter and optionally add 
     221 * your own function tied to the wp_page_menu_args filter hook. 
     222 * 
     223 * @since Twenty Ten 1.0 
     224 */ 
     225function twentyten_page_menu_args( $args ) { 
    222226    $args['show_home'] = true; 
    223227    return $args; 
    224228} 
    225 add_filter('wp_page_menu_args', 'twentyten_page_menu_args'); 
    226 endif; 
     229add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' ); 
    227230 
    228231/** 
     
    232235 * function tied to the excerpt_length filter hook. 
    233236 * 
     237 * @since Twenty Ten 1.0 
    234238 * @return int 
    235239 */ 
     
    245249 * function tied to the excerpt_more filter hook. 
    246250 * 
    247  * @since 3.0.0 
     251 * @since Twenty Ten 1.0 
    248252 * @return string A pretty 'Continue reading' link. 
    249253 */ 
     
    258262 * Galleries are styled by the theme in Twenty Ten's style.css. 
    259263 * 
     264 * @since Twenty Ten 1.0 
    260265 * @return string The gallery style filter, with the styles themselves removed. 
    261266 */ 
     
    274279 * Used as a callback by wp_list_comments() for displaying the comments. 
    275280 * 
    276  * @since 3.0.0 
     281 * @since Twenty Ten 1.0 
    277282 */ 
    278283function twentyten_comment( $comment, $args, $depth ) { 
     
    316321 * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own 
    317322 * function tied to the init hook. 
     323 * 
     324 * @since Twenty Ten 1.0 
    318325 * @uses register_sidebar 
    319326 */ 
     
    385392    ) ); 
    386393} 
    387 add_action( 'init', 'twentyten_widgets_init' ); 
     394/** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */ 
     395add_action( 'widgets_init', 'twentyten_widgets_init' ); 
    388396 
    389397/** 
    390398 * Removes the default styles that are packaged with the Recent Comments widget. 
     399 * 
     400 * To override this in a child theme, remove the filter and optionally add your own 
     401 * function tied to the widgets_init action hook. 
     402 * 
     403 * @since Twenty Ten 1.0 
    391404 */ 
    392405function twentyten_remove_recent_comments_style() { 
     
    396409add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' ); 
    397410 
    398 /** 
    399  * Get the URL of the next image in a gallery for attachment pages 
    400  */ 
    401 function twentyten_get_next_attachment_url() { 
    402     global $post; 
    403     $post = get_post( $post ); 
    404     $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) ); 
    405   
    406     foreach ( $attachments as $k => $attachment ) { 
    407         if ( $attachment->ID == $post->ID ) 
    408             break; 
    409     } 
    410     $k++; 
    411     if ( isset( $attachments[ $k ] ) ) 
    412         return get_attachment_link( $attachments[ $k ]->ID ); 
    413     else 
    414         return get_permalink( $post->post_parent ); 
    415 } 
    416  
    417 /** 
    418  * Returns HTML with meta information for the current post—date/time and author. 
     411if ( ! function_exists( 'twentyten_posted_on' ) ) : 
     412/** 
     413 * Prints HTML with meta information for the current post—date/time and author. 
     414 * 
     415 * @since Twenty Ten 1.0 
    419416 */ 
    420417function twentyten_posted_on() { 
    421     return sprintf( __( '<span %1$s>Posted on</span> %2$s by %3$s', 'twentyten' ), 
     418    printf( __( '<span %1$s>Posted on</span> %2$s by %3$s', 'twentyten' ), 
    422419        'class="meta-prep meta-prep-author"', 
    423420        sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">', 
     
    434431     
    435432} 
    436  
    437 /** 
    438  * Returns HTML with meta information for the current post—category, tags and permalink 
    439  */ 
    440  
     433endif; 
     434 
     435if ( ! function_exists( 'twentyten_posted_in' ) ) : 
     436/** 
     437 * Prints HTML with meta information for the current post (category, tags and permalink). 
     438 * 
     439 * @since Twenty Ten 1.0 
     440 */ 
    441441function twentyten_posted_in() { 
    442     $tag_list = get_the_tag_list( '', ', ', '' ); 
     442    // Retrieves tag list of current post, separated by commas. 
     443    $tag_list = get_the_tag_list( '', ', ' ); 
    443444    if ( $tag_list ) { 
    444         $utility_text = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' ); 
     445        $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' ); 
    445446    } else { 
    446         $utility_text = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' ); 
     447        $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' ); 
    447448    } 
    448     return sprintf( 
    449         $utility_text, 
     449    // Prints the string, replacing the placeholders. 
     450    printf( 
     451        $posted_in, 
    450452        get_the_category_list( ', ' ), 
    451453        $tag_list, 
    452454        get_permalink(), 
    453         the_title_attribute( 'echo=0' ), 
    454         get_post_comments_feed_link() 
     455        the_title_attribute( 'echo=0' ) 
    455456    );   
    456457} 
     458endif; 
  • trunk/wp-content/themes/twentyten/loop.php

    r14692 r14698  
    4242 
    4343            <div class="entry-meta"> 
    44                 <?php echo twentyten_posted_on(); ?> 
     44                <?php twentyten_posted_on(); ?> 
    4545            </div><!-- .entry-meta --> 
    4646 
     
    8585 
    8686            <div class="entry-utility"> 
    87                 <?php echo twentyten_posted_on(); ?> 
     87                <?php twentyten_posted_on(); ?> 
    8888                <span class="meta-sep">|</span> 
    8989                <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> 
     
    9898 
    9999            <div class="entry-meta"> 
    100                 <?php echo twentyten_posted_on(); ?> 
     100                <?php twentyten_posted_on(); ?> 
    101101            </div><!-- .entry-meta --> 
    102102 
  • trunk/wp-content/themes/twentyten/single.php

    r14692 r14698  
    2525 
    2626                    <div class="entry-meta"> 
    27                         <?php echo twentyten_posted_on(); ?> 
     27                        <?php twentyten_posted_on(); ?> 
    2828                    </div><!-- .entry-meta --> 
    2929 
     
    5151 
    5252                    <div class="entry-utility"> 
    53                         <?php echo twentyten_posted_in(); ?> 
     53                        <?php twentyten_posted_in(); ?> 
    5454                        <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?> 
    5555                    </div><!-- .entry-utility --> 
Note: See TracChangeset for help on using the changeset viewer.