PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/themes/esquire/image.php

https://github.com/Bochet/festival_lgbt
PHP | 125 lines | 87 code | 9 blank | 29 comment | 10 complexity | b4378c1a370526402c23222559a4946b MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * The main template file.
  4. *
  5. * This is the most generic template file in a WordPress theme
  6. * and one of the two required files for a theme (the other being style.css).
  7. * It is used to display a page when nothing more specific matches a query.
  8. * E.g., it puts together the home page when no home.php file exists.
  9. * Learn more: http://codex.wordpress.org/Template_Hierarchy
  10. *
  11. * @package Esquire
  12. */
  13. get_header(); ?>
  14. <?php
  15. /* Queue the first post, that way we know
  16. * what date we're dealing with (if that is the case).
  17. *
  18. * We reset this later so we can run the loop
  19. * properly with a call to rewind_posts().
  20. */
  21. if ( have_posts() )
  22. the_post();
  23. ?>
  24. <?php if ( is_archive() ) : ?>
  25. <div id="header">
  26. <h2>
  27. <?php if ( is_day() ) : ?>
  28. <?php printf( __( 'Posted on %s &hellip;', 'esquire' ), '<span>' . get_the_date() . '</span>' ); ?>
  29. <?php elseif ( is_month() ) : ?>
  30. <?php printf( __( 'Posted in %s &hellip;', 'esquire' ), '<span>' . get_the_date( 'F Y' ) . '</span>' ); ?>
  31. <?php elseif ( is_year() ) : ?>
  32. <?php printf( __( 'Posted in %s &hellip;', 'esquire' ), '<span>' . get_the_date( 'Y' ) . '</span>' ); ?>
  33. <?php elseif( is_author() ) : ?>
  34. <?php printf( __( 'Posted by %s &hellip;', 'esquire' ), '<span>' . get_the_author() . '</span>' ); ?>
  35. <?php elseif ( is_category() ) : ?>
  36. <?php printf( __( 'Filed under %s &hellip;', 'esquire' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?>
  37. <?php elseif ( is_tag() ) : ?>
  38. <?php printf( __( 'Tagged with %s &hellip;', 'esquire' ), '<span>' . single_tag_title( '', false ) . '</span>' ); ?>
  39. <?php endif; ?>
  40. </h2>
  41. </div>
  42. <?php endif; ?>
  43. <?php if ( is_search() ) : ?>
  44. <div id="header">
  45. <h2>
  46. <?php printf( __( 'Matches for: &ldquo;%s&rdquo; &hellip;', 'esquire' ), '<span>' . get_search_query() . '</span>' ); ?>
  47. </h2>
  48. </div>
  49. <?php endif; ?>
  50. <?php
  51. /* Since we called the_post() above, we need to
  52. * rewind the loop back to the beginning that way
  53. * we can run the loop properly, in full.
  54. */
  55. rewind_posts();
  56. ?>
  57. <div id="posts">
  58. <div class="hentry image-attachment">
  59. <div class="postbody text">
  60. <h1><?php the_title(); ?></h1>
  61. <div class="content">
  62. <?php
  63. /**
  64. * 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,
  65. * 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
  66. */
  67. $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' ) ) );
  68. foreach ( $attachments as $k => $attachment ) {
  69. if ( $attachment->ID == $post->ID )
  70. break;
  71. }
  72. $k++;
  73. // If there is more than 1 attachment in a gallery
  74. if ( count( $attachments ) > 1 ) {
  75. if ( isset( $attachments[ $k ] ) )
  76. // get the URL of the next image attachment
  77. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
  78. else
  79. // or get the URL of the first image attachment
  80. $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
  81. } else {
  82. // or, if there's only 1 image, get the URL of the image
  83. $next_attachment_url = wp_get_attachment_url();
  84. }
  85. ?>
  86. <p>
  87. <a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
  88. $attachment_size = apply_filters( 'esquire_attachment_size', 560 );
  89. echo wp_get_attachment_image( $post->ID, array( 560, 560 ) );
  90. ?></a>
  91. </p>
  92. <?php if ( ! empty( $post->post_excerpt ) ) : ?>
  93. <p><?php the_excerpt(); ?></p>
  94. <?php endif; ?>
  95. <?php the_content(); ?>
  96. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'esquire' ), 'after' => '</div>' ) ); ?>
  97. <p>
  98. <?php
  99. $metadata = wp_get_attachment_metadata();
  100. printf( __( 'Published <abbr class="published" title="%1$s">%2$s</abbr> at <a href="%3$s" title="Link to full-size image">%4$s &times; %5$s</a> in <a href="%6$s" title="Return to %7$s" rel="gallery">%7$s</a>', 'esquire' ),
  101. esc_attr( get_the_time() ),
  102. get_the_date(),
  103. wp_get_attachment_url(),
  104. $metadata['width'],
  105. $metadata['height'],
  106. get_permalink( $post->post_parent ),
  107. get_the_title( $post->post_parent )
  108. );
  109. ?>
  110. <?php edit_post_link( __( 'Edit', 'esquire' ), '<span class="sep">|</span> <span class="edit-link">', '</span>' ); ?>
  111. </p>
  112. </div><!-- .content -->
  113. </div><!-- .postbody -->
  114. </div>
  115. </div><!-- #posts -->
  116. <?php get_footer(); ?>