{"id":5610,"date":"2026-02-12T20:44:55","date_gmt":"2026-02-13T01:44:55","guid":{"rendered":"https:\/\/chubes.net\/?documentation=wp_embed-class"},"modified":"2026-03-13T03:28:21","modified_gmt":"2026-03-13T07:28:21","slug":"wp_embed-class","status":"publish","type":"documentation","link":"https:\/\/chubes.net\/docs\/wordpress-core\/embeds\/wp_embed-class\/","title":{"rendered":"WP_Embed Class"},"content":{"rendered":"<p>API for embedding rich media content from URLs into post content.<\/p>\n<p><strong>Since:<\/strong> 2.9.0<br \/>\n<strong>Source:<\/strong> <code>wp-includes\/class-wp-embed.php<\/code><\/p>\n<h2>Overview<\/h2>\n<p><code>WP_Embed<\/code> is the core class that processes content and converts URLs to embedded media. It handles:<\/p>\n<ul>\n<li><code><\/code> shortcode processing<\/li>\n<li>Auto-embedding of standalone URLs<\/li>\n<li>Custom embed handler registration<\/li>\n<li>oEmbed result caching<\/li>\n<\/ul>\n<h2>Global Instance<\/h2>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">global $wp_embed;\n<\/code><\/pre><\/div>\n<p>WordPress initializes <code>$wp_embed<\/code> during load. Use wrapper functions rather than accessing directly.<\/p>\n<h2>Properties<\/h2>\n<table>\n<thead>\n<tr>\n<th>Property<\/th>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>$handlers<\/code><\/td>\n<td>array<\/td>\n<td>Registered embed handlers by priority<\/td>\n<\/tr>\n<tr>\n<td><code>$post_ID<\/code><\/td>\n<td>int<\/td>\n<td>Current post ID context<\/td>\n<\/tr>\n<tr>\n<td><code>$usecache<\/code><\/td>\n<td>bool<\/td>\n<td>Whether to use cached results (default true)<\/td>\n<\/tr>\n<tr>\n<td><code>$linkifunknown<\/code><\/td>\n<td>bool<\/td>\n<td>Link URLs that can&#8217;t be embedded (default true)<\/td>\n<\/tr>\n<tr>\n<td><code>$last_attr<\/code><\/td>\n<td>array<\/td>\n<td>Attributes from last shortcode call<\/td>\n<\/tr>\n<tr>\n<td><code>$last_url<\/code><\/td>\n<td>string<\/td>\n<td>URL from last shortcode call<\/td>\n<\/tr>\n<tr>\n<td><code>$return_false_on_fail<\/code><\/td>\n<td>bool<\/td>\n<td>Return false instead of link on failure<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Constructor<\/h2>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function __construct()\n<\/code><\/pre><\/div>\n<p>Sets up:<\/p>\n<ul>\n<li><code>the_content<\/code> filter at priority 8 for <code>run_shortcode()<\/code> and <code>autoembed()<\/code><\/li>\n<li>Same filters for <code>widget_text_content<\/code> and <code>widget_block_content<\/code><\/li>\n<li>Placeholder <code><\/code> shortcode for <code>strip_shortcodes()<\/code><\/li>\n<li>Admin ajax cache trigger on post save<\/li>\n<\/ul>\n<h2>Methods<\/h2>\n<h3>Handler Registration<\/h3>\n<h4>register_handler()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function register_handler( \n    string $id, \n    string $regex, \n    callable $callback, \n    int $priority = 10 \n): void\n<\/code><\/pre><\/div>\n<p>Registers a custom embed handler.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<ul>\n<li><code>$id<\/code> &#8211; Unique identifier<\/li>\n<li><code>$regex<\/code> &#8211; URL matching pattern<\/li>\n<li><code>$callback<\/code> &#8211; Handler function <code>( $matches, $attr, $url, $rawattr )<\/code><\/li>\n<li><code>$priority<\/code> &#8211; Lower executes first<\/li>\n<\/ul>\n<p><strong>Internal structure:<\/strong><\/p>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">$this-&gt;handlers[ $priority ][ $id ] = [\n    'regex'    =&gt; $regex,\n    'callback' =&gt; $callback,\n];\n<\/code><\/pre><\/div>\n<hr \/>\n<h4>unregister_handler()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function unregister_handler( string $id, int $priority = 10 ): void\n<\/code><\/pre><\/div>\n<p>Removes a registered handler.<\/p>\n<hr \/>\n<h3>Content Processing<\/h3>\n<h4>run_shortcode()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function run_shortcode( string $content ): string\n<\/code><\/pre><\/div>\n<p>Processes <code><\/code> shortcodes in content.<\/p>\n<p><strong>Process:<\/strong><\/p>\n<ol>\n<li>Backs up all registered shortcodes<\/li>\n<li>Removes all shortcodes<\/li>\n<li>Registers only <code><\/code> \u2192 <code>$this-&gt;shortcode()<\/code><\/li>\n<li>Runs <code>do_shortcode()<\/code><\/li>\n<li>Restores original shortcodes<\/li>\n<\/ol>\n<p><strong>Why priority 8?<\/strong> Runs before <code>wpautop()<\/code> (priority 10) to prevent <code>&lt;p&gt;<\/code> tags around embeds.<\/p>\n<hr \/>\n<h4>autoembed()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function autoembed( string $content ): string\n<\/code><\/pre><\/div>\n<p>Converts standalone URLs to embeds without shortcode.<\/p>\n<p><strong>URL detection:<\/strong><\/p>\n<ul>\n<li>URLs on their own line (with optional whitespace)<\/li>\n<li>URLs alone in a <code>&lt;p&gt;<\/code> tag<\/li>\n<\/ul>\n<p><strong>Process:<\/strong><\/p>\n<ol>\n<li>Replace newlines in HTML tags with placeholders<\/li>\n<li>Match standalone URLs via regex<\/li>\n<li>Call <code>autoembed_callback()<\/code> for each match<\/li>\n<li>Restore newlines<\/li>\n<\/ol>\n<p><strong>Regex patterns:<\/strong><\/p>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\"><\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code\"><code>^(s*)(https?:\/\/[^s&lt;&gt;&quot;]+)(s*)$   \/\/ Line-level\n(&lt;p[^&gt;]*&gt;s*)(https?:\/\/[^s&lt;&gt;&quot;]+)(s*&lt;\/p&gt;)  \/\/ Paragraph-level\n<\/code><\/pre><\/div>\n<hr \/>\n<h4>autoembed_callback()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function autoembed_callback( array $matches ): string\n<\/code><\/pre><\/div>\n<p>Callback for <code>autoembed()<\/code> regex replacements.<\/p>\n<p>Temporarily sets <code>$linkifunknown = false<\/code> so failed embeds return the URL as-is, not as a link.<\/p>\n<hr \/>\n<h3>Shortcode Handler<\/h3>\n<h4>shortcode()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function shortcode( array $attr, string $url = '' ): string|false\n<\/code><\/pre><\/div>\n<p>Main <code><\/code> shortcode handler.<\/p>\n<p><strong>Attributes:<\/strong><\/p>\n<ul>\n<li><code>src<\/code> &#8211; Alternative to URL in shortcode content<\/li>\n<li><code>width<\/code> &#8211; Override width<\/li>\n<li><code>height<\/code> &#8211; Override height<\/li>\n<\/ul>\n<p><strong>Process:<\/strong><\/p>\n<ol>\n<li>Get URL from content or <code>src<\/code> attribute<\/li>\n<li>Fix KSES <code>&amp;amp;<\/code> \u2192 <code>&amp;<\/code> conversion<\/li>\n<li>Check registered handlers first<\/li>\n<li>Check cache (post meta or oembed_cache post type)<\/li>\n<li>If not cached or expired, call <code>wp_oembed_get()<\/code><\/li>\n<li>Store result in cache<\/li>\n<li>Return HTML or fallback link<\/li>\n<\/ol>\n<p><strong>Caching keys:<\/strong><\/p>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">$key_suffix = md5( $url . serialize( $attr ) );\n$cachekey = '_oembed_' . $key_suffix;\n$cachekey_time = '_oembed_time_' . $key_suffix;\n<\/code><\/pre><\/div>\n<p><strong>Cache TTL:<\/strong> Controlled by <code>oembed_ttl<\/code> filter (default <code>DAY_IN_SECONDS<\/code>).<\/p>\n<hr \/>\n<h4>get_embed_handler_html()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function get_embed_handler_html( array $attr, string $url ): string|false\n<\/code><\/pre><\/div>\n<p>Checks registered handlers for URL match.<\/p>\n<p><strong>Since:<\/strong> 5.5.0<\/p>\n<p><strong>Process:<\/strong><\/p>\n<ol>\n<li>Sort handlers by priority (<code>ksort<\/code>)<\/li>\n<li>Test each handler&#8217;s regex against URL<\/li>\n<li>If match, call handler callback<\/li>\n<li>Apply <code>embed_handler_html<\/code> filter to result<\/li>\n<\/ol>\n<hr \/>\n<h3>Caching<\/h3>\n<h4>cache_oembed()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function cache_oembed( int $post_id ): void\n<\/code><\/pre><\/div>\n<p>Triggers caching of all embeds in a post&#8217;s content.<\/p>\n<p>Called via admin-ajax after post save. Processes content with <code>$usecache = false<\/code> to force fresh fetches.<\/p>\n<hr \/>\n<h4>delete_oembed_caches()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function delete_oembed_caches( int $post_id ): void\n<\/code><\/pre><\/div>\n<p>Deletes all oEmbed cache entries from post meta.<\/p>\n<p><strong>Note:<\/strong> Unused by core since 4.0.0.<\/p>\n<p>Removes all meta keys starting with <code>_oembed_<\/code>.<\/p>\n<hr \/>\n<h4>find_oembed_post_id()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function find_oembed_post_id( string $cache_key ): int|null\n<\/code><\/pre><\/div>\n<p>Finds cached embed stored as <code>oembed_cache<\/code> post type.<\/p>\n<p><strong>Since:<\/strong> 4.9.0<\/p>\n<p>Uses object cache (<code>oembed_cache_post<\/code> group) for performance.<\/p>\n<hr \/>\n<h3>Fallback Handling<\/h3>\n<h4>maybe_make_link()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function maybe_make_link( string $url ): string|false\n<\/code><\/pre><\/div>\n<p>Returns linked URL or plain URL when embed fails.<\/p>\n<p><strong>Behavior:<\/strong><\/p>\n<ul>\n<li>If <code>$return_false_on_fail<\/code> \u2192 returns <code>false<\/code><\/li>\n<li>If <code>$linkifunknown<\/code> \u2192 returns <code>&lt;a href=&quot;...&quot;&gt;URL&lt;\/a&gt;<\/code><\/li>\n<li>Otherwise \u2192 returns URL as-is<\/li>\n<\/ul>\n<p>Filtered by <code>embed_maybe_make_link<\/code>.<\/p>\n<hr \/>\n<h3>Admin Integration<\/h3>\n<h4>maybe_run_ajax_cache()<\/h4>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">public function maybe_run_ajax_cache(): void\n<\/code><\/pre><\/div>\n<p>Outputs JavaScript to trigger cache refresh on post save.<\/p>\n<p>Hooked to <code>edit_form_advanced<\/code> and <code>edit_page_form<\/code>.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">javascript<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-javascript\"><code class=\"language-javascript\">jQuery( function($) {\n    $.get( &quot;\/wp-admin\/admin-ajax.php?action=oembed-cache&amp;post=123&quot; );\n} );\n<\/code><\/pre><\/div>\n<hr \/>\n<h2>Usage Example<\/h2>\n<h3>Processing Content<\/h3>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">\/\/ WordPress handles this automatically via filters, but manually:\nglobal $wp_embed;\n\n$content = 'Check out this video: https:\/\/www.youtube.com\/watch?v=dQw4w9WgXcQ';\n$content = $wp_embed-&gt;autoembed( $content );\n<\/code><\/pre><\/div>\n<h3>Custom Handler<\/h3>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">global $wp_embed;\n\n$wp_embed-&gt;register_handler(\n    'viddler',\n    '#https?:\/\/(?:www.)?viddler.com\/v\/([a-z0-9]+)#i',\n    function( $matches, $attr, $url, $rawattr ) {\n        return sprintf(\n            '&lt;iframe src=&quot;https:\/\/www.viddler.com\/embed\/%s&quot; width=&quot;%d&quot; height=&quot;%d&quot;&gt;&lt;\/iframe&gt;',\n            esc_attr( $matches[1] ),\n            esc_attr( $attr['width'] ),\n            esc_attr( $attr['height'] )\n        );\n    },\n    5 \/\/ Higher priority (lower number)\n);\n<\/code><\/pre><\/div>\n<h3>Disable Auto-Embed<\/h3>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">\/\/ Remove autoembed from content\nremove_filter( 'the_content', [ $GLOBALS['wp_embed'], 'autoembed' ], 8 );\n<\/code><\/pre><\/div>\n<h3>Force Fresh Fetch<\/h3>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">global $wp_embed;\n\n$wp_embed-&gt;usecache = false;\n$html = $wp_embed-&gt;shortcode( [], 'https:\/\/example.com\/video' );\n$wp_embed-&gt;usecache = true;\n<\/code><\/pre><\/div>\n<h2>Filters Applied<\/h2>\n<table>\n<thead>\n<tr>\n<th>Filter<\/th>\n<th>Location<\/th>\n<th>Purpose<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>embed_handler_html<\/code><\/td>\n<td><code>get_embed_handler_html()<\/code><\/td>\n<td>Filter handler output<\/td>\n<\/tr>\n<tr>\n<td><code>oembed_ttl<\/code><\/td>\n<td><code>shortcode()<\/code><\/td>\n<td>Cache duration<\/td>\n<\/tr>\n<tr>\n<td><code>embed_oembed_html<\/code><\/td>\n<td><code>shortcode()<\/code><\/td>\n<td>Filter cached\/fetched HTML<\/td>\n<\/tr>\n<tr>\n<td><code>embed_oembed_discover<\/code><\/td>\n<td><code>shortcode()<\/code><\/td>\n<td>Enable URL discovery<\/td>\n<\/tr>\n<tr>\n<td><code>embed_cache_oembed_types<\/code><\/td>\n<td><code>cache_oembed()<\/code><\/td>\n<td>Post types to cache<\/td>\n<\/tr>\n<tr>\n<td><code>embed_maybe_make_link<\/code><\/td>\n<td><code>maybe_make_link()<\/code><\/td>\n<td>Filter fallback link<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Cache Storage<\/h2>\n<h3>With Post Context<\/h3>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">\/\/ Stored in post meta\nupdate_post_meta( $post_id, '_oembed_abc123', '&lt;iframe...&gt;' );\nupdate_post_meta( $post_id, '_oembed_time_abc123', time() );\n<\/code><\/pre><\/div>\n<h3>Without Post Context<\/h3>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">\/\/ Stored as oembed_cache post type\nwp_insert_post([\n    'post_type'    =&gt; 'oembed_cache',\n    'post_status'  =&gt; 'publish',\n    'post_name'    =&gt; 'abc123...',  \/\/ md5 hash\n    'post_content' =&gt; '&lt;iframe...&gt;',\n]);\n<\/code><\/pre><\/div>\n<h3>Failed Embed Marker<\/h3>\n<div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre class=\"wp-block-code language-php\"><code class=\"language-php\">\/\/ Stores special marker to prevent re-fetching\nupdate_post_meta( $post_id, '_oembed_abc123', '{{unknown}}' );\n<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>API for embedding rich media content from URLs into post content. Since: 2.9.0 Source: wp-includes\/class-wp-embed.php Overview WP_Embed is the core class that processes content and converts URLs to embedded media&#8230;.<\/p>\n","protected":false},"featured_media":0,"template":"","meta":{"footnotes":""},"tags":[],"project":[620],"project_type":[749],"class_list":["post-5610","documentation","type-documentation","status-publish","hentry","project-embeds","project_type-wordpress-reference"],"project_info":{"id":589,"name":"WordPress Core","slug":"wordpress-core"},"project_type_info":{"id":749,"name":"WordPress Reference","slug":"wordpress-reference"},"_links":{"self":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/5610","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation"}],"about":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/types\/documentation"}],"version-history":[{"count":1,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/5610\/revisions"}],"predecessor-version":[{"id":6974,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/5610\/revisions\/6974"}],"wp:attachment":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/media?parent=5610"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/tags?post=5610"},{"taxonomy":"project","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/project?post=5610"},{"taxonomy":"project_type","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/project_type?post=5610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}