Better protection against double widget insertion. Fixes #6191 props mdawaffe.
git-svn-id: http://svn.automattic.com/wordpress/trunk@7275 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1567bfb195
commit
04543417c9
|
@ -48,7 +48,7 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
|
|||
|
||||
ob_start();
|
||||
$args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ) ) );
|
||||
call_user_func_array( 'wp_widget_control', $args );
|
||||
$sidebar_args = call_user_func_array( 'wp_widget_control', $args );
|
||||
$widget_control_template = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
|
@ -70,9 +70,12 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
|
|||
'edit' => $widget['id'],
|
||||
'key' => array_search( $widget['id'], $sidebars_widgets[$sidebar] ),
|
||||
) ) );
|
||||
$widget_control_template = '<li><textarea rows="1" cols="1">' . htmlspecialchars( $widget_control_template ) . '</textarea></li>';
|
||||
|
||||
$widget_control_template = '<textarea rows="1" cols="1">' . htmlspecialchars( $widget_control_template ) . '</textarea>';
|
||||
}
|
||||
|
||||
$widget_control_template = $sidebar_args['before_widget'] . $widget_control_template . $sidebar_args['after_widget'];
|
||||
|
||||
$no_widgets_shown = false;
|
||||
|
||||
?>
|
||||
|
@ -201,7 +204,8 @@ function wp_widget_control( $sidebar_args ) {
|
|||
$widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
|
||||
|
||||
|
||||
echo $sidebar_args['before_widget'];
|
||||
if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] )
|
||||
echo $sidebar_args['before_widget'];
|
||||
?>
|
||||
<h4 class="widget-title"><?php echo $widget_title ?>
|
||||
|
||||
|
@ -242,7 +246,9 @@ function wp_widget_control( $sidebar_args ) {
|
|||
</div>
|
||||
</div>
|
||||
<?php
|
||||
echo $sidebar_args['after_widget'];
|
||||
if ( empty($sidebar_args['_display']) || 'template' != $sidebar_args['_display'] )
|
||||
echo $sidebar_args['after_widget'];
|
||||
return $sidebar_args;
|
||||
}
|
||||
|
||||
function wp_widget_control_ob_filter( $string ) {
|
||||
|
|
|
@ -104,8 +104,8 @@ jQuery(function($) {
|
|||
$('a.widget-control-remove', context).click( function() {
|
||||
var w = $(this).parents('li:first').find('input[@name^="widget-id"]').val();
|
||||
$(this).parents('li:first').remove();
|
||||
var t = $('#widget-list ul#widget-control-info-' + w + ' textarea'); // will be empty for multi-widgets
|
||||
t.parents('.widget-control-info:first').html( t.text() ).parents('li.widget-list-item:first').children( 'h4' ).children('a.widget-action')
|
||||
var t = $('#widget-list ul#widget-control-info-' + w + ' textarea');
|
||||
t.parent().html( t.text() ).parents('li.widget-list-item:first').children( 'h4' ).children('a.widget-action')
|
||||
.show().text( widgetsL10n.add ).unbind().click( addClick );
|
||||
var n = parseInt( $('#widget-count').text(), 10 ) - 1;
|
||||
$('#widget-count').text( n.toString() )
|
||||
|
|
|
@ -174,7 +174,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' ), '20080305' );
|
||||
$this->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20080313' );
|
||||
$this->localize( 'admin-widgets', 'widgetsL10n', array(
|
||||
'add' => __('Add'),
|
||||
'edit' => __('Edit'),
|
||||
|
|
Loading…
Reference in New Issue