Make WordPress Core

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

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

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

  • 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 ( 'ul' == $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; ?>
    12691256
    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>
     1257                $output .=
     1258                                  '<'. $tag .' '. comment_class(empty( $args['has_children'] ) ? '' : 'parent', null, null, false) .' id="comment-'. get_comment_ID() .'">' . "\n";
     1259                if ( 'ul' == $args['style'] ) :
     1260                        $output .= '<div id="div-comment-'. get_comment_ID() .'" class="comment-body">' . "\n";
     1261                endif;
     1262                $output .= '<div class="comment-author vcard">' . "\n";
     1263                if ($args['avatar_size'] != 0)
     1264                        $output .= get_avatar( $comment, $args['avatar_size'] );
     1265                $output .= sprintf(__('<cite class="fn">%s</cite> <span class="says">says:</span>' . "\n"), get_comment_author_link());
     1266                $output .= '</div>' . "\n";
     1267                if ($comment->comment_approved == '0') :
     1268                        $output .= '<em>' . __('Your comment is awaiting moderation.') . '</em> . "\n"';
     1269                        $output .= '<br /> . "\n"';
     1270                endif;
    12711271
    1272                 <?php comment_text() ?>
     1272                $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";
    12731273
    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 ( 'ul' == $args['style'] ) : ?>
    1278                 </div>
    1279                 <?php endif; ?>
    1280 <?php
     1274                $output .= apply_filters('comment_text', get_comment_text() ) . "\n";
     1275
     1276                $output .= '<div class="reply">' . "\n" .
     1277                                   get_comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) . "\n" .
     1278                                   '</div>' . "\n";
     1279                if ( 'ul' == $args['style'] ) :
     1280                        $output .= '</div>' . "\n";
     1281                endif;
    12811282        }
    12821283
    12831284        /**
     
    12951296                        return;
    12961297                }
    12971298                if ( 'div' == $args['style'] )
    1298                         echo "</div>\n";
     1299                        $output .= "</div>\n";
    12991300                else
    1300                         echo "</li>\n";
     1301                        $output .= "</li>\n";
    13011302        }
    13021303
    13031304}
     
    13221323        $comment_depth = 1;
    13231324
    13241325        $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' => '');
     1326                'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '', 'echo' => 1);
    13261327
    13271328        $r = wp_parse_args( $args, $defaults );
    13281329
     
    13901391        if ( empty($walker) )
    13911392                $walker = new Walker_Comment;
    13921393
    1393         $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
     1394        $output = $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
    13941395        $wp_query->max_num_comment_pages = $walker->max_pages;
    13951396
    13961397        $in_comment_loop = false;
     1398
     1399        if ( $r['echo'] )
     1400                echo $output;
     1401        else
     1402                return $output;
    13971403}
    13981404
    13991405?>
  • 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/**