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

WordPress Trac noreply at wordpress.org
Sun May 23 08:50:59 UTC 2021


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

 * status:  reviewing => closed
 * resolution:   => fixed


Comment:

 In [changeset:"50953" 50953]:
 {{{
 #!CommitTicketReference repository="" revision="50953"
 Widgets: Make sure `WP_Widget` constructor creates a correct `id_base`
 value for a namespaced widget class.

 The `id_base` value is used for the widget's `id` and `class` attributes
 and also for the option name which stores the widget settings (unless the
 widget specifies a custom `option_name` value).

 With this change, any backslashes in the `id_base` for a namespaced widget
 class are converted to hyphens, making it easier to style the output or
 target the widget with JavaScript.

 This also avoids a `preg_match(): Compilation failed` PHP warning from
 `next_widget_id_number()` on the Widgets screen, previously caused by
 unescaped backslashes.

 Props Mte90, hermpheus, rogerlos, welcher, SergeyBiryukov.
 Fixes #44098.
 }}}

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


More information about the wp-trac mailing list