There is an enhancement for comment display in WordPress 2.7. New template tags are introduced.
This WordPress theme will be using those enchancement too.
In the header file, header.php , code as following is added right before the call to wp_head(); for supporting new JavaScrip functionality with comment threading in WordPress 2.7.
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
// enables nested comments in WP 2.7 ?>
Nows, let's concerntrate on comments file, comments.php , itself. Due to this theme support at least WordPress version 2.7, it won't include any legacy code that support WordPress version less then 2.7. I used Migrating Plugins and Themes to 2.7/Enhanced Comment Display as reference. Great reference. We won't repeat on what they already said. An example of comments file, comments.php that supporting WordPress 2.7 comments enhancement as following.
<?php
/**
* @package WordPress
* @subpackage Your_Theme
*/
?>
<!-- Comments for WP 2.7 and more -->
<?php
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' ==
basename($_SERVER['SCRIPT_FILENAME']))
die (__('Please do not load this page directly. Thanks!'));
if ( post_password_required() ) : ?>
<p><?php _e('This post is password protected. Enter the password to view
comments.'); ?></p>
<?php return; endif; // END: if ( post_password_required() ) ?>
<h3>
<?php comments_number(__('No Comments'), __('1 Comment'),
__('% Comments')); ?>
</h3>
<?php if ( have_comments() ) : // Showing all the comments ?>
<ul>
<?php wp_list_comments(); ?>
</ul>
<?php previous_comments_link(); ?>
<?php next_comments_link(); ?>
<?php else : // this is displayed if there are no comments so far ?>
<p><?php _e('No comments yet.'); ?></p>
<?php endif; // END: if ( $comments ) ?>
<?php if ( comments_open() ) : ?>
<div id="respond">
<h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?>
</h3>
<div id="cancel-comment-reply">
<small><?php cancel_comment_reply_link() ?></small>
</div>
<?php if ( get_option('comment_registration') && !$user_ID ) :
// If registration required ?>
<p><?php printf(__('You must be <a href="%s">logged in</a>
to post a comment.'),
get_option('siteurl')."/wp-login.php?redirect_to="
.urlencode(get_permalink()));?></p>
<?php else : // If registration do not required ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php"
method="post" id="commentform">
<?php if ( $user_ID ) : // Log in user info ?>
<p><?php printf(__('Logged in as %s.'),
'<a href="'.get_option('siteurl').'/wp-admin/profile.php">'
.$user_identity.'</a>'); ?>
<a href="<?php echo wp_logout_url(get_permalink()); ?>"
title="<?php _e('Log out of this account'); ?>">
<?php _e('Log out »'); ?></a></p>
<?php else : // Public user ?>
<p><input type="text" name="author" id="author" value="
<?php echo $comment_author; ?>" size="22" tabindex="1" />
<label for="author"><small><?php _e('Name'); ?>
<?php if ($req) _e('(required)'); ?></small></label></p>
<p><input type="text" name="email" id="email"
value="<?php echo $comment_author_email; ?>" size="22"
tabindex="2" />
<label for="email"><small>
<?php _e('Mail (will not be published)');?>
<?php if ($req) _e('(required)'); ?></small></label></p>
<p><input type="text" name="url" id="url" value="
<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small><?php _e('Website'); ?></small></label></p>
<?php endif; ?>
<p><small><strong>XHTML:</strong>
<?php printf(__('You can use these tags: %s'), allowed_tags()); ?>
</small></p>
<p><textarea name="comment" id="comment" cols="100%" rows="10"
tabindex="4"></textarea></p>
<p><input name="submit" type="submit" id="submit" tabindex="5"
value="<?php echo attribute_escape(__('Submit Comment')); ?>" /></p>
<?php comment_id_fields(); ?>
<?php do_action('comment_form', $post->ID); ?>
</form>
</div>
<?php endif; // END: if ( get_option('comment_registration') && !$user_ID )
// If registration required and not logged in ?>
<?php else : // Comments are closed ?>
<p><?php _e('Sorry, the comment form is closed at this time.'); ?></p>
<?php endif; // END: if ( comments_open() )?>
Currently there is no plan on developing popup comments template. Therefore, there will be no popup comments file, comments-popup.php , in this theme. However, if you want to publish your theme publicly, you might want to consider for adding it.
Related Posts
References
Comments
Comments powered by Disqus