# get_oembed_response_data_for_url()

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

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

## Сигнатура

```php
get_oembed_response_data_for_url( string $url, array $args ): object|false
```

## Описание

Получает данные ответа oEmbed для указанного URL.

## Параметры

- `$url` `string` — обязательный. URL, который следует проверить на наличие тегов
  - для обнаружения.
- `$args` `array` — обязательный. Аргументы удалённого запроса oEmbed.

## Возвращаемое значение

`object|false`

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

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

```php
function get_oembed_response_data_for_url( $url, $args ) {
	$switched_blog = false;

	if ( is_multisite() ) {
		$url_parts = wp_parse_args(
			wp_parse_url( $url ),
			array(
				'host' => '',
				'port' => null,
				'path' => '/',
			)
		);

		$qv = array(
			'domain'                 => $url_parts['host'] . ( $url_parts['port'] ? ':' . $url_parts['port'] : '' ),
			'path'                   => '/',
			'update_site_meta_cache' => false,
		);

		// In case of subdirectory configs, set the path.
		if ( ! is_subdomain_install() ) {
			$path = explode( '/', ltrim( $url_parts['path'], '/' ) );
			$path = reset( $path );

			if ( $path ) {
				$qv['path'] = get_network()->path . $path . '/';
			}
		}

		$sites = get_sites( $qv );
		$site  = reset( $sites );

		// Do not allow embeds for deleted/archived/spam sites.
		if ( ! empty( $site->deleted ) || ! empty( $site->spam ) || ! empty( $site->archived ) ) {
			return false;
		}

		if ( $site && get_current_blog_id() !== (int) $site->blog_id ) {
			switch_to_blog( $site->blog_id );
			$switched_blog = true;
		}
	}

	$post_id = url_to_postid( $url );

	/** This filter is documented in wp-includes/class-wp-oembed-controller.php */
	$post_id = apply_filters( 'oembed_request_post_id', $post_id, $url );

	if ( ! $post_id ) {
		if ( $switched_blog ) {
			restore_current_blog();
		}

		return false;
	}

	$width = $args['width'] ?? 0;

	$data = get_oembed_response_data( $post_id, $width );

	if ( $switched_blog ) {
		restore_current_blog();
	}

	return $data ? (object) $data : false;
}
```

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

- 5.0.0 — Introduced.

## Связанные

Использует: [`get_network`](https://chugunov.pro/api-wordpress/functions/get_network/), [`get_sites`](https://chugunov.pro/api-wordpress/functions/get_sites/), [`get_oembed_response_data`](https://chugunov.pro/api-wordpress/functions/get_oembed_response_data/), [`wp_parse_url`](https://chugunov.pro/api-wordpress/functions/wp_parse_url/), [`url_to_postid`](https://chugunov.pro/api-wordpress/functions/url_to_postid/), [`is_subdomain_install`](https://chugunov.pro/api-wordpress/functions/is_subdomain_install/), [`switch_to_blog`](https://chugunov.pro/api-wordpress/functions/switch_to_blog/), [`restore_current_blog`](https://chugunov.pro/api-wordpress/functions/restore_current_blog/), [`is_multisite`](https://chugunov.pro/api-wordpress/functions/is_multisite/), [`get_current_blog_id`](https://chugunov.pro/api-wordpress/functions/get_current_blog_id/), [`wp_parse_args`](https://chugunov.pro/api-wordpress/functions/wp_parse_args/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: `WP_oEmbed_Controller::get_proxy_item`, [`wp_filter_pre_oembed_result`](https://chugunov.pro/api-wordpress/functions/wp_filter_pre_oembed_result/).

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