Description:
Plugin Download: [download id="2" format="1"]
Version: Version 1.0
Requirements: PHP 5 & WordPress 2.7.x
Based on the comment_form_title function, this plugin allows you to add the name of the comment author to the Leave a Reply title. Replaces the comment_reply_link function.
Caution:
Use this plugin at your own risk. It’s not going to blow up your website but it requires more knowledge than I can include here. Before using, you should read and understand this and this.
Important:
If you use this plugin, do not add the following to your template (from these instructions):
if ( is_singular() ) wp_enqueue_script( 'comment-reply' )
The Enhanced Javascript Comment Functionality plugin takes care of it for you.
To make this plugin work:
You must add a comment_author id to some element, preferably in your comments.php theme file. For example, in my comments.php, I use:
You must be using the callback parameter in wp_list_comments, likely in your comments.php theme file. For example, in my comments.php, I use:
You must use this plugin’s ejcf_comment_reply_link function instead of the WordPress comment_reply_link or get_comment_reply_link. For example, in my style_the_comment function (located in my theme’s functions.php), I use:
$comment_reply_link = ejcf_comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => __('Reply to Comment'), 'noreplytext' => __('Reply to Post'), 'replytext' => __('Reply to %s'), 'echo' => 0)));
This is the full function:
function style_the_comment($comment, $args, $depth) {
global $comment_count;
$comment_count++;
$GLOBALS['comment'] = $comment;
$comment_reply_link = ejcf_comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => __('Reply to Comment'), 'noreplytext' => __('Reply to Post'), 'replytext' => __('Reply to %s'), 'echo' => 0)));
$output = '
';
echo $output;
}
Details, details:
The ejcf_comment_reply_link function replaces the comment_reply_link and get_comment_reply_link functions. As of the writing of this, the comment_reply_link codex page contains no details. So let me break it down for you:
- The reply_text parameter is what appears in every comment.
- The noreplytext parameter is what will appear as the title of the comment form if your commenter cancels his or her reply to the comment. For continuity, it should be the same as what you use in comment_form_title.
- The replytext parameter is what will appear as the title of the comment form if your commenter is replying to a comment. %s equals the name of the author of the comment.
- When set to one, the echo parameter echos the resultant string of the ejcf_comment_reply_link function. When set to zero, the resultant string is returned.
In my style_the_comment function, the resultant string is:
Reply to Comment
'.$comment_reply_link.' ' : '').'