get_oembed_endpoint_url() WordPress Function

The get_oembed_endpoint_url function is used to get the URL for the oEmbed endpoint.

get_oembed_endpoint_url( string $permalink = '', string $format = 'json' ) #

Retrieves the oEmbed endpoint URL for a given permalink.


Description

Pass an empty string as the first argument to get the endpoint base URL.


Top ↑

Parameters

$permalink

(string)(Optional) The permalink used for the url query arg.

Default value: ''

$format

(string)(Optional) The requested response format.

Default value: 'json'


Top ↑

Return

(string) The oEmbed endpoint URL.


Top ↑

Source

File: wp-includes/embed.php

function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) {
	$url = rest_url( 'oembed/1.0/embed' );

	if ( '' !== $permalink ) {
		$url = add_query_arg(
			array(
				'url'    => urlencode( $permalink ),
				'format' => ( 'json' !== $format ) ? $format : false,
			),
			$url
		);
	}

	/**
	 * Filters the oEmbed endpoint URL.
	 *
	 * @since 4.4.0
	 *
	 * @param string $url       The URL to the oEmbed endpoint.
	 * @param string $permalink The permalink used for the `url` query arg.
	 * @param string $format    The requested response format.
	 */
	return apply_filters( 'oembed_endpoint_url', $url, $permalink, $format );
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.