As you may have noticed, I have made improvements to the "commenting experience" at this blog. The first is the "Recent Comments" section, which can currently be seen on the sidebar at your right. This was simple copy and pasting from the WordPress Wiki entry "Recent Comments."

The other improvement can be seen on the individual entry pages; the comment previews. I was slightly dismayed to find that nobody seems to have made a hack to create MT-style comments, where you can choose whether you preview or post on the first page. Instead, WordPress hackers seemed to be split between LaughingLizard's Comment Preview (which requires that you preview all comments before posting them), Codeman38's update to this hack, or Chris Davis' Live Preview plugin, which dynamically updates the preview as you type a comment. All three of these were nice, but not what I was looking for.

Thus I set about to create my own preview page, using LaughingLizard's code as a template. First, I needed to change the buttons in wp-comments.php:
<input name="submit" id="preview" type="submit" "tabindex="5" value="< ?php _e('Preview'); ?>" />
<input name="submit" id="submit" type="submit" tabindex="6" value="<?php _e('Post'); ?>" style="font-weight: bold;" />

Then I added a massive if statement to take care of the previewing in wp-comments-post.php:
// Ugly preview hack - 7-28-2004
if($_POST['submit'] == "Preview"){
$raw_comment = $comment;
// this was adapted from Mark Ghosh's (LaughingLizard) Comment Preview hack at http://weblogtoolscollection.com
// comment formatting
$comment = make_clickable($comment);
$comment = convert_chars($comment);
$comment = wpautop($comment);
$comment = balanceTags($comment);
$comment = convert_smilies($comment);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo get_settings('blogname'); ?> - Comments on "<?php the_title() ?>"</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_settings('blog_charset'); ?>" />
<style type="text/css" media="screen">
@import url( wp-layout.css );
body { margin: 3px; padding: 10px}
</style>
</head>
<body id="commentspopup">
<h1 id="header"><a href="<?php echo get_settings('siteurl'); ?>" title="<?php echo get_settings('blogname'); ?>"><?php echo get_settings('blogname'); ?></a></h1>
<h2 id="comments">Your Comment Preview:</h2>
<ol id="commentlist">
<?php echo stripslashes($comment); ?> by <?php
if (empty($url)) :
echo $author;
else:
echo "<a href='$url' rel='external'>$author</a>";
endif;
?>
</ol>
<hr />
<form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<p>
<input type="text" name="author" id="author" class="textarea" value="<?php echo $author; ?>" size="28" tabindex="1" />
<label for="author"><?php _e('Name'); ?></label>
<input type="hidden" name="comment_post_ID" value="<?php echo $comment_post_ID; ?>" />
<input type="hidden" name="redirect_to" value="<?php echo $redirect_to; ?>" />
</p>
<p>
<input type="text" name="email" id="email" value="<?php echo $email; ?>" size="28" tabindex="2" />
<label for="email"><?php _e('E-mail'); ?></label>
</p>
<p>
<input type="text" name="url" id="url" value="<?php echo $url; ?>" size="28" tabindex="3" />
<label for="url"><?php _e('<acronym title="Uniform Resource Identifier">URI</acronym>'); ?></label>
</p>
<p>
<label for="comment"><?php _e('Your Comment'); ?></label>
<br />
<textarea name="comment" id="comment" cols="60" rows="4" tabindex="4"><?php echo stripslashes($raw_comment); ?></textarea>
</p>
<p>
<input name="submit" id="preview" type="submit" tabindex="5" value="<?php _e('Preview'); ?>" />
<input name="submit" id="submit" type="submit" tabindex="6" value="<?php _e('Post'); ?>" style="font-weight: bold;" />
</p>
</form>
</body></html>
<?
exit();
}

Then I debugged in order to stop the addition of slashes, debugged some more in order to see why the comments were not being properly posted, accidentally comment spammed myself and realized that all of the comments I had thought were not being accepted were being added to post #0, made sure all necessary form variables were being carried over, and then saw my test comment appear properly.