Make WordPress Core

Ticket #10948: comment-walker-echo-issue-284.diff

File comment-walker-echo-issue-284.diff, 5.5 KB (added by MikeLittle, 15 years ago)

Patch to fix issue in version 2.8.4. Diff-ed against tag 2.8.4

  • wp-includes/comment-template.php

     
    11901190                        case 'div':
    11911191                                break;
    11921192                        case 'ol':
    1193                                 echo "<ol class='children'>\n";
     1193                                $output .= "<ol class='children'>\n";
    11941194                                break;
    11951195                        default:
    11961196                        case 'ul':
    1197                                 echo "<ul class='children'>\n";
     1197                                $output .= "<ul class='children'>\n";
    11981198                                break;
    11991199                }
    12001200        }
     
    12141214                        case 'div':
    12151215                                break;
    12161216                        case 'ol':
    1217                                 echo "</ol>\n";
     1217                                $output .= "</ol>\n";
    12181218                                break;
    12191219                        default:
    12201220                        case 'ul':
    1221                                 echo "</ul>\n";
     1221                                $output .= "</ul>\n";
    12221222                                break;
    12231223                }
    12241224        }
     
    12511251                        $tag = 'li';
    12521252                        $add_below = 'div-comment';
    12531253                }
    1254 ?>
    1255                 <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
    1256                 <?php if ( 'ul' == $args['style'] ) : ?>
    1257                 <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
    1258                 <?php endif; ?>
    1259                 <div class="comment-author vcard">
    1260                 <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
    1261                 <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
    1262                 </div>
    1263 <?php if ($comment->comment_approved == '0') : ?>
    1264                 <em><?php _e('Your comment is awaiting moderation.') ?></em>
    1265                 <br />
    1266 <?php endif; ?>
    12671254
    1268                 <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>
     1255                $output .=
     1256                                  '<'. $tag .' '. comment_class(empty( $args['has_children'] ) ? '' : 'parent', null, null, false) .' id="comment-'. get_comment_ID() .'">' . "\n";
     1257                if ( 'ul' == $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)
     1262                        $output .= get_avatar( $comment, $args['avatar_size'] );
     1263                $output .= sprintf(__('<cite class="fn">%s</cite> <span class="says">says:</span>' . "\n"), get_comment_author_link());
     1264                $output .= '</div>' . "\n";
     1265                if ($comment->comment_approved == '0') :
     1266                        $output .= '<em>' . __('Your comment is awaiting moderation.') . '</em> . "\n"';
     1267                        $output .= '<br /> . "\n"';
     1268                endif;
    12691269
    1270                 <?php comment_text() ?>
     1270                $output .= '<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";
    12711271
    1272                 <div class="reply">
    1273                 <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
    1274                 </div>
    1275                 <?php if ( 'ul' == $args['style'] ) : ?>
    1276                 </div>
    1277                 <?php endif; ?>
    1278 <?php
     1272                $output .= apply_filters('comment_text', get_comment_text() ) . "\n";
     1273
     1274                $output .= '<div class="reply">' . "\n" .
     1275                                   get_comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) . "\n" .
     1276                                   '</div>' . "\n";
     1277                if ( 'ul' == $args['style'] ) :
     1278                        $output .= '</div>' . "\n";
     1279                endif;
    12791280        }
    12801281
    12811282        /**
     
    12931294                        return;
    12941295                }
    12951296                if ( 'div' == $args['style'] )
    1296                         echo "</div>\n";
     1297                        $output .= "</div>\n";
    12971298                else
    1298                         echo "</li>\n";
     1299                        $output .= "</li>\n";
    12991300        }
    13001301
    13011302}
     
    13201321        $comment_depth = 1;
    13211322
    13221323        $defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
    1323                 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
     1324                'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '', 'echo' => 1);
    13241325
    13251326        $r = wp_parse_args( $args, $defaults );
    13261327
     
    13881389        if ( empty($walker) )
    13891390                $walker = new Walker_Comment;
    13901391
    1391         $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
     1392        $output = $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
    13921393        $wp_query->max_num_comment_pages = $walker->max_pages;
    13931394
    13941395        $in_comment_loop = false;
     1396
     1397        if ( $r['echo'] )
     1398                echo $output;
     1399        else
     1400                return $output;
    13951401}
    13961402
    13971403?>
  • wp-includes/link-template.php

     
    765765 * @param string $after Optional. Display after edit link.
    766766 * @return string|null HTML content, if $echo is set to false.
    767767 */
    768 function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
     768function edit_comment_link( $link = 'Edit This', $before = '', $after = '', $echo = true ) {
    769769        global $comment, $post;
    770770
    771771        if ( $post->post_type == 'page' ) {
     
    777777        }
    778778
    779779        $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
    780         echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
     780        if ($echo)
     781                echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
     782        else
     783                return $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
    781784}
    782785
    783786/**