WordPress.org

Make WordPress Core

Ticket #28314: comment-template.php.patch

File comment-template.php.patch, 2.6 KB (added by Ninos Ego, 7 years ago)
  • trunk/wp-includes/comment-template.php

     
    14391439 *
    14401440 * @since 2.7.0
    14411441 *
    1442  * @param string $text Optional. Text to display for cancel reply link. Default empty.
     1442 * @param array $args {
     1443 *     Optional. Override default arguments.
     1444 *
     1445 *     @type string $text Optional. Text to display for cancel reply link. Default empty.
     1446 *     @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
     1447 *                              to addComment.moveForm(), and appended to the link URL as a hash value.
     1448 *                              Default 'respond'.
     1449 * }
    14431450 */
    1444 function get_cancel_comment_reply_link( $text = '' ) {
    1445         if ( empty($text) )
    1446                 $text = __('Click here to cancel reply.');
     1451function get_cancel_comment_reply_link( $args = array() ) {
     1452        $defaults = array(
     1453                'text'       => __('Click here to cancel reply.'),
     1454                'respond_id' => 'respond'
     1455        );
    14471456
    1448         $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
    1449         $link = esc_html( remove_query_arg('replytocom') ) . '#respond';
     1457        /**
     1458         * Fallback for earlier Wordpress versions
     1459         *
     1460         * @since 3.9.2
     1461         */
     1462        if( !is_array($args) )
     1463                $args = array('text' => $args);
    14501464
     1465        $args = wp_parse_args($args, $defaults);
     1466
     1467        extract($args, EXTR_SKIP);
     1468
     1469        $comment = get_comment($_GET['replytocom']);
     1470        $style = $comment && $comment->comment_post_ID == get_the_ID() ? '' : ' style="display:none;"';
     1471        $link = esc_html( remove_query_arg('replytocom') ) . '#' . $respond_id;
     1472
    14511473        $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>';
    14521474        /**
    14531475         * Filter the cancel comment reply link HTML.
     
    14661488 *
    14671489 * @since 2.7.0
    14681490 *
    1469  * @param string $text Optional. Text to display for cancel reply link. Default empty.
     1491 * @param array $args {
     1492 *     Optional. Override default arguments.
     1493 *
     1494 *     @type string $text Optional. Text to display for cancel reply link. Default empty.
     1495 *     @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
     1496 *                              to addComment.moveForm(), and appended to the link URL as a hash value.
     1497 *                              Default 'respond'.
     1498 * }
    14701499 */
    1471 function cancel_comment_reply_link( $text = '' ) {
    1472         echo get_cancel_comment_reply_link($text);
     1500function cancel_comment_reply_link( $args = array() ) {
     1501        echo get_cancel_comment_reply_link($args);
    14731502}
    14741503
    14751504/**