[wp-trac] [WordPress Trac] #34361: Embed shortcode is not working in text widgets
WordPress Trac
noreply at wordpress.org
Tue Oct 20 09:01:27 UTC 2015
#34361: Embed shortcode is not working in text widgets
-------------------------+------------------------
Reporter: Surbma | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Widgets | Version: 4.3.1
Severity: normal | Resolution: duplicate
Keywords: | Focuses:
-------------------------+------------------------
Changes (by swissspidy):
* status: new => closed
* resolution: => duplicate
* component: Embeds => Widgets
* milestone: Awaiting Review =>
Comment:
> Thank you for your reply! Can you please give a working example code?
Something like this should work (untested!):
{{{#!php
<?php
function 34361_widget_text_embeds($text) {
global $wp_embed;
return $wp_embed->run_shortcode( $text );
}
add_filter( 'widget_text', '34361_widget_text_embeds' );
}}}
If it doesn't, that's because of the caching in post meta. See
https://core.trac.wordpress.org/ticket/10457#comment:33
See also `WP_Embed::__construct` for the various hooks that are used for
embeds.
> Is it something, that never will change to make it easy to use in a text
widget?
Shortcodes in widgets are being discussed in #10457. There are some edge
cases that need to be considered, like the post meta cache for embeds.
Closing this ticket as a duplicate.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34361#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list