WordPress 4.9 is just around the corner, and it comes with fantastic widget improvements. Finally, users will be able to add shortcodes to the core Text widget without using plugins or added code from themes. This was revealed last week by Weston Ruter, who's part of the WordPress core development team.
This new feature is in response to a longstanding request – over 8 years – to support shortcodes in the Text widget. In the dev note for the feature, Ruter breaks down the technical details and explains why it took this long to implement the feature.
One reason for the long delay with adding shortcode support in Text widgets was due to many shortcodes looking for a global $post when they run. Since the global $post varies depending on whatever the query is, the shortcodes in a Text widget could render wildly different on different templates of a site. The solution worked out was to temporarily nullify the global $post before doing the shortcodes so that they will consistently have the same global state, with this global $post then restored after the shortcodes are done. So if you have shortcodes that depend on a global $post—or call get_post()—then you should make sure that they short-circuit when $post is null in order for them to behave properly if used in the Text widget.
Besides shortcodes, WordPress 4.9 will also allow users to embed media in the Text widget. There's now a new “Add Media” button in the Text widget, making it easy for you to add images, galleries, videos, audio, and other media.
WordPress 4.9 also allows you to display oEmbeds in the Text widget, while the Video widget has been expanded to support any oEmbed provider for video.
WordPress 4.9 is due for release on November 14, 2017.