Permalink
Browse files

Fixed display of empty wrapper elements on post and archive pages

  • Loading branch information...
1 parent 2fc60ba commit 2199a368cd4d382780ab725bc91310aff95acab9 @splorp committed Oct 17, 2012
Showing with 96 additions and 11 deletions.
  1. +2 −0 archive.php
  2. +4 −0 category.php
  3. +4 −0 comments.php
  4. +62 −10 functions.php
  5. +6 −0 image.php
  6. +2 −0 index.php
  7. +4 −1 readme.md
  8. +4 −0 search.php
  9. +6 −0 single.php
  10. +2 −0 tag.php
View
@@ -29,7 +29,9 @@
<h2>Archives</h2>
<?php } ?>
+ <?php if (show_posts_link_nav()): ?>
<p><?php next_posts_link('Older'); delim_posts_link(); previous_posts_link('Newer') ?></p>
+ <?php endif; ?>
<?php while (have_posts()) : the_post(); ?>
View
@@ -25,7 +25,9 @@
}
?>
+ <?php if (show_posts_link_nav()): ?>
<p><?php next_posts_link('Older'); delim_posts_link(); previous_posts_link('Newer') ?></p>
+ <?php endif; ?>
<?php
/* Start the Loop */
@@ -42,7 +44,9 @@
<?php endwhile; ?>
+ <?php if (show_posts_link_nav()): ?>
<p><?php next_posts_link('Older'); delim_posts_link(); previous_posts_link('Newer') ?></p>
+ <?php endif; ?>
<?php else : ?>
View
@@ -20,13 +20,17 @@
if ( have_comments() ) : ?>
<h3><?php comments_number('No Comments', 'One comment', '% comments' );?> on “<?php the_title(); ?>”</h3>
+<?php if (show_comments_link_nav()): ?>
<p><?php previous_comments_link('Older'); delim_comment_link(); next_comments_link('Newer') ?></p>
+<?php endif; ?>
<ol>
<?php wp_list_comments('type=comment&callback=tersus_comment'); ?>
</ol>
+<?php if (show_comments_link_nav()): ?>
<p><?php previous_comments_link('Older'); delim_comment_link(); next_comments_link('Newer') ?></p>
+<?php endif; ?>
<?php else : // No comments posted
if ( comments_open() ) : // Comments are open, but no comments posted
View
@@ -425,6 +425,59 @@ function insertThumbnailRSS($content) {
add_filter('the_content_feed', 'insertThumbnailRSS');
+// Tests whether post paging links should be shown
+
+ function show_post_link_nav() {
+ $prev = get_previous_post();
+ $next = get_next_post();
+ if ( $prev || $next ) {
+ return true;
+ }
+ }
+
+
+// Tests whether archive paging links should be shown
+
+ function show_posts_link_nav() {
+ $prev = get_previous_posts_link();
+ $next = get_next_posts_link();
+ if ( $prev || $next ) {
+ return true;
+ }
+ }
+
+
+// Tests whether comment paging links should be shown
+
+ function show_comments_link_nav() {
+ $prev = get_previous_comments_link();
+ $next = get_next_comments_link();
+ if ( $prev || $next ) {
+ return true;
+ }
+ }
+
+
+// Tests whether image paging links should be shown
+
+ function show_image_link_nav() {
+
+ ob_start();
+ previous_image_link();
+ $prev = ob_get_contents();
+ ob_end_clean();
+
+ ob_start();
+ next_image_link();
+ $next = ob_get_contents();
+ ob_end_clean();
+
+ if ( $prev || $next ) {
+ return true;
+ }
+ }
+
+
// Removes the link delimiter when viewing first or last post
function delim_post_link() {
@@ -450,7 +503,6 @@ function delim_posts_link() {
// Removes the link delimiter when viewing first or last comment
function delim_comment_link() {
-
$prev = get_previous_comments_link();
$next = get_next_comments_link();
if ( $prev && $next ) {
@@ -463,15 +515,15 @@ function delim_comment_link() {
function delim_image_link() {
- ob_start();
- previous_image_link();
- $prev = ob_get_contents();
- ob_end_clean();
-
- ob_start();
- next_image_link();
- $next = ob_get_contents();
- ob_end_clean();
+ ob_start();
+ previous_image_link();
+ $prev = ob_get_contents();
+ ob_end_clean();
+
+ ob_start();
+ next_image_link();
+ $next = ob_get_contents();
+ ob_end_clean();
if ( $prev && $next ) {
echo " | ";
View
@@ -10,7 +10,9 @@
<section id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+<?php if (show_image_link_nav()): ?>
<p><?php previous_image_link(0,'Previous Image'); delim_image_link(); next_image_link(0,'Next Image'); ?></p>
+<?php endif; ?>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
@@ -46,6 +48,10 @@
</article>
+<?php if (show_image_link_nav()): ?>
+ <p><?php previous_image_link(0,'Previous Image'); delim_image_link(); next_image_link(0,'Next Image'); ?></p>
+<?php endif; ?>
+
<?php comments_template(); ?>
<?php endwhile; else: ?>
View
@@ -44,7 +44,9 @@
<?php endwhile; ?>
+ <?php if (show_posts_link_nav()): ?>
<p><?php next_posts_link('Older'); delim_posts_link(); previous_posts_link('Newer') ?></p>
+ <?php endif; ?>
<?php else : ?>
View
@@ -67,11 +67,14 @@ The [HTML5 Shiv](https://github.com/afarkas/html5shiv) script is licensed under
+ The theme version is once again displayed in the footer
+ The name and version of the child theme are now displayed in the footer
+ Fixed improperly generated gallery description lists
-+ Replaced the externally linked HTML5 Shiv with a local, minified version
++ Fixed display of empty wrapper elements on post and archive pages
++ Standardized comment navigation links
+ Added support for `wp_nav_menu` navigation menu
+ Added theme option to toggle the display of navigation menu
+ Added theme option to toggle the display of theme information in the footer
+ Added language attribute to `<html>` element
++ Simplified subcategory lists
++ Replaced the externally linked HTML5 Shiv with a local, minified version
+ Embiggened theme screenshot
View
@@ -12,7 +12,9 @@
<h2>Search: “<span><?php the_search_query(); ?></span>”</h2>
+<?php if (show_posts_link_nav()): ?>
<p><?php next_posts_link('Older'); delim_posts_link(); previous_posts_link('Newer') ?></p>
+<?php endif; ?>
<?php while (have_posts()) : the_post(); ?>
@@ -26,7 +28,9 @@
<?php endwhile; ?>
+<?php if (show_posts_link_nav()): ?>
<p><?php next_posts_link('Older'); delim_posts_link(); previous_posts_link('Newer') ?></p>
+<?php endif; ?>
<?php else : ?>
View
@@ -10,7 +10,9 @@
<section id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+<?php if (show_post_link_nav()): ?>
<p><?php previous_post_link('%link'); delim_post_link(); next_post_link('%link') ?></p>
+<?php endif; ?>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
@@ -45,6 +47,10 @@
</article>
+<?php if (show_post_link_nav()): ?>
+ <p><?php previous_post_link('%link'); delim_post_link(); next_post_link('%link') ?></p>
+<?php endif; ?>
+
<?php comments_template(); ?>
<?php endwhile; else: ?>
View
@@ -11,7 +11,9 @@
<?php if (have_posts()) : ?>
<h2><?php printf( __( 'Tag: %s' ), '<span>' . single_tag_title( '', false ) . '</span>' ); ?></h2>
+ <?php if (show_posts_link_nav()): ?>
<p><?php next_posts_link('Older'); delim_posts_link(); previous_posts_link('Newer') ?></p>
+ <?php endif; ?>
<?php
$tag_description = tag_description();

0 comments on commit 2199a36

Please sign in to comment.