[wp-trac] [WordPress Trac] #41394: Custom HTML widget applies widget_text filters with unexpected $instance data

WordPress Trac noreply at wordpress.org
Fri Jul 21 04:54:54 UTC 2017


#41394: Custom HTML widget applies widget_text filters with unexpected $instance
data
--------------------------+--------------------------
 Reporter:  westonruter   |       Owner:  westonruter
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  4.8.1
Component:  Widgets       |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+--------------------------
Description changed by westonruter:

Old description:

> The Custom HTML widget (#40907) applies the `widget_text` filters on its
> content to ensure that when a user moves HTML from a Text widget over to
> a Custom HTML widget, it will get all of the same filters applied. See
> [41086]. There are still `widget_text_content` and
> `widget_custom_html_content` filters that apply to the Text widget and
> Custom HTML widget respectively, but they share this same `widget_text`
> filter that has been around since WP 2.3.0.
>
> When the Custom HTML widget applies the `widget_text` filters, it is
> supplying the Custom HTML widget's `$instance` as the filter's second
> argument. This could cause problems for plugins that filter `widget_text`
> because they may expect a widget's instance data to look like:
>
> {{{#!json
> {
>     "title": "The Title",
>     "text": "Hell World",
>     "filter": false
> }
> }}}
>
> When instead the Custom HTML widget instances look like:
>
> {{{#!json
> {
>     "title": "The Title",
>     "content": "Hell World"
> }
> }}}
>
> So in order to preserve backwards compatibility for plugins that look at
> the `$instance` param, the instance data needs to be transformed from the
> Custom HTML instance schema over to the Text widget instance schema.

New description:

 The Custom HTML widget (#40907) applies the `widget_text` filters on its
 content to ensure that when a user moves HTML from a Text widget over to a
 Custom HTML widget, it will get all of the same filters applied. See
 [41086]. There are still `widget_text_content` and
 `widget_custom_html_content` filters that apply to the Text widget and
 Custom HTML widget respectively, but they share this same `widget_text`
 filter that has been around since WP 2.3.0.

 When the Custom HTML widget applies the `widget_text` filters, it is
 supplying the Custom HTML widget's `$instance` as the filter's second
 argument. This could cause problems for plugins that filter `widget_text`
 because they may expect a widget's instance data to look like:

 {{{#!json
 {
     "title": "The Title",
     "text": "Hello World",
     "filter": false
 }
 }}}

 When instead the Custom HTML widget instances look like:

 {{{#!json
 {
     "title": "The Title",
     "content": "Hello World"
 }
 }}}

 So in order to preserve backwards compatibility for plugins that look at
 the `$instance` param, the instance data needs to be transformed from the
 Custom HTML instance schema over to the Text widget instance schema.

--

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


More information about the wp-trac mailing list