Make WordPress Core

Ticket #8550: SupportForMultipleCommentsOnPage.diff

File SupportForMultipleCommentsOnPage.diff, 4.8 KB (added by yoavf, 17 years ago)
  • comment-template.php

     
    986986        if ( get_option('comment_registration') && !$user_ID )
    987987                $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
    988988        else
    989                 $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>";
    990 
     989                $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>";
    991990        return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post);
    992991}
    993992
     
    10051004function comment_reply_link($args = array(), $comment = null, $post = null) {
    10061005        echo get_comment_reply_link($args, $comment, $post);
    10071006}
     1007/**
     1008 * Retrieve HTML content for reply to post link.
     1009 **Consider merging  with  get_comment_reply_link() **
     1010 *
     1011 * The default arguments that can be override are 'add_below', 'respond_id',
     1012 * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
     1013 * used, if the user must log in or register first before posting a comment. The
     1014 * 'reply_text' will be used, if they can post a reply. The 'add_below' and
     1015 * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
     1016 * parameters.
     1017 *
     1018 * @since 2.7.0
     1019 *
     1020 * @param array $args Optional. Override default options.
     1021  * @param int $post Optional. Post that the comment is going to be displayed on.
     1022 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
     1023 */
    10081024
     1025
     1026function get_post_reply_link($args = array(), $comment = null, $post = null) {
     1027        global $user_ID;
     1028        $defaults = array('add_below' => 'prologue', 'respond_id' => 'respond', 'reply_text' => __('Reply'),
     1029                'login_text' => __('Log in to Reply'), 'before' => '', 'after' => '');
     1030
     1031        $args = wp_parse_args($args, $defaults);
     1032        extract($args, EXTR_SKIP);
     1033        $post = get_post($post);
     1034        if ( 'open' != $post->comment_status )
     1035                return false;
     1036        $link = '';
     1037        if ( get_option('comment_registration') && !$user_ID ) {
     1038                $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
     1039                }
     1040        else  {
     1041                $link = "<a rel='nofollow' href='#' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"$post->ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
     1042                }
     1043        return apply_filters('post_reply_link', $before . $link . $after, $post);
     1044}
     1045
    10091046/**
     1047 * Displays the HTML content for reply to post link.
     1048 **Consider merging  with  comment_reply_link() **
     1049 * @since 2.7.0
     1050 * @see get_post_reply_link() Echoes result
     1051 *
     1052 * @param array $args Optional. Override default options.
     1053  * @param int $post Optional. Post that the comment is going to be displayed on.
     1054 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
     1055 */
     1056function post_reply_link ($args = array(), $post = null) {
     1057        echo get_post_reply_link($args, $post);
     1058}
     1059
     1060/**
    10101061 * Retrieve HTML content for cancel comment reply link.
    10111062 *
    10121063 * @since 2.7.0
     
    10421093        global $id;
    10431094
    10441095        $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
    1045         echo "<input type='hidden' name='comment_post_ID' value='$id' />\n";
     1096        echo "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
    10461097        echo "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
    10471098}
    10481099
  • js/comment-reply.js

     
    11
    22addComment = {
    3         moveForm : function(commId, parentId, respondId) {
    4                 var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent');
     3        moveForm : function(commId, parentId, respondId, postId) {
     4                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');
    55
    66                if ( ! comm || ! respond || ! cancel || ! parent )
    77                        return;
     
    1414                        div.style.display = 'none';
    1515                        respond.parentNode.insertBefore(div, respond);
    1616                }
    17 
     17               
     18               
    1819                comm.parentNode.insertBefore(respond, comm.nextSibling);
     20                post.value=postId
    1921                parent.value = parentId;
    2022                cancel.style.display = '';
    2123