[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * The loop that displays an attachment 4 * 5 * The loop displays the posts and the post content. See 6 * https://developer.wordpress.org/themes/basics/the-loop/ to understand it and 7 * https://developer.wordpress.org/themes/basics/template-tags/ to understand 8 * the tags used in it. 9 * 10 * This can be overridden in child themes with loop-attachment.php. 11 * 12 * @package WordPress 13 * @subpackage Twenty_Ten 14 * @since Twenty Ten 1.2 15 */ 16 ?> 17 18 <?php 19 if ( have_posts() ) { 20 while ( have_posts() ) : 21 the_post(); 22 ?> 23 24 <?php 25 if ( ! empty( $post->post_parent ) ) : 26 /* translators: %s: Post title. */ 27 $post_title = sprintf( __( 'Go to %s', 'twentyten' ), strip_tags( get_the_title( $post->post_parent ) ) ); 28 ?> 29 <p class="page-title"><a href="<?php echo esc_url( get_permalink( $post->post_parent ) ); ?>" title="<?php echo esc_attr( $post_title ); ?>" rel="gallery"> 30 <?php 31 /* translators: %s: Title of parent post. */ 32 printf( __( '<span class="meta-nav">←</span> %s', 'twentyten' ), get_the_title( $post->post_parent ) ); 33 ?> 34 </a></p> 35 <?php endif; ?> 36 37 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 38 <h2 class="entry-title"><?php the_title(); ?></h2> 39 40 <div class="entry-meta"> 41 <?php 42 printf( 43 /* translators: %s: Author display name. */ 44 __( '<span class="%1$s">By</span> %2$s', 'twentyten' ), 45 'meta-prep meta-prep-author', 46 sprintf( 47 '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', 48 esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), 49 /* translators: %s: Author display name. */ 50 esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ), 51 get_the_author() 52 ) 53 ); 54 ?> 55 <span class="meta-sep">|</span> 56 <?php 57 printf( 58 /* translators: 1: CSS classes, 2: Date. */ 59 __( '<span class="%1$s">Published</span> %2$s', 'twentyten' ), 60 'meta-prep meta-prep-entry-date', 61 sprintf( 62 '<span class="entry-date"><abbr class="published" title="%1$s">%2$s</abbr></span>', 63 esc_attr( get_the_time() ), 64 get_the_date() 65 ) 66 ); 67 if ( wp_attachment_is_image() ) { 68 echo ' <span class="meta-sep">|</span> '; 69 $metadata = wp_get_attachment_metadata(); 70 printf( 71 /* translators: %s: Image dimensions. */ 72 __( 'Full size is %s pixels', 'twentyten' ), 73 sprintf( 74 '<a href="%1$s" title="%2$s">%3$s × %4$s</a>', 75 esc_url( wp_get_attachment_url() ), 76 esc_attr( __( 'Link to full-size image', 'twentyten' ) ), 77 $metadata['width'], 78 $metadata['height'] 79 ) 80 ); 81 } 82 ?> 83 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?> 84 </div><!-- .entry-meta --> 85 86 <div class="entry-content"> 87 <div class="entry-attachment"> 88 <?php 89 if ( wp_attachment_is_image() ) : 90 $attachments = array_values( 91 get_children( 92 array( 93 'post_parent' => $post->post_parent, 94 'post_status' => 'inherit', 95 'post_type' => 'attachment', 96 'post_mime_type' => 'image', 97 'order' => 'ASC', 98 'orderby' => 'menu_order ID', 99 ) 100 ) 101 ); 102 foreach ( $attachments as $k => $attachment ) { 103 if ( $attachment->ID === $post->ID ) { 104 break; 105 } 106 } 107 108 // If there is more than 1 image attachment in a gallery... 109 if ( count( $attachments ) > 1 ) { 110 ++$k; 111 if ( isset( $attachments[ $k ] ) ) { 112 // ...get the URL of the next image attachment. 113 $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 114 } else { 115 // ...or get the URL of the first image attachment. 116 $next_attachment_url = get_attachment_link( $attachments[0]->ID ); 117 } 118 } else { 119 // Or, if there's only 1 image attachment, get the URL of the image. 120 $next_attachment_url = wp_get_attachment_url(); 121 } 122 ?> 123 <p class="attachment"><a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"> 124 <?php 125 /** 126 * Filters the Twenty Ten default attachment width. 127 * 128 * @since Twenty Ten 1.0 129 * 130 * @param int The default attachment width in pixels. Default 900. 131 */ 132 $attachment_width = apply_filters( 'twentyten_attachment_size', 900 ); 133 /** 134 * Filters the Twenty Ten default attachment height. 135 * 136 * @since Twenty Ten 1.0 137 * 138 * @param int The default attachment height in pixels. Default 900. 139 */ 140 $attachment_height = apply_filters( 'twentyten_attachment_height', 900 ); 141 // Filterable image width with, essentially, no limit for image height. 142 echo wp_get_attachment_image( $post->ID, array( $attachment_width, $attachment_height ) ); 143 ?> 144 </a></p> 145 146 <div id="nav-below" class="navigation"> 147 <div class="nav-previous"><?php previous_image_link( false ); ?></div> 148 <div class="nav-next"><?php next_image_link( false ); ?></div> 149 </div><!-- #nav-below --> 150 <?php else : ?> 151 <a href="<?php echo esc_url( wp_get_attachment_url() ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php echo esc_html( wp_basename( get_permalink() ) ); ?></a> 152 <?php endif; ?> 153 </div><!-- .entry-attachment --> 154 <div class="entry-caption"> 155 <?php 156 if ( ! empty( $post->post_excerpt ) ) { 157 the_excerpt(); 158 } 159 ?> 160 </div> 161 162 <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?> 163 <?php 164 wp_link_pages( 165 array( 166 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 167 'after' => '</div>', 168 ) 169 ); 170 ?> 171 172 </div><!-- .entry-content --> 173 174 <div class="entry-utility"> 175 <?php twentyten_posted_in(); ?> 176 <?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?> 177 </div><!-- .entry-utility --> 178 </div><!-- #post-<?php the_ID(); ?> --> 179 180 <?php comments_template(); ?> 181 182 <?php endwhile; 183 } // End of the loop. ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |