From 51115a6816f8a7b072f37bdd24ec03bdd15845d4 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 22 Sep 2015 05:09:24 +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. Built from https://develop.svn.wordpress.org/trunk@34381 git-svn-id: http://core.svn.wordpress.org/trunk@34345 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- .../widgets/class-wp-widget-calendar.php | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index 2a070b31f2..17bde8f194 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34380'; +$wp_version = '4.4-alpha-34381'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/widgets/class-wp-widget-calendar.php b/wp-includes/widgets/class-wp-widget-calendar.php index 8fd7aebed0..4329bcf18a 100644 --- a/wp-includes/widgets/class-wp-widget-calendar.php +++ b/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++; } /**