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
This commit is contained in:
parent
0ad726ef4d
commit
3a00b7c5f0
@ -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++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user