wp/wp-includes/widgets/class-wp-widget-calendar.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    17 class WP_Widget_Calendar extends WP_Widget {
    17 class WP_Widget_Calendar extends WP_Widget {
    18 	/**
    18 	/**
    19 	 * Ensure that the ID attribute only appears in the markup once
    19 	 * Ensure that the ID attribute only appears in the markup once
    20 	 *
    20 	 *
    21 	 * @since 4.4.0
    21 	 * @since 4.4.0
    22 	 *
       
    23 	 * @static
       
    24 	 * @var int
    22 	 * @var int
    25 	 */
    23 	 */
    26 	private static $instance = 0;
    24 	private static $instance = 0;
    27 
    25 
    28 	/**
    26 	/**
    30 	 *
    28 	 *
    31 	 * @since 2.8.0
    29 	 * @since 2.8.0
    32 	 */
    30 	 */
    33 	public function __construct() {
    31 	public function __construct() {
    34 		$widget_ops = array(
    32 		$widget_ops = array(
    35 			'classname' => 'widget_calendar',
    33 			'classname'                   => 'widget_calendar',
    36 			'description' => __( 'A calendar of your site’s Posts.' ),
    34 			'description'                 => __( 'A calendar of your site’s Posts.' ),
    37 			'customize_selective_refresh' => true,
    35 			'customize_selective_refresh' => true,
    38 		);
    36 		);
    39 		parent::__construct( 'calendar', __( 'Calendar' ), $widget_ops );
    37 		parent::__construct( 'calendar', __( 'Calendar' ), $widget_ops );
    40 	}
    38 	}
    41 
    39 
    79 	 *                            WP_Widget::form().
    77 	 *                            WP_Widget::form().
    80 	 * @param array $old_instance Old settings for this instance.
    78 	 * @param array $old_instance Old settings for this instance.
    81 	 * @return array Updated settings to save.
    79 	 * @return array Updated settings to save.
    82 	 */
    80 	 */
    83 	public function update( $new_instance, $old_instance ) {
    81 	public function update( $new_instance, $old_instance ) {
    84 		$instance = $old_instance;
    82 		$instance          = $old_instance;
    85 		$instance['title'] = sanitize_text_field( $new_instance['title'] );
    83 		$instance['title'] = sanitize_text_field( $new_instance['title'] );
    86 
    84 
    87 		return $instance;
    85 		return $instance;
    88 	}
    86 	}
    89 
    87 
    94 	 *
    92 	 *
    95 	 * @param array $instance Current settings.
    93 	 * @param array $instance Current settings.
    96 	 */
    94 	 */
    97 	public function form( $instance ) {
    95 	public function form( $instance ) {
    98 		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    96 		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    99 		$title = sanitize_text_field( $instance['title'] );
       
   100 		?>
    97 		?>
   101 		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
    98 		<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
   102 		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
    99 		<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /></p>
   103 		<?php
   100 		<?php
   104 	}
   101 	}
   105 }
   102 }