Make WordPress Core

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: steven_gardner's profile steven_gardner 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)

#1 @ocean90
9 years ago

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:

Settings that are prefixed by widget_ are expected to be actual widgets, and the setting args for these are filtered for the needs of widgets. The dynamic setting filters are applying here, to also handle widgets that get created on the client before being persisted to the DB. So yes, consider this to be a reserved setting ID prefix.

#2 @steven_gardner
9 years ago

Thanks, sorry for the duplication.
I didn't see that ticket.

S

#3 follow-up: @westonruter
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 @westonruter
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 the widget_ prefix is reserved for actual widgets.

See notice here: https://developer.wordpress.org/themes/advanced-topics/customizer-api/#setting-id-naming-convention-notice

#5 @celloexpressions
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.

#6 @ocean90
9 years ago

#36841 was marked as a duplicate.

#7 @celloexpressions
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?

Note: See TracTickets for help on using tickets.