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

WordPress Trac noreply at wordpress.org
Tue Nov 14 11:33:06 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:
-------------------------------------------------+-------------------------
Changes (by bobbingwide):

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


Comment:

 Replying to [comment:62 bobbingwide]:
 > I understand that this problem does not occur with the Custom HTML
 widget.

 Having thought about this a little longer I'd like to re-open this ticket.
 As previously noted, I have shortcodes which make use of the context in
 which they're run.
 With WordPress 4.9, those that are in text widgets will not have direct
 access to global $post
 but those that are in custom HTML widgets will.

 So if I had one of each widget on the same sidebar, one of the shortcodes
 would work as expected but the other wouldn't.

 This is not backward compatible.

 I would like to see code that nulled the global $post reverted.

 Consider the alternative scenario, where the user tries a shortcode that
 wasn't previously expanded in widgets and the shortcode uses global $post
 or get_post().

 There'll still be different results depending on which widget the
 shortcode's being run from.

 It would be an odd situation where the expected results come from the text
 widget but the custom HTML widget produces the wrong results. Especially
 if the text widget's suggesting the user tried the custom HTML widget.

 Notes:
 - My actual example is this [bw_related post_type=shortcode_example ].
 - My shortcode expansion logic is sensitive to whether or not the page is
 an archive.

 P.S. I have already changed my plugin, but I imagine there are many others
 which have not changed.

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


More information about the wp-trac mailing list