PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/WP960gs-master/loop-attachment.php

https://github.com/racs182/Cloud_hosting_pagoda
PHP | 99 lines | 88 code | 7 blank | 4 comment | 12 complexity | e9e83a0725baf2e3acf6538b418319ba MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, AGPL-1.0
  1. <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  2. <?php if ( ! empty( $post->post_parent ) ) : ?>
  3. <p class="page-title">
  4. <a href="<?php echo get_permalink( $post->post_parent ); ?>" title="<?php echo esc_attr( sprintf( __( 'Return to %s', 'twentyten' ), strip_tags( get_the_title( $post->post_parent ) ) ) ); ?>" rel="gallery">
  5. <?php printf( __( '<span class="meta-nav">&larr;</span> %s', 'twentyten' ), get_the_title( $post->post_parent ) ); ?>
  6. </a>
  7. </p>
  8. <?php endif; ?>
  9. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  10. <h2 class="entry-title"><?php the_title(); ?></h2>
  11. <div class="entry-meta">
  12. <?php
  13. printf( __( '<span class="%1$s">By</span> %2$s', 'twentyten' ),
  14. 'meta-prep meta-prep-author',
  15. sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
  16. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  17. esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
  18. get_the_author()
  19. )
  20. );
  21. ?>
  22. <span class="meta-sep">|</span>
  23. <?php
  24. printf( __( '<span class="%1$s">Published</span> %2$s', 'twentyten' ),
  25. 'meta-prep meta-prep-entry-date',
  26. sprintf( '<span class="entry-date"><abbr class="published" title="%1$s">%2$s</abbr></span>',
  27. esc_attr( get_the_time() ),
  28. get_the_date()
  29. )
  30. );
  31. if ( wp_attachment_is_image() ) {
  32. echo ' <span class="meta-sep">|</span> ';
  33. $metadata = wp_get_attachment_metadata();
  34. printf( __( 'Full size is %s pixels', 'twentyten' ),
  35. sprintf( '<a href="%1$s" title="%2$s">%3$s &times; %4$s</a>',
  36. wp_get_attachment_url(),
  37. esc_attr( __( 'Link to full-size image', 'twentyten' ) ),
  38. $metadata['width'],
  39. $metadata['height']
  40. )
  41. );
  42. }
  43. ?>
  44. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  45. </div><!-- .entry-meta -->
  46. <div class="entry-content">
  47. <div class="entry-attachment">
  48. <?php
  49. if ( wp_attachment_is_image() ) :
  50. $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' ) ) );
  51. foreach ( $attachments as $k => $attachment ) {
  52. if ( $attachment->ID == $post->ID )
  53. break;
  54. }
  55. $k++;
  56. // If there is more than 1 image attachment in a gallery
  57. if ( count( $attachments ) > 1 ) {
  58. if ( isset( $attachments[ $k ] ) )
  59. // get the URL of the next image attachment
  60. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  61. else
  62. // or get the URL of the first image attachment
  63. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  64. } else {
  65. // or, if there's only 1 image attachment, get the URL of the image
  66. $next_attachment_url = wp_get_attachment_url();
  67. }
  68. ?>
  69. <p class="attachment"><a href="<?php echo $next_attachment_url; ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php
  70. $attachment_width = apply_filters( 'twentyten_attachment_size', 900 );
  71. $attachment_height = apply_filters( 'twentyten_attachment_height', 900 );
  72. echo wp_get_attachment_image( $post->ID, array( $attachment_width, $attachment_height ) ); // filterable image width with, essentially, no limit for image height.
  73. ?></a></p>
  74. <div id="nav-below" class="navigation">
  75. <div class="nav-previous"><?php previous_image_link( false ); ?></div>
  76. <div class="nav-next"><?php next_image_link( false ); ?></div>
  77. </div><!-- #nav-below -->
  78. <?php else : ?>
  79. <a href="<?php echo wp_get_attachment_url(); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php echo basename( get_permalink() ); ?></a>
  80. <?php endif; ?>
  81. </div><!-- .entry-attachment -->
  82. <div class="entry-caption"><?php if ( !empty( $post->post_excerpt ) ) the_excerpt(); ?></div>
  83. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  84. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
  85. </div><!-- .entry-content -->
  86. <div class="entry-utility">
  87. <?php twentyten_posted_in(); ?>
  88. <?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?>
  89. </div><!-- .entry-utility -->
  90. </div><!-- #post-## -->
  91. <?php comments_template(); ?>
  92. <?php endwhile; // end of the loop. ?>