'disable_oembed', 'title' => 'Disable oEmbed', 'desc' => 'Remove oEmbed discovery links, the oEmbed REST routes and wp-embed.js', 'icon' => 'x', 'help' => 'Other WordPress sites can show your posts as embedded cards by reading the oEmbed links in your pages. This removes those links and the /wp-json/oembed/ routes, stops WordPress from looking up oEmbed data for addresses that are not on its built-in provider list, and stops loading wp-embed.js. YouTube, Vimeo and other built-in provider embeds already in your posts still display. Adding a new embed in the block editor may fail, because the editor previews embeds through the oEmbed route this removes. The /embed/ version of each post still exists.', 'before' => 'oEmbed discovery links in the page head and the oEmbed API active', 'after' => 'Links and API removed. Existing YouTube and Vimeo embeds still display.', 'benefit' => 'Useful if you do not want other sites to embed your posts as cards. The speed gain is small: the discovery links are two short tags on posts and pages, and WordPress only loads wp-embed.js (about 1 KB) on pages that contain an embedded WordPress post.', 'level' => 'standard', 'audience' => 'everyone', 'priority' => 5, 'detect' => function () { return array( 'detected' => true, 'message' => 'oEmbed discovery and wp-embed.js loaded on every page', 'safe' => true, 'savings' => 'Discovery links + embed script', ); }, 'callback' => function () { add_action( 'init', function () { remove_action( 'rest_api_init', 'wp_oembed_register_route' ); add_filter( 'embed_oembed_discover', '__return_false' ); remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); remove_action( 'wp_head', 'wp_oembed_add_host_js' ); add_filter( 'tiny_mce_plugins', function ( $plugins ) { return array_diff( $plugins, array( 'wpembed' ) ); } ); }, 9999 ); add_action( 'wp_footer', function () { wp_dequeue_script( 'wp-embed' ); } ); }, );