Make WordPress Core

Ticket #10569: 10569.2.patch

File 10569.2.patch, 2.7 KB (added by joedolson, 10 years ago)

Add filter over args array

  • wp-includes/comment-template.php

     
    13111311function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
    13121312
    13131313        $defaults = array(
    1314                 'add_below'     => 'comment',
    1315                 'respond_id'    => 'respond',
    1316                 'reply_text'    => __( 'Reply' ),
    1317                 'reply_to_text' => __( 'Reply to %s' ),
    1318                 'login_text'    => __( 'Log in to Reply' ),
    1319                 'depth'         => 0,
    1320                 'before'        => '',
    1321                 'after'         => ''
     1314                'add_below'  => 'comment',
     1315                'respond_id' => 'respond',
     1316                'reply_text' => __('Reply'),
     1317                'login_text' => __('Log in to Reply'),
     1318                'depth'      => 0,
     1319                'before'     => '',
     1320                'after'      => ''
    13221321        );
    13231322
    13241323        $args = wp_parse_args( $args, $defaults );
     
    13281327        }
    13291328
    13301329        $comment = get_comment( $comment );
    1331 
    13321330        if ( empty( $post ) ) {
    13331331                $post = $comment->comment_post_ID;
    13341332        }
    1335 
    13361333        $post = get_post( $post );
    1337 
     1334        /**
     1335         * Filter the comment reply link arguments.
     1336         *
     1337         * @since 4.1.0
     1338         *
     1339         * @param array   $args    An array of arguments overriding the defaults.
     1340         * @param object  $comment The object of the comment being replied.
     1341         * @param WP_Post $post    The WP_Post object.
     1342         */
     1343        $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );
     1344       
     1345        $add_below = $args['add_below'];
     1346        $respond_id = $args['respond_id'];
     1347        $reply_text = $args['reply_text'];
     1348       
    13381349        if ( ! comments_open( $post->ID ) ) {
    13391350                return false;
    13401351        }
    13411352
    13421353        if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
    1343                 $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
    1344                         esc_url( wp_login_url( get_permalink() ) ),
    1345                         $args['login_text']
    1346                 );
     1354                $link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $args['login_text'] . '</a>';
    13471355        } else {
    1348                 $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
    1349                         $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID
    1350                 );
    1351 
    1352                 $link = sprintf( "<a class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
    1353                         esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $args['respond_id'],
    1354                         $onclick,
    1355                         esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
    1356                         $args['reply_text']
    1357                 );
     1356                $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\")'>$reply_text</a>";
    13581357        }
    13591358        /**
    13601359         * Filter the comment reply link.