Make WordPress Core

Changeset 10169


Ignore:
Timestamp:
12/10/2008 11:49:37 AM (16 years ago)
Author:
azaozz
Message:

Enable support for threaded comments and comment reply on index page, props yoavf, fixes #8550

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment-template.php

    r10150 r10169  
    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}
     
    10061005    echo get_comment_reply_link($args, $comment, $post);
    10071006}
     1007/**
     1008 * Retrieve HTML content for reply to post link.
     1009 *
     1010 * The default arguments that can be override are 'add_below', 'respond_id',
     1011 * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
     1012 * used, if the user must log in or register first before posting a comment. The
     1013 * 'reply_text' will be used, if they can post a reply. The 'add_below' and
     1014 * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
     1015 * parameters.
     1016 *
     1017 * @since 2.7.0
     1018 *
     1019 * @param array $args Optional. Override default options.
     1020 * @param int $post Optional. Post that the comment is going to be displayed on.
     1021 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
     1022 */
     1023
     1024
     1025function get_post_comments_link($args = array(), $comment = null, $post = null) {
     1026    global $user_ID;
     1027
     1028    $defaults = array('add_below' => 'prologue', 'respond_id' => 'respond', 'reply_text' => __('Leave a Comment'),
     1029        'login_text' => __('Log in to leave a Comment'), 'before' => '', 'after' => '');
     1030
     1031    $args = wp_parse_args($args, $defaults);
     1032    extract($args, EXTR_SKIP);
     1033    $post = get_post($post);
     1034   
     1035    if ( 'open' != $post->comment_status )
     1036        return false;
     1037
     1038    if ( get_option('comment_registration') && !$user_ID ) {
     1039        $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
     1040    } else {
     1041        $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>";
     1042    }
     1043    return apply_filters('post_comments_link', $before . $link . $after, $post);
     1044}
     1045
     1046/**
     1047 * Displays the HTML content for reply to post link.
     1048 * @since 2.7.0
     1049 * @see get_post_comments_link() Echoes result
     1050 *
     1051 * @param array $args Optional. Override default options.
     1052 * @param int $post Optional. Post that the comment is going to be displayed on.
     1053 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
     1054 */
     1055function post_comments_link ($args = array(), $post = null) {
     1056    echo get_post_comments_link($args, $post);
     1057}
    10081058
    10091059/**
     
    10431093
    10441094    $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
    1045     echo "<input type='hidden' name='comment_post_ID' value='$id' />\n";
     1095    echo "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
    10461096    echo "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
    10471097}
  • trunk/wp-includes/js/comment-reply.js

    r9114 r10169  
    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 )
     
    88
    99        t.respondId = respondId;
     10        postId = postId || false;
    1011
    1112        if ( ! t.I('wp-temp-form-div') ) {
     
    1718
    1819        comm.parentNode.insertBefore(respond, comm.nextSibling);
     20        if ( post && postId )
     21            post.value = postId;
    1922        parent.value = parentId;
    2023        cancel.style.display = '';
  • trunk/wp-includes/script-loader.php

    r10160 r10169  
    141141    $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' );
    142142
    143     $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081009');
     143    $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081210');
    144144
    145145    if ( is_admin() ) {
Note: See TracChangeset for help on using the changeset viewer.