Skip to content

Commit 685dbde

Browse files
committed
Print wp_oembed_add_discovery_links() at wp_head priority 4 if still hooked at priority 10
1 parent 2bf4822 commit 685dbde

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/wp-includes/default-filters.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@
704704
add_action( 'rest_api_init', 'wp_oembed_register_route' );
705705
add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 );
706706

707-
add_action( 'wp_head', 'wp_oembed_add_discovery_links' );
707+
add_action( 'wp_head', 'wp_oembed_add_discovery_links', 4 ); // Printed after feed_links() and feed_links_extra().
708+
add_action( 'wp_head', 'wp_oembed_add_discovery_links' ); // Unhooked the first time that wp_oembed_add_discovery_links() runs for back-compat.
708709
add_action( 'wp_head', 'wp_oembed_add_host_js' ); // Back-compat for sites disabling oEmbed host JS by removing action.
709710
add_filter( 'embed_oembed_html', 'wp_maybe_enqueue_oembed_host_js' );
710711

src/wp-includes/embed.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,17 @@ function wp_oembed_register_route() {
332332
*
333333
* @since 4.4.0
334334
* @since 6.8.0 Output was adjusted to only embed if the post supports it.
335+
* @since 6.9.0 Now runs first at `wp_head` priority 4, with a fallback to priority 10.
335336
*/
336337
function wp_oembed_add_discovery_links() {
338+
// For back-compat, short-circuit if a plugin has removed the action at the original priority.
339+
if ( ! has_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 ) ) {
340+
return;
341+
}
342+
343+
// Prevent running again at the original priority.
344+
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
345+
337346
$output = '';
338347

339348
if ( is_singular() && is_post_embeddable() ) {

0 commit comments

Comments
 (0)