<?php
/* This is comment.phps by Christian Montoya, [URL unfurl="true"]http://www.christianmontoya.com[/URL]
Available to you under the do-whatever-you-want license. If you like it,
you are totally welcome to link back to me.
Use of this code does not grant you the right to use the design or any of the
other files on my site. Beyond this file, all rights are reserved, unless otherwise noted.
Enjoy!
*/
?>
<!-- Comments code provided by christianmontoya.com -->
<?php if(!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) : ?>
<?php die('You can not access this page directly!'); ?>
<?php endif; ?>
<?php if (!empty($post->post_password) && $_COOKIE['wp-postpass_'.COOKIEHASH]!=$post->post_password) : ?>
<p id="comments-locked">Enter your password to view comments.</p>
<?php return; endif; ?>
<?php if ($comments) : ?>
<?php
/* Author values for author highlighting */
/* Enter your email and name as they appear in the admin options */
/*
* a new parameter of alternative has been added. If you
* do not want to vary the bubble alternation (and keep the same bubble colours)
* setting alternative to true and setting a text-colour (ideally in the normal hexadecimal notation #ffffff)
* creates an alternative way of highlighting admin comments.
* setting alternative to false maintains the original structure but to differentiate you will need
* to ensure you have images with suitable background colours
*/
$author = array(
"authorStyle" => "author",
"email" => "jamie@followtheboat.com",
"alternative" => false,
"text-colour" => "blue"
);
/* Count the totals */
$numPingBacks = 0;
$numComments = 0;
/* Loop throught comments to count these totals */
foreach ($comments as $comment) {
if (get_comment_type() != "comment") { $numPingBacks++; }
else { $numComments++; }
}
/* This is a loop for printing pingbacks/trackbacks if there are any */
if ($numPingBacks != 0) : ?>
<h2 class="comments-header"><?php _e($numPingBacks); ?> Trackbacks/Pingbacks</h2>
<ol id="trackbacks">
<?php foreach ($comments as $comment) : ?>
<?php if (get_comment_type()!="comment") : ?>
<li id="comment-<?php comment_ID() ?>" class="<?php _e($thiscomment); ?>">
<?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?>:
<?php comment_author_link(); ?> on <?php comment_date(); ?>
</li>
<?php if('odd'==$thiscomment) { $thiscomment = 'even'; } else { $thiscomment = 'odd'; } ?>
<?php endif; endforeach; ?>
</ol>
<?php endif; ?>
<?php
/* This is a loop for printing comments */
if ($numComments != 0) : ?>
<h2 class="comment-header"><br><img src="<?php bloginfo('template_directory'); ?>/images/miniq.gif"> <?php _e($numComments); ?> responses to '<?php the_title(); ?>'</h2>
<div class="comments">
<ol id="comments">
<?php foreach ($comments as $comment) : ?>
<?php if (get_comment_type()=="comment") :
//this sets the class for the comment depending on who wrote it.
if ($author['alternative']){
$commentClass = ($commentClass=='odd' ? 'even' : 'odd');
$authorStyle = strtolower($comment->comment_author_email) == strtolower($author['email']) ? 'style="color='.$author['text-colour'].';"' : '';
} else {
$commentClass = (strtolower($comment->comment_author_email) == strtolower($author['email'])) ? $author['authorStyle'] : ($commentClass=='odd' ? 'even' : 'odd');
$authorStyle = '';
} ?>
<li id="comment-<?php comment_ID(); ?>" class="<?php echo $commentClass;?>">
<?php comment_author() ?>, <?php print $comment->extra_location; ?>
<br><div class="comment-date"><?php comment_date() ?></div>
<?php /* Or maybe put gravatars here. The typical thing is to float them in the CSS */
/* Typical gravatar call:
<img src="<?php gravatar("R", 80, "YOUR DEFAULT GRAVATAR URL");
alt="" class="gravatar" width="80" height="80">
*/ ?>
<div class="speech1container">
<div class="speech1"></div>
<div class="speech1topwrap">
<div class="speech2a"></div>
<div class="speech2b"><img src="<?php bloginfo('template_directory'); ?>/images/speech1_r2_c2_spacer.gif" width="507" height="6" /></div>
<br class="clear" />
</div>
<div class="speech3">
<div class="speech3pad" <?php echo $authorStyle;?>><?php comment_text(); ?> </div>
</div>
<div class="speech4"><img src="<?php bloginfo('template_directory'); ?>/images/speech1_r5_c1_spacer.gif" width="570" height="8" /></div>
</div>
</li> <br /><br /> <br /><br /> <br /><br /> <br /><br />
<?php endif; endforeach; ?>
</ol>
</div>
<?php endif; ?>
<?php else :
/* No comments at all means a simple message instead */
?>
<p><i>Currently there are no comments on the post '<?php the_title(); ?>'. Use the form below and be the first to say something!</i>
<p> </p> <p> </p>
<?php endif; ?>
<?php if (comments_open()) : ?>
<?php /* This would be a good place for live preview...
<div id="live-preview">
<h2 class="comments-header">Live Preview</h2>
<?php live_preview(); ?>
</div>
*/ ?>
<div id="comments-header"></div>
<div id="comment-formcontainer">
<div class="comment-formborder">
<p> </p>
<?php if (get_option('comment_registration') && !$user_ID ) : ?>
<p id="comments-blocked">You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=
<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ($user_ID) : ?>
<p><a class=screenshot rel=<?php bloginfo('template_directory'); ?>/images/tt-login.gif>
<img src=<?php bloginfo('template_directory'); ?>/images/minilogin.gif height=17 width=17></a> You are logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php">
<?php echo $user_identity; ?></a>.
<p><a class=screenshot rel=<?php bloginfo('template_directory'); ?>/images/tt-logout.gif>
<img src=<?php bloginfo('template_directory'); ?>/images/minilogout.gif height=17 width=17></a> <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout"
title="Log out of this account">Logout</a>. </p>
</p>
<?php else : ?>
<p><label for="author"><strong>Name</strong><?php if ($req) _e(' (required)'); ?></label><br>
<input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" />
</p>
<p> </p>
<p><label for="email"><strong>E-mail (will not be published)</strong><?php if ($req) _e(' (required)'); ?></label><br>
<input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" />
</p>
<p> </p>
<p><label for="location"><strong>Location (town and country)</strong></label><br>
<input type="text" name="location" id="location" size="22" /></p>
<p> </p>
<p><label for="url"><strong>Website</strong></label><br>
<input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" />
</p>
<p> </p>
<?php endif; ?>
<?php /* You might want to display this:
<p>XHTML: You can use these tags: <?php echo allowed_tags(); ?></p> */ ?>
<p><a class=screenshot rel=<?php bloginfo('template_directory'); ?>/images/tt-chat.gif>
<img src=<?php bloginfo('template_directory'); ?>/images/minichat.gif height=17 width=17></a> Your comments:<br>
<textarea name="comment" id="comment" rows="5" cols="30"></textarea></p>
<?php /* Buttons are easier to style than input[type=submit],
but you can replace:
<button type="submit" name="submit" id="sub">Submit</button>
with:
<input type="submit" name="submit" id="sub" value="Submit" />
if you like */
?>
<p><button type="submit" name="submit" id="sub">Submit</button>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>"></p>
<?php do_action('comment_form', $post->ID); ?>
</form>
</div>
</div>
<?php endif; // If registration required and not logged in ?>
<?php else : // Comments are closed ?>
<p id="comments-closed">Sorry, comments for this entry are closed at this time.</p>
<?php endif; ?>
<div class="postdata"> <a class=screenshot rel=<?php bloginfo('template_directory'); ?>/images/tt-rsspost.gif>
<img src=<?php bloginfo('template_directory'); ?>/images/minirss.gif height=17 width=17></a> <?php comments_rss_link(' RSS feed for comments on this post'); ?> <br>
<?php if (pings_open()) : ?>
<a class=screenshot rel=<?php bloginfo('template_directory'); ?>/images/tt-track.gif>
<img src=<?php bloginfo('template_directory'); ?>/images/minitrack.gif height=17 width=17></a>
<a href="<?php trackback_url() ?>" rel="trackback"> Get a Trackback link</a>
</div>
<?php endif; ?>