Make WordPress Core

Changeset 29823


Ignore:
Timestamp:
10/02/2014 08:44:34 PM (10 years ago)
Author:
SergeyBiryukov
Message:

Make link construction in get_comment_reply_link() and get_post_reply_link() more readable.

see #16433.

File:
1 edited

Legend:

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

    r29822 r29823  
    13221322    }
    13231323
    1324     $add_below = $args['add_below'];
    1325     $respond_id = $args['respond_id'];
    1326     $reply_text = $args['reply_text'];
    1327 
    13281324    $comment = get_comment( $comment );
     1325
    13291326    if ( empty( $post ) ) {
    13301327        $post = $comment->comment_post_ID;
    13311328    }
     1329
    13321330    $post = get_post( $post );
    13331331
     
    13371335
    13381336    if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
    1339         $link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $args['login_text'] . '</a>';
     1337        $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
     1338            esc_url( wp_login_url( get_permalink() ) ),
     1339            $args['login_text']
     1340        );
    13401341    } else {
    1341         $link = "<a class='comment-reply-link' href='" . esc_url( 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\")' aria-label='" . esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ) . "'>$reply_text</a>";
     1342        $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
     1343            $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID
     1344        );
     1345
     1346        $link = sprintf( "<a class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
     1347            esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $args['respond_id'],
     1348            $onclick,
     1349            esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
     1350            $args['reply_text']
     1351        );
    13421352    }
    13431353    /**
     
    14051415
    14061416    $args = wp_parse_args($args, $defaults);
    1407     $add_below = $args['add_below'];
    1408     $respond_id = $args['respond_id'];
    1409     $reply_text = $args['reply_text'];
     1417
    14101418    $post = get_post($post);
    14111419
     
    14151423
    14161424    if ( get_option('comment_registration') && ! is_user_logged_in() ) {
    1417         $link = '<a rel="nofollow" href="' . wp_login_url( get_permalink() ) . '">' . $args['login_text'] . '</a>';
     1425        $link = sprintf( '<a rel="nofollow" href="%s">%s</a>',
     1426            wp_login_url( get_permalink() ),
     1427            $args['login_text']
     1428        );
    14181429    } else {
    1419         $link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
     1430        $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )',
     1431            $args['add_below'], $post->ID, $args['respond_id']
     1432        );
     1433
     1434        $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>",
     1435            get_permalink( $post->ID ) . '#' . $args['respond_id'],
     1436            $onclick,
     1437            $args['reply_text']
     1438        );
    14201439    }
    14211440    $formatted_link = $args['before'] . $link . $args['after'];
Note: See TracChangeset for help on using the changeset viewer.