[wp-trac] [WordPress Trac] #32208: apply_filters('the_content') not working as expected in some cases

WordPress Trac noreply at wordpress.org
Thu Apr 30 20:57:19 UTC 2015


#32208: apply_filters('the_content') not working as expected in some cases
--------------------------+----------------------
 Reporter:  zabatonni     |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Embeds        |     Version:  4.2.1
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |     Focuses:
--------------------------+----------------------
Changes (by Viper007Bond):

 * status:  reopened => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 @SergeyBiryukov is correct. `WP_Embed`, the class which is hooked onto the
 `the_content` filter, caches oEmbed results to the post's meta and is not
 designed to be used outside of post types (posts, pages, etc.).

 Even if it does work in some cases, it's doing extra HTTP requests and
 spamming the post meta of whatever was the last post to be displayed on
 the page due to the `$post` global.

 If you wish to use it inside of a widget, then you need to use the lower
 level `wp_oembed_get()` function and implement your own caching to avoid
 doing a HTTP request on each page load.

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


More information about the wp-trac mailing list