Make WordPress Core


Ignore:
Timestamp:
08/14/2013 04:38:01 PM (13 years ago)
Author:
lancewillett
Message:

Twenty Fourteen: first pass at matching code standards achieved with Twenty Thirteen development. See #24858, props obenland.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/image.php

    r24832 r25021  
    1010?>
    1111
    12 <div id="primary" class="content-area image-attachment">
     12<section id="primary" class="content-area image-attachment">
    1313        <div id="content" class="site-content full-width" role="main">
    1414
    … …  
    1717                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    1818                        <header class="entry-header">
    19                                 <h1 class="entry-title"><?php the_title(); ?></h1>
     19                                <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    2020
    2121                                <div class="entry-meta">
    … …  
    3232
    3333                        <div class="entry-content">
    34 
    3534                                <div class="entry-attachment">
    3635                                        <div class="attachment">
    37                                                 <?php
    38                                                         /**
    39                                                          * Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
    40                                                          * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
    41                                                          */
    42                                                         $attachments = array_values( get_children( array(
    43                                                                 'post_parent'    => $post->post_parent,
    44                                                                 'post_status'    => 'inherit',
    45                                                                 'post_type'      => 'attachment',
    46                                                                 'post_mime_type' => 'image',
    47                                                                 'order'          => 'ASC',
    48                                                                 'orderby'        => 'menu_order ID'
    49                                                         ) ) );
    50                                                         foreach ( $attachments as $k => $attachment ) {
    51                                                                 if ( $attachment->ID == $post->ID )
    52                                                                         break;
    53                                                         }
    54                                                         $k++;
    55                                                         // If there is more than 1 attachment in a gallery
    56                                                         if ( count( $attachments ) > 1 ) {
    57                                                                 if ( isset( $attachments[ $k ] ) )
    58                                                                         // get the URL of the next image attachment
    59                                                                         $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
    60                                                                 else
    61                                                                         // or get the URL of the first image attachment
    62                                                                         $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
    63                                                         } else {
    64                                                                 // or, if there's only 1 image, get the URL of the image
    65                                                                 $next_attachment_url = wp_get_attachment_url();
    66                                                         }
    67                                                 ?>
    68 
    69                                                 <a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
    70                                                         $attachment_size = apply_filters( 'twentyfourteen_attachment_size', array( 1200, 1200 ) ); // Filterable image size.
    71                                                         echo wp_get_attachment_image( $post->ID, $attachment_size );
    72                                                 ?></a>
     36                                                <?php twentyfourteen_the_attached_image(); ?>
    7337                                        </div><!-- .attachment -->
    7438
    75                                         <?php if ( ! empty( $post->post_excerpt ) ) : ?>
     39                                        <?php if ( has_excerpt() ) : ?>
    7640                                        <div class="entry-caption">
    7741                                                <?php the_excerpt(); ?>
    … …  
    8044                                </div><!-- .entry-attachment -->
    8145
    82                                 <?php the_content(); ?>
    8346                                <?php
     47                                        the_content();
    8448                                        wp_link_pages( array(
    8549                                                'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>',
    8650                                                'after'       => '</div>',
    8751                                                'link_before' => '<span>',
    88                                                 'link_after'  => '</span>'
     52                                                'link_after'  => '</span>',
    8953                                        ) );
    9054                                ?>
    … …  
    9256
    9357                        <footer class="entry-meta">
    94                                 <?php if ( comments_open() && pings_open() ) : // Comments and trackbacks open ?>
    95                                         <?php printf( __( '<a class="comment-link" href="#respond" title="Post a comment">Post a comment</a> or leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'twentyfourteen' ), get_trackback_url() ); ?>
    96                                 <?php elseif ( ! comments_open() && pings_open() ) : // Only trackbacks open ?>
    97                                         <?php printf( __( 'Comments are closed, but you can leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'twentyfourteen' ), get_trackback_url() ); ?>
    98                                 <?php elseif ( comments_open() && ! pings_open() ) : // Only comments open ?>
    99                                         <?php _e( 'Trackbacks are closed, but you can <a class="comment-link" href="#respond" title="Post a comment">post a comment</a>.', 'twentyfourteen' ); ?>
    100                                 <?php elseif ( ! comments_open() && ! pings_open() ) : // Comments and trackbacks closed ?>
    101                                         <?php _e( 'Both comments and trackbacks are currently closed.', 'twentyfourteen' ); ?>
    102                                 <?php endif; ?>
     58                                <?php
     59                                        if ( comments_open() && pings_open() ) : // Comments and trackbacks open
     60                                                printf( __( '<a class="comment-link" href="#respond" title="Post a comment">Post a comment</a> or leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'twentyfourteen' ), get_trackback_url() );
     61                                        elseif ( ! comments_open() && pings_open() ) : // Only trackbacks open
     62                                                printf( __( 'Comments are closed, but you can leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'twentyfourteen' ), get_trackback_url() );
     63                                        elseif ( comments_open() && ! pings_open() ) : // Only comments open
     64                                                _e( 'Trackbacks are closed, but you can <a class="comment-link" href="#respond" title="Post a comment">post a comment</a>.', 'twentyfourteen' );
     65                                        elseif ( ! comments_open() && ! pings_open() ) : // Comments and trackbacks closed
     66                                                _e( 'Both comments and trackbacks are currently closed.', 'twentyfourteen' );
     67                                        endif;
     68                                ?>
    10369                        </footer><!-- .entry-meta -->
    104                 </article><!-- #post-<?php the_ID(); ?> -->
     70                </article><!-- #post-## -->
    10571
    10672                <nav id="image-navigation" class="site-navigation">
    … …  
    11379        <?php endwhile; // end of the loop. ?>
    11480
    115         </div><!-- #content .site-content -->
    116 </div><!-- #primary .content-area .image-attachment -->
     81        </div><!-- #content -->
     82</section><!-- #primary -->
    11783
    118 <?php get_sidebar(); ?>
    119 
    120 <?php get_footer(); ?>
     84<?php
     85get_sidebar();
     86get_footer();
Note: See TracChangeset for help on using the changeset viewer.