[wp-trac] [WordPress Trac] #44098: Widget classes when custom widget class is namespaced

WordPress Trac noreply at wordpress.org
Sun May 23 08:47:28 UTC 2021


#44098: Widget classes when custom widget class is namespaced
-------------------------------------------------+-------------------------
 Reporter:  rogerlos                             |       Owner:
                                                 |  SergeyBiryukov
     Type:  defect (bug)                         |      Status:  reviewing
 Priority:  normal                               |   Milestone:  5.8
Component:  Widgets                              |     Version:  5.4.2
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch dev-feedback needs-        |     Focuses:
  testing needs-unit-tests                       |
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 Thanks for the PR!

 Just noting that this also has backward compatibility concerns, as the
 `id_base` value is not only used for the widget's `id` and `class`
 attributes, but also for the option name which stores the widget settings
 (unless the widget specifies a custom `option_name` value).

 If we only take the last part of the widget class name as `id_base`, it
 could conflict with a widget of the same name from another namespace, or a
 non-namespaced widget of the same name.

 So it seems better to take the whole widget class name (including the
 namespace) and convert backslashes to hyphens, that way we should get a
 unique value.

 That might still cause some previously saved namespaced widgets to
 disappear or lose their settings due to the option name change, but let's
 try this during the beta phase and see if we have any reports of that.

 If we do get any reports, we might want to consider only doing this for
 the `classname` value and not for `id_base`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44098#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list