<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[23694] trunk/wp-includes/comment-template.php: Improve wp_list_comments() markup.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/23694">23694</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2013-03-14 04:26:04 +0000 (Thu, 14 Mar 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Improve wp_list_comments() markup.
* Whitespace cleanup
* Accepts format=html5 which uses some of the HTML5 elements
* Some helpful HTML comments to help untangle the HTML
* Other misc code cleanup
props lancewillett, obenland, georgestephanis. fixes <a href="http://core.trac.wordpress.org/ticket/20088">#20088</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescommenttemplatephp">trunk/wp-includes/comment-template.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescommenttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/comment-template.php (23693 => 23694)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/comment-template.php        2013-03-14 03:06:07 UTC (rev 23693)
+++ trunk/wp-includes/comment-template.php        2013-03-14 04:26:04 UTC (rev 23694)
</span><span class="lines">@@ -1244,11 +1244,11 @@
</span><span class="cx">                         case 'div':
</span><span class="cx">                                 break;
</span><span class="cx">                         case 'ol':
</span><del>-                                echo "<ol class='children'>\n";
</del><ins>+                                echo '<ol class="children">' . "\n";
</ins><span class="cx">                                 break;
</span><span class="cx">                         default:
</span><span class="cx">                         case 'ul':
</span><del>-                                echo "<ul class='children'>\n";
</del><ins>+                                echo '<ul class="children">' . "\n";
</ins><span class="cx">                                 break;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -1268,11 +1268,11 @@
</span><span class="cx">                         case 'div':
</span><span class="cx">                                 break;
</span><span class="cx">                         case 'ol':
</span><del>-                                echo "</ol>\n";
</del><ins>+                                echo "</ol><!-- .children -->\n";
</ins><span class="cx">                                 break;
</span><span class="cx">                         default:
</span><span class="cx">                         case 'ul':
</span><del>-                                echo "</ul>\n";
</del><ins>+                                echo "</ul><!-- .children -->\n";
</ins><span class="cx">                                 break;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -1330,13 +1330,67 @@
</span><span class="cx">                 $GLOBALS['comment_depth'] = $depth;
</span><span class="cx">                 $GLOBALS['comment'] = $comment;
</span><span class="cx">
</span><del>-                if ( !empty($args['callback']) ) {
-                        call_user_func($args['callback'], $comment, $args, $depth);
</del><ins>+                if ( !empty( $args['callback'] ) ) {
+                        call_user_func( $args['callback'], $comment, $args, $depth );
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                extract($args, EXTR_SKIP);
</del><ins>+                if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) {
+                        $this->ping( $comment, $depth, $args );
+                } elseif ( 'html5' === $args['format'] ) {
+                        $this->html5_comment( $comment, $depth, $args );
+                } else {
+                        $this->comment( $comment, $depth, $args );
+                }
+        }
</ins><span class="cx">
</span><ins>+        /**
+         * @see Walker::end_el()
+         * @since 2.7.0
+         *
+         * @param string $output Passed by reference. Used to append additional content.
+         * @param object $comment
+         * @param int $depth Depth of comment.
+         * @param array $args
+         */
+        function end_el( &$output, $comment, $depth = 0, $args = array() ) {
+                if ( !empty( $args['end-callback'] ) ) {
+                        call_user_func( $args['end-callback'], $comment, $args, $depth );
+                        return;
+                }
+                if ( 'div' == $args['style'] )
+                        echo "</div><!-- #comment-## -->\n";
+                else
+                        echo "</li><!-- #comment-## -->\n";
+        }
+
+        /**
+         * @since 3.6
+         * @access protected
+         *
+         * @param object $comment
+         * @param int $depth Depth of comment.
+         * @param array $args
+         */
+        protected function ping( $comment, $depth, $args ) {
+                $tag = ( 'div' == $args['style'] ) ? 'div' : 'li';
+?>
+                <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
+                        <div class="comment-body">
+                                <?php _e( 'Pingback:' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
+                        </div>
+<?php
+        }
+
+        /**
+         * @since 3.6
+         * @access protected
+         *
+         * @param object $comment Comment to display.
+         * @param int $depth Depth of comment.
+         * @param array $args Optional args.
+         */
+        protected function comment( $comment, $depth, $args ) {
</ins><span class="cx">                 if ( 'div' == $args['style'] ) {
</span><span class="cx">                         $tag = 'div';
</span><span class="cx">                         $add_below = 'comment';
</span><span class="lines">@@ -1345,30 +1399,30 @@
</span><span class="cx">                         $add_below = 'div-comment';
</span><span class="cx">                 }
</span><span class="cx"> ?>
</span><del>-                <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
</del><ins>+                <<?php echo $tag; ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?> id="comment-<?php comment_ID(); ?>">
</ins><span class="cx">                 <?php if ( 'div' != $args['style'] ) : ?>
</span><del>-                <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
</del><ins>+                <div id="div-comment-<?php comment_ID(); ?>" class="comment-body">
</ins><span class="cx">                 <?php endif; ?>
</span><span class="cx">                 <div class="comment-author vcard">
</span><del>-                <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
-                <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
</del><ins>+                        <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
+                        <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>
</ins><span class="cx">                 </div>
</span><del>-<?php if ($comment->comment_approved == '0') : ?>
-                <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
</del><ins>+                <?php if ( '0' == $comment->comment_approved ) : ?>
+                <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ) ?></em>
</ins><span class="cx">                 <br />
</span><del>-<?php endif; ?>
</del><ins>+                <?php endif; ?>
</ins><span class="cx">
</span><del>-                <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">
</del><ins>+                <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
</ins><span class="cx">                         <?php
</span><span class="cx">                                 /* translators: 1: date, 2: time */
</span><del>-                                printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'&nbsp;&nbsp;','' );
</del><ins>+                                printf( __( '%1$s at %2$s' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '&nbsp;&nbsp;', '' );
</ins><span class="cx">                         ?>
</span><span class="cx">                 </div>
</span><span class="cx">
</span><span class="cx">                 <?php comment_text() ?>
</span><span class="cx">
</span><span class="cx">                 <div class="reply">
</span><del>-                <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</del><ins>+                        <?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</ins><span class="cx">                 </div>
</span><span class="cx">                 <?php if ( 'div' != $args['style'] ) : ?>
</span><span class="cx">                 </div>
</span><span class="lines">@@ -1377,25 +1431,48 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><del>-         * @see Walker::end_el()
-         * @since 2.7.0
</del><ins>+         * @since 3.6
+         * @access protected
</ins><span class="cx">          *
</span><del>-         * @param string $output Passed by reference. Used to append additional content.
-         * @param object $comment
</del><ins>+         * @param object $comment Comment to display.
</ins><span class="cx">          * @param int $depth Depth of comment.
</span><del>-         * @param array $args
</del><ins>+         * @param array $args Optional args.
</ins><span class="cx">          */
</span><del>-        function end_el(&$output, $comment, $depth = 0, $args = array() ) {
-                if ( !empty($args['end-callback']) ) {
-                        call_user_func($args['end-callback'], $comment, $args, $depth);
-                        return;
-                }
-                if ( 'div' == $args['style'] )
-                        echo "</div>\n";
-                else
-                        echo "</li>\n";
</del><ins>+        protected function html5_comment( $comment, $depth, $args ) {
+                $tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
+?>
+                <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>>
+                        <article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
+                                <footer class="comment-meta">
+                                        <div class="comment-author vcard">
+                                                <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
+                                                <?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
+                                        </div><!-- .comment-author -->
+
+                                        <div class="comment-metadata">
+                                                <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
+                                                        <time datetime="<?php comment_time( 'c' ); ?>">
+                                                                <?php printf( _x( '%1$s at %2$s', '1: date, 2: time' ), get_comment_date(), get_comment_time() ); ?>
+                                                        </time>
+                                                </a>
+                                                <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
+                                        </div><!-- .comment-metadata -->
+
+                                        <?php if ( '0' == $comment->comment_approved ) : ?>
+                                        <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p>
+                                        <?php endif; ?>
+                                </footer><!-- .comment-meta -->
+
+                                <div class="comment-content">
+                                        <?php comment_text(); ?>
+                                </div><!-- .comment-content -->
+
+                                <div class="reply">
+                                        <?php comment_reply_link( array_merge( $args, array( 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
+                                </div><!-- .reply -->
+                        </article><!-- .comment-body -->
+<?php
</ins><span class="cx">         }
</span><del>-
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -1417,8 +1494,21 @@
</span><span class="cx">         $comment_alt = $comment_thread_alt = 0;
</span><span class="cx">         $comment_depth = 1;
</span><span class="cx">
</span><del>-        $defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
-                'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
</del><ins>+        $defaults = array(
+                'walker' => null,
+                'max_depth' => '',
+                'style' => 'ul',
+                'callback' => null,
+                'end-callback' => null,
+                'type' => 'all',
+                'page' => '',
+                'per_page' => '',
+                'avatar_size' => 32,
+                'reverse_top_level' => null,
+                'reverse_children' => '',
+                'format' => 'xhtml', // or html5
+                'short_ping' => false,
+        );
</ins><span class="cx">
</span><span class="cx">         $r = wp_parse_args( $args, $defaults );
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>