Opened 12 years ago
Closed 12 years ago
#21761 closed enhancement (fixed)
Hide Appearance > Widgets menu when no sidebars are registered
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | UI | Keywords: | has-patch |
Focuses: | Cc: |
Description
If a theme doesn't register any sidebars, the Appearance > Widgets menu is still shown and widgets.php displays
No Sidebars Defined
The theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please follow these instructions.
This is bad UX -- we're offering a menu for a feature the user doesn't meaningfully have access to, and the Widgetizing Themes instructions offered in the link are really meant for theme designers. We should hide the menu when the feature isn't registered, as we do for Headers and Backgrounds.
Attachments (3)
Change History (12)
#2
follow-up:
↓ 3
@
12 years ago
- Cc justin@… added
Just for reference to the discussion: http://lists.wordpress.org/pipermail/theme-reviewers/2012-August/010507.html
I'd love to see this happen. I'm off to see if I can dig up what needs to change.
#3
in reply to:
↑ 2
;
follow-up:
↓ 4
@
12 years ago
Replying to greenshady:
A tip: look here :)
#4
in reply to:
↑ 3
@
12 years ago
I've uploaded two separate patches. I wasn't sure the best route to take there, so I tried two different options that I think would work.
We should probably also block access and add the "You do not have sufficient permissions to access this page." message to the widgets screen in the admin, which would be consistent with the background and header features.
Replying to azaozz:
Replying to greenshady:
A tip: look here :)
I thought I was going crazy there for a while. I swore I looked in every file in /wp-admin
.
#5
@
12 years ago
Both patches have the same problem for me - they hide the Widgets menu whether the theme supports widgets or not. I'll poke at them to see if I can get the check working. Pure speculation: I wonder if this is related to the fact that it's being added directly at _admin_menu rather than later with admin_menu & the API.
#6
@
12 years ago
I can confirm that as well. I should've checked that one can actually use widgets with the patches. This is because this the wp_maybe_load_widgets
function is hooked to plugins_loaded
:
add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 );
That's too early for themes to control. I'm not sure if there are any plugins that this will affect if changed to a different hook.
Without testing, my guess is that it'd need to move to something like:
add_action( 'widgets_init', 'wp_maybe_load_widgets', 99 );
This made sense back in 2.2 (rough guess). Not anymore, I agree.