Make WordPress Core

Ticket #10948: comment-walker-echo-issue-trunk-12304.diff

File comment-walker-echo-issue-trunk-12304.diff, 5.6 KB (added by MikeLittle, 15 years ago)

Patch to fix issue. Diff-ed against trunk at rev 12304

  • wp-includes/comment-template.php

     
    11921192                        case 'div':
    11931193                                break;
    11941194                        case 'ol':
    1195                                 echo "<ol class='children'>\n";
     1195                                $output .= "<ol class='children'>\n";
    11961196                                break;
    11971197                        default:
    11981198                        case 'ul':
    1199                                 echo "<ul class='children'>\n";
     1199                                $output .= "<ul class='children'>\n";
    12001200                                break;
    12011201                }
    12021202        }
     
    12161216                        case 'div':
    12171217                                break;
    12181218                        case 'ol':
    1219                                 echo "</ol>\n";
     1219                                $output .= "</ol>\n";
    12201220                                break;
    12211221                        default:
    12221222                        case 'ul':
    1223                                 echo "</ul>\n";
     1223                                $output .= "</ul>\n";
    12241224                                break;
    12251225                }
    12261226        }
     
    12531253                        $tag = 'li';
    12541254                        $add_below = 'div-comment';
    12551255                }
    1256 ?>
    1257                 <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
    1258                 <?php if ( 'div' != $args['style'] ) : ?>
    1259                 <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
    1260                 <?php endif; ?>
    1261                 <div class="comment-author vcard">
    1262                 <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
    1263                 <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
    1264                 </div>
    1265 <?php if ($comment->comment_approved == '0') : ?>
    1266                 <em><?php _e('Your comment is awaiting moderation.') ?></em>
    1267                 <br />
    1268 <?php endif; ?>
    1269 
    1270                 <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'&nbsp;&nbsp;','') ?></div>
    1271 
    1272                 <?php comment_text() ?>
    1273 
    1274                 <div class="reply">
    1275                 <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
    1276                 </div>
    1277                 <?php if ( 'div' != $args['style'] ) : ?>
    1278                 </div>
    1279                 <?php endif; ?>
    1280 <?php
     1256        $output .= ' <' . $tag .  ' ' . comment_class(empty( $args['has_children'] ) ? '' : 'parent', null, null, false) .' id="comment-' . get_comment_ID() . '">' . "\n";
     1257                if ( 'div' != $args['style'] ) :
     1258            $output .= ' <div id="div-comment-' . get_comment_ID() . '" class="comment-body">' . "\n";
     1259                endif;
     1260        $output .= ' <div class="comment-author vcard">' . "\n";
     1261                if ($args['avatar_size'] != 0) $output .= ' ' . get_avatar( $comment, $args['avatar_size'] );
     1262        $output .= sprintf(__(' <cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link());
     1263        $output .= ' </div>' . "\n";
     1264        if ($comment->comment_approved == '0') :
     1265            $output .= '<em>'. __('Your comment is awaiting moderation.') . '</em>' . "\n";
     1266            $output .= '<br />' . "\n";
     1267        endif;
     1268        $output .= "\n" . ' <div class="comment-meta commentmetadata"><a href="' . htmlspecialchars( get_comment_link( $comment->comment_ID ) ) . '">' . sprintf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) . '</a>' .  edit_comment_link(__('(Edit)'),'&nbsp;&nbsp;','', false) . '</div>' . "\n\n ";
     1269        $output .= apply_filters('comment_text', get_comment_text() ) . "\n";
     1270        $output .= ' <div class="reply">';
     1271        $output .= get_comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) . "\n";
     1272        $output .= ' </div>' . "\n";
     1273                if ( 'div' != $args['style'] ) :
     1274            $output .= ' </div>' . "\n";
     1275        endif;
    12811276        }
    12821277
    12831278        /**
     
    12951290                        return;
    12961291                }
    12971292                if ( 'div' == $args['style'] )
    1298                         echo "</div>\n";
     1293                        $output .= " </div>\n";
    12991294                else
    1300                         echo "</li>\n";
     1295                        $output .= " </li>\n";
    13011296        }
    13021297
    13031298}
     
    13221317        $comment_depth = 1;
    13231318
    13241319        $defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
    1325                 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
     1320                'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '', 'echo' => 1);
    13261321
    13271322        $r = wp_parse_args( $args, $defaults );
    13281323
     
    13901385        if ( empty($walker) )
    13911386                $walker = new Walker_Comment;
    13921387
    1393         $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
     1388        $output = $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
    13941389        $wp_query->max_num_comment_pages = $walker->max_pages;
    13951390
    13961391        $in_comment_loop = false;
     1392
     1393        if ( $r['echo'] )
     1394                echo $output;
     1395        else
     1396                return $output;
    13971397}
    13981398
    13991399?>
  • wp-includes/link-template.php

     
    820820 * @param string $after Optional. Display after edit link.
    821821 * @return string|null HTML content, if $echo is set to false.
    822822 */
    823 function edit_comment_link( $link = null, $before = '', $after = '' ) {
     823function edit_comment_link( $link = null, $before = '', $after = '', $echo = true ) {
    824824        global $comment, $post;
    825825
    826826        if ( $post->post_type == 'page' ) {
     
    835835                $link = __('Edit This');
    836836
    837837        $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
    838         echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
     838        if ($echo)
     839                echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
     840        else
     841                return $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
    839842}
    840843
    841844/**