mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Widgets: Create a unique HTML ID for the <ul>
element of Recent Comments widget if more than one instance is displayed on the page.
Props peterwilsoncc, audrasjb, birgire, justinahinon, mbrailer, desrosj. Fixes #46747. Built from https://develop.svn.wordpress.org/trunk@47371 git-svn-id: http://core.svn.wordpress.org/trunk@47158 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
00f110740b
commit
8b0a0c44aa
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.4-beta2-47370';
|
||||
$wp_version = '5.4-beta2-47371';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
@ -34,6 +34,8 @@ class WP_Widget_Categories extends WP_Widget {
|
||||
* Outputs the content for the current Categories widget instance.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 4.2.0 Creates a unique HTML ID for the `<select>` element
|
||||
* if more than one instance is displayed on the page.
|
||||
*
|
||||
* @staticvar bool $first_dropdown
|
||||
*
|
||||
|
@ -66,12 +66,18 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
||||
* Outputs the content for the current Recent Comments widget instance.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 5.4.0 Creates a unique HTML ID for the `<ul>` element
|
||||
* if more than one instance is displayed on the page.
|
||||
*
|
||||
* @staticvar bool $first_instance
|
||||
*
|
||||
* @param array $args Display arguments including 'before_title', 'after_title',
|
||||
* 'before_widget', and 'after_widget'.
|
||||
* @param array $instance Settings for the current Recent Comments widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
static $first_instance = true;
|
||||
|
||||
if ( ! isset( $args['widget_id'] ) ) {
|
||||
$args['widget_id'] = $this->id;
|
||||
}
|
||||
@ -116,7 +122,10 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
||||
$output .= $args['before_title'] . $title . $args['after_title'];
|
||||
}
|
||||
|
||||
$output .= '<ul id="recentcomments">';
|
||||
$recent_comments_id = ( $first_instance ) ? 'recentcomments' : "recentcomments-{$this->number}";
|
||||
$first_instance = false;
|
||||
|
||||
$output .= '<ul id="' . esc_attr( $recent_comments_id ) . '">';
|
||||
if ( is_array( $comments ) && $comments ) {
|
||||
// Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
|
||||
$post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
|
||||
|
Loading…
Reference in New Issue
Block a user