Make WordPress Core

Changeset 7726


Ignore:
Timestamp:
04/17/2008 08:36:59 PM (18 years ago)
Author:
ryan
Message:

Tweak unused widgets interface. Make widget titles less repetitive. fixes #6349 #5823 for trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/widgets.php

    r7469 r7726  
    2222                $already_shown = array();
    2323                foreach ( $wp_registered_widgets as $name => $widget ) :
    24                         if ( in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
     24                        if ( 'all' == $show && in_array( $widget['callback'], $already_shown ) ) // We already showed this multi-widget
    2525                                continue;
    2626
     
    4848
    4949                        ob_start();
    50                                 $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ) ) );
     50                                $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) );
    5151                                $sidebar_args = call_user_func_array( 'wp_widget_control', $args );
    5252                        $widget_control_template = ob_get_contents();
     
    6262                                        'edit' => false
    6363                                );
    64                                 if ( $is_multi ) {
     64                                if ( 'all' == $show && $is_multi ) {
    6565                                        // it's a multi-widget.  We only need to show it in the list once.
    6666                                        $already_shown[] = $widget['callback'];
     
    9393                        $no_widgets_shown = false;
    9494
     95
     96                        if ( 'all' != $show && $sidebar_args['_widget_title'] )
     97                                $widget_title = $sidebar_args['_widget_title'];
     98                        else
     99                                $widget_title = $widget['name'];
    95100                ?>
    96101
     
    98103                        <h4 class="widget-title widget-draggable">
    99104
    100                                 <?php echo wp_specialchars( $widget['name'] ); ?>
     105                                <?php echo $widget_title; ?>
    101106
    102107                                <?php if ( 'add' == $action ) : ?>
     
    193198        $id_format = $widget['id'];
    194199        // We aren't showing a widget control, we're outputing a template for a mult-widget control
    195         if ( 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) {
     200        if ( 'all' == $sidebar_args['_show'] && 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) {
    196201                // number == -1 implies a template where id numbers are replaced by a generic '%i%'
    197202                $control['params'][0]['number'] = -1;
     
    203208        $widget_title = '';
    204209        // We grab the normal widget output to find the widget's title
    205         if ( is_callable( $widget['_callback'] ) ) {
     210        if ( ( 'all' != $sidebar_args['_show'] || 'template' != $sidebar_args['_display'] ) && is_callable( $widget['_callback'] ) ) {
    206211                ob_start();
    207212                $args = func_get_args();
     
    213218        unset($wp_registered_widgets[$widget_id]['_callback']);
    214219
    215         if ( $widget_title && $widget_title != $control['name'] )
     220        if ( $widget_title && $widget_title != $sidebar_args['widget_name'] )
    216221                $widget_title = sprintf( _c('%1$s: %2$s|1: widget name, 2: widget title' ), $sidebar_args['widget_name'], $widget_title );
    217222        else
    218223                $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
     224
     225        $sidebar_args['_widget_title'] = $widget_title;
    219226
    220227        if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] )
     
    271278                return '';
    272279        $string = substr( $string, $beg + 14 , $end - $beg - 14);
    273         return wp_specialchars( strip_tags( $string ) );
     280        $string = str_replace( '&nbsp;', ' ', $string );
     281        return trim( wp_specialchars( strip_tags( $string ) ) );
    274282}
    275283
Note: See TracChangeset for help on using the changeset viewer.