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

WordPress Trac noreply at wordpress.org
Tue Nov 14 16:28:07 UTC 2017


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

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


Comment:

 Replying to [comment:66 bobbingwide]:
 > Replying to [comment:65 westonruter]:
 > > Core does not apply shortcodes in the Custom HTML widget at all.
 >
 > Does that make sense? Should that not have been part of the
 implementation?

 It is intentionally not part of the core implementation. Shortcodes are
 for content. The presence of something that looks like a shortcode could
 mess up HTML if it is unintentionally converted.

 > > 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.
 >
 > Yes, exactly. Had I done that in my shortcode enabled text widget then
 that's what gallery would have done.
 > So now 4.9 would break it.

 In that case your shortcodes should be using `get_queried_object()`
 instead of `get_post()`.

 > > 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.
 >
 > That could resolve the inconsistency but it means that 4.9 will be
 shipped with broken backward compatibility.

 Core never officially supported shortcodes in the Text widget until 4.9 in
 part because of the problems of the global `$post` and how different
 shortcodes rely on it in different ways (content, caching, context, etc).
 So if this is backwards-incompatible with some plugins, then I think
 that's just how it's going to have to be. Developers have the
 [https://make.wordpress.org/core/2017/10/24/widget-improvements-in-
 wordpress-4-9/ dev note] to refer to on how shortcodes are now officially
 supported in core. If they need to post context for shortcodes, then they
 need to explicitly use `get_queried_object()` to opt-in for that. I'll
 update the dev note to mention that.

 I've opened #42547 to add nullification of global `$post` to the Custom
 HTML widget.

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


More information about the wp-trac mailing list