Changeset 10785 for trunk/wp-includes/widgets.php
- Timestamp:
- 03/14/2009 05:24:11 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/widgets.php
r10784 r10785 210 210 211 211 foreach( (array) $_POST['widget-' . $this->id_base] as $number => $new_instance ) { 212 $new_instance = stripslashes_deep($new_instance); 212 213 $this->_set($number); 213 214 if ( isset($all_instances[$number]) ) … … 1004 1005 <?php 1005 1006 } 1007 1008 /** 1009 * Pages widget class 1010 * 1011 * @since 2.8.0 1012 */ 1013 class WP_Widget_Pages extends WP_Widget { 1014 1015 function WP_Widget_Pages() { 1016 $widget_ops = array('classname' => 'widget_pages', 'description' => __( "Your blog's WordPress Pages") ); 1017 $this->WP_Widget('pages', __('Pages'), $widget_ops); 1018 } 1019 1020 function widget( $args, $instance ) { 1021 extract( $args ); 1022 1023 $title = empty( $instance['title'] ) ? __( 'Pages' ) : apply_filters('widget_title', $instance['title']); 1024 $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby']; 1025 $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude']; 1026 1027 if ( $sortby == 'menu_order' ) 1028 $sortby = 'menu_order, post_title'; 1029 1030 $out = wp_list_pages( array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ); 1031 1032 if ( !empty( $out ) ) { 1033 echo $before_widget; 1034 echo $before_title . $title . $after_title; 1035 ?> 1036 <ul> 1037 <?php echo $out; ?> 1038 </ul> 1039 <?php 1040 echo $after_widget; 1041 } 1042 } 1043 1044 function update( $new_instance, $old_instance ) { 1045 if ( !isset($new_instance['submit']) ) // user clicked cancel? 1046 return false; 1047 1048 $instance = $old_instance; 1049 $instance['title'] = strip_tags($new_instance['title']); 1050 if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) { 1051 $instance['sortby'] = $new_instance['sortby']; 1052 } else { 1053 $instance['sortby'] = 'menu_order'; 1054 } 1055 1056 $instance['exclude'] = strip_tags( $new_instance['exclude'] ); 1057 1058 return $instance; 1059 } 1060 1061 function form( $instance ) { 1062 //Defaults 1063 $instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') ); 1064 $title = attribute_escape( $instance['title'] ); 1065 $exclude = attribute_escape( $instance['exclude'] ); 1066 ?> 1067 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p> 1068 <p> 1069 <label for="<?php echo $this->get_field_id('sortby'); ?>"><?php _e( 'Sort by:' ); ?> 1070 <select name="<?php echo $this->get_field_name('sortby'); ?>" id="<?php echo $this->get_field_id('sortby'); ?>" class="widefat"> 1071 <option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option> 1072 <option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option> 1073 <option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option> 1074 </select> 1075 </label> 1076 </p> 1077 <p> 1078 <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:' ); ?> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" /></label> 1079 <br /> 1080 <small><?php _e( 'Page IDs, separated by commas.' ); ?></small> 1081 </p> 1082 <input type="hidden" id="<?php echo $this->get_field_id('submit'); ?>" name="<?php echo $this->get_field_name('submit'); ?>" value="1" /> 1083 <?php 1084 } 1085 1086 } 1087 1006 1088 1007 1089 /** … … 2232 2314 return; 2233 2315 2234 $widget_ops = array('classname' => 'widget_pages', 'description' => __( "Your blog's WordPress Pages") ); 2235 wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $widget_ops); 2236 wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control' ); 2316 //$widget_ops = array('classname' => 'widget_pages', 'description' => __( "Your blog's WordPress Pages") ); 2317 //wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $widget_ops); 2318 //wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control' ); 2319 new WP_Widget_Pages(); 2237 2320 2238 2321 $widget_ops = array('classname' => 'widget_calendar', 'description' => __( "A calendar of your blog's posts") );
Note: See TracChangeset
for help on using the changeset viewer.