Opened 9 years ago
Last modified 4 years ago
#36559 new defect (bug)
Using "widget" as part of setting title breaks the customizer since 4.5
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.5 |
Component: | Customize | Keywords: | close |
Focuses: | Cc: |
Description
Hi, My theme "Indie" had several customizer options that have the word "Widget" as part of the add_setting and add_control title:
'widget_bg' 'widget_txt' 'widget_txt_highlight' 'widget_txt_highlight_hover'
This broke the customizer completely showing no options other than the widget panel.
I've replaced these names and the customizer works again.
This problem was reported to me since 4.5 release.
Thanks
Steven
Change History (7)
#3
follow-up:
↓ 4
@
9 years ago
@steven_gardner hi. It's not actually a duplicate, but just that it came up in conversation recently.
A potential solution to help avoid this problem in the first place is to change logic in \WP_Customize_Widgets::get_setting_args()
to check if the matched id_base
pattern in the regular expression ^widget_(?P<id_base>.+?)(?:\[(?P<widget_number>\d+)\])?$
actually corresponds to the ID base of a registered widget.
The immediate fix is to just not use widget_
as the prefix in your Customizer settings/controls, and this is what I'm going to update the Customizer API documentation to make note of, that the widget_
prefix is reserved for actual widgets.
#4
in reply to:
↑ 3
@
9 years ago
Replying to westonruter:
The immediate fix is to just not use
widget_
as the prefix in your Customizer settings/controls, and this is what I'm going to update the Customizer API documentation to make note of, that thewidget_
prefix is reserved for actual widgets.
See notice here: https://developer.wordpress.org/themes/advanced-topics/customizer-api/#setting-id-naming-convention-notice
#5
@
9 years ago
I would prefer for widget*
and nav_manu*
to be entirely reserved, since future changes there could add things that conflict with themes and plugins.
#7
@
4 years ago
- Keywords close added
- Milestone set to Awaiting Review
I would now suggest closing this in favor of the documented restrictions on setting names (now here: https://developer.wordpress.org/themes/customize-api/customizer-objects/#settings).
Is there anything else that core can easily do to flag these restrictions?
Hello @steven_gardner, welcome to the WordPress Trac!
The same was reported two weeks ago on Slack too, see https://wordpress.slack.com/archives/core/p1459530599002514.
@westonruter: