[wp-trac] [WordPress Trac] #10457: Parse shortcodes in text widgets by default

WordPress Trac noreply at wordpress.org
Tue Nov 14 15:41:38 UTC 2017

#10457: Parse shortcodes in text widgets by default
 Reporter:  ionfish                              |       Owner:
     Type:  enhancement                          |  westonruter
 Priority:  normal                               |      Status:  reopened
Component:  Widgets                              |   Milestone:  4.9
 Severity:  normal                               |     Version:  2.8
 Keywords:  westi-likes has-patch commit has-    |  Resolution:
  unit-tests has-dev-note                        |     Focuses:

Comment (by westonruter):

 @bobbingwide so you're saying the Text widget and the Custom HTML widget
 are inconsistent here? Core does not apply shortcodes in the Custom HTML
 widget at all. The Custom HTML widget does apply the `widget_text` filter
 for compatibility with code that users may have copied from the legacy
 (non-visual) Text widget over to the Custom HTML widget, but in core
 itself no shortcode processing is done with this filter. Core applies
 shortcodes at `widget_text_content` not `widget_text`.  Do you have a
 plugin that adds shortcode processing to the `widget_text` filter?

 So the solution isn't to remove the nullification of the `$post` in the
 Text widget, but rather to ''add'' `$post` nullification to the Custom
 HTML widget. Shortcodes that use the `$post` as context but then ''cache''
 the output for performance will behave very strangely if we don't unset
 `$post`. Not all shortcodes will work in a widget context. Instance, if
 you add a `[gallery]` shortcode without any arguments, in a post context
 it will grab all of the attachments of the current post. But in a widget
 there very well may not be a `$post` global, and this usage of the
 `[gallery]` won't work. So it's up to the plugin developer and the user to
 use the shortcodes in their appropriate context.

 I suggest we open a ticket for 4.9.1 that adds nullification of the
 `$post` for the Custom HTML widget and we re-close this ticket.

Ticket URL: <https://core.trac.wordpress.org/ticket/10457#comment:65>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list