Make WordPress Core

Ticket #20088: 20088.6.diff

File 20088.6.diff, 8.1 KB (added by obenland, 11 years ago)
  • wp-includes/comment-template.php

     
    12441244                        case 'div':
    12451245                                break;
    12461246                        case 'ol':
    1247                                 echo "<ol class='children'>\n";
     1247                                echo '<ol class="children">' . "\n";
    12481248                                break;
    12491249                        default:
    12501250                        case 'ul':
    1251                                 echo "<ul class='children'>\n";
     1251                                echo '<ul class="children">' . "\n";
    12521252                                break;
    12531253                }
    12541254        }
     
    12681268                        case 'div':
    12691269                                break;
    12701270                        case 'ol':
    1271                                 echo "</ol>\n";
     1271                                echo "</ol><!-- .children -->\n";
    12721272                                break;
    12731273                        default:
    12741274                        case 'ul':
    1275                                 echo "</ul>\n";
     1275                                echo "</ul><!-- .children -->\n";
    12761276                                break;
    12771277                }
    12781278        }
     
    13301330                $GLOBALS['comment_depth'] = $depth;
    13311331                $GLOBALS['comment'] = $comment;
    13321332
    1333                 if ( !empty($args['callback']) ) {
    1334                         call_user_func($args['callback'], $comment, $args, $depth);
     1333                if ( !empty( $args['callback'] ) ) {
     1334                        call_user_func( $args['callback'], $comment, $args, $depth );
     1335                        return;
     1336                }
     1337
     1338                if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) {
     1339                        $this->ping( 'div' === $args['style'] ? 'div' : 'li' );
     1340                } elseif ( 'html5' === $args['markup'] ) {
     1341                        $this->html5_comment( $comment, $depth, $args );
     1342                } else {
     1343                        $this->comment( $comment, $depth, $args );
     1344                }
     1345        }
     1346
     1347        /**
     1348         * @see Walker::end_el()
     1349         * @since 2.7.0
     1350         *
     1351         * @param string $output Passed by reference. Used to append additional content.
     1352         * @param object $comment
     1353         * @param int $depth Depth of comment.
     1354         * @param array $args
     1355         */
     1356        function end_el( &$output, $comment, $depth = 0, $args = array() ) {
     1357                if ( !empty( $args['end-callback'] ) ) {
     1358                        call_user_func( $args['end-callback'], $comment, $args, $depth );
    13351359                        return;
    13361360                }
     1361                if ( 'div' == $args['style'] )
     1362                        echo "</div><!-- #comment-## -->\n";
     1363                else
     1364                        echo "</li><!-- #comment-## -->\n";
     1365        }
    13371366
    1338                 extract($args, EXTR_SKIP);
     1367        /**
     1368         * @since 3.6
     1369         * @access protected
     1370         *
     1371         * @param string $tag
     1372         */
     1373        protected function ping( $tag ) {
     1374?>
     1375                <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
     1376                        <div class="comment-body">
     1377                                <?php _e( 'Pingback:' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
     1378                        </div>
     1379<?php
     1380        }
    13391381
     1382        /**
     1383         * @since 3.6
     1384         * @access protected
     1385         *
     1386         * @param object $comment Comment to display.
     1387         * @param int $depth Depth of comment.
     1388         * @param array $args Optional args.
     1389         */
     1390        protected function comment( $comment, $depth, $args ) {
    13401391                if ( 'div' == $args['style'] ) {
    13411392                        $tag = 'div';
    13421393                        $add_below = 'comment';
     
    13451396                        $add_below = 'div-comment';
    13461397                }
    13471398?>
    1348                 <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
     1399                <<?php echo $tag; ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?> id="comment-<?php comment_ID(); ?>">
    13491400                <?php if ( 'div' != $args['style'] ) : ?>
    1350                 <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
     1401                <div id="div-comment-<?php comment_ID(); ?>" class="comment-body">
    13511402                <?php endif; ?>
    13521403                <div class="comment-author vcard">
    1353                 <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
    1354                 <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
     1404                        <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
     1405                        <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>
    13551406                </div>
    1356 <?php if ($comment->comment_approved == '0') : ?>
    1357                 <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
     1407                <?php if ( '0' == $comment->comment_approved ) : ?>
     1408                <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ) ?></em>
    13581409                <br />
    1359 <?php endif; ?>
     1410                <?php endif; ?>
    13601411
    1361                 <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">
     1412                <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
    13621413                        <?php
    13631414                                /* translators: 1: date, 2: time */
    1364                                 printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'&nbsp;&nbsp;','' );
     1415                                printf( __( '%1$s at %2$s' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '&nbsp;&nbsp;', '' );
    13651416                        ?>
    13661417                </div>
    13671418
    13681419                <?php comment_text() ?>
    13691420
    13701421                <div class="reply">
    1371                 <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
     1422                        <?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    13721423                </div>
    13731424                <?php if ( 'div' != $args['style'] ) : ?>
    13741425                </div>
     
    13771428        }
    13781429
    13791430        /**
    1380          * @see Walker::end_el()
    1381          * @since 2.7.0
     1431         * @since 3.6
     1432         * @access protected
    13821433         *
    1383          * @param string $output Passed by reference. Used to append additional content.
    1384          * @param object $comment
     1434         * @param object $comment Comment to display.
    13851435         * @param int $depth Depth of comment.
    1386          * @param array $args
     1436         * @param array $args Optional args.
    13871437         */
    1388         function end_el(&$output, $comment, $depth = 0, $args = array() ) {
    1389                 if ( !empty($args['end-callback']) ) {
    1390                         call_user_func($args['end-callback'], $comment, $args, $depth);
    1391                         return;
    1392                 }
    1393                 if ( 'div' == $args['style'] )
    1394                         echo "</div>\n";
    1395                 else
    1396                         echo "</li>\n";
    1397         }
     1438        protected function html5_comment( $comment, $depth, $args ) {
     1439                $tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
     1440?>
     1441                <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>>
     1442                        <article class="comment-body">
     1443                                <footer class="comment-meta">
     1444                                        <div class="comment-author vcard">
     1445                                                <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
     1446                                                <?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
     1447                                        </div><!-- .comment-author -->
     1448
     1449                                        <div class="comment-metadata">
     1450                                                <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
     1451                                                        <time datetime="<?php comment_time( 'c' ); ?>">
     1452                                                                <?php printf( _x( '%1$s at %2$s', '1: date, 2: time' ), get_comment_date(), get_comment_time() ); ?>
     1453                                                        </time>
     1454                                                </a>
     1455                                                <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
     1456                                        </div><!-- .comment-metadata -->
     1457
     1458                                        <?php if ( '0' == $comment->comment_approved ) : ?>
     1459                                        <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p>
     1460                                        <?php endif; ?>
     1461                                </footer><!-- .comment-meta -->
    13981462
     1463                                <div class="comment-content">
     1464                                        <?php comment_text(); ?>
     1465                                </div><!-- .comment-content -->
     1466
     1467                                <div class="reply">
     1468                                        <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
     1469                                </div><!-- .reply -->
     1470                        </article><!-- .comment-body -->
     1471<?php
     1472        }
    13991473}
    14001474
    14011475/**
     
    14171491        $comment_alt = $comment_thread_alt = 0;
    14181492        $comment_depth = 1;
    14191493
    1420         $defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
    1421                 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
     1494        $defaults = array(
     1495                'walker'            => null,
     1496                'max_depth'         => '',
     1497                'style'             => 'ul',
     1498                'callback'          => null,
     1499                'end-callback'      => null,
     1500                'type'              => 'all',
     1501                'page'              => '',
     1502                'per_page'          => '',
     1503                'avatar_size'       => 32,
     1504                'reverse_top_level' => null,
     1505                'reverse_children'  => '',
     1506                'markup'            => '', // 'html5' or empty string
     1507                'short_ping'        => false,
     1508        );
    14221509
    14231510        $r = wp_parse_args( $args, $defaults );
    14241511