Changeset 10786
- Timestamp:
- 03/14/2009 05:25:59 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/widgets.php
r10785 r10786 926 926 927 927 /* Default Widgets */ 928 929 /**930 * Display pages widget.931 *932 * @since 2.2.0933 *934 * @param array $args Widget arguments.935 */936 function wp_widget_pages( $args ) {937 extract( $args );938 $options = get_option( 'widget_pages' );939 940 $title = empty( $options['title'] ) ? __( 'Pages' ) : apply_filters('widget_title', $options['title']);941 $sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby'];942 $exclude = empty( $options['exclude'] ) ? '' : $options['exclude'];943 944 if ( $sortby == 'menu_order' ) {945 $sortby = 'menu_order, post_title';946 }947 948 $out = wp_list_pages( array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) );949 950 if ( !empty( $out ) ) {951 ?>952 <?php echo $before_widget; ?>953 <?php echo $before_title . $title . $after_title; ?>954 <ul>955 <?php echo $out; ?>956 </ul>957 <?php echo $after_widget; ?>958 <?php959 }960 }961 962 /**963 * Display and process pages widget options form.964 *965 * @since 2.2.0966 */967 function wp_widget_pages_control() {968 $options = $newoptions = get_option('widget_pages');969 if ( isset($_POST['pages-submit']) ) {970 $newoptions['title'] = strip_tags(stripslashes($_POST['pages-title']));971 972 $sortby = stripslashes( $_POST['pages-sortby'] );973 974 if ( in_array( $sortby, array( 'post_title', 'menu_order', 'ID' ) ) ) {975 $newoptions['sortby'] = $sortby;976 } else {977 $newoptions['sortby'] = 'menu_order';978 }979 980 $newoptions['exclude'] = strip_tags( stripslashes( $_POST['pages-exclude'] ) );981 }982 if ( $options != $newoptions ) {983 $options = $newoptions;984 update_option('widget_pages', $options);985 }986 $title = attribute_escape($options['title']);987 $exclude = attribute_escape( $options['exclude'] );988 ?>989 <p><label for="pages-title"><?php _e('Title:'); ?> <input class="widefat" id="pages-title" name="pages-title" type="text" value="<?php echo $title; ?>" /></label></p>990 <p>991 <label for="pages-sortby"><?php _e( 'Sort by:' ); ?>992 <select name="pages-sortby" id="pages-sortby" class="widefat">993 <option value="post_title"<?php selected( $options['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option>994 <option value="menu_order"<?php selected( $options['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option>995 <option value="ID"<?php selected( $options['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>996 </select>997 </label>998 </p>999 <p>1000 <label for="pages-exclude"><?php _e( 'Exclude:' ); ?> <input type="text" value="<?php echo $exclude; ?>" name="pages-exclude" id="pages-exclude" class="widefat" /></label>1001 <br />1002 <small><?php _e( 'Page IDs, separated by commas.' ); ?></small>1003 </p>1004 <input type="hidden" id="pages-submit" name="pages-submit" value="1" />1005 <?php1006 }1007 928 1008 929 /** … … 2314 2235 return; 2315 2236 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 2237 new WP_Widget_Pages(); 2320 2238
Note: See TracChangeset
for help on using the changeset viewer.