<!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 &quot;&lt;ol class='children'&gt;\n&quot;;
</del><ins>+                                echo '&lt;ol class=&quot;children&quot;&gt;' . &quot;\n&quot;;
</ins><span class="cx">                                 break;
</span><span class="cx">                         default:
</span><span class="cx">                         case 'ul':
</span><del>-                                echo &quot;&lt;ul class='children'&gt;\n&quot;;
</del><ins>+                                echo '&lt;ul class=&quot;children&quot;&gt;' . &quot;\n&quot;;
</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 &quot;&lt;/ol&gt;\n&quot;;
</del><ins>+                                echo &quot;&lt;/ol&gt;&lt;!-- .children --&gt;\n&quot;;
</ins><span class="cx">                                 break;
</span><span class="cx">                         default:
</span><span class="cx">                         case 'ul':
</span><del>-                                echo &quot;&lt;/ul&gt;\n&quot;;
</del><ins>+                                echo &quot;&lt;/ul&gt;&lt;!-- .children --&gt;\n&quot;;
</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-&gt;comment_type || 'trackback' == $comment-&gt;comment_type ) &amp;&amp; $args['short_ping'] ) {
+                        $this-&gt;ping( $comment, $depth, $args );
+                } elseif ( 'html5' === $args['format'] ) {
+                        $this-&gt;html5_comment( $comment, $depth, $args );
+                } else {
+                        $this-&gt;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( &amp;$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 &quot;&lt;/div&gt;&lt;!-- #comment-## --&gt;\n&quot;;
+                else
+                        echo &quot;&lt;/li&gt;&lt;!-- #comment-## --&gt;\n&quot;;
+        }
+
+        /**
+         * @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';
+?&gt;
+                &lt;&lt;?php echo $tag; ?&gt; id=&quot;comment-&lt;?php comment_ID(); ?&gt;&quot; &lt;?php comment_class(); ?&gt;&gt;
+                        &lt;div class=&quot;comment-body&quot;&gt;
+                                &lt;?php _e( 'Pingback:' ); ?&gt; &lt;?php comment_author_link(); ?&gt; &lt;?php edit_comment_link( __( 'Edit' ), '&lt;span class=&quot;edit-link&quot;&gt;', '&lt;/span&gt;' ); ?&gt;
+                        &lt;/div&gt;
+&lt;?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"> ?&gt;
</span><del>-                &lt;&lt;?php echo $tag ?&gt; &lt;?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?&gt; id=&quot;comment-&lt;?php comment_ID() ?&gt;&quot;&gt;
</del><ins>+                &lt;&lt;?php echo $tag; ?&gt; &lt;?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?&gt; id=&quot;comment-&lt;?php comment_ID(); ?&gt;&quot;&gt;
</ins><span class="cx">                 &lt;?php if ( 'div' != $args['style'] ) : ?&gt;
</span><del>-                &lt;div id=&quot;div-comment-&lt;?php comment_ID() ?&gt;&quot; class=&quot;comment-body&quot;&gt;
</del><ins>+                &lt;div id=&quot;div-comment-&lt;?php comment_ID(); ?&gt;&quot; class=&quot;comment-body&quot;&gt;
</ins><span class="cx">                 &lt;?php endif; ?&gt;
</span><span class="cx">                 &lt;div class=&quot;comment-author vcard&quot;&gt;
</span><del>-                &lt;?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?&gt;
-                &lt;?php printf(__('&lt;cite class=&quot;fn&quot;&gt;%s&lt;/cite&gt; &lt;span class=&quot;says&quot;&gt;says:&lt;/span&gt;'), get_comment_author_link()) ?&gt;
</del><ins>+                        &lt;?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?&gt;
+                        &lt;?php printf( __( '&lt;cite class=&quot;fn&quot;&gt;%s&lt;/cite&gt; &lt;span class=&quot;says&quot;&gt;says:&lt;/span&gt;' ), get_comment_author_link() ); ?&gt;
</ins><span class="cx">                 &lt;/div&gt;
</span><del>-&lt;?php if ($comment-&gt;comment_approved == '0') : ?&gt;
-                &lt;em class=&quot;comment-awaiting-moderation&quot;&gt;&lt;?php _e('Your comment is awaiting moderation.') ?&gt;&lt;/em&gt;
</del><ins>+                &lt;?php if ( '0' == $comment-&gt;comment_approved ) : ?&gt;
+                &lt;em class=&quot;comment-awaiting-moderation&quot;&gt;&lt;?php _e( 'Your comment is awaiting moderation.' ) ?&gt;&lt;/em&gt;
</ins><span class="cx">                 &lt;br /&gt;
</span><del>-&lt;?php endif; ?&gt;
</del><ins>+                &lt;?php endif; ?&gt;
</ins><span class="cx"> 
</span><del>-                &lt;div class=&quot;comment-meta commentmetadata&quot;&gt;&lt;a href=&quot;&lt;?php echo htmlspecialchars( get_comment_link( $comment-&gt;comment_ID ) ) ?&gt;&quot;&gt;
</del><ins>+                &lt;div class=&quot;comment-meta commentmetadata&quot;&gt;&lt;a href=&quot;&lt;?php echo esc_url( get_comment_link( $comment-&gt;comment_ID ) ); ?&gt;&quot;&gt;
</ins><span class="cx">                         &lt;?php
</span><span class="cx">                                 /* translators: 1: date, 2: time */
</span><del>-                                printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?&gt;&lt;/a&gt;&lt;?php edit_comment_link(__('(Edit)'),'&amp;nbsp;&amp;nbsp;','' );
</del><ins>+                                printf( __( '%1$s at %2$s' ), get_comment_date(),  get_comment_time() ); ?&gt;&lt;/a&gt;&lt;?php edit_comment_link( __( '(Edit)' ), '&amp;nbsp;&amp;nbsp;', '' );
</ins><span class="cx">                         ?&gt;
</span><span class="cx">                 &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;?php comment_text() ?&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;div class=&quot;reply&quot;&gt;
</span><del>-                &lt;?php comment_reply_link(array_merge( $args, array('add_below' =&gt; $add_below, 'depth' =&gt; $depth, 'max_depth' =&gt; $args['max_depth']))) ?&gt;
</del><ins>+                        &lt;?php comment_reply_link( array_merge( $args, array( 'add_below' =&gt; $add_below, 'depth' =&gt; $depth, 'max_depth' =&gt; $args['max_depth'] ) ) ); ?&gt;
</ins><span class="cx">                 &lt;/div&gt;
</span><span class="cx">                 &lt;?php if ( 'div' != $args['style'] ) : ?&gt;
</span><span class="cx">                 &lt;/div&gt;
</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(&amp;$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 &quot;&lt;/div&gt;\n&quot;;
-                else
-                        echo &quot;&lt;/li&gt;\n&quot;;
</del><ins>+        protected function html5_comment( $comment, $depth, $args ) {
+                $tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
+?&gt;
+                &lt;&lt;?php echo $tag; ?&gt; id=&quot;comment-&lt;?php comment_ID(); ?&gt;&quot; &lt;?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?&gt;&gt;
+                        &lt;article id=&quot;div-comment-&lt;?php comment_ID(); ?&gt;&quot; class=&quot;comment-body&quot;&gt;
+                                &lt;footer class=&quot;comment-meta&quot;&gt;
+                                        &lt;div class=&quot;comment-author vcard&quot;&gt;
+                                                &lt;?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?&gt;
+                                                &lt;?php printf( __( '%s &lt;span class=&quot;says&quot;&gt;says:&lt;/span&gt;' ), sprintf( '&lt;cite class=&quot;fn&quot;&gt;%s&lt;/cite&gt;', get_comment_author_link() ) ); ?&gt;
+                                        &lt;/div&gt;&lt;!-- .comment-author --&gt;
+
+                                        &lt;div class=&quot;comment-metadata&quot;&gt;
+                                                &lt;a href=&quot;&lt;?php echo esc_url( get_comment_link( $comment-&gt;comment_ID ) ); ?&gt;&quot;&gt;
+                                                        &lt;time datetime=&quot;&lt;?php comment_time( 'c' ); ?&gt;&quot;&gt;
+                                                                &lt;?php printf( _x( '%1$s at %2$s', '1: date, 2: time' ), get_comment_date(), get_comment_time() ); ?&gt;
+                                                        &lt;/time&gt;
+                                                &lt;/a&gt;
+                                                &lt;?php edit_comment_link( __( 'Edit' ), '&lt;span class=&quot;edit-link&quot;&gt;', '&lt;/span&gt;' ); ?&gt;
+                                        &lt;/div&gt;&lt;!-- .comment-metadata --&gt;
+
+                                        &lt;?php if ( '0' == $comment-&gt;comment_approved ) : ?&gt;
+                                        &lt;p class=&quot;comment-awaiting-moderation&quot;&gt;&lt;?php _e( 'Your comment is awaiting moderation.' ); ?&gt;&lt;/p&gt;
+                                        &lt;?php endif; ?&gt;
+                                &lt;/footer&gt;&lt;!-- .comment-meta --&gt;
+
+                                &lt;div class=&quot;comment-content&quot;&gt;
+                                        &lt;?php comment_text(); ?&gt;
+                                &lt;/div&gt;&lt;!-- .comment-content --&gt;
+
+                                &lt;div class=&quot;reply&quot;&gt;
+                                        &lt;?php comment_reply_link( array_merge( $args, array( 'add_below' =&gt; 'div-comment', 'depth' =&gt; $depth, 'max_depth' =&gt; $args['max_depth'] ) ) ); ?&gt;
+                                &lt;/div&gt;&lt;!-- .reply --&gt;
+                        &lt;/article&gt;&lt;!-- .comment-body --&gt;
+&lt;?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' =&gt; null, 'max_depth' =&gt; '', 'style' =&gt; 'ul', 'callback' =&gt; null, 'end-callback' =&gt; null, 'type' =&gt; 'all',
-                'page' =&gt; '', 'per_page' =&gt; '', 'avatar_size' =&gt; 32, 'reverse_top_level' =&gt; null, 'reverse_children' =&gt; '');
</del><ins>+        $defaults = array(
+                'walker'            =&gt; null,
+                'max_depth'         =&gt; '',
+                'style'             =&gt; 'ul',
+                'callback'          =&gt; null,
+                'end-callback'      =&gt; null,
+                'type'              =&gt; 'all',
+                'page'              =&gt; '',
+                'per_page'          =&gt; '',
+                'avatar_size'       =&gt; 32,
+                'reverse_top_level' =&gt; null,
+                'reverse_children'  =&gt; '',
+                'format'            =&gt; 'xhtml', // or html5
+                'short_ping'        =&gt; 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>