WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/wp-includes/widgets.php

    r5473 r5714  
    7676    $id = sanitize_title($name);
    7777    $options = array();
    78     if ( !empty($classname) )
     78    if ( !empty($classname) && is_string($classname) )
    7979        $options['classname'] = $classname;
    80     $params = array_slice(func_get_args(), 3);
     80    $params = array_slice(func_get_args(), 2);
    8181    $args = array($id, $name, $output_callback, $options);
    8282    if ( !empty($params) )
     
    327327/* Default Widgets */
    328328
    329 function wp_widget_pages($args) {
    330     extract($args);
    331     $options = get_option('widget_pages');
    332     $title = empty($options['title']) ? __('Pages') : $options['title'];
    333     echo $before_widget . $before_title . $title . $after_title . "<ul>\n";
    334     wp_list_pages("title_li=");
    335     echo "</ul>\n" . $after_widget;
     329function wp_widget_pages( $args ) {
     330    extract( $args );
     331    $options = get_option( 'widget_pages' );
     332   
     333    $title = empty( $options['title'] ) ? __( 'Pages' ) : $options['title'];
     334    $sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby'];
     335    $exclude = empty( $options['exclude'] ) ? '' : '&exclude=' . $options['exclude'];
     336   
     337    if ( $sortby == 'menu_order' ) {
     338        $sortby = 'menu_order, post_title';
     339    }
     340   
     341    $out = wp_list_pages( 'title_li=&echo=0&sort_column=' . $sortby . $exclude );
     342   
     343    if ( !empty( $out ) ) {
     344?>
     345    <?php echo $before_widget; ?>
     346        <?php echo $before_title . $title . $after_title; ?>
     347        <ul>
     348            <?php echo $out; ?>
     349        </ul>
     350    <?php echo $after_widget; ?>
     351<?php
     352    }
    336353}
    337354
    338355function wp_widget_pages_control() {
    339356    $options = $newoptions = get_option('widget_pages');
    340     if ( $_POST["pages-submit"] ) {
    341         $newoptions['title'] = strip_tags(stripslashes($_POST["pages-title"]));
     357    if ( $_POST['pages-submit'] ) {
     358        $newoptions['title'] = strip_tags(stripslashes($_POST['pages-title']));
     359       
     360        $sortby = stripslashes( $_POST['pages-sortby'] );
     361       
     362        if ( in_array( $sortby, array( 'post_title', 'menu_order', 'ID' ) ) ) {
     363            $newoptions['sortby'] = $sortby;
     364        } else {
     365            $newoptions['sortby'] = 'menu_order';
     366        }
     367       
     368        $newoptions['exclude'] = strip_tags( stripslashes( $_POST['pages-exclude'] ) );
    342369    }
    343370    if ( $options != $newoptions ) {
     
    346373    }
    347374    $title = attribute_escape($options['title']);
     375    $exclude = attribute_escape( $options['exclude'] );
    348376?>
    349377            <p><label for="pages-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="pages-title" name="pages-title" type="text" value="<?php echo $title; ?>" /></label></p>
     378            <p><label for="pages-sortby"><?php _e( 'Sort by:' ); ?>
     379                <select name="pages-sortby" id="pages-sortby">
     380                    <option value="post_title"<?php selected( $options['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option>
     381                    <option value="menu_order"<?php selected( $options['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option>
     382                    <option value="ID"<?php selected( $options['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>
     383                </select></label></p>
     384            <p><label for="pages-exclude"><?php _e( 'Exclude:' ); ?> <input type="text" value="<?php echo $exclude; ?>" name="pages-exclude" id="pages-exclude" style="width: 180px;" /></label><br />
     385            <small><?php _e( 'Page IDs, separated by commas.' ); ?></small></p>
    350386            <input type="hidden" id="pages-submit" name="pages-submit" value="1" />
    351387<?php
     
    354390function wp_widget_links($args) {
    355391    global $wp_db_version;
    356     extract($args);
     392    extract($args, EXTR_SKIP);
    357393    if ( $wp_db_version < 3582 ) {
    358394        // This ONLY works with li/h2 sidebars.
     
    494530    $options = get_option('widget_text');
    495531    $title = $options[$number]['title'];
    496     if ( empty($title) )
    497         $title = '&nbsp;';
    498     $text = $options[$number]['text'];
     532    $text = apply_filters( 'widget_text', $options[$number]['text'] );
    499533?>
    500534        <?php echo $before_widget; ?>
    501             <?php $title ? print($before_title . $title . $after_title) : null; ?>
     535            <?php if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
    502536            <div class="textwidget"><?php echo $text; ?></div>
    503537        <?php echo $after_widget; ?>
     
    520554    }
    521555    $title = attribute_escape($options[$number]['title']);
    522     $text = attribute_escape($options[$number]['text']);
    523 ?>
    524             <input style="width: 450px;" id="text-title-<?php echo "$number"; ?>" name="text-title-<?php echo "$number"; ?>" type="text" value="<?php echo $title; ?>" />
    525             <textarea style="width: 450px; height: 280px;" id="text-text-<?php echo "$number"; ?>" name="text-text-<?php echo "$number"; ?>"><?php echo $text; ?></textarea>
     556    $text = format_to_edit($options[$number]['text']);
     557?>
     558            <input style="width: 450px;" id="text-title-<?php echo $number; ?>" name="text-title-<?php echo $number; ?>" type="text" value="<?php echo $title; ?>" />
     559            <textarea style="width: 450px; height: 280px;" id="text-text-<?php echo $number; ?>" name="text-text-<?php echo $number; ?>"><?php echo $text; ?></textarea>
    526560            <input type="hidden" id="text-submit-<?php echo "$number"; ?>" name="text-submit-<?php echo "$number"; ?>" value="1" />
    527561<?php
     
    772806function wp_widget_rss($args, $number = 1) {
    773807    require_once(ABSPATH . WPINC . '/rss.php');
    774     extract($args);
     808    extract($args, EXTR_SKIP);
    775809    $options = get_option('widget_rss');
    776810    if ( isset($options['error']) && $options['error'] )
     
    827861        }
    828862    } else {
    829         echo __('<li>An error has occured; the feed is probably down. Try again later.</li>');
     863        echo '<li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li>';
    830864    }
    831865?>
     
    929963    $class = array('classname' => 'widget_pages');
    930964    wp_register_sidebar_widget('pages', __('Pages'), 'wp_widget_pages', $class);
    931     wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control', $dims90);
     965    wp_register_widget_control('pages', __('Pages'), 'wp_widget_pages_control', $dims150);
    932966    $class['classname'] = 'widget_calendar';
    933967    wp_register_sidebar_widget('calendar', __('Calendar'), 'wp_widget_calendar', $class);
Note: See TracChangeset for help on using the changeset viewer.