diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index 38dcca4f50..e3f2625c92 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -47,7 +47,8 @@ function wp_list_widgets( $show = 'all', $_search = false ) { continue; ob_start(); - wp_widget_control( 'no-key', $widget['id'], '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 ); $widget_control_template = ob_get_contents(); ob_end_clean(); @@ -122,89 +123,132 @@ function wp_list_widgets( $show = 'all', $_search = false ) { - \n"; + $params[0]['after_widget'] = ""; + $params[0]['before_title'] = "%BEG_OF_TITLE%"; + $params[0]['after_title'] = "%END_OF_TITLE%"; + $wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback']; + $wp_registered_widgets[$widget_id]['callback'] = 'wp_widget_control'; + return $params; +} + +/* + * Meta widget used to display the control form for a widget. Called from dynamic_sidebar() + */ +function wp_widget_control( $sidebar_args ) { + global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets, $edit_widget; + $widget_id = $sidebar_args['widget_id']; + $sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false; + + $control = $wp_registered_widget_controls[$widget_id]; + $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 = $edit_widget > 0 && $key && $edit_widget == $key; // (bool) are we currently editing this widget $id_format = $widget['id']; - if ( 'template' == $display && isset($control['params'][0]['number']) ) { + // We aren't showing a widget control, we're outputing a template for a mult-widget control + if ( 'template' == $sidebar_args['_display'] && isset($control['params'][0]['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} if ( isset($control['id_base']) ) $id_format = $control['id_base'] . '-%i%'; } + + $widget_title = ''; + // We grab the normal widget output to find the widget's title + if ( is_callable( $widget['_callback'] ) ) { + ob_start(); + $args = func_get_args(); + call_user_func_array( $widget['_callback'], $args ); + $widget_title = ob_get_clean(); + $widget_title = wp_widget_control_ob_filter( $widget_title ); + } + $wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback']; + unset($wp_registered_widgets[$widget_id]['_callback']); + + if ( $widget_title ) + $widget_title = sprintf( _c('%1$s: %2$s|widget_admin_title' ), $sidebar_args['widget_name'], $widget_title ); + else + $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) ); + + + echo $sidebar_args['before_widget']; ?> +

-
  • -

    + - + - + - + - + - +

    + +
    > + + ' . __('There are no options for this widget.') . '

    '; + ?> + + + + +
    + + + + -
  • - -
    > - - ' . __('There are no options for this widget.') . '

    '; - ?> - - - - -
    - - - - - - - - "> -
    -
    + "> +
    - - +
    - +