Make WordPress Core

Ticket #15400: 15400.patch

File 15400.patch, 1.8 KB (added by chalet16, 15 years ago)
  • wp-includes/default-widgets.php

     
    648648                        $number = 5;
    649649                else if ( $number < 1 )
    650650                        $number = 1;
    651 
     651                add_action('comments_clauses', array( 'WP_Widget_Recent_Comments', 'comments_query_filter'));
    652652                $comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) );
     653                remove_action('comments_clauses', array( 'WP_Widget_Recent_Comments', 'comments_query_filter'));
    653654                $output .= $before_widget;
    654655                if ( $title )
    655656                        $output .= $before_title . $title . $after_title;
    656 
     657               
    657658                $output .= '<ul id="recentcomments">';
    658659                if ( $comments ) {
     660
    659661                        foreach ( (array) $comments as $comment) {
    660                                 $output .=  '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
     662                                get_post($comment);
     663
     664                                $output .=  '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment) ) . '">' . get_the_title($comment) . '</a>') . '</li>';
    661665                        }
    662666                }
    663667                $output .= '</ul>';
     
    692696                <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
    693697<?php
    694698        }
     699       
     700        function comments_query_filter($pieces) {
     701                global $wpdb;
     702               
     703                $pieces['join'] .= " LEFT JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )";
     704               
     705                return $pieces;
     706        }
    695707}
    696708
    697709/**