WordPress.org

Make WordPress Core

Ticket #10910: 10910-cancel_comment_reply_link.patch

File 10910-cancel_comment_reply_link.patch, 3.4 KB (added by zeo, 4 years ago)

In HTML5, small element represent different meaning from HTML4. Besides, small element probably the most hated element in the history of kubrick theme. Switching to span. Adds new parameter $before, $after to cancel_comment_reply_link(). Also checks when needed.

  • wp-includes/comment-template.php

     
    11091109 * @since 2.7.0 
    11101110 * 
    11111111 * @param string $text Optional. Text to display for cancel reply link. 
     1112 * @param string $before The text or HTML to display before the cancel reply link. 
     1113 * @param string $after The text or HTML to display after the cancel reply link. 
    11121114 */ 
    1113 function get_cancel_comment_reply_link($text = '') { 
     1115function get_cancel_comment_reply_link($text = '', $before = '', $after = '') { 
     1116        if ( '0' == get_comments_number() || ( !comments_open() && !pings_open() ) || !get_option('thread_comments') || ( get_option('comment_registration') && !is_user_logged_in() ) )  
     1117                return false; 
     1118 
    11141119        if ( empty($text) ) 
    11151120                $text = __('Click here to cancel reply.'); 
    11161121 
    11171122        $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; 
    11181123        $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; 
    1119         return apply_filters('cancel_comment_reply_link', '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>', $link, $text); 
     1124        $return = $before . '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>' . $after; 
     1125        return apply_filters('cancel_comment_reply_link', $return); 
    11201126} 
    11211127 
    11221128/** 
     
    11251131 * @since 2.7.0 
    11261132 * 
    11271133 * @param string $text Optional. Text to display for cancel reply link. 
     1134 * @param string $before The text or HTML to display before the cancel reply link. 
     1135 * @param string $after The text or HTML to display after the cancel reply link. 
    11281136 */ 
    1129 function cancel_comment_reply_link($text = '') { 
    1130         echo get_cancel_comment_reply_link($text); 
     1137function cancel_comment_reply_link($text = '', $before = '', $after = '') { 
     1138        echo get_cancel_comment_reply_link($text, $before, $after); 
    11311139} 
    11321140 
    11331141/** 
     
    14911499 
    14921500        $commenter = wp_get_current_commenter(); 
    14931501 
    1494         $req = get_option( 'require_name_email' ); 
     1502        $req = get_option( 'require_name_email' );       
    14951503        $aria_req = ( $req ? " aria-required='true'" : '' ); 
    14961504        $fields =  array( 
    14971505                'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . 
     
    15161524                'title_reply_to'       => __( 'Leave a Reply to %s' ), 
    15171525                'cancel_reply_link'    => __( 'Cancel reply' ), 
    15181526                'label_submit'         => __( 'Post Comment' ), 
     1527                'cancel_reply_link_before' => '<span>', 
     1528                'cancel_reply_link_after'  => '</span>' 
    15191529        ); 
    15201530 
    15211531        $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); 
     
    15241534                <?php if ( comments_open() ) : ?> 
    15251535                        <?php do_action( 'comment_form_before' ); ?> 
    15261536                        <div id="respond"> 
    1527                                 <h3 id="reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3> 
     1537                                <h3 id="reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <?php cancel_comment_reply_link( $args['cancel_reply_link'], $args['cancel_reply_link_before'], $args['cancel_reply_link_after'] ); ?></h3> 
    15281538                                <?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?> 
    15291539                                        <?php echo $args['must_log_in']; ?> 
    15301540                                        <?php do_action( 'comment_form_must_log_in_after' ); ?>