Make WordPress Core

Changeset 14541


Ignore:
Timestamp:
05/10/2010 07:06:22 PM (16 years ago)
Author:
nbachiyski
Message:

Clean up loop i18n. Props zeo, see #13198

  • Take out tags from strings
  • Extract two common and complicatd strings into functions
  • Whitespace
Location:
trunk/wp-content/themes/twentyten
Files:
4 edited

Legend:

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

    r14532 r14541  
    8181
    8282                                        <div class="entry-utility">
    83                                         <?php
    84                                                 $tag_list = get_the_tag_list();
    85                                                 if ( $tag_list ) {
    86                                                         $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' );
    87                                                 } else {
    88                                                         $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' );
    89                                                 }
    90                                                 printf(
    91                                                         $utility_text,
    92                                                         get_the_category_list( ', ' ),
    93                                                         $tag_list,
    94                                                         get_permalink(),
    95                                                         the_title_attribute( 'echo=0' ),
    96                                                         get_post_comments_feed_link()
    97                                                 );
    98                                         ?>
    99 <?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?>
     83                                                <?php echo twentyten_posted_in(); ?>
     84                                                <?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?>
    10085                                        </div><!-- .entry-utility -->
    10186                                </div><!-- #post-<?php the_ID(); ?> -->
  • trunk/wp-content/themes/twentyten/functions.php

    r14534 r14541  
    412412                return get_permalink( $post->post_parent );
    413413}
     414
     415/**
     416 * Returns HTML with meta information for the current post—date/time and author.
     417 */
     418function twentyten_posted_on() {
     419        return sprintf( __( '<span %1$s>Posted on</span> %2$s by %3$s', 'twentyten' ),
     420                'class="meta-prep meta-prep-author"',
     421                sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">',
     422                        get_permalink(),
     423                        esc_attr( get_the_time() ),
     424                        get_the_date()
     425                ),
     426                sprintf( '</span> <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
     427                        get_author_posts_url( get_the_author_meta( 'ID' ) ),
     428                        sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
     429                        get_the_author()
     430                )
     431        );
     432       
     433}
     434
     435/**
     436 * Returns HTML with meta information for the current post—category, tags and permalink
     437 */
     438
     439function twentyten_posted_in() {
     440        $tag_list = get_the_tag_list();
     441        if ( $tag_list ) {
     442                $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' );
     443        } else {
     444                $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' );
     445        }
     446        return sprintf(
     447                $utility_text,
     448                get_the_category_list( ', ' ),
     449                $tag_list,
     450                get_permalink(),
     451                the_title_attribute( 'echo=0' ),
     452                get_post_comments_feed_link()
     453        );     
     454}
  • trunk/wp-content/themes/twentyten/loop.php

    r14501 r14541  
    4242
    4343                        <div class="entry-meta">
    44                                 <?php
    45                                         printf( __( '<span class="meta-prep meta-prep-author">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'twentyten' ),
    46                                                 get_permalink(),
    47                                                 esc_attr( get_the_time() ),
    48                                                 get_the_date(),
    49                                                 get_author_posts_url( get_the_author_meta( 'ID' ) ),
    50                                                 sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
    51                                                 get_the_author()
    52                                         );
    53                                 ?>
     44                                <?php echo twentyten_posted_on(); ?>
    5445                        </div><!-- .entry-meta -->
    5546
    5647                        <div class="entry-content">
    5748                                <div class="gallery-thumb">
    58                                         <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php
    59                                         $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
    60                                         $total_images = count( $images );
    61                                         $image = array_shift( $images );
    62                                         echo wp_get_attachment_image( $image->ID, 'thumbnail' );
    63                                         ?></a>
     49<?php
     50        $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
     51        $total_images = count( $images );
     52        $image = array_shift( $images );
     53        $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
     54?>
     55                                        <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
    6456                                </div>
    6557                                <p><em><?php printf( __( 'This gallery contains <a %1$s>%2$s photos</a>.', 'twentyten' ),
     
    7365                        <div class="entry-utility">
    7466                                <a href="<?php echo get_term_link( _x('gallery', 'gallery category slug', 'twentyten'), 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
    75                                 <span class="meta-sep"> | </span>
     67                                <span class="meta-sep">|</span>
    7668                                <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    7769                                <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
     
    9385
    9486                        <div class="entry-utility">
    95                                 <?php
    96                                         printf( __( '<span class="meta-prep meta-prep-author">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'twentyten' ),
    97                                                 get_permalink(),
    98                                                 esc_attr( get_the_time() ),
    99                                                 get_the_date(),
    100                                                 get_author_posts_url( get_the_author_meta( 'ID' ) ),
    101                                                 sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
    102                                                 get_the_author()
    103                                         );
    104                                 ?>
    105                                 <span class="meta-sep"> | </span>
     87                                <?php echo twentyten_posted_on(); ?>
     88                                <span class="meta-sep">|</span>
    10689                                <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    10790                                <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
     
    11598
    11699                        <div class="entry-meta">
    117                                 <?php
    118                                         printf( __( '<span class="meta-prep meta-prep-author">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'twentyten' ),
    119                                                 get_permalink(),
    120                                                 esc_attr( get_the_time() ),
    121                                                 get_the_date(),
    122                                                 get_author_posts_url( get_the_author_meta( 'ID' ) ),
    123                                                 sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
    124                                                 get_the_author()
    125                                         );
    126                                 ?>
     100                                <?php echo twentyten_posted_on(); ?>
    127101                        </div><!-- .entry-meta -->
    128102
     
    139113
    140114                        <div class="entry-utility">
    141                                 <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e( 'Posted in ', 'twentyten' ); ?></span><?php the_category( ', ' ); ?></span>
    142                                 <span class="meta-sep"> | </span>
    143                                 <?php the_tags( '<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">' . __( 'Tagged ', 'twentyten' ) . '</span>', ', ', '<span class="meta-sep"> | </span>' ); ?>
     115                                <span class="cat-links">
     116                                        <span class="entry-utility-prep entry-utility-prep-cat-links">
     117                                        <?php
     118                                                printf( __('Posted in %s', 'twentyten' ), '</span> '.get_the_category_list( ', ' ) );
     119                                        ?>                                     
     120                                </span>
     121                                <span class="meta-sep">|</span>
     122                                <?php the_tags( '<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">' . __( 'Tagged ', 'twentyten' ) . '</span>', ', ', '<span class="meta-sep">|</span>' ); ?>
    144123                                <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    145124                                <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  • trunk/wp-content/themes/twentyten/single.php

    r14476 r14541  
    2525
    2626                                        <div class="entry-meta">
    27                                                 <span class="meta-prep meta-prep-author"><?php _e( 'Posted on ', 'twentyten' ); ?></span>
    28                                                 <a href="<?php the_permalink(); ?>" title="<?php the_time(); ?>" rel="bookmark"><span class="entry-date"><?php echo get_the_date(); ?></span></a>
    29                                                 <span class="meta-sep"><?php _e( ' by ', 'twentyten' ); ?></span>
    30                                                 <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
     27                                                <?php echo twentyten_posted_on(); ?>
    3128                                        </div><!-- .entry-meta -->
    3229
     
    5249
    5350                                        <div class="entry-utility">
    54                                         <?php
    55                                                 $tag_list = get_the_tag_list('', ', ');
    56                                                 if ( '' != $tag_list ) {
    57                                                         $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' );
    58                                                 } else {
    59                                                         $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' );
    60                                                 }
    61                                                 printf(
    62                                                         $utility_text,
    63                                                         get_the_category_list( ', ' ),
    64                                                         $tag_list,
    65                                                         get_permalink(),
    66                                                         the_title_attribute( 'echo=0' )
    67                                                 );
    68                                         ?>
    69 
    70 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
     51                                                <?php echo twentyten_posted_in(); ?>
     52                                                <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
    7153                                        </div><!-- .entry-utility -->
    7254                                </div><!-- #post-<?php the_ID(); ?> -->
Note: See TracChangeset for help on using the changeset viewer.