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
This commit is contained in:
Scott Taylor 2015-09-22 05:09:24 +00:00
parent eb1e8f41a0
commit 51115a6816
2 changed files with 18 additions and 2 deletions

View File

@ -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.

View File

@ -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 '<div id="calendar_wrap">';
if ( 0 === self::$instance ) {
echo '<div id="calendar_wrap" class="calendar_wrap">';
} else {
echo '<div class="calendar_wrap">';
}
get_calendar();
echo '</div>';
echo $args['after_widget'];
self::$instance++;
}
/**