Make WordPress Core


Ignore:
Timestamp:
06/11/2011 05:07:18 AM (15 years ago)
Author:
dd32
Message:

Showcase template cleanup. See #17748

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyeleven/showcase.php

    r18266 r18269  
    7979                                        /**
    8080                                         * We're going to add a class to our featured post for featured images
    81                                          * by default it'll have no class though.
    82                                          */
    83                                         $feature_class = '';
     81                                         * by default it'll have the feature-text class.
     82                                         */
     83                                        $feature_class = 'feature-text';
    8484
    8585                                        if ( has_post_thumbnail() ) {
     
    9595                                                        $feature_class = 'feature-image large';
    9696                                                }
    97                                         } else {
    98                                                 $feature_class = 'feature-text';
    9997                                        }
    100                                 ?>
    101 
    102                                 <?php if ( has_post_thumbnail() ) : ?>
    103                                 <section class="featured-post <?php echo $feature_class; ?>" id="featured-post-<?php echo $counter_slider; ?>">
    104                                 <?php else : ?>
    105                                 <section class="featured-post" id="featured-post-<?php echo $counter_slider; ?>">
    106                                 <?php endif; ?>
    107 
    108                                         <?php
    109                                                 /**
    110                                                  * If the thumbnail is as big as the header image
    111                                                  * make it a large featured post, otherwise render it small
    112                                                  */
    113                                                 if ( has_post_thumbnail() ) {
    114                                                         if ( $image[1] >= HEADER_IMAGE_WIDTH ) { ?>
    115                                                                 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"> <?php the_post_thumbnail( 'large-feature' ); ?></a>
    116                                                         <?php } else { ?>
    117                                                                 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail( 'small-feature' ); ?></a>
    118                                                         <?php }
    119                                                 }
    12098                                        ?>
    121                                         <?php get_template_part( 'content', 'featured' ); ?>
    122                                 </section>
     99
     100                                        <section class="featured-post <?php echo $feature_class; ?>" id="featured-post-<?php echo $counter_slider; ?>">
     101       
     102                                                <?php
     103                                                        /**
     104                                                         * If the thumbnail is as big as the header image
     105                                                         * make it a large featured post, otherwise render it small
     106                                                         */
     107                                                        if ( has_post_thumbnail() ) {
     108                                                                if ( $image[1] >= HEADER_IMAGE_WIDTH )
     109                                                                        $thumbnail_size = 'large-feature';
     110                                                                else
     111                                                                        $thumbnail_size = 'small-feature';
     112                                                                ?>
     113                                                                <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail( $thumbnail_size ); ?></a>
     114                                                                <?php
     115                                                        }
     116                                                ?>
     117                                                <?php get_template_part( 'content', 'featured' ); ?>
     118                                        </section>
    123119                                <?php endwhile; ?>
    124120
     
    130126                                        <ul>
    131127                                        <?php
    132                                                 /**
    133                                                  * We need to query the same set of posts again
    134                                                  * to populate the navigation dots
    135                                                  */
    136                                         $featured->query( $featured_args );
    137128
    138129                                                // Reset the counter so that we end up with matching elements
     
    145136                                        while ( $featured->have_posts() ) : $featured->the_post();
    146137                                                $counter_slider++;
    147                                     ?>
    148                                                 <li><a href="#featured-post-<?php echo $counter_slider; ?>" title="<?php printf( esc_attr__( 'Featuring: %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" <?php
    149                                                 if ( 1 == $counter_slider ) :
    150                                                         echo 'class="active"';
    151                                                 endif;
    152                                                 ?>></a></li>
     138                                                        if ( 1 == $counter_slider )
     139                                                                $class = 'class="active"';
     140                                                        else
     141                                                                $class = '';
     142                                        ?>
     143                                                <li><a href="#featured-post-<?php echo $counter_slider; ?>" title="<?php printf( esc_attr__( 'Featuring: %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" <?php echo $class; ?>></a></li>
    153144                                        <?php endwhile; ?>
    154145                                        </ul>
     
    178169                                                'no_found_rows' => true,
    179170                                        );
     171
    180172                                        // Our new query for the Recent Posts section.
    181173                                        $recent = new WP_Query( $recent_args );
    182                                         $counter = 0;
    183 
    184                                         while ( $recent->have_posts() ) : $recent->the_post();
     174
     175                                        // The first Recent post is displayed normally
     176                                        if ( $recent->have_posts() ) : $recent->the_post();
     177
    185178                                                // Set $more to 0 in order to only get the first part of the post.
    186179                                                global $more;
    187180                                                $more = 0;
    188                                                 $counter++;
    189 
    190                                                 if ( 1 == $counter ) :
    191                                                         get_template_part( 'content', get_post_format() );
    192                                                         echo '<ol class="other-recent-posts">';
    193 
    194                                                 else : ?>
    195                                                         <li class="entry-title">
    196                                                                 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
    197                                                                 <span class="comments-link">
    198                                                                         <?php comments_popup_link( __( '<span class="leave-reply">Leave a reply</span>', 'twentyeleven' ), __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?>
    199                                                                 </span>
    200                                                         </li>
    201 
    202                                                 <?php endif;
     181
     182                                                get_template_part( 'content', get_post_format() );
     183
     184                                                echo '<ol class="other-recent-posts">';
     185
     186                                        endif;
     187
     188                                        // For all other recent posts, just display the title and comment status.
     189                                        while ( $recent->have_posts() ) : $recent->the_post(); ?>
     190
     191                                                <li class="entry-title">
     192                                                        <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
     193                                                        <span class="comments-link">
     194                                                                <?php comments_popup_link( __( '<span class="leave-reply">Leave a reply</span>', 'twentyeleven' ), __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?>
     195                                                        </span>
     196                                                </li>
     197
     198                                        <?php
    203199                                        endwhile;
     200
     201                                        // If we had some posts, close the <ol>
     202                                        if ( $recent->post_count > 0 )
     203                                                echo '</ol>';
    204204                                        ?>
    205 
    206                                         </ol>
    207205                                </section><!-- .recent-posts -->
    208206
Note: See TracChangeset for help on using the changeset viewer.