Avoid data-loss when editing multi-widgets. Props mdawaffe. fixes #6636 for trunk

git-svn-id: http://svn.automattic.com/wordpress/trunk@7620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-04-07 21:40:32 +00:00
parent 92fe7fcad0
commit 3794dc04b4
3 changed files with 11 additions and 3 deletions

View File

@ -11,7 +11,7 @@ jQuery(function($) {
var widgetAnim = $.browser.msie ? function() {
var t = $(this);
if ( t.is(':visible') ) {
if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); }
if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); }
li.css( 'marginLeft', 0 );
t.siblings('h4').children('a').text( widgetsL10n.edit );
} else {
@ -25,7 +25,7 @@ jQuery(function($) {
var t = $(this);
if ( t.is(':visible') ) {
if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); }
if ( disableFields ) { t.find( ':input:enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); }
if ( width > 250 )
li.animate( { marginLeft: 0 } );
t.siblings('h4').children('a').text( widgetsL10n.edit );

View File

@ -187,7 +187,7 @@ class WP_Scripts {
'saveText' => attribute_escape(__('Save »')),
'confirmText' => __("Are you sure you want to delete the file '%title%'?\nClick ok to delete or cancel to go back.")
) );
$this->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20080319' );
$this->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20080407c' );
$this->localize( 'admin-widgets', 'widgetsL10n', array(
'add' => __('Add'),
'edit' => __('Edit'),

View File

@ -614,6 +614,8 @@ function wp_widget_text_control($widget_args) {
}
foreach ( (array) $_POST['widget-text'] as $widget_number => $widget_text ) {
if ( !isset($widget_text['text']) && isset($options[$widget_number]) ) // user clicked cancel
continue;
$title = strip_tags(stripslashes($widget_text['title']));
if ( current_user_can('unfiltered_html') )
$text = stripslashes( $widget_text['text'] );
@ -750,6 +752,8 @@ function wp_widget_categories_control( $widget_args ) {
}
foreach ( (array) $_POST['widget-categories'] as $widget_number => $widget_cat ) {
if ( !isset($widget_cat['title']) && isset($options[$widget_number]) ) // user clicked cancel
continue;
$title = trim(strip_tags(stripslashes($widget_cat['title'])));
$count = isset($widget_cat['count']);
$hierarchical = isset($widget_cat['hierarchical']);
@ -1170,6 +1174,8 @@ function wp_widget_rss_control($widget_args) {
}
foreach( (array) $_POST['widget-rss'] as $widget_number => $widget_rss ) {
if ( !isset($widget_rss['url']) && isset($options[$widget_number]) ) // user clicked cancel
continue;
$widget_rss = stripslashes_deep( $widget_rss );
$url = sanitize_url(strip_tags($widget_rss['url']));
$options[$widget_number] = wp_widget_rss_process( $widget_rss, !isset($urls[$url]) );
@ -1460,6 +1466,8 @@ function widget_many_control( $widget_args = 1 ) {
foreach ( (array) $_POST['widget-many'] as $widget_number => $widget_many_instance ) {
// compile data from $widget_many_instance
if ( !isset($widget_many_instance['something']) && isset($options[$widget_number]) ) // user clicked cancel
continue;
$something = wp_specialchars( $widget_many_instance['something'] );
$options[$widget_number] = array( 'something' => $something ); // Even simple widgets should store stuff in array, rather than in scalar
}