WordPress.org

Make WordPress Core

Changeset 11009


Ignore:
Timestamp:
04/20/2009 10:58:50 AM (10 years ago)
Author:
azaozz
Message:

Add and edit widget when js is disabled, see #9511

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r10988 r11009  
    785785                    $x->send();
    786786                }
    787                 if ( !$mid = add_meta( $pid ) ) 
     787                if ( !$mid = add_meta( $pid ) )
    788788                    die(__('Please provide a custom field value.'));
    789789            } else {
     
    814814        if ( !$u = update_meta( $mid, $key, $value ) )
    815815            die('0'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
    816    
     816
    817817        $key = stripslashes($key);
    818818        $value = stripslashes($value);
     
    12891289        $widget = isset($wp_registered_widgets[$del_id]) ? $wp_registered_widgets[$del_id] : false;
    12901290
    1291         if ( !in_array($del_id, $sidebar, true) || !$widget )
     1291        if ( !in_array($del_id, $sidebar, true) )
    12921292            die('-1');
    12931293
    1294         $option = str_replace( '-', '_', 'widget_' . $id_base );
    1295         $data = get_option($option);
    1296 
    1297         if ( isset($widget['params'][0]['number']) ) {
    1298             $number = $widget['params'][0]['number'];
    1299             if ( is_array($data) && isset($data[$number]) ) {
    1300                 unset( $data[$number] );
    1301                 update_option($option, $data);
    1302             }
    1303         } else {
    1304             if ( $data ) {
    1305                 $data = array();
    1306                 update_option($option, $data);
     1294        if ( $widget ) {
     1295            $option = str_replace( '-', '_', 'widget_' . $id_base );
     1296            $data = get_option($option);
     1297
     1298            if ( isset($widget['params'][0]['number']) ) {
     1299                $number = $widget['params'][0]['number'];
     1300                if ( is_array($data) && isset($data[$number]) ) {
     1301                    unset( $data[$number] );
     1302                    update_option($option, $data);
     1303                }
     1304            } else {
     1305                if ( $data ) {
     1306                    $data = array();
     1307                    update_option($option, $data);
     1308                }
    13071309            }
    13081310        }
  • trunk/wp-admin/css/colors-classic.css

    r10943 r11009  
    951951#editorcontainer,
    952952#post-status-info,
    953 #titlediv #title {
     953#titlediv #title,
     954.editwidget .widget-control {
    954955    border-color: #dfdfdf;
    955956}
  • trunk/wp-admin/css/colors-fresh.css

    r10943 r11009  
    951951#editorcontainer,
    952952#post-status-info,
    953 #titlediv #title {
     953#titlediv #title,
     954.editwidget .widget-control {
    954955    border-color: #dfdfdf;
    955956}
  • trunk/wp-admin/css/widgets.css

    r10916 r11009  
    153153}
    154154
     155.editwidget .widget-control {
     156    display: block;
     157    border-width: 1px;
     158    border-style: solid;
     159    padding: 10px;
     160    -moz-border-radius: 6px;
     161    -khtml-border-radius: 6px;
     162    -webkit-border-radius: 6px;
     163    border-radius: 6px;
     164}
    155165
     166.widget-position table {
     167    width: 100%;
     168    margin-top: 12px;
     169}
     170
     171.widget-position table td {
     172    height: 3em;
     173    line-height: 3em;
     174    vertical-align: middle;
     175}
  • trunk/wp-admin/includes/widgets.php

    r10941 r11009  
    2020    global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
    2121
    22     if ( $_search ) {
     22    if ( $_search ) {
    2323        // sanitize
    2424        $search = preg_replace( '/[^\w\s]/', '', $_search );
     
    6969            $no_widgets_shown = false;
    7070
    71             $args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' );
     71            $args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' );
    7272
    7373            if ( isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']) ) {
     
    8383
    8484            $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
    85             call_user_func_array( 'wp_widget_control', $args );
     85            call_user_func_array( 'wp_widget_control', $args );
    8686        }
    8787
    88         if ( $no_widgets_shown )
     88        if ( $no_widgets_shown )
    8989          echo '<li>' . __( 'No matching widgets' ) . "</li>\n";
    9090?>
     
    133133    $params[0]['after_title'] = "%END_OF_TITLE%"; // deprecated
    134134    if ( is_callable( $wp_registered_widgets[$widget_id]['callback'] ) ) {
    135         $wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback'];
     135        $wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback'];
    136136        $wp_registered_widgets[$widget_id]['callback'] = 'wp_widget_control';
    137137    }
     
    165165    $widget_id = $sidebar_args['widget_id'];
    166166    $sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false;
    167 
     167    $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : '-1'; // position of widget in sidebar
    168168    $control = isset($wp_registered_widget_controls[$widget_id]) ? $wp_registered_widget_controls[$widget_id] : array();
    169     $widget  = $wp_registered_widgets[$widget_id];
    170 
    171     $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : 'no-key'; // position of widget in sidebar
    172 
    173     $edit = isset($_GET['editwidget']); // editing without js
    174     $nonce = $edit ? wp_create_nonce("edit-widget_$widget_id") : '';
     169    $widget = $wp_registered_widgets[$widget_id];
    175170
    176171    $id_format = $widget['id'];
    177 
    178172    $widget_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
    179173    $id_base = isset($control['id_base']) ? $control['id_base'] : $widget_id;
     
    181175    $add_new = isset($sidebar_args['_add']) ? $sidebar_args['_add'] : '';
    182176
     177    $query_arg = array( 'editwidget' => $widget['id'] );
     178    if ( $add_new ) {
     179        $query_arg['addnew'] = 1;
     180        if ( $multi_number ) {
     181            $query_arg['num'] = $multi_number;
     182            $query_arg['base'] = $id_base;
     183        }
     184    } else {
     185        $query_arg['sidebar'] = $sidebar_id;
     186        $query_arg['key'] = $key;
     187    }
     188
    183189    // We aren't showing a widget control, we're outputing a template for a mult-widget control
    184190    if ( isset($sidebar_args['_display']) && 'template' == $sidebar_args['_display'] && $widget_number ) {
    185191        // number == -1 implies a template where id numbers are replaced by a generic '__i__'
    186192        $control['params'][0]['number'] = -1;
    187         // if given, id_base means widget id's should be constructed like {$id_base}-{$id_number}
     193        // with id_base widget id's are constructed like {$id_base}-{$id_number}
    188194        if ( isset($control['id_base']) )
    189195            $id_format = $control['id_base'] . '-__i__';
     
    194200
    195201    $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
     202    $has_form = 0;
    196203
    197204    echo $sidebar_args['before_widget']; ?>
    198         <div class="widget-top">
    199         <div class="widget-title-action">
    200 <?php       if ( !$edit ) { ?>
    201             <a class="widget-action widget-control-edit" href="<?php echo clean_url( add_query_arg( array( 'edit' => $id_format, 'key' => $key ) ) ); ?>"></a>
     205    <div class="widget-top">
     206    <div class="widget-title-action">
     207        <a class="widget-action widget-control-edit" href="<?php echo clean_url( add_query_arg( $query_arg ) ); ?>"></a>
     208    </div>
     209    <div class="widget-title"><h4><?php echo $widget_title ?></h4></div>
     210    </div>
     211
     212    <div class="widget-inside">
     213    <form action="" method="post">
     214    <div class="widget-control">
     215<?php
     216    if ( isset($control['callback']) )
     217        $has_form = call_user_func_array( $control['callback'], $control['params'] );
     218    else
     219        echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n"; ?>
     220
     221    <input type="hidden" name="widget-id" class="widget-id" value="<?php echo $id_format; ?>" />
     222    <input type="hidden" name="id_base" class="id_base" value="<?php echo $id_base; ?>" />
     223    <input type="hidden" name="widget-width" class="widget-width" value="<?php echo $control['width']; ?>" />
     224    <input type="hidden" name="widget-height" class="widget-height" value="<?php echo $control['height']; ?>" />
     225    <input type="hidden" name="widget_number" class="widget_number" value="<?php echo $widget_number; ?>" />
     226    <input type="hidden" name="multi_number" class="multi_number" value="<?php echo $multi_number; ?>" />
     227    <input type="hidden" name="add_new" class="add_new" value="<?php echo $add_new; ?>" />
     228
     229    <div class="widget-control-actions">
     230        <a class="button widget-control-remove alignleft" href="<?php echo $edit ? clean_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key, '_wpnonce' => $nonce ) ) ) : '#remove'; ?>"><?php _e('Remove'); ?></a>
     231<?php       if ( false !== $has_form ) { ?>
     232        <input type="submit" name="savewidget" class="button-primary widget-control-save alignright" value="<?php _e('Save'); ?>" />
    202233<?php       } ?>
    203         </div>
    204         <div class="widget-title"><h4><?php echo $widget_title ?></h4></div>
    205         </div>
    206 
    207         <div class="widget-inside">
    208         <form action="" method="post">
    209         <div class="widget-control">
    210 <?php
    211             if ( isset($control['callback']) )
    212                 call_user_func_array( $control['callback'], $control['params'] );
    213             else
    214                 echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n"; ?>
    215 
    216             <input type="hidden" name="widget-id" class="widget-id" value="<?php echo $id_format; ?>" />
    217             <input type="hidden" name="id_base" class="id_base" value="<?php echo $id_base; ?>" />
    218             <input type="hidden" name="widget-width" class="widget-width" value="<?php echo $control['width']; ?>" />
    219             <input type="hidden" name="widget-height" class="widget-height" value="<?php echo $control['height']; ?>" />
    220             <input type="hidden" name="widget_number" class="widget_number" value="<?php echo $widget_number; ?>" />
    221             <input type="hidden" name="multi_number" class="multi_number" value="<?php echo $multi_number; ?>" />
    222             <input type="hidden" name="add_new" class="add_new" value="<?php echo $add_new; ?>" />
    223 
    224             <div class="widget-control-actions">
    225                 <a class="button widget-control-remove alignleft" href="<?php echo $edit ? clean_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key, '_wpnonce' => $nonce ) ) ) : '#remove'; ?>"><?php _e('Remove'); ?></a>
    226 <?php       if ( !empty($control) ) { ?>
    227                 <input type="submit" name="savewidget" class="button-primary widget-control-save alignright" value="<?php _e('Save'); ?>" />
    228 <?php       } ?>
    229                 <br class="clear" />
    230             </div>
    231         </div>
    232         </form>
    233         <div class="widget-description">
     234        <br class="clear" />
     235    </div>
     236    </div>
     237    </form>
     238
     239    <div class="widget-description">
    234240<?php echo ( $widget_description = wp_widget_description($widget_id) ) ? "$widget_description\n" : "$widget_title\n"; ?>
    235         </div>
    236         </div>
     241    </div>
     242    </div>
    237243<?php
    238244    echo $sidebar_args['after_widget'];
    239 
    240245    return $sidebar_args;
    241246}
  • trunk/wp-admin/widgets.php

    r10927 r11009  
    2626// register the inactive_widgets area as sidebar
    2727register_sidebar(array(
    28     'name' => '',
     28    'name' => __('Inactive Widgets'),
    2929    'id' => 'wp_inactive_widgets',
    3030    'before_widget' => '',
     
    3939    $sidebars_widgets = wp_get_widget_defaults();
    4040
    41 // look for "lost" widgets, this has to run at each theme change
     41// look for "lost" widgets, this has to run at least on each theme change
    4242function retrieve_widgets() {
    4343    global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets;
     
    112112
    113113if ( count($wp_registered_sidebars) == 1 ) {
    114     // If only the "wp_inactive_widgets" is defined the theme has no sidebars, die.
     114    // If only "wp_inactive_widgets" is defined the theme has no sidebars, die.
    115115    require_once( 'admin-header.php' );
    116116?>
     
    130130}
    131131
     132// We're saving a widget without js
     133if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) {
     134    $widget_id = $_POST['widget-id'];
     135    check_admin_referer("save-delete-widget-$widget_id");
     136
     137    $sidebar_id = $_POST['insidebar'];
     138    $position = isset($_POST[$sidebar_id . '_position']) ? (int) $_POST[$sidebar_id . '_position'] - 1 : 0;
     139    $_POST['sidebar'] = $sidebar_id;
     140
     141    $id_base = $_POST['id_base'];
     142    $number = isset($_POST['multi_number']) ? $_POST['multi_number'] : '';
     143    $sidebar = isset($sidebars_widgets[$sidebar_id]) ? $sidebars_widgets[$sidebar_id] : array();
     144
     145    // delete
     146    if ( isset($_POST['removewidget']) && $_POST['removewidget'] ) {
     147        $widget = isset($wp_registered_widgets[$widget_id]) ? $wp_registered_widgets[$widget_id] : false;
     148
     149        if ( !in_array($widget_id, $sidebar, true) || !$widget ) {
     150            wp_redirect('widgets.php?error=0');
     151            exit;
     152        }
     153
     154        $option = str_replace( '-', '_', 'widget_' . $id_base );
     155        $data = get_option($option);
     156
     157        if ( isset($widget['params'][0]['number']) ) {
     158            $number = $widget['params'][0]['number'];
     159            if ( is_array($data) && isset($data[$number]) ) {
     160                unset( $data[$number] );
     161                update_option($option, $data);
     162            }
     163        } else {
     164            if ( $data ) {
     165                $data = array();
     166                update_option($option, $data);
     167            }
     168        }
     169
     170        $sidebar = array_diff( $sidebar, array($widget_id) );
     171    } else {
     172        // save
     173        foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
     174            if ( $name != $id_base || !is_callable($control['callback']) )
     175                continue;
     176
     177            if ( $number ) {
     178                // don't delete other instances of the same multi-widget
     179                foreach ( $sidebar as $_widget_id ) {
     180                    if ( isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) )
     181                        unset($wp_registered_widgets[$_widget_id]['params'][0]['number']);
     182                }
     183                $widget_id = "$id_base-$number";
     184            }
     185
     186            ob_start();
     187                call_user_func_array( $control['callback'], $control['params'] );
     188            ob_end_clean();
     189
     190            // remove old position
     191            $sidebar = array_diff( $sidebar, array($widget_id) );
     192            foreach ( $sidebars_widgets as $key => $sb ) {
     193                if ( is_array($sb) && in_array($widget_id, $sb, true) )
     194                    $sidebars_widgets[$key] = array_diff( $sb, array($widget_id) );
     195            }
     196
     197            array_splice( $sidebar, $position, 0, $widget_id );
     198            break;
     199        }
     200    }
     201
     202    $sidebars_widgets[$sidebar_id] = $sidebar;
     203    wp_set_sidebars_widgets($sidebars_widgets);
     204
     205    wp_redirect('widgets.php?message=0');
     206    exit;
     207}
     208
     209// Output the widget form without js
     210if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
     211    $widget_id = $_GET['editwidget'];
     212
     213    if ( isset($_GET['addnew']) ) {
     214        // Default to the first sidebar
     215        $sidebar = array_shift( $keys = array_keys($wp_registered_sidebars) );
     216
     217        if ( isset($_GET['base']) && isset($_GET['num']) ) { // multi-widget
     218            // Copy minimal info from an existing instance of this widget to a new instance
     219            foreach ( $wp_registered_widget_controls as $control ) {
     220                if ( $_GET['base'] === $control['id_base'] ) {
     221                    $control_callback = $control['callback'];
     222                    $multi_number = (int) $_GET['num'];
     223                    $control['params'][0]['number'] = $multi_number;
     224                    $control['id'] = $control['id_base'] . '-' . $multi_number;
     225                    $wp_registered_widget_controls[$control['id']] = $control;
     226                    break;
     227                }
     228            }
     229        }
     230    }
     231
     232    if ( isset($wp_registered_widget_controls[$widget_id]) && !isset($control) ) {
     233        $control = $wp_registered_widget_controls[$widget_id];
     234        $control_callback = $control['callback'];
     235    }
     236
     237    if ( !isset($sidebar) )
     238        $sidebar = isset($_GET['sidebar']) ? $_GET['sidebar'] : 'wp_inactive_widgets';
     239
     240    if ( !isset($multi_number) )
     241        $multi_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
     242
     243    $id_base = isset($control['id_base']) ? $control['id_base'] : $control['id'];
     244
     245    // show the widget form
     246    if ( is_callable( $control_callback ) ) {
     247        $width = ' style="width:' . max($control['width'], 350) . 'px"';
     248        $key = isset($_GET['key']) ? (int) $_GET['key'] : 0;
     249
     250        require_once( 'admin-header.php' ); ?>
     251        <div class="wrap">
     252        <?php screen_icon(); ?>
     253        <h2><?php echo wp_specialchars( $title ); ?></h2>
     254        <div class="editwidget"<?php echo $width; ?>>
     255        <h3><?php printf( __( 'Widget %s' ), wp_specialchars( strip_tags($control['name']) ) ); ?></h3>
     256
     257        <form action="widgets.php" method="post">
     258        <div class="widget-control">
     259<?php   call_user_func_array( $control_callback, $control['params'] ); ?>
     260        </div>
     261
     262        <div class="widget-position">
     263        <table class="widefat"><thead><tr><th><?php _e('Sidebar'); ?></th><th><?php _e('Position'); ?></th></tr></thead><tbody>
     264<?php   foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) {
     265            echo "\t\t<tr><td><label><input type='radio' name='insidebar' value='$sbname'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>";
     266            if ( 'wp_inactive_widgets' == $sbname ) {
     267                echo '&nbsp;';
     268            } else {
     269                if ( !isset($sidebars_widgets[$sbname]) || !is_array($sidebars_widgets[$sbname]) ) {
     270                    $j = 1;
     271                } else {
     272                    $j = count($sidebars_widgets[$sbname]);
     273                    if ( isset($_GET['addnew']) || !in_array($widget_id, $sidebars_widgets[$sbname], true) )
     274                        $j++;
     275                }
     276                $selected = '';
     277                echo "\t\t<select name='{$sbname}_position'>\n";
     278                echo "\t\t<option value=''>" . __('-- select --') . "</option>\n";
     279                for ( $i = 1; $i <= $j; $i++ ) {
     280                    if ( in_array($widget_id, $sidebars_widgets[$sbname], true) )
     281                        $selected = selected( $i, $key + 1, false );
     282                    echo "\t\t<option value='$i'$selected> $i </option>\n";
     283                }
     284                echo "\t\t</select>\n";
     285            }
     286            echo "</td></tr>\n";
     287        } ?>
     288        </tbody></table>
     289        </div>
     290
     291        <div class="widget-control-actions">
     292<?php   if ( isset($_GET['addnew']) ) { ?>
     293        <a href="widgets.php" class="button alignleft"><?php _e('Cancel'); ?></a>
     294<?php   } else { ?>
     295        <input type="submit" name="removewidget" class="button alignleft" value="<?php _e('Remove'); ?>" />
     296<?php   } ?>
     297        <input type="submit" name="savewidget" class="button-primary alignright" value="<?php _e('Save Widget'); ?>" />
     298        <input type="hidden" name="widget-id" class="widget-id" value="<?php echo $widget_id; ?>" />
     299        <input type="hidden" name="id_base" class="id_base" value="<?php echo $id_base; ?>" />
     300        <input type="hidden" name="multi_number" class="multi_number" value="<?php echo $multi_number; ?>" />
     301<?php   wp_nonce_field("save-delete-widget-$widget_id"); ?>
     302        </div>
     303        </form>
     304        </div>
     305        </div>
     306<?php
     307        require_once( 'admin-footer.php' );
     308        exit;
     309    }
     310    wp_redirect('widgets.php?error=1');
     311    exit;
     312}
     313
    132314/*
    133315// Unsanitized!
     
    136318// Not entirely sure what all should be here
    137319$show_values = array(
    138     ''       => $widget_search ? __( 'Show any widgets' ) : __( 'Show all widgets' ),
     320    ''      => $widget_search ? __( 'Show any widgets' ) : __( 'Show all widgets' ),
    139321    'unused' => __( 'Show unused widgets' ),
    140     'used'   => __( 'Show used widgets' )
     322    'used'  => __( 'Show used widgets' )
    141323);
     324
     325$show = isset($_GET['show']) && isset($show_values[$_GET['show']]) ? attribute_escape( $_GET['show'] ) : false;
    142326*/
    143327
    144 $show = isset($_GET['show']) && isset($show_values[$_GET['show']]) ? attribute_escape( $_GET['show'] ) : false;
    145 
    146328$messages = array(
    147     'updated' => __('Changes saved.')
     329    __('Changes saved.')
     330);
     331
     332$errors = array(
     333    __('Error while saving.'),
     334    __('Error in displaying the widget settings form.')
    148335);
    149336
     
    154341<h2><?php echo wp_specialchars( $title ); ?></h2>
    155342
    156 <?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) : ?>
     343<?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?>
    157344<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
    158 <?php endif; ?>
    159 
    160 <!--
    161     <form id="widgets-filter" action="" method="get">
    162 
    163     <div class="widget-liquid-left-holder">
    164     <div id="available-widgets-filter" class="widget-liquid-left">
    165         <h3><label for="show"><?php _e('Available Widgets'); ?></label></h3>
    166         <div class="nav">
    167             <select name="show" id="show">
    168 <?php //foreach ( $show_values as $show_value => $show_text ) : $show_value = attribute_escape( $show_value ); ?>
    169                 <option value='<?php //echo $show_value; ?>'<?php //selected( $show_value, $show ); ?>><?php //echo wp_specialchars( $show_text ); ?></option>
    170 <?php //endforeach; ?>
    171             </select>
    172             <input type="submit" value="<?php _e('Show' ); ?>" class="button-secondary" />
    173             <p class="pagenav">
    174                 <?php // echo $page_links; ?>
    175             </p>
    176         </div>
     345<?php } ?>
     346<?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?>
     347<div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div>
     348<?php } ?>
     349
     350<div class="widget-liquid-left">
     351<div id="widgets-left">
     352    <div id="available-widgets" class="widgets-holder-wrap">
     353        <h3 class="sidebar-name"><?php _e('Available Widgets'); ?></h3>
     354        <?php wp_list_widgets(); ?>
     355        <br class="clear" />
    177356    </div>
     357
     358    <div id="wp_inactive_widgets" class="widgets-holder-wrap">
     359        <h3 class="sidebar-name"><?php _e('Inactive Widgets'); ?>
     360        <span><img src="images/loading-publish.gif" class="ajax-feedback" title="" alt="" /></span></h3>
     361        <?php wp_list_widget_controls('wp_inactive_widgets'); ?>
     362        <br class="clear" />
    178363    </div>
    179 
    180     <div id="available-sidebars" class="widget-liquid-right">
    181         <h3><label for="sidebar-selector"><?php _e('Current Widgets'); ?></label></h3>
    182 
    183         <div class="nav">
    184             <select id="sidebar-selector" name="sidebar">
    185 <?php //foreach ( $wp_registered_sidebars as $sidebar_id => $registered_sidebar ) : $sidebar_id = attribute_escape( $sidebar_id ); ?>
    186                 <option value='<?php //echo $sidebar_id; ?>'<?php selected( $sidebar_id, $open_sidebar ); ?>><?php //echo wp_specialchars( $registered_sidebar['name'] ); ?></option>
    187 <?php //endforeach; ?>
    188             </select>
    189             <input type="submit" value="<?php _e('Show' ); ?>" class="button-secondary" />
    190         </div>
    191 
     364</div>
     365</div>
     366
     367<div class="widget-liquid-right">
     368<?php
     369$i = 0;
     370foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
     371    if ( 'wp_inactive_widgets' == $sidebar )
     372        continue; ?>
     373    <div id="<?php echo attribute_escape( $sidebar ); ?>" class="widgets-holder-wrap">
     374    <h3 class="sidebar-name"><?php echo wp_specialchars( $registered_sidebar['name'] ); ?>
     375    <span><img src="images/loading-publish.gif" class="ajax-feedback" title="" alt="" /></span></h3>
     376    <?php wp_list_widget_controls( $sidebar, $i ); // Show the control forms for each of the widgets in this sidebar ?>
    192377    </div>
    193 
    194     </form>
    195 -->
    196 
    197     <div class="widget-liquid-left">
    198     <div id="widgets-left">
    199         <div id="available-widgets" class="widgets-holder-wrap">
    200             <h3 class="sidebar-name"><?php _e('Available Widgets'); ?></h3>
    201             <?php wp_list_widgets(); ?>
    202             <br class="clear" />
    203         </div>
    204 
    205         <div id="wp_inactive_widgets" class="widgets-holder-wrap">
    206             <h3 class="sidebar-name"><?php _e('Inactive Widgets'); ?>
    207             <span><img src="images/loading-publish.gif" class="ajax-feedback" title="" alt="" /></span></h3>
    208             <?php wp_list_widget_controls('wp_inactive_widgets'); ?>
    209             <br class="clear" />
    210         </div>
    211     </div>
    212     </div>
    213 
    214 <!--
    215     <div id="current-widgets-head" class="widget-liquid-right">
    216 
    217         <div id="sidebar-info">
    218             <p><?php //echo $sidebar_info_text; ?></p>
    219             <p><?php _e( 'Add more from the Available Widgets section.' ); ?></p>
    220         </div>
    221 
    222     </div>
    223 -->
    224 
    225     <div class="widget-liquid-right">
    226 <?php
    227     $i = 0;
    228     foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
    229         if ( 'wp_inactive_widgets' == $sidebar )
    230             continue;
    231         ?>
    232         <div id="<?php echo attribute_escape( $sidebar ); ?>" class="widgets-holder-wrap">
    233         <h3 class="sidebar-name"><?php echo wp_specialchars( $registered_sidebar['name'] ); ?>
    234         <span><img src="images/loading-publish.gif" class="ajax-feedback" title="" alt="" /></span></h3>
    235         <?php wp_list_widget_controls( $sidebar, $i ); // Show the control forms for each of the widgets in this sidebar ?>
    236         </div>
    237 <?php
    238        $i++;
    239     } ?>
    240     </div>
    241     <form action="" method="post">
    242     <?php wp_nonce_field( 'save-sidebar-widgets', '_wpnonce_widgets', false ); ?>
    243     </form>
    244     <br class="clear" />
     378<?php
     379    $i++;
     380} ?>
     381</div>
     382<form action="" method="post">
     383<?php wp_nonce_field( 'save-sidebar-widgets', '_wpnonce_widgets', false ); ?>
     384</form>
     385<br class="clear" />
    245386</div>
    246387
  • trunk/wp-includes/default-widgets.php

    r10912 r11009  
    186186        echo $after_widget;
    187187    }
    188 
    189     function form( $instance ) { ?>
    190         <input name="<?php echo $this->get_field_name('title'); ?>" type="hidden" value="" />
    191 <?php
    192     }
    193 
    194188}
    195189
  • trunk/wp-includes/script-loader.php

    r10994 r11009  
    425425    $styles->add_data( 'ie', 'conditional', 'lte IE 7' );
    426426
    427     $styles->add( 'colors', true, array(), '20090415' ); // Register "meta" stylesheet for admin colors
     427    $styles->add( 'colors', true, array(), '20090419' ); // Register "meta" stylesheet for admin colors
    428428    $styles->add( 'colors-fresh', '/wp-admin/css/colors-fresh.css', array(), '20081210'); // for login.php.  Is there a better way?
    429429    $styles->add_data( 'colors-fresh', 'rtl', true );
     
    433433    $styles->add( 'global', '/wp-admin/css/global.css', array(), '20090415' );
    434434    $styles->add( 'media', '/wp-admin/css/media.css', array(), '20090325' );
    435     $styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20090411' );
     435    $styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20090419' );
    436436    $styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20090305' );
    437437    $styles->add( 'install', '/wp-admin/css/install.css', array(), '20081210' );
  • trunk/wp-includes/widgets.php

    r10991 r11009  
    2424class WP_Widget {
    2525
    26     var $id_base;           // Root id for all widgets of this type.
     26    var $id_base;           // Root id for all widgets of this type.
    2727    var $name;              // Name for this widget type.
    2828    var $widget_options;    // Option array passed to wp_register_sidebar_widget()
     
    6262    /** Echo the settings update form
    6363     *
    64      * @param array $instance Current settings 
     64     * @param array $instance Current settings
    6565     */
    6666    function form($instance) {
    6767        echo '<p>' . __('There are no options for this widget.') . '</p>';
     68        return false;
    6869    }
    6970
     
    8889    function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
    8990        $this->id_base = $id_base;
     91    //  $this->id_base = str_replace( 'wp_widget_', '', strtolower(get_class($this)) );
    9092        $this->name = $name;
    9193        $this->option_name = 'widget_' . $id_base;
    9294        $this->widget_options = wp_parse_args( $widget_options, array('classname' => $this->option_name) );
    9395        $this->control_options = wp_parse_args( $control_options, array('id_base' => $this->id_base) );
    94 
    95         //add_action( 'widgets_init', array( &$this, '_register' ) );
    9696    }
    9797
     
    208208                }
    209209            } else {
    210                 foreach ( (array) $_POST['widget-' . $this->id_base] as $number => $new_instance ) {
     210                if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) {
     211                    $settings = $_POST['widget-' . $this->id_base];
     212                } else {
     213                    $num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number'];
     214                    $settings = array( $num => array() );
     215                }
     216
     217                foreach ( $settings as $number => $new_instance ) {
    211218                    $new_instance = stripslashes_deep($new_instance);
    212219                    $this->_set($number);
     
    245252        }
    246253
    247         $this->form($instance);
     254        return $this->form($instance);
    248255    }
    249256
Note: See TracChangeset for help on using the changeset viewer.