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

git-svn-id: http://svn.automattic.com/wordpress/trunk@11009 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-04-20 10:58:50 +00:00
parent e8abe70f25
commit 0200501698
9 changed files with 340 additions and 169 deletions

View File

@ -784,7 +784,7 @@ case 'add-meta' :
) );
$x->send();
}
if ( !$mid = add_meta( $pid ) )
if ( !$mid = add_meta( $pid ) )
die(__('Please provide a custom field value.'));
} else {
die('0');
@ -813,7 +813,7 @@ case 'add-meta' :
die('-1');
if ( !$u = update_meta( $mid, $key, $value ) )
die('0'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
$key = stripslashes($key);
$value = stripslashes($value);
$x = new WP_Ajax_Response( array(
@ -1288,22 +1288,24 @@ case 'save-widget' :
$del_id = $_POST['widget-id'];
$widget = isset($wp_registered_widgets[$del_id]) ? $wp_registered_widgets[$del_id] : false;
if ( !in_array($del_id, $sidebar, true) || !$widget )
if ( !in_array($del_id, $sidebar, true) )
die('-1');
$option = str_replace( '-', '_', 'widget_' . $id_base );
$data = get_option($option);
if ( $widget ) {
$option = str_replace( '-', '_', 'widget_' . $id_base );
$data = get_option($option);
if ( isset($widget['params'][0]['number']) ) {
$number = $widget['params'][0]['number'];
if ( is_array($data) && isset($data[$number]) ) {
unset( $data[$number] );
update_option($option, $data);
}
} else {
if ( $data ) {
$data = array();
update_option($option, $data);
if ( isset($widget['params'][0]['number']) ) {
$number = $widget['params'][0]['number'];
if ( is_array($data) && isset($data[$number]) ) {
unset( $data[$number] );
update_option($option, $data);
}
} else {
if ( $data ) {
$data = array();
update_option($option, $data);
}
}
}

View File

@ -950,7 +950,8 @@ abbr.required,
#editorcontainer,
#post-status-info,
#titlediv #title {
#titlediv #title,
.editwidget .widget-control {
border-color: #dfdfdf;
}

View File

@ -950,7 +950,8 @@ abbr.required,
#editorcontainer,
#post-status-info,
#titlediv #title {
#titlediv #title,
.editwidget .widget-control {
border-color: #dfdfdf;
}

View File

@ -152,4 +152,24 @@ div#sidebar-info {
font-weight: normal;
}
.editwidget .widget-control {
display: block;
border-width: 1px;
border-style: solid;
padding: 10px;
-moz-border-radius: 6px;
-khtml-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
}
.widget-position table {
width: 100%;
margin-top: 12px;
}
.widget-position table td {
height: 3em;
line-height: 3em;
vertical-align: middle;
}

View File

@ -19,7 +19,7 @@
function wp_list_widgets( $show = 'all', $_search = false ) {
global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
if ( $_search ) {
if ( $_search ) {
// sanitize
$search = preg_replace( '/[^\w\s]/', '', $_search );
// array of terms
@ -68,7 +68,7 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
$already_shown[] = $widget['callback'];
$no_widgets_shown = false;
$args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' );
$args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' );
if ( isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']) ) {
$id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
@ -82,10 +82,10 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
}
$args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
call_user_func_array( 'wp_widget_control', $args );
call_user_func_array( 'wp_widget_control', $args );
}
if ( $no_widgets_shown )
if ( $no_widgets_shown )
echo '<li>' . __( 'No matching widgets' ) . "</li>\n";
?>
</ul>
@ -132,7 +132,7 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) {
$params[0]['before_title'] = "%BEG_OF_TITLE%"; // deprecated
$params[0]['after_title'] = "%END_OF_TITLE%"; // deprecated
if ( is_callable( $wp_registered_widgets[$widget_id]['callback'] ) ) {
$wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback'];
$wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback'];
$wp_registered_widgets[$widget_id]['callback'] = 'wp_widget_control';
}
@ -164,27 +164,33 @@ function wp_widget_control( $sidebar_args ) {
$widget_id = $sidebar_args['widget_id'];
$sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false;
$key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : '-1'; // position of widget in sidebar
$control = isset($wp_registered_widget_controls[$widget_id]) ? $wp_registered_widget_controls[$widget_id] : array();
$widget = $wp_registered_widgets[$widget_id];
$key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : 'no-key'; // position of widget in sidebar
$edit = isset($_GET['editwidget']); // editing without js
$nonce = $edit ? wp_create_nonce("edit-widget_$widget_id") : '';
$widget = $wp_registered_widgets[$widget_id];
$id_format = $widget['id'];
$widget_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
$id_base = isset($control['id_base']) ? $control['id_base'] : $widget_id;
$multi_number = isset($sidebar_args['_multi_num']) ? $sidebar_args['_multi_num'] : '';
$add_new = isset($sidebar_args['_add']) ? $sidebar_args['_add'] : '';
$query_arg = array( 'editwidget' => $widget['id'] );
if ( $add_new ) {
$query_arg['addnew'] = 1;
if ( $multi_number ) {
$query_arg['num'] = $multi_number;
$query_arg['base'] = $id_base;
}
} else {
$query_arg['sidebar'] = $sidebar_id;
$query_arg['key'] = $key;
}
// We aren't showing a widget control, we're outputing a template for a mult-widget control
if ( isset($sidebar_args['_display']) && 'template' == $sidebar_args['_display'] && $widget_number ) {
// number == -1 implies a template where id numbers are replaced by a generic '__i__'
$control['params'][0]['number'] = -1;
// if given, id_base means widget id's should be constructed like {$id_base}-{$id_number}
// with id_base widget id's are constructed like {$id_base}-{$id_number}
if ( isset($control['id_base']) )
$id_format = $control['id_base'] . '-__i__';
}
@ -193,50 +199,49 @@ function wp_widget_control( $sidebar_args ) {
unset($wp_registered_widgets[$widget_id]['_callback']);
$widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
$has_form = 0;
echo $sidebar_args['before_widget']; ?>
<div class="widget-top">
<div class="widget-title-action">
<?php if ( !$edit ) { ?>
<a class="widget-action widget-control-edit" href="<?php echo clean_url( add_query_arg( array( 'edit' => $id_format, 'key' => $key ) ) ); ?>"></a>
<?php } ?>
</div>
<div class="widget-title"><h4><?php echo $widget_title ?></h4></div>
</div>
<div class="widget-top">
<div class="widget-title-action">
<a class="widget-action widget-control-edit" href="<?php echo clean_url( add_query_arg( $query_arg ) ); ?>"></a>
</div>
<div class="widget-title"><h4><?php echo $widget_title ?></h4></div>
</div>
<div class="widget-inside">
<form action="" method="post">
<div class="widget-control">
<div class="widget-inside">
<form action="" method="post">
<div class="widget-control">
<?php
if ( isset($control['callback']) )
call_user_func_array( $control['callback'], $control['params'] );
else
echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n"; ?>
if ( isset($control['callback']) )
$has_form = call_user_func_array( $control['callback'], $control['params'] );
else
echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n"; ?>
<input type="hidden" name="widget-id" class="widget-id" value="<?php echo $id_format; ?>" />
<input type="hidden" name="id_base" class="id_base" value="<?php echo $id_base; ?>" />
<input type="hidden" name="widget-width" class="widget-width" value="<?php echo $control['width']; ?>" />
<input type="hidden" name="widget-height" class="widget-height" value="<?php echo $control['height']; ?>" />
<input type="hidden" name="widget_number" class="widget_number" value="<?php echo $widget_number; ?>" />
<input type="hidden" name="multi_number" class="multi_number" value="<?php echo $multi_number; ?>" />
<input type="hidden" name="add_new" class="add_new" value="<?php echo $add_new; ?>" />
<input type="hidden" name="widget-id" class="widget-id" value="<?php echo $id_format; ?>" />
<input type="hidden" name="id_base" class="id_base" value="<?php echo $id_base; ?>" />
<input type="hidden" name="widget-width" class="widget-width" value="<?php echo $control['width']; ?>" />
<input type="hidden" name="widget-height" class="widget-height" value="<?php echo $control['height']; ?>" />
<input type="hidden" name="widget_number" class="widget_number" value="<?php echo $widget_number; ?>" />
<input type="hidden" name="multi_number" class="multi_number" value="<?php echo $multi_number; ?>" />
<input type="hidden" name="add_new" class="add_new" value="<?php echo $add_new; ?>" />
<div class="widget-control-actions">
<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>
<?php if ( !empty($control) ) { ?>
<input type="submit" name="savewidget" class="button-primary widget-control-save alignright" value="<?php _e('Save'); ?>" />
<div class="widget-control-actions">
<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>
<?php if ( false !== $has_form ) { ?>
<input type="submit" name="savewidget" class="button-primary widget-control-save alignright" value="<?php _e('Save'); ?>" />
<?php } ?>
<br class="clear" />
</div>
</div>
</form>
<div class="widget-description">
<br class="clear" />
</div>
</div>
</form>
<div class="widget-description">
<?php echo ( $widget_description = wp_widget_description($widget_id) ) ? "$widget_description\n" : "$widget_title\n"; ?>
</div>
</div>
</div>
</div>
<?php
echo $sidebar_args['after_widget'];
return $sidebar_args;
}

View File

@ -25,7 +25,7 @@ $parent_file = 'themes.php';
// register the inactive_widgets area as sidebar
register_sidebar(array(
'name' => '',
'name' => __('Inactive Widgets'),
'id' => 'wp_inactive_widgets',
'before_widget' => '',
'after_widget' => '',
@ -38,7 +38,7 @@ $sidebars_widgets = wp_get_sidebars_widgets();
if ( empty( $sidebars_widgets ) )
$sidebars_widgets = wp_get_widget_defaults();
// look for "lost" widgets, this has to run at each theme change
// look for "lost" widgets, this has to run at least on each theme change
function retrieve_widgets() {
global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets;
@ -111,7 +111,7 @@ function retrieve_widgets() {
retrieve_widgets();
if ( count($wp_registered_sidebars) == 1 ) {
// If only the "wp_inactive_widgets" is defined the theme has no sidebars, die.
// If only "wp_inactive_widgets" is defined the theme has no sidebars, die.
require_once( 'admin-header.php' );
?>
@ -129,22 +129,209 @@ if ( count($wp_registered_sidebars) == 1 ) {
exit;
}
// We're saving a widget without js
if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) {
$widget_id = $_POST['widget-id'];
check_admin_referer("save-delete-widget-$widget_id");
$sidebar_id = $_POST['insidebar'];
$position = isset($_POST[$sidebar_id . '_position']) ? (int) $_POST[$sidebar_id . '_position'] - 1 : 0;
$_POST['sidebar'] = $sidebar_id;
$id_base = $_POST['id_base'];
$number = isset($_POST['multi_number']) ? $_POST['multi_number'] : '';
$sidebar = isset($sidebars_widgets[$sidebar_id]) ? $sidebars_widgets[$sidebar_id] : array();
// delete
if ( isset($_POST['removewidget']) && $_POST['removewidget'] ) {
$widget = isset($wp_registered_widgets[$widget_id]) ? $wp_registered_widgets[$widget_id] : false;
if ( !in_array($widget_id, $sidebar, true) || !$widget ) {
wp_redirect('widgets.php?error=0');
exit;
}
$option = str_replace( '-', '_', 'widget_' . $id_base );
$data = get_option($option);
if ( isset($widget['params'][0]['number']) ) {
$number = $widget['params'][0]['number'];
if ( is_array($data) && isset($data[$number]) ) {
unset( $data[$number] );
update_option($option, $data);
}
} else {
if ( $data ) {
$data = array();
update_option($option, $data);
}
}
$sidebar = array_diff( $sidebar, array($widget_id) );
} else {
// save
foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
if ( $name != $id_base || !is_callable($control['callback']) )
continue;
if ( $number ) {
// don't delete other instances of the same multi-widget
foreach ( $sidebar as $_widget_id ) {
if ( isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) )
unset($wp_registered_widgets[$_widget_id]['params'][0]['number']);
}
$widget_id = "$id_base-$number";
}
ob_start();
call_user_func_array( $control['callback'], $control['params'] );
ob_end_clean();
// remove old position
$sidebar = array_diff( $sidebar, array($widget_id) );
foreach ( $sidebars_widgets as $key => $sb ) {
if ( is_array($sb) && in_array($widget_id, $sb, true) )
$sidebars_widgets[$key] = array_diff( $sb, array($widget_id) );
}
array_splice( $sidebar, $position, 0, $widget_id );
break;
}
}
$sidebars_widgets[$sidebar_id] = $sidebar;
wp_set_sidebars_widgets($sidebars_widgets);
wp_redirect('widgets.php?message=0');
exit;
}
// Output the widget form without js
if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
$widget_id = $_GET['editwidget'];
if ( isset($_GET['addnew']) ) {
// Default to the first sidebar
$sidebar = array_shift( $keys = array_keys($wp_registered_sidebars) );
if ( isset($_GET['base']) && isset($_GET['num']) ) { // multi-widget
// Copy minimal info from an existing instance of this widget to a new instance
foreach ( $wp_registered_widget_controls as $control ) {
if ( $_GET['base'] === $control['id_base'] ) {
$control_callback = $control['callback'];
$multi_number = (int) $_GET['num'];
$control['params'][0]['number'] = $multi_number;
$control['id'] = $control['id_base'] . '-' . $multi_number;
$wp_registered_widget_controls[$control['id']] = $control;
break;
}
}
}
}
if ( isset($wp_registered_widget_controls[$widget_id]) && !isset($control) ) {
$control = $wp_registered_widget_controls[$widget_id];
$control_callback = $control['callback'];
}
if ( !isset($sidebar) )
$sidebar = isset($_GET['sidebar']) ? $_GET['sidebar'] : 'wp_inactive_widgets';
if ( !isset($multi_number) )
$multi_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
$id_base = isset($control['id_base']) ? $control['id_base'] : $control['id'];
// show the widget form
if ( is_callable( $control_callback ) ) {
$width = ' style="width:' . max($control['width'], 350) . 'px"';
$key = isset($_GET['key']) ? (int) $_GET['key'] : 0;
require_once( 'admin-header.php' ); ?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo wp_specialchars( $title ); ?></h2>
<div class="editwidget"<?php echo $width; ?>>
<h3><?php printf( __( 'Widget %s' ), wp_specialchars( strip_tags($control['name']) ) ); ?></h3>
<form action="widgets.php" method="post">
<div class="widget-control">
<?php call_user_func_array( $control_callback, $control['params'] ); ?>
</div>
<div class="widget-position">
<table class="widefat"><thead><tr><th><?php _e('Sidebar'); ?></th><th><?php _e('Position'); ?></th></tr></thead><tbody>
<?php foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) {
echo "\t\t<tr><td><label><input type='radio' name='insidebar' value='$sbname'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>";
if ( 'wp_inactive_widgets' == $sbname ) {
echo '&nbsp;';
} else {
if ( !isset($sidebars_widgets[$sbname]) || !is_array($sidebars_widgets[$sbname]) ) {
$j = 1;
} else {
$j = count($sidebars_widgets[$sbname]);
if ( isset($_GET['addnew']) || !in_array($widget_id, $sidebars_widgets[$sbname], true) )
$j++;
}
$selected = '';
echo "\t\t<select name='{$sbname}_position'>\n";
echo "\t\t<option value=''>" . __('-- select --') . "</option>\n";
for ( $i = 1; $i <= $j; $i++ ) {
if ( in_array($widget_id, $sidebars_widgets[$sbname], true) )
$selected = selected( $i, $key + 1, false );
echo "\t\t<option value='$i'$selected> $i </option>\n";
}
echo "\t\t</select>\n";
}
echo "</td></tr>\n";
} ?>
</tbody></table>
</div>
<div class="widget-control-actions">
<?php if ( isset($_GET['addnew']) ) { ?>
<a href="widgets.php" class="button alignleft"><?php _e('Cancel'); ?></a>
<?php } else { ?>
<input type="submit" name="removewidget" class="button alignleft" value="<?php _e('Remove'); ?>" />
<?php } ?>
<input type="submit" name="savewidget" class="button-primary alignright" value="<?php _e('Save Widget'); ?>" />
<input type="hidden" name="widget-id" class="widget-id" value="<?php echo $widget_id; ?>" />
<input type="hidden" name="id_base" class="id_base" value="<?php echo $id_base; ?>" />
<input type="hidden" name="multi_number" class="multi_number" value="<?php echo $multi_number; ?>" />
<?php wp_nonce_field("save-delete-widget-$widget_id"); ?>
</div>
</form>
</div>
</div>
<?php
require_once( 'admin-footer.php' );
exit;
}
wp_redirect('widgets.php?error=1');
exit;
}
/*
// Unsanitized!
$widget_search = isset($_GET['s']) ? $_GET['s'] : false;
// Not entirely sure what all should be here
$show_values = array(
'' => $widget_search ? __( 'Show any widgets' ) : __( 'Show all widgets' ),
'' => $widget_search ? __( 'Show any widgets' ) : __( 'Show all widgets' ),
'unused' => __( 'Show unused widgets' ),
'used' => __( 'Show used widgets' )
'used' => __( 'Show used widgets' )
);
*/
$show = isset($_GET['show']) && isset($show_values[$_GET['show']]) ? attribute_escape( $_GET['show'] ) : false;
*/
$messages = array(
'updated' => __('Changes saved.')
__('Changes saved.')
);
$errors = array(
__('Error while saving.'),
__('Error in displaying the widget settings form.')
);
require_once( 'admin-header.php' ); ?>
@ -153,95 +340,49 @@ require_once( 'admin-header.php' ); ?>
<?php screen_icon(); ?>
<h2><?php echo wp_specialchars( $title ); ?></h2>
<?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) : ?>
<?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?>
<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
<?php endif; ?>
<?php } ?>
<?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?>
<div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div>
<?php } ?>
<!--
<form id="widgets-filter" action="" method="get">
<div class="widget-liquid-left-holder">
<div id="available-widgets-filter" class="widget-liquid-left">
<h3><label for="show"><?php _e('Available Widgets'); ?></label></h3>
<div class="nav">
<select name="show" id="show">
<?php //foreach ( $show_values as $show_value => $show_text ) : $show_value = attribute_escape( $show_value ); ?>
<option value='<?php //echo $show_value; ?>'<?php //selected( $show_value, $show ); ?>><?php //echo wp_specialchars( $show_text ); ?></option>
<?php //endforeach; ?>
</select>
<input type="submit" value="<?php _e('Show' ); ?>" class="button-secondary" />
<p class="pagenav">
<?php // echo $page_links; ?>
</p>
</div>
</div>
<div class="widget-liquid-left">
<div id="widgets-left">
<div id="available-widgets" class="widgets-holder-wrap">
<h3 class="sidebar-name"><?php _e('Available Widgets'); ?></h3>
<?php wp_list_widgets(); ?>
<br class="clear" />
</div>
<div id="available-sidebars" class="widget-liquid-right">
<h3><label for="sidebar-selector"><?php _e('Current Widgets'); ?></label></h3>
<div class="nav">
<select id="sidebar-selector" name="sidebar">
<?php //foreach ( $wp_registered_sidebars as $sidebar_id => $registered_sidebar ) : $sidebar_id = attribute_escape( $sidebar_id ); ?>
<option value='<?php //echo $sidebar_id; ?>'<?php selected( $sidebar_id, $open_sidebar ); ?>><?php //echo wp_specialchars( $registered_sidebar['name'] ); ?></option>
<?php //endforeach; ?>
</select>
<input type="submit" value="<?php _e('Show' ); ?>" class="button-secondary" />
</div>
</div>
</form>
-->
<div class="widget-liquid-left">
<div id="widgets-left">
<div id="available-widgets" class="widgets-holder-wrap">
<h3 class="sidebar-name"><?php _e('Available Widgets'); ?></h3>
<?php wp_list_widgets(); ?>
<br class="clear" />
</div>
<div id="wp_inactive_widgets" class="widgets-holder-wrap">
<h3 class="sidebar-name"><?php _e('Inactive Widgets'); ?>
<span><img src="images/loading-publish.gif" class="ajax-feedback" title="" alt="" /></span></h3>
<?php wp_list_widget_controls('wp_inactive_widgets'); ?>
<br class="clear" />
</div>
</div>
</div>
<!--
<div id="current-widgets-head" class="widget-liquid-right">
<div id="sidebar-info">
<p><?php //echo $sidebar_info_text; ?></p>
<p><?php _e( 'Add more from the Available Widgets section.' ); ?></p>
</div>
</div>
-->
<div class="widget-liquid-right">
<?php
$i = 0;
foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
if ( 'wp_inactive_widgets' == $sidebar )
continue;
?>
<div id="<?php echo attribute_escape( $sidebar ); ?>" class="widgets-holder-wrap">
<h3 class="sidebar-name"><?php echo wp_specialchars( $registered_sidebar['name'] ); ?>
<div id="wp_inactive_widgets" class="widgets-holder-wrap">
<h3 class="sidebar-name"><?php _e('Inactive Widgets'); ?>
<span><img src="images/loading-publish.gif" class="ajax-feedback" title="" alt="" /></span></h3>
<?php wp_list_widget_controls( $sidebar, $i ); // Show the control forms for each of the widgets in this sidebar ?>
</div>
<?php
$i++;
} ?>
<?php wp_list_widget_controls('wp_inactive_widgets'); ?>
<br class="clear" />
</div>
<form action="" method="post">
<?php wp_nonce_field( 'save-sidebar-widgets', '_wpnonce_widgets', false ); ?>
</form>
<br class="clear" />
</div>
</div>
<div class="widget-liquid-right">
<?php
$i = 0;
foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
if ( 'wp_inactive_widgets' == $sidebar )
continue; ?>
<div id="<?php echo attribute_escape( $sidebar ); ?>" class="widgets-holder-wrap">
<h3 class="sidebar-name"><?php echo wp_specialchars( $registered_sidebar['name'] ); ?>
<span><img src="images/loading-publish.gif" class="ajax-feedback" title="" alt="" /></span></h3>
<?php wp_list_widget_controls( $sidebar, $i ); // Show the control forms for each of the widgets in this sidebar ?>
</div>
<?php
$i++;
} ?>
</div>
<form action="" method="post">
<?php wp_nonce_field( 'save-sidebar-widgets', '_wpnonce_widgets', false ); ?>
</form>
<br class="clear" />
</div>
<?php

View File

@ -185,12 +185,6 @@ class WP_Widget_Search extends WP_Widget {
echo $after_widget;
}
function form( $instance ) { ?>
<input name="<?php echo $this->get_field_name('title'); ?>" type="hidden" value="" />
<?php
}
}
/**

View File

@ -424,7 +424,7 @@ function wp_default_styles( &$styles ) {
$styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20090415' );
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
$styles->add( 'colors', true, array(), '20090415' ); // Register "meta" stylesheet for admin colors
$styles->add( 'colors', true, array(), '20090419' ); // Register "meta" stylesheet for admin colors
$styles->add( 'colors-fresh', '/wp-admin/css/colors-fresh.css', array(), '20081210'); // for login.php. Is there a better way?
$styles->add_data( 'colors-fresh', 'rtl', true );
$styles->add( 'colors-classic', '/wp-admin/css/colors-classic.css', array(), '20081210');
@ -432,7 +432,7 @@ function wp_default_styles( &$styles ) {
$styles->add( 'global', '/wp-admin/css/global.css', array(), '20090415' );
$styles->add( 'media', '/wp-admin/css/media.css', array(), '20090325' );
$styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20090411' );
$styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20090419' );
$styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20090305' );
$styles->add( 'install', '/wp-admin/css/install.css', array(), '20081210' );
$styles->add( 'theme-editor', '/wp-admin/css/theme-editor.css', array(), '20081210' );

View File

@ -23,7 +23,7 @@
*/
class WP_Widget {
var $id_base; // Root id for all widgets of this type.
var $id_base; // Root id for all widgets of this type.
var $name; // Name for this widget type.
var $widget_options; // Option array passed to wp_register_sidebar_widget()
var $control_options; // Option array passed to wp_register_widget_control()
@ -61,10 +61,11 @@ class WP_Widget {
/** Echo the settings update form
*
* @param array $instance Current settings
* @param array $instance Current settings
*/
function form($instance) {
echo '<p>' . __('There are no options for this widget.') . '</p>';
return false;
}
// Functions you'll need to call.
@ -87,12 +88,11 @@ class WP_Widget {
*/
function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
$this->id_base = $id_base;
// $this->id_base = str_replace( 'wp_widget_', '', strtolower(get_class($this)) );
$this->name = $name;
$this->option_name = 'widget_' . $id_base;
$this->widget_options = wp_parse_args( $widget_options, array('classname' => $this->option_name) );
$this->control_options = wp_parse_args( $control_options, array('id_base' => $this->id_base) );
//add_action( 'widgets_init', array( &$this, '_register' ) );
}
/** Constructs name attributes for use in form() fields
@ -207,7 +207,14 @@ class WP_Widget {
}
}
} else {
foreach ( (array) $_POST['widget-' . $this->id_base] as $number => $new_instance ) {
if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) {
$settings = $_POST['widget-' . $this->id_base];
} else {
$num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number'];
$settings = array( $num => array() );
}
foreach ( $settings as $number => $new_instance ) {
$new_instance = stripslashes_deep($new_instance);
$this->_set($number);
@ -244,7 +251,7 @@ class WP_Widget {
$instance = $all_instances[ $widget_args['number'] ];
}
$this->form($instance);
return $this->form($instance);
}
/** Helper function: Registers a single instance. */