From 10c5eefc71221178f6ddfe534c7ffd5376326e77 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 17 Mar 2009 02:33:08 +0000 Subject: [PATCH] Move calendar widget to WP_Widget. see #8441 git-svn-id: http://svn.automattic.com/wordpress/trunk@10799 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-widgets.php | 46 ++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php index da260bbbcb..9f2b24a46a 100644 --- a/wp-includes/default-widgets.php +++ b/wp-includes/default-widgets.php @@ -335,6 +335,48 @@ function wp_widget_calendar_control() { 'widget_calendar', 'description' => __( "A calendar of your blog's posts") ); + $this->WP_Widget('calendar', __('Calendar'), $widget_ops); + } + + function widget( $args, $instance ) { + extract($args); + $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); + echo $before_widget . $before_title . $title . $after_title; + echo '
'; + get_calendar(); + echo '
'; + echo $after_widget; + } + + function update( $new_instance, $old_instance ) { + if ( !isset($new_instance['submit']) ) // user clicked cancel? + return false; + + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + + return $instance; + } + + function form( $instance ) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); + $title = strip_tags($instance['title']); +?> +

+ + 'widget_calendar', 'description' => __( "A calendar of your blog's posts") ); - wp_register_sidebar_widget('calendar', __('Calendar'), 'wp_widget_calendar', $widget_ops); - wp_register_widget_control('calendar', __('Calendar'), 'wp_widget_calendar_control' ); + new WP_Widget_Calendar(); new WP_Widget_Archives();