Make WordPress Core

Opened 18 years ago

Closed 17 years ago

#8756 closed defect (bug) (invalid)

No continuity constraint between dynamic_sidebar and register_sidebar leeds to no widgets in the sidebar in admin mode

Reported by: e-gaulue Owned by:
Priority: normal Milestone:
Component: Widgets Version: 2.7
Severity: trivial Keywords: widget sidebar
Cc: Focuses:

Description

register_sidebar allows you to set sidebars with different id and name.

In order to have your widget display you go in dynamic_sidebar function.

This function accepts a number or whatever. If you set it to the integer "2" it looks for the sidebar with the "sidebar-2" index. If you set it to something else it applies sanitize_title on the parameter and it tries to find a corresponding sidebar name then it set te index. If it doesn't find it, the index will stay with the sanitize_title value of the parameter and it goes on.

In the admin interface we will come here because of this code (in wp-admin/widgets.php):

<div id="current-sidebar">
	<?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?>
</div>

With $sidebar being :

if ( isset($_GET['sidebar']) && isset($wp_registered_sidebars[$_GET['sidebar']]) ) {
	$sidebar = attribute_escape( $_GET['sidebar'] );
(...)

So it's the sidebar['id'], but at no time it has been sinitize with sanitize_title(). So the function dynamic_sidebar don't find the sidebar. Having an uppercase sidebar['id'] is enough to fall in that trap.

I propose several possibilities :

  • sanitize sidebar['id'] with sanitize_title at sidebar registration time
  • modify the dynamic_sidebar function by keeping the original value of index during sidebar['name'] search
  • modify the dynamic_sidebar function by escaping the sidebar['name'] search if isset($wp_registered_sidebars[$index])
  • modify the dynamic_sidebar function by changing the test in the sidebar['name'] search to : if ( sanitize_title($value['name']) == $index || sanitize_title($value['index'])== $index )

Change History (5)

#1 @ryan
18 years ago

  • Component GeneralWidgets
  • Owner anonymous removed

#2 @Denis-de-Bernardy
17 years ago

Is this still current? See: #9511

#3 @janeforshort
17 years ago

  • Milestone 2.8Future Release

Punting due to feature freeze. Reconsider with next release.

#4 @Denis-de-Bernardy
17 years ago

  • Milestone Future Release2.8
  • Priority highest omg bbqnormal

#5 @Denis-de-Bernardy
17 years ago

  • Milestone 2.8
  • Resolutioninvalid
  • Status newclosed

Please re-open with feedback if this is still current with the new widgets interface

Note: See TracTickets for help on using tickets.