From 3a00b7c5f0b3e4d1f91c0c57ea4bdfeb61d502d9 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 22 Sep 2015 05:08:33 +0000 Subject: [PATCH] Widgets: add a `static` property to `WP_Widget_Calendar` to ensure that the `id` attribute is only output once. Props MikeHansenMe, wonderboymusic. Fixes #24604. git-svn-id: https://develop.svn.wordpress.org/trunk@34381 602fd350-edb4-49c9-b593-d223f7449a82 --- .../widgets/class-wp-widget-calendar.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/widgets/class-wp-widget-calendar.php b/src/wp-includes/widgets/class-wp-widget-calendar.php index 8fd7aebed0..4329bcf18a 100644 --- a/src/wp-includes/widgets/class-wp-widget-calendar.php +++ b/src/wp-includes/widgets/class-wp-widget-calendar.php @@ -7,6 +7,16 @@ * @subpackage Widgets */ class WP_Widget_Calendar extends WP_Widget { + /** + * Ensure that the ID attribute only appears in the markup once + * + * @since 4.4.0 + * + * @static + * @access private + * @var int + */ + private static $instance = 0; public function __construct() { $widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site’s Posts.') ); @@ -25,10 +35,16 @@ class WP_Widget_Calendar extends WP_Widget { if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } - echo '
'; + if ( 0 === self::$instance ) { + echo '
'; + } else { + echo '
'; + } get_calendar(); echo '
'; echo $args['after_widget']; + + self::$instance++; } /**