diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
index 286cd9c648..88be328719 100644
--- a/wp-includes/comment-template.php
+++ b/wp-includes/comment-template.php
@@ -986,8 +986,7 @@ function get_comment_reply_link($args = array(), $comment = null, $post = null)
if ( get_option('comment_registration') && !$user_ID )
$link = '' . $login_text . '';
else
- $link = "comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\")'>$reply_text";
-
+ $link = "comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text";
return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post);
}
@@ -1005,6 +1004,57 @@ function get_comment_reply_link($args = array(), $comment = null, $post = null)
function comment_reply_link($args = array(), $comment = null, $post = null) {
echo get_comment_reply_link($args, $comment, $post);
}
+/**
+ * Retrieve HTML content for reply to post link.
+ *
+ * The default arguments that can be override are 'add_below', 'respond_id',
+ * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
+ * used, if the user must log in or register first before posting a comment. The
+ * 'reply_text' will be used, if they can post a reply. The 'add_below' and
+ * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
+ * parameters.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Optional. Override default options.
+ * @param int $post Optional. Post that the comment is going to be displayed on.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+
+
+function get_post_comments_link($args = array(), $comment = null, $post = null) {
+ global $user_ID;
+
+ $defaults = array('add_below' => 'prologue', 'respond_id' => 'respond', 'reply_text' => __('Leave a Comment'),
+ 'login_text' => __('Log in to leave a Comment'), 'before' => '', 'after' => '');
+
+ $args = wp_parse_args($args, $defaults);
+ extract($args, EXTR_SKIP);
+ $post = get_post($post);
+
+ if ( 'open' != $post->comment_status )
+ return false;
+
+ if ( get_option('comment_registration') && !$user_ID ) {
+ $link = '' . $login_text . '';
+ } else {
+ $link = "$reply_text";
+ }
+ return apply_filters('post_comments_link', $before . $link . $after, $post);
+}
+
+/**
+ * Displays the HTML content for reply to post link.
+ * @since 2.7.0
+ * @see get_post_comments_link() Echoes result
+ *
+ * @param array $args Optional. Override default options.
+ * @param int $post Optional. Post that the comment is going to be displayed on.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+function post_comments_link ($args = array(), $post = null) {
+ echo get_post_comments_link($args, $post);
+}
/**
* Retrieve HTML content for cancel comment reply link.
@@ -1042,7 +1092,7 @@ function comment_id_fields() {
global $id;
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
- echo "\n";
+ echo "\n";
echo "\n";
}
@@ -1310,4 +1360,4 @@ function wp_list_comments($args = array(), $comments = null ) {
$in_comment_loop = false;
}
-?>
\ No newline at end of file
+?>
diff --git a/wp-includes/js/comment-reply.js b/wp-includes/js/comment-reply.js
index ff992d5258..20154253a4 100644
--- a/wp-includes/js/comment-reply.js
+++ b/wp-includes/js/comment-reply.js
@@ -1,12 +1,13 @@
addComment = {
- moveForm : function(commId, parentId, respondId) {
- var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent');
+ moveForm : function(commId, parentId, respondId, postId) {
+ var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');
if ( ! comm || ! respond || ! cancel || ! parent )
return;
t.respondId = respondId;
+ postId = postId || false;
if ( ! t.I('wp-temp-form-div') ) {
div = document.createElement('div');
@@ -16,6 +17,8 @@ addComment = {
}
comm.parentNode.insertBefore(respond, comm.nextSibling);
+ if ( post && postId )
+ post.value = postId;
parent.value = parentId;
cancel.style.display = '';
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index b6954aa9d0..de620756b9 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -140,7 +140,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' );
$scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' );
- $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081009');
+ $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081210');
if ( is_admin() ) {
$scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' );