[wp-trac] [WordPress Trac] #11160: Inconsistancies in Naming and Using Sidebar Names and IDs.
WordPress Trac
wp-trac at lists.automattic.com
Wed Nov 18 17:01:37 UTC 2009
#11160: Inconsistancies in Naming and Using Sidebar Names and IDs.
-----------------------------+----------------------------------------------
Reporter: CharlesClarkson | Owner: azaozz
Type: defect (bug) | Status: new
Priority: normal | Milestone: 2.9
Component: Widgets | Version: 2.9
Severity: normal | Keywords: has-patch needs-testing
-----------------------------+----------------------------------------------
Comment(by CharlesClarkson):
Replying to [comment:3 azaozz]:
> Removed some duplicate code. Needs quite a bit of testing if we want it
in 2.9.
The second patch
([http://core.trac.wordpress.org/attachment/ticket/11160/11160-1.patch
11160-1.patch]) breaks backward compatibility. Especially with
dynamic_sidebar which I wanted to leave alone. Here's the more efficient
code from the second patch:
{{{
if ( (int) $args ) { // $args could be int 1 or string '1'
return "sidebar-$args";
} elseif ( is_string($args) ) {
$name = sanitize_title($args);
if ( array_key_exists($name, (array) $wp_registered_sidebars) )
return $name;
foreach ( (array) $wp_registered_sidebars as $id => $value ) {
if ( sanitize_title($value['name']) == $name )
return $id;
}
}
return false;
}}}
That first test catches strings, which dynamic_sidebar() doesn't catch
now. Users who have figured out that they can place 1 in quotes and name
their sidebars by numbers, will find their sidebars break after the patch.
{{{
if ( (int) $args ) { // $args could be int 1 or string '1'
}}}
In second test of the code you make the id take precedence over the name.
This is the opposite of dynamic_sidebar() which assumes you have passed
the name of a sidebar if a string was passed.
{{{
if ( array_key_exists($name, (array) $wp_registered_sidebars) )
return $name;
}}}
It is not necessary (or desirable) to fix dynamic_sidebar(). The array
interface allows programmers to specify unambiguous sidebar ids and names.
The rest of the second patch is great.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/11160#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list