From 77518dd6ca5fa14d4f0f4390744170ac30d97247 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 14 Mar 2009 17:24:11 +0000 Subject: [PATCH] Convert pages to WP_Widget. see #8441 git-svn-id: http://svn.automattic.com/wordpress/trunk@10785 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/widgets.php | 89 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 3 deletions(-) diff --git a/wp-includes/widgets.php b/wp-includes/widgets.php index 07c76e3a9e..8a77d01080 100644 --- a/wp-includes/widgets.php +++ b/wp-includes/widgets.php @@ -209,6 +209,7 @@ class WP_Widget { } foreach( (array) $_POST['widget-' . $this->id_base] as $number => $new_instance ) { + $new_instance = stripslashes_deep($new_instance); $this->_set($number); if ( isset($all_instances[$number]) ) $instance = $this->update($new_instance, $all_instances[$number]); @@ -1004,6 +1005,87 @@ function wp_widget_pages_control() { 'widget_pages', 'description' => __( "Your blog's WordPress Pages") ); + $this->WP_Widget('pages', __('Pages'), $widget_ops); + } + + function widget( $args, $instance ) { + extract( $args ); + + $title = empty( $instance['title'] ) ? __( 'Pages' ) : apply_filters('widget_title', $instance['title']); + $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; + $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; + + if ( $sortby == 'menu_order' ) + $sortby = 'menu_order, post_title'; + + $out = wp_list_pages( array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ); + + if ( !empty( $out ) ) { + echo $before_widget; + echo $before_title . $title . $after_title; + ?> + + 'post_title', 'title' => '', 'exclude' => '') ); + $title = attribute_escape( $instance['title'] ); + $exclude = attribute_escape( $instance['exclude'] ); + ?> +

+

+ +

+

+ +
+ +

+ + 'widget_pages', 'description' => __( "Your blog's WordPress Pages") ); - wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $widget_ops); - wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control' ); + //$widget_ops = array('classname' => 'widget_pages', 'description' => __( "Your blog's WordPress Pages") ); + //wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $widget_ops); + //wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control' ); + new WP_Widget_Pages(); $widget_ops = array('classname' => 'widget_calendar', 'description' => __( "A calendar of your blog's posts") ); wp_register_sidebar_widget('calendar', __('Calendar'), 'wp_widget_calendar', $widget_ops);