Make WordPress Core

Changeset 34381


Ignore:
Timestamp:
09/22/2015 05:08:33 AM (9 years ago)
Author:
wonderboymusic
Message:

Widgets: add a static property to WP_Widget_Calendar to ensure that the id attribute is only output once.

Props MikeHansenMe, wonderboymusic.
Fixes #24604.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-widget-calendar.php

    r33954 r34381  
    88 */
    99class WP_Widget_Calendar extends WP_Widget {
     10    /**
     11     * Ensure that the ID attribute only appears in the markup once
     12     *
     13     * @since 4.4.0
     14     *
     15     * @static
     16     * @access private
     17     * @var int
     18     */
     19    private static $instance = 0;
    1020
    1121    public function __construct() {
     
    2636            echo $args['before_title'] . $title . $args['after_title'];
    2737        }
    28         echo '<div id="calendar_wrap">';
     38        if ( 0 === self::$instance ) {
     39            echo '<div id="calendar_wrap" class="calendar_wrap">';
     40        } else {
     41            echo '<div class="calendar_wrap">';
     42        }
    2943        get_calendar();
    3044        echo '</div>';
    3145        echo $args['after_widget'];
     46
     47        self::$instance++;
    3248    }
    3349
Note: See TracChangeset for help on using the changeset viewer.