Opened 13 years ago
Last modified 4 years ago
#17078 new defect (bug)
is_active_sidebar() doesn't work with Numeric sidebar ID's
Reported by: | lanceo | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.8 |
Component: | Widgets | Keywords: | close 2nd-opinion |
Focuses: | Cc: |
Description
This needs a small fix:
Function is_active_sidebar( $index) converts $index to a string
then uses wp_get_sidebars_widgets() to see if the sidebar is active
..but keys in the array wp_get_sidebars_widgets() generates can be integers if the ID's of the registered sidebars are integers
Change History (10)
#3
@
13 years ago
- Summary changed from functions not compatible to is_active_sidebar() doesn't work with Numeric sidebar ID's
Just updating the title to something descriptive. I think I've interpreted the issue here correctly..
#4
@
11 years ago
- Component changed from General to Widgets
- Milestone changed from Awaiting Review to Future Release
I think there is a more established ticket somewhere.
#9
@
4 years ago
WordPress defaults to sidebar-$index
when given a numeric sidebar ID. If we were to allow numeric sidebar IDs there's no way to tell if the user is asking for sidebar-$index
or index 123
since both could exist. Even if we prioritize sidebar-$index
then 123
it wouldn't be clear if/when one loads over the other. I guess my point is that it makes backwards compatibility rough and we likely need to choose one over the other. Since sidebar-$index
is the default we should stick with that methodology and alert the user otherwise.
I guess the next question is, should we force register_sidebar()
to fail when given a numeric ID accompanied with a __doing_it_wrong()
notice or?...
Using an integer breaks
dynamic_sidebar()
as well, so the sidebar would never be displayed anyway. Also noticed that even using a numeric string breaks a sidebar's widgets from being displayed in the dashboard, but does work withdynamic_sidebar()
and related.Numeric sidebar IDs sound like bad practice too.
Code to reproduce: