Better protection against double widget insertion. Fixes #6191 props mdawaffe.
git-svn-id: https://develop.svn.wordpress.org/trunk@7275 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
29b3ff82c1
commit
e63fc7126a
@ -48,7 +48,7 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
|
|||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ) ) );
|
$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();
|
$widget_control_template = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
@ -70,9 +70,12 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
|
|||||||
'edit' => $widget['id'],
|
'edit' => $widget['id'],
|
||||||
'key' => array_search( $widget['id'], $sidebars_widgets[$sidebar] ),
|
'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;
|
$no_widgets_shown = false;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -201,7 +204,8 @@ function wp_widget_control( $sidebar_args ) {
|
|||||||
$widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
|
$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 ?>
|
<h4 class="widget-title"><?php echo $widget_title ?>
|
||||||
|
|
||||||
@ -242,7 +246,9 @@ function wp_widget_control( $sidebar_args ) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?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 ) {
|
function wp_widget_control_ob_filter( $string ) {
|
||||||
|
@ -104,8 +104,8 @@ jQuery(function($) {
|
|||||||
$('a.widget-control-remove', context).click( function() {
|
$('a.widget-control-remove', context).click( function() {
|
||||||
var w = $(this).parents('li:first').find('input[@name^="widget-id"]').val();
|
var w = $(this).parents('li:first').find('input[@name^="widget-id"]').val();
|
||||||
$(this).parents('li:first').remove();
|
$(this).parents('li:first').remove();
|
||||||
var t = $('#widget-list ul#widget-control-info-' + w + ' textarea'); // will be empty for multi-widgets
|
var t = $('#widget-list ul#widget-control-info-' + w + ' textarea');
|
||||||
t.parents('.widget-control-info:first').html( t.text() ).parents('li.widget-list-item:first').children( 'h4' ).children('a.widget-action')
|
t.parent().html( t.text() ).parents('li.widget-list-item:first').children( 'h4' ).children('a.widget-action')
|
||||||
.show().text( widgetsL10n.add ).unbind().click( addClick );
|
.show().text( widgetsL10n.add ).unbind().click( addClick );
|
||||||
var n = parseInt( $('#widget-count').text(), 10 ) - 1;
|
var n = parseInt( $('#widget-count').text(), 10 ) - 1;
|
||||||
$('#widget-count').text( n.toString() )
|
$('#widget-count').text( n.toString() )
|
||||||
|
@ -174,7 +174,7 @@ class WP_Scripts {
|
|||||||
'saveText' => attribute_escape(__('Save »')),
|
'saveText' => attribute_escape(__('Save »')),
|
||||||
'confirmText' => __("Are you sure you want to delete the file '%title%'?\nClick ok to delete or cancel to go back.")
|
'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(
|
$this->localize( 'admin-widgets', 'widgetsL10n', array(
|
||||||
'add' => __('Add'),
|
'add' => __('Add'),
|
||||||
'edit' => __('Edit'),
|
'edit' => __('Edit'),
|
||||||
|
Loading…
Reference in New Issue
Block a user