PageRenderTime 37ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/wp-content/themes/coraline/loop.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 154 lines | 124 code | 24 blank | 6 comment | 27 complexity | 4fbf385321f5a6e95247289672d8aba1 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @package WordPress
  4. * @subpackage Coraline
  5. * @since Coraline 1.0
  6. */
  7. ?>
  8. <?php /* Display navigation to next/previous pages when applicable */ ?>
  9. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  10. <div id="nav-above" class="navigation">
  11. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'coraline' ) ); ?></div>
  12. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'coraline' ) ); ?></div>
  13. </div><!-- #nav-above -->
  14. <?php endif; ?>
  15. <?php /* If there are no posts to display, such as an empty archive page */ ?>
  16. <?php if ( ! have_posts() ) : ?>
  17. <div id="post-0" class="post error404 not-found">
  18. <h1 class="entry-title"><?php _e( 'Not Found', 'coraline' ); ?></h1>
  19. <div class="entry-content">
  20. <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'coraline' ); ?></p>
  21. <?php get_search_form(); ?>
  22. </div><!-- .entry-content -->
  23. </div><!-- #post-0 -->
  24. <?php endif; ?>
  25. <?php
  26. // Start the Loop.
  27. $options = get_option( 'coraline_theme_options' ); while ( have_posts() ) : the_post(); ?>
  28. <?php /* How to display posts in the Gallery category. */ ?>
  29. <?php if ( ( isset( $options['gallery_category'] ) && '0' != $options['gallery_category'] && in_category( $options['gallery_category'] ) ) || 'gallery' == get_post_format( $post->ID ) ) : ?>
  30. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  31. <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'coraline' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  32. <div class="entry-meta">
  33. <?php coraline_posted_on(); ?>
  34. </div><!-- .entry-meta -->
  35. <div class="entry-content">
  36. <?php if ( post_password_required() ) : ?>
  37. <?php the_content(); ?>
  38. <?php else : ?>
  39. <?php
  40. $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  41. if ( $images ) :
  42. $total_images = count( $images );
  43. $image = array_shift( $images );
  44. $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  45. ?>
  46. <div class="gallery-thumb">
  47. <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  48. </div><!-- .gallery-thumb -->
  49. <p><em><?php printf( __( 'This gallery contains <a %1$s>%2$s photos</a>.', 'coraline' ),
  50. 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'coraline' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
  51. $total_images
  52. ); ?></em></p>
  53. <?php endif; ?>
  54. <?php the_excerpt(); ?>
  55. <?php endif; ?>
  56. </div><!-- .entry-content -->
  57. <div class="entry-info">
  58. <span class="comments-link"><?php comments_popup_link( __( '&rarr; Leave a comment', 'coraline' ), __( '&rarr; 1 Comment', 'coraline' ), __( '&rarr; % Comments', 'coraline' ) ); ?></span>
  59. <?php
  60. $cat_slug = sanitize_title( $options['gallery_category'] );
  61. if ( in_category( $cat_slug ) ) :
  62. ?>
  63. <p><a href="<?php echo get_term_link( $cat_slug, 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'coraline' ); ?>"><?php _e( 'More Galleries', 'coraline' ); ?></a></p>
  64. <?php endif; ?>
  65. <p><?php edit_post_link( __( 'Edit', 'coraline' ), '', '' ); ?></p>
  66. </div><!-- .entry-info -->
  67. </div><!-- #post-## -->
  68. <?php /* How to display posts in the asides category */ ?>
  69. <?php elseif ( isset( $options['aside_category'] ) && '0' != $options['aside_category'] && in_category( $options['aside_category'] ) || 'aside' == get_post_format( $post->ID ) ) : ?>
  70. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  71. <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
  72. <div class="entry-summary aside">
  73. <?php the_excerpt(); ?>
  74. </div><!-- .entry-summary -->
  75. <?php else : ?>
  76. <div class="entry-content aside">
  77. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'coraline' ) ); ?>
  78. </div><!-- .entry-content -->
  79. <?php endif; ?>
  80. <div class="entry-info">
  81. <p class="comments-link"><?php comments_popup_link( __( '&rarr; Leave a comment', 'coraline' ), __( '&rarr; 1 Comment', 'coraline' ), __( '&rarr; % Comments', 'coraline' ) ); ?></p>
  82. <p><?php coraline_posted_on(); ?></p>
  83. <?php edit_post_link( __( 'Edit', 'coraline' ), '', '' ); ?>
  84. </div><!-- .entry-info -->
  85. </div><!-- #post-## -->
  86. <?php /* How to display all other posts. */ ?>
  87. <?php else : ?>
  88. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  89. <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'coraline' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  90. <div class="entry-meta">
  91. <?php coraline_posted_on(); ?><span class="comments-link"><span class="meta-sep">|</span> <?php comments_popup_link( __( 'Leave a comment', 'coraline' ), __( '1 Comment', 'coraline' ), __( '% Comments', 'coraline' ) ); ?></span>
  92. </div><!-- .entry-meta -->
  93. <?php if ( is_search() ) : // Display excerpts for search. ?>
  94. <div class="entry-summary">
  95. <?php the_excerpt(); ?>
  96. </div><!-- .entry-summary -->
  97. <?php else : ?>
  98. <div class="entry-content">
  99. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'coraline' ) ); ?>
  100. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'coraline' ), 'after' => '</div>' ) ); ?>
  101. </div><!-- .entry-content -->
  102. <?php endif; ?>
  103. <div class="entry-info">
  104. <p class="comments-link"><?php comments_popup_link( __( '&rarr; Leave a comment', 'coraline' ), __( '&rarr; 1 Comment', 'coraline' ), __( '&rarr; % Comments', 'coraline' ) ); ?></p>
  105. <?php if ( count( get_the_category() ) ) : ?>
  106. <p class="cat-links">
  107. <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'coraline' ), 'entry-info-prep entry-info-prep-cat-links', get_the_category_list( ', ' ) ); ?>
  108. </p>
  109. <?php endif; ?>
  110. <?php
  111. $tags_list = get_the_tag_list( '', ', ' );
  112. if ( $tags_list ):
  113. ?>
  114. <p class="tag-links">
  115. <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'coraline' ), 'entry-info-prep entry-info-prep-tag-links', $tags_list ); ?>
  116. </p>
  117. <?php endif; ?>
  118. <?php edit_post_link( __( 'Edit', 'coraline' ), '<p class="edit-link">', '</p>' ); ?>
  119. </div><!-- .entry-info -->
  120. </div><!-- #post-## -->
  121. <?php comments_template( '', true ); ?>
  122. <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
  123. <?php endwhile; // End the loop. Whew. ?>
  124. <?php /* Display navigation to next/previous pages when applicable */ ?>
  125. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  126. <div id="nav-below" class="navigation">
  127. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'coraline' ) ); ?></div>
  128. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'coraline' ) ); ?></div>
  129. </div><!-- #nav-below -->
  130. <?php endif; ?>