wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_oembed_add_discovery_links › WordPress Function

Since4.4.0
Deprecatedn/a
wp_oembed_add_discovery_links ( No parameters )
Defined at:
Codex:
Change Log:
  • 6.8.0
  • 6.9.0

Adds oEmbed discovery links in the head element of the website.



Source

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 );
}