Ticket #24799: trac#24799-fix-ids-in-comment-template.patch
File trac#24799-fix-ids-in-comment-template.patch, 8.1 KB (added by , 10 years ago) |
---|
-
wp-includes/comment-template.php
977 977 $post_id = $post ? $post->ID : 0; 978 978 979 979 if ( current_user_can( 'unfiltered_html' ) ) { 980 wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled' , false );980 wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled' . $post_id, false ); 981 981 echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n"; 982 982 } 983 983 } … … 1364 1364 * @since 2.7.0 1365 1365 * 1366 1366 * @param string $text Optional. Text to display for cancel reply link. Default empty. 1367 * @param string $id optional. Id attribute for cancel link 1367 1368 */ 1368 1369 function get_cancel_comment_reply_link( $text = '' ) { 1369 1370 if ( empty($text) ) 1370 1371 $text = __('Click here to cancel reply.'); 1371 1372 1372 1373 $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; 1373 1374 1375 $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link"href="' . $link . '"' . $style . '>' . $text . '</a>';1374 $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; 1375 $id = empty( $id ) ? '' : "id='cancel-comment-reply-link-" . esc_attr( $id ) . "'"; 1376 $formatted_link = '<a rel="nofollow" ' . $id . ' href="' . $link . '"' . $style . '>' . $text . '</a>'; 1376 1377 /** 1377 1378 * Filter the cancel comment reply link HTML. 1378 1379 * … … 1406 1407 */ 1407 1408 function get_comment_id_fields( $id = 0 ) { 1408 1409 if ( empty( $id ) ) 1409 1410 $id = get_the_ID(); 1410 1411 1412 // ensure unique html id attribute values 1413 $comment_post_id = 'comment_post_id_' . $id; 1414 $comment_parent = 'comment_parent_' . $id; 1415 1411 1416 $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; 1412 $result = "<input type='hidden' name='comment_post_ID' value='$id' id=' comment_post_ID' />\n";1413 $result .= "<input type='hidden' name='comment_parent' id=' comment_parent' value='$replytoid' />\n";1417 $result = "<input type='hidden' name='comment_post_ID' value='$id' id='$comment_post_id' />\n"; 1418 $result .= "<input type='hidden' name='comment_parent' id='$comment_parent' value='$replytoid' />\n"; 1414 1419 1415 1420 /** 1416 1421 * Filter the returned comment id fields. … … 1950 1955 $req = get_option( 'require_name_email' ); 1951 1956 $aria_req = ( $req ? " aria-required='true'" : '' ); 1952 1957 $html5 = 'html5' === $args['format']; 1953 $fields = array( 1958 1959 // ensure unique html id attributes by appending the post id to it 1960 $author_id_attr = 'author-' . $post_id; 1961 $email_id_attr = 'email-' . $post_id; 1962 $url_id_attr = 'url-' . $post_id; 1963 $comment_id_attr = 'comment-' . $post_id; 1964 $respond_id_attr = 'respond-' . $post_id; 1965 $reply_id_attr = 'reply-' . $post_id; 1966 $id_form = 'commentform-' . $post_id; 1967 $id_submit = 'submit-' . $post_id; 1968 $id_cancel_reply_link = 'cancel-comment-reply-link' . $post_id; 1969 1970 1971 $fields = array( 1954 1972 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . 1955 '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"'. $aria_req . ' /></p>',1973 "<input id='$author_id_attr' name='author' type='text' value='" . esc_attr( $commenter['comment_author'] ) . "' size='30'" . $aria_req . ' /></p>', 1956 1974 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . 1957 '<input id="email" name="email" '. ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',1975 "<input id='$email_id_attr' name='email' " . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>', 1958 1976 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . 1959 '<input id="url" name="url" '. ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',1977 "<input id='$url_id_attr' name='url' " . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', 1960 1978 ); 1961 1979 1962 1980 $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); … … 1971 1989 $fields = apply_filters( 'comment_form_default_fields', $fields ); 1972 1990 $defaults = array( 1973 1991 'fields' => $fields, 1974 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',1992 'comment_field' => "<p class='comment-form-comment'><label for='$comment_id_attr'>" . _x( 'Comment', 'noun' ) . "</label> <textarea id='$comment_id_attr' name='comment' cols='45' rows='8' aria-required='true'></textarea></p>", 1975 1993 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', 1976 1994 'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', 1977 1995 'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>', 1978 1996 'comment_notes_after' => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>', 1979 'id_form' => 'commentform',1980 'id_submit' => 'submit',1997 'id_form' => $id_form, 1998 'id_submit' => $id_submit, 1981 1999 'title_reply' => __( 'Leave a Reply' ), 1982 2000 'title_reply_to' => __( 'Leave a Reply to %s' ), 1983 'cancel_reply_link' => __( 'Cancel reply' ), 1984 'label_submit' => __( 'Post Comment' ), 2001 'cancel_reply_link' => __( 'Cancel reply' ), 2002 'id_cancel_reply_link' => $id_cancel_reply_link, 2003 'label_submit' => __( 'Post Comment' ), 2004 'html_before_form' => "<div id='$respond_id_attr' class='comment-respond'>", 2005 'html_after_form' => '</div>', 2006 'title_before_html' => "<h3 id='$reply_id_attr' class='comment-reply-title'>", 2007 'title_after_html' => '</h3>', 1985 2008 'format' => 'xhtml', 1986 2009 ); 1987 2010 … … 2006 2029 */ 2007 2030 do_action( 'comment_form_before' ); 2008 2031 ?> 2009 <div id="respond" class="comment-respond">2010 <h3 id="reply-title" class="comment-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>2032 <?php echo $args['html_before_form']; ?> 2033 <?php echo $args['title_before_html']; comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'], $args['id_cancel_reply_link'] ); ?></small><?php echo $args['title_after_html']; ?> 2011 2034 <?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?> 2012 2035 <?php echo $args['must_log_in']; ?> 2013 2036 <?php … … 2109 2132 ?> 2110 2133 </form> 2111 2134 <?php endif; ?> 2112 </div><!-- #respond -->2135 <?php echo $args['html_after_form']; ?><!-- #respond --> 2113 2136 <?php 2114 2137 /** 2115 2138 * Fires after the comment form.