Enable support for threaded comments and comment reply on index page, props yoavf, fixes #8550
git-svn-id: https://develop.svn.wordpress.org/trunk@10169 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
39b79d727f
commit
06f8ce3117
@ -986,8 +986,7 @@ function get_comment_reply_link($args = array(), $comment = null, $post = null)
|
|||||||
if ( get_option('comment_registration') && !$user_ID )
|
if ( get_option('comment_registration') && !$user_ID )
|
||||||
$link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
|
$link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
|
||||||
else
|
else
|
||||||
$link = "<a rel='nofollow' href='" . wp_specialchars( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\")'>$reply_text</a>";
|
$link = "<a rel='nofollow' href='" . wp_specialchars( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
|
||||||
|
|
||||||
return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post);
|
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) {
|
function comment_reply_link($args = array(), $comment = null, $post = null) {
|
||||||
echo get_comment_reply_link($args, $comment, $post);
|
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 = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
|
||||||
|
} else {
|
||||||
|
$link = "<a rel='nofollow' href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
|
||||||
|
}
|
||||||
|
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.
|
* Retrieve HTML content for cancel comment reply link.
|
||||||
@ -1042,7 +1092,7 @@ function comment_id_fields() {
|
|||||||
global $id;
|
global $id;
|
||||||
|
|
||||||
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
|
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
|
||||||
echo "<input type='hidden' name='comment_post_ID' value='$id' />\n";
|
echo "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
|
||||||
echo "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
|
echo "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
|
|
||||||
addComment = {
|
addComment = {
|
||||||
moveForm : function(commId, parentId, respondId) {
|
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');
|
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 )
|
if ( ! comm || ! respond || ! cancel || ! parent )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
t.respondId = respondId;
|
t.respondId = respondId;
|
||||||
|
postId = postId || false;
|
||||||
|
|
||||||
if ( ! t.I('wp-temp-form-div') ) {
|
if ( ! t.I('wp-temp-form-div') ) {
|
||||||
div = document.createElement('div');
|
div = document.createElement('div');
|
||||||
@ -16,6 +17,8 @@ addComment = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
comm.parentNode.insertBefore(respond, comm.nextSibling);
|
comm.parentNode.insertBefore(respond, comm.nextSibling);
|
||||||
|
if ( post && postId )
|
||||||
|
post.value = postId;
|
||||||
parent.value = parentId;
|
parent.value = parentId;
|
||||||
cancel.style.display = '';
|
cancel.style.display = '';
|
||||||
|
|
||||||
|
@ -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-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( '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() ) {
|
if ( is_admin() ) {
|
||||||
$scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' );
|
$scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' );
|
||||||
|
Loading…
Reference in New Issue
Block a user