# wp_oembed_add_discovery_links()

URL: https://chugunov.pro/api-wordpress/functions/wp_oembed_add_discovery_links/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 4.4.0.

## Сигнатура

```php
wp_oembed_add_discovery_links()
```

## Описание

Добавляет ссылки обнаружения oEmbed в элемент head сайта.

## Исходный код

Файл: `wp-includes/embed.php:337`

```php
function wp_oembed_add_discovery_links() {
	if ( doing_action( 'wp_head' ) ) {
		// For back-compat, short-circuit if a plugin has removed the action at the original priority.
		if ( ! has_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 ) ) {
			return;
		}

		// Prevent running again at the original priority.
		remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
	}

	$output = '';

	if ( is_singular() && is_post_embeddable() ) {
		$output .= '<link rel="alternate" title="' . _x( 'oEmbed (JSON)', 'oEmbed resource link name' ) . '" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";

		if ( class_exists( 'SimpleXMLElement' ) ) {
			$output .= '<link rel="alternate" title="' . _x( 'oEmbed (XML)', 'oEmbed resource link name' ) . '" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
		}
	}

	/**
	 * Filters the oEmbed discovery links HTML.
	 *
	 * @since 4.4.0
	 *
	 * @param string $output HTML of the discovery links.
	 */
	echo apply_filters( 'oembed_discovery_links', $output );
}
```

## История изменений

- 6.9.0 — Now runs first at wp_head priority 4, with a fallback to priority 10. This helps ensure the discovery links appear within the first 150KB.
- 6.8.0 — Output was adjusted to only embed if the post supports it.
- 4.4.0 — Introduced.

## Связанные

Использует: [`is_post_embeddable`](https://chugunov.pro/api-wordpress/functions/is_post_embeddable/), [`get_oembed_endpoint_url`](https://chugunov.pro/api-wordpress/functions/get_oembed_endpoint_url/), [`is_singular`](https://chugunov.pro/api-wordpress/functions/is_singular/), [`has_action`](https://chugunov.pro/api-wordpress/functions/has_action/), [`remove_action`](https://chugunov.pro/api-wordpress/functions/remove_action/), [`doing_action`](https://chugunov.pro/api-wordpress/functions/doing_action/), [`_x`](https://chugunov.pro/api-wordpress/functions/_x/), [`esc_url`](https://chugunov.pro/api-wordpress/functions/esc_url/), [`get_permalink`](https://chugunov.pro/api-wordpress/functions/get_permalink/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_oembed_add_discovery_links/
