WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 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:
Milestone: Priority: normal
Severity: trivial Version: 2.7
Component: Widgets Keywords: widget sidebar
Focuses: Cc:

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)

comment:1 @ryan6 years ago

  • Component changed from General to Widgets
  • Owner anonymous deleted

comment:2 @Denis-de-Bernardy6 years ago

Is this still current? See: #9511

comment:3 @janeforshort6 years ago

  • Milestone changed from 2.8 to Future Release

Punting due to feature freeze. Reconsider with next release.

comment:4 @Denis-de-Bernardy6 years ago

  • Milestone changed from Future Release to 2.8
  • Priority changed from highest omg bbq to normal

comment:5 @Denis-de-Bernardy6 years ago

  • Milestone 2.8 deleted
  • Resolution set to invalid
  • Status changed from new to closed

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

Note: See TracTickets for help on using tickets.