WordPress.org

Make WordPress Core

Ticket #46747: 46747-3.diff

File 46747-3.diff, 1.5 KB (added by birgire, 5 months ago)
  • src/wp-includes/widgets/class-wp-widget-recent-comments.php

    diff --git src/wp-includes/widgets/class-wp-widget-recent-comments.php src/wp-includes/widgets/class-wp-widget-recent-comments.php
    index 6d89eee..b1aaa93 100644
    class WP_Widget_Recent_Comments extends WP_Widget { 
    6666         * Outputs the content for the current Recent Comments widget instance.
    6767         *
    6868         * @since 2.8.0
     69         * @since 5.3.0 Added $first_recentcomments staticvar.
     70         *
     71         * @staticvar bool $first_dropdown
    6972         *
    7073         * @param array $args     Display arguments including 'before_title', 'after_title',
    7174         *                        'before_widget', and 'after_widget'.
    7275         * @param array $instance Settings for the current Recent Comments widget instance.
    7376         */
    7477        public function widget( $args, $instance ) {
     78                static $first_recentcomments = true;
     79
    7580                if ( ! isset( $args['widget_id'] ) ) {
    7681                        $args['widget_id'] = $this->id;
    7782                }
    class WP_Widget_Recent_Comments extends WP_Widget { 
    116121                        $output .= $args['before_title'] . $title . $args['after_title'];
    117122                }
    118123
    119                 $output .= '<ul id="recentcomments">';
     124                $recentcomments_id    = ( $first_recentcomments ) ? 'recentcomments' : $args['widget_id'];
     125                $first_recentcomments = false;
     126
     127                $output .= '<ul id="' . esc_attr( $recentcomments_id ) . '">';
    120128                if ( is_array( $comments ) && $comments ) {
    121129                        // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
    122130                        $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );