2015-10-06 05:59:24 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2015-10-09 00:38:25 +02:00
|
|
|
* oEmbed API: Top-level oEmbed functionality
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage oEmbed
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers an embed handler.
|
|
|
|
*
|
|
|
|
* Should probably only be used for sites that do not support oEmbed.
|
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
2024-03-06 06:05:12 +01:00
|
|
|
* @global WP_Embed $wp_embed WordPress Embed object.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @param string $id An internal ID/name for the handler. Needs to be unique.
|
|
|
|
* @param string $regex The regex that will be used to see if this handler should be used for a URL.
|
|
|
|
* @param callable $callback The callback function that will be called if the regex is matched.
|
|
|
|
* @param int $priority Optional. Used to specify the order in which the registered handlers will
|
|
|
|
* be tested. Default 10.
|
|
|
|
*/
|
|
|
|
function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) {
|
|
|
|
global $wp_embed;
|
|
|
|
$wp_embed->register_handler( $id, $regex, $callback, $priority );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregisters a previously-registered embed handler.
|
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
2024-03-06 06:05:12 +01:00
|
|
|
* @global WP_Embed $wp_embed WordPress Embed object.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @param string $id The handler ID that should be removed.
|
|
|
|
* @param int $priority Optional. The priority of the handler to be removed. Default 10.
|
|
|
|
*/
|
|
|
|
function wp_embed_unregister_handler( $id, $priority = 10 ) {
|
|
|
|
global $wp_embed;
|
|
|
|
$wp_embed->unregister_handler( $id, $priority );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-01 16:42:25 +01:00
|
|
|
* Creates default array of embed parameters.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* The width defaults to the content width as specified by the theme. If the
|
|
|
|
* theme does not specify a content width, then 500px is used.
|
|
|
|
*
|
|
|
|
* The default height is 1.5 times the width, or 1000px, whichever is smaller.
|
|
|
|
*
|
2016-05-23 21:01:27 +02:00
|
|
|
* The {@see 'embed_defaults'} filter can be used to adjust either of these values.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
|
|
|
* @global int $content_width
|
|
|
|
*
|
|
|
|
* @param string $url Optional. The URL that should be embedded. Default empty.
|
2021-12-07 13:20:02 +01:00
|
|
|
* @return int[] {
|
2019-11-05 22:23:02 +01:00
|
|
|
* Indexed array of the embed width and height in pixels.
|
|
|
|
*
|
|
|
|
* @type int $0 The embed width.
|
|
|
|
* @type int $1 The embed height.
|
|
|
|
* }
|
2015-10-06 05:59:24 +02:00
|
|
|
*/
|
|
|
|
function wp_embed_defaults( $url = '' ) {
|
2018-12-14 04:25:40 +01:00
|
|
|
if ( ! empty( $GLOBALS['content_width'] ) ) {
|
2015-10-06 05:59:24 +02:00
|
|
|
$width = (int) $GLOBALS['content_width'];
|
2018-12-14 04:25:40 +01:00
|
|
|
}
|
2015-10-06 05:59:24 +02:00
|
|
|
|
2018-12-14 04:25:40 +01:00
|
|
|
if ( empty( $width ) ) {
|
2015-10-06 05:59:24 +02:00
|
|
|
$width = 500;
|
2018-12-14 04:25:40 +01:00
|
|
|
}
|
2015-10-06 05:59:24 +02:00
|
|
|
|
2024-02-17 16:24:08 +01:00
|
|
|
$height = min( (int) ceil( $width * 1.5 ), 1000 );
|
2015-10-06 05:59:24 +02:00
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the default array of embed dimensions.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
2020-11-25 13:14:05 +01:00
|
|
|
* @param int[] $size {
|
2019-11-03 23:23:01 +01:00
|
|
|
* Indexed array of the embed width and height in pixels.
|
|
|
|
*
|
|
|
|
* @type int $0 The embed width.
|
2019-11-04 10:37:02 +01:00
|
|
|
* @type int $1 The embed height.
|
2019-11-03 23:23:01 +01:00
|
|
|
* }
|
2015-11-01 16:42:25 +01:00
|
|
|
* @param string $url The URL that should be embedded.
|
2015-10-06 05:59:24 +02:00
|
|
|
*/
|
|
|
|
return apply_filters( 'embed_defaults', compact( 'width', 'height' ), $url );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to fetch the embed HTML for a provided URL using oEmbed.
|
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
|
|
|
* @see WP_oEmbed
|
|
|
|
*
|
|
|
|
* @param string $url The URL that should be embedded.
|
2021-01-05 18:16:11 +01:00
|
|
|
* @param array|string $args {
|
2020-11-17 11:11:11 +01:00
|
|
|
* Optional. Additional arguments for retrieving embed HTML. Default empty.
|
|
|
|
*
|
|
|
|
* @type int|string $width Optional. The `maxwidth` value passed to the provider URL.
|
|
|
|
* @type int|string $height Optional. The `maxheight` value passed to the provider URL.
|
|
|
|
* @type bool $discover Optional. Determines whether to attempt to discover link tags
|
|
|
|
* at the given URL for an oEmbed provider when the provider URL
|
|
|
|
* is not found in the built-in providers list. Default true.
|
|
|
|
* }
|
2020-01-11 19:32:05 +01:00
|
|
|
* @return string|false The embed HTML on success, false on failure.
|
2015-10-06 05:59:24 +02:00
|
|
|
*/
|
|
|
|
function wp_oembed_get( $url, $args = '' ) {
|
|
|
|
$oembed = _wp_oembed_get_object();
|
|
|
|
return $oembed->get_html( $url, $args );
|
|
|
|
}
|
|
|
|
|
2016-08-26 11:49:28 +02:00
|
|
|
/**
|
|
|
|
* Returns the initialized WP_oEmbed object.
|
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
* @access private
|
|
|
|
*
|
|
|
|
* @return WP_oEmbed object.
|
|
|
|
*/
|
|
|
|
function _wp_oembed_get_object() {
|
|
|
|
static $wp_oembed = null;
|
|
|
|
|
|
|
|
if ( is_null( $wp_oembed ) ) {
|
|
|
|
$wp_oembed = new WP_oEmbed();
|
|
|
|
}
|
|
|
|
return $wp_oembed;
|
|
|
|
}
|
|
|
|
|
2015-10-06 05:59:24 +02:00
|
|
|
/**
|
|
|
|
* Adds a URL format and oEmbed provider URL pair.
|
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
|
|
|
* @see WP_oEmbed
|
|
|
|
*
|
2020-07-23 02:52:05 +02:00
|
|
|
* @param string $format The format of URL that this provider can handle. You can use asterisks
|
|
|
|
* as wildcards.
|
|
|
|
* @param string $provider The URL to the oEmbed provider.
|
|
|
|
* @param bool $regex Optional. Whether the `$format` parameter is in a RegEx format. Default false.
|
2015-10-06 05:59:24 +02:00
|
|
|
*/
|
|
|
|
function wp_oembed_add_provider( $format, $provider, $regex = false ) {
|
|
|
|
if ( did_action( 'plugins_loaded' ) ) {
|
2018-12-14 04:25:40 +01:00
|
|
|
$oembed = _wp_oembed_get_object();
|
|
|
|
$oembed->providers[ $format ] = array( $provider, $regex );
|
2015-10-06 05:59:24 +02:00
|
|
|
} else {
|
|
|
|
WP_oEmbed::_add_provider_early( $format, $provider, $regex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes an oEmbed provider.
|
|
|
|
*
|
|
|
|
* @since 3.5.0
|
|
|
|
*
|
|
|
|
* @see WP_oEmbed
|
|
|
|
*
|
|
|
|
* @param string $format The URL format for the oEmbed provider to remove.
|
|
|
|
* @return bool Was the provider removed successfully?
|
|
|
|
*/
|
|
|
|
function wp_oembed_remove_provider( $format ) {
|
|
|
|
if ( did_action( 'plugins_loaded' ) ) {
|
|
|
|
$oembed = _wp_oembed_get_object();
|
|
|
|
|
|
|
|
if ( isset( $oembed->providers[ $format ] ) ) {
|
|
|
|
unset( $oembed->providers[ $format ] );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
WP_oEmbed::_remove_provider_early( $format );
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if default embed handlers should be loaded.
|
|
|
|
*
|
|
|
|
* Checks to make sure that the embeds library hasn't already been loaded. If
|
|
|
|
* it hasn't, then it will load the embeds library.
|
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
|
|
|
* @see wp_embed_register_handler()
|
|
|
|
*/
|
|
|
|
function wp_maybe_load_embeds() {
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters whether to load the default embed handlers.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* Returning a falsey value will prevent loading the default embed handlers.
|
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
|
|
|
* @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
|
|
|
|
*/
|
|
|
|
if ( ! apply_filters( 'load_default_embeds', true ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' );
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the audio embed handler callback.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @param callable $handler Audio embed handler callback function.
|
|
|
|
*/
|
2020-10-18 19:27:06 +02:00
|
|
|
wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . implode( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 );
|
2015-10-06 05:59:24 +02:00
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the video embed handler callback.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @param callable $handler Video embed handler callback function.
|
|
|
|
*/
|
2020-10-18 19:27:06 +02:00
|
|
|
wp_embed_register_handler( 'video', '#^https?://.+?\.(' . implode( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 );
|
2015-10-06 05:59:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* YouTube iframe embed handler callback.
|
|
|
|
*
|
|
|
|
* Catches YouTube iframe embed URLs that are not parsable by oEmbed but can be translated into a URL that is.
|
|
|
|
*
|
|
|
|
* @since 4.0.0
|
|
|
|
*
|
2024-03-06 06:05:12 +01:00
|
|
|
* @global WP_Embed $wp_embed WordPress Embed object.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @param array $matches The RegEx matches from the provided regex when calling
|
|
|
|
* wp_embed_register_handler().
|
|
|
|
* @param array $attr Embed attributes.
|
|
|
|
* @param string $url The original URL that was matched by the regex.
|
|
|
|
* @param array $rawattr The original unmodified attributes.
|
|
|
|
* @return string The embed HTML.
|
|
|
|
*/
|
|
|
|
function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
|
|
|
|
global $wp_embed;
|
2018-12-14 04:25:40 +01:00
|
|
|
$embed = $wp_embed->autoembed( sprintf( 'https://youtube.com/watch?v=%s', urlencode( $matches[2] ) ) );
|
2015-10-06 05:59:24 +02:00
|
|
|
|
|
|
|
/**
|
2024-04-12 19:47:13 +02:00
|
|
|
* Filters the YouTube embed output.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @since 4.0.0
|
|
|
|
*
|
|
|
|
* @see wp_embed_handler_youtube()
|
|
|
|
*
|
|
|
|
* @param string $embed YouTube embed output.
|
|
|
|
* @param array $attr An array of embed attributes.
|
|
|
|
* @param string $url The original URL that was matched by the regex.
|
|
|
|
* @param array $rawattr The original unmodified attributes.
|
|
|
|
*/
|
|
|
|
return apply_filters( 'wp_embed_handler_youtube', $embed, $attr, $url, $rawattr );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Audio embed handler callback.
|
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @param array $matches The RegEx matches from the provided regex when calling wp_embed_register_handler().
|
|
|
|
* @param array $attr Embed attributes.
|
|
|
|
* @param string $url The original URL that was matched by the regex.
|
|
|
|
* @param array $rawattr The original unmodified attributes.
|
|
|
|
* @return string The embed HTML.
|
|
|
|
*/
|
|
|
|
function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) {
|
|
|
|
$audio = sprintf( '[audio src="%s" /]', esc_url( $url ) );
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the audio embed output.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @param string $audio Audio embed output.
|
|
|
|
* @param array $attr An array of embed attributes.
|
|
|
|
* @param string $url The original URL that was matched by the regex.
|
|
|
|
* @param array $rawattr The original unmodified attributes.
|
|
|
|
*/
|
|
|
|
return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Video embed handler callback.
|
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @param array $matches The RegEx matches from the provided regex when calling wp_embed_register_handler().
|
|
|
|
* @param array $attr Embed attributes.
|
|
|
|
* @param string $url The original URL that was matched by the regex.
|
|
|
|
* @param array $rawattr The original unmodified attributes.
|
|
|
|
* @return string The embed HTML.
|
|
|
|
*/
|
|
|
|
function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) {
|
|
|
|
$dimensions = '';
|
|
|
|
if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) {
|
|
|
|
$dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] );
|
|
|
|
$dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] );
|
|
|
|
}
|
|
|
|
$video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) );
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the video embed output.
|
2015-10-06 05:59:24 +02:00
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @param string $video Video embed output.
|
|
|
|
* @param array $attr An array of embed attributes.
|
|
|
|
* @param string $url The original URL that was matched by the regex.
|
|
|
|
* @param array $rawattr The original unmodified attributes.
|
|
|
|
*/
|
|
|
|
return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr );
|
|
|
|
}
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
|
|
|
|
/**
|
2015-10-29 23:51:24 +01:00
|
|
|
* Registers the oEmbed REST API route.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
2015-10-29 23:51:24 +01:00
|
|
|
function wp_oembed_register_route() {
|
2015-10-09 00:40:24 +02:00
|
|
|
$controller = new WP_oEmbed_Controller();
|
2015-10-29 23:51:24 +01:00
|
|
|
$controller->register_routes();
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-04-02 15:55:11 +02:00
|
|
|
* Adds oEmbed discovery links in the head element of the website.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function wp_oembed_add_discovery_links() {
|
|
|
|
$output = '';
|
|
|
|
|
2016-01-15 08:56:26 +01:00
|
|
|
if ( is_singular() ) {
|
2024-06-03 00:02:16 +02:00
|
|
|
$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";
|
2015-10-22 18:38:26 +02:00
|
|
|
|
|
|
|
if ( class_exists( 'SimpleXMLElement' ) ) {
|
2024-06-03 00:02:16 +02:00
|
|
|
$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";
|
2015-10-22 18:38:26 +02:00
|
|
|
}
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the oEmbed discovery links HTML.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param string $output HTML of the discovery links.
|
|
|
|
*/
|
|
|
|
echo apply_filters( 'oembed_discovery_links', $output );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 00:50:25 +02:00
|
|
|
* Adds the necessary JavaScript to communicate with the embedded iframes.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
2022-01-04 16:23:59 +01:00
|
|
|
* This function is no longer used directly. For back-compat it exists exclusively as a way to indicate that the oEmbed
|
|
|
|
* host JS _should_ be added. In `default-filters.php` there remains this code:
|
|
|
|
*
|
|
|
|
* add_action( 'wp_head', 'wp_oembed_add_host_js' )
|
|
|
|
*
|
|
|
|
* Historically a site has been able to disable adding the oEmbed host script by doing:
|
|
|
|
*
|
|
|
|
* remove_action( 'wp_head', 'wp_oembed_add_host_js' )
|
|
|
|
*
|
|
|
|
* In order to ensure that such code still works as expected, this function remains. There is now a `has_action()` check
|
|
|
|
* in `wp_maybe_enqueue_oembed_host_js()` to see if `wp_oembed_add_host_js()` has not been unhooked from running at the
|
|
|
|
* `wp_head` action.
|
|
|
|
*
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
* @since 4.4.0
|
2022-01-04 16:23:59 +01:00
|
|
|
* @deprecated 5.9.0 Use {@see wp_maybe_enqueue_oembed_host_js()} instead.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*/
|
2022-01-04 16:23:59 +01:00
|
|
|
function wp_oembed_add_host_js() {}
|
2021-11-11 03:49:18 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enqueue the wp-embed script if the provided oEmbed HTML contains a post embed.
|
|
|
|
*
|
|
|
|
* In order to only enqueue the wp-embed script on pages that actually contain post embeds, this function checks if the
|
|
|
|
* provided HTML contains post embed markup and if so enqueues the script so that it will get printed in the footer.
|
|
|
|
*
|
|
|
|
* @since 5.9.0
|
|
|
|
*
|
|
|
|
* @param string $html Embed markup.
|
|
|
|
* @return string Embed markup (without modifications).
|
|
|
|
*/
|
|
|
|
function wp_maybe_enqueue_oembed_host_js( $html ) {
|
2022-01-04 16:23:59 +01:00
|
|
|
if (
|
|
|
|
has_action( 'wp_head', 'wp_oembed_add_host_js' )
|
|
|
|
&&
|
|
|
|
preg_match( '/<blockquote\s[^>]*?wp-embedded-content/', $html )
|
|
|
|
) {
|
2021-11-11 03:49:18 +01:00
|
|
|
wp_enqueue_script( 'wp-embed' );
|
|
|
|
}
|
|
|
|
return $html;
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 00:50:25 +02:00
|
|
|
* Retrieves the URL to embed a specific post in an iframe.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post.
|
|
|
|
* @return string|false The post embed URL on success, false if the post doesn't exist.
|
|
|
|
*/
|
|
|
|
function get_post_embed_url( $post = null ) {
|
|
|
|
$post = get_post( $post );
|
|
|
|
|
|
|
|
if ( ! $post ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-15 08:56:26 +01:00
|
|
|
$embed_url = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' );
|
|
|
|
$path_conflict = get_page_by_path( str_replace( home_url(), '', $embed_url ), OBJECT, get_post_types( array( 'public' => true ) ) );
|
|
|
|
|
|
|
|
if ( ! get_option( 'permalink_structure' ) || $path_conflict ) {
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
$embed_url = add_query_arg( array( 'embed' => 'true' ), get_permalink( $post ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the URL to embed a specific post.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param string $embed_url The post embed URL.
|
|
|
|
* @param WP_Post $post The corresponding post object.
|
|
|
|
*/
|
2022-06-01 20:14:10 +02:00
|
|
|
return sanitize_url( apply_filters( 'post_embed_url', $embed_url, $post ) );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 00:50:25 +02:00
|
|
|
* Retrieves the oEmbed endpoint URL for a given permalink.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
2015-10-09 00:50:25 +02:00
|
|
|
* Pass an empty string as the first argument to get the endpoint base URL.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param string $permalink Optional. The permalink used for the `url` query arg. Default empty.
|
|
|
|
* @param string $format Optional. The requested response format. Default 'json'.
|
|
|
|
* @return string The oEmbed endpoint URL.
|
|
|
|
*/
|
|
|
|
function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) {
|
2015-10-29 23:51:24 +01:00
|
|
|
$url = rest_url( 'oembed/1.0/embed' );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
|
|
|
|
if ( '' !== $permalink ) {
|
2018-12-14 04:25:40 +01:00
|
|
|
$url = add_query_arg(
|
|
|
|
array(
|
|
|
|
'url' => urlencode( $permalink ),
|
|
|
|
'format' => ( 'json' !== $format ) ? $format : false,
|
|
|
|
),
|
|
|
|
$url
|
|
|
|
);
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the oEmbed endpoint URL.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 00:50:25 +02:00
|
|
|
* Retrieves the embed code for a specific post.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param int $width The width for the response.
|
|
|
|
* @param int $height The height for the response.
|
2015-10-31 16:51:25 +01:00
|
|
|
* @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
* @return string|false Embed code on success, false if post doesn't exist.
|
|
|
|
*/
|
2015-10-31 16:51:25 +01:00
|
|
|
function get_post_embed_html( $width, $height, $post = null ) {
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
$post = get_post( $post );
|
|
|
|
|
|
|
|
if ( ! $post ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$embed_url = get_post_embed_url( $post );
|
|
|
|
|
2021-11-11 03:49:18 +01:00
|
|
|
$secret = wp_generate_password( 10, false );
|
|
|
|
$embed_url .= "#?secret={$secret}";
|
2015-10-30 00:11:24 +01:00
|
|
|
|
2021-11-13 08:28:00 +01:00
|
|
|
$output = sprintf(
|
2021-11-11 03:49:18 +01:00
|
|
|
'<blockquote class="wp-embedded-content" data-secret="%1$s"><a href="%2$s">%3$s</a></blockquote>',
|
|
|
|
esc_attr( $secret ),
|
|
|
|
esc_url( get_permalink( $post ) ),
|
|
|
|
get_the_title( $post )
|
|
|
|
);
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
|
|
|
|
$output .= sprintf(
|
2021-11-11 03:49:18 +01:00
|
|
|
'<iframe sandbox="allow-scripts" security="restricted" src="%1$s" width="%2$d" height="%3$d" title="%4$s" data-secret="%5$s" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>',
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
esc_url( $embed_url ),
|
|
|
|
absint( $width ),
|
|
|
|
absint( $height ),
|
2016-03-07 11:00:29 +01:00
|
|
|
esc_attr(
|
|
|
|
sprintf(
|
2019-09-03 02:41:05 +02:00
|
|
|
/* translators: 1: Post title, 2: Site title. */
|
2016-03-07 11:00:29 +01:00
|
|
|
__( '“%1$s” — %2$s' ),
|
|
|
|
get_the_title( $post ),
|
|
|
|
get_bloginfo( 'name' )
|
|
|
|
)
|
2021-11-11 03:49:18 +01:00
|
|
|
),
|
|
|
|
esc_attr( $secret )
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
);
|
|
|
|
|
2023-07-09 23:48:22 +02:00
|
|
|
/*
|
|
|
|
* Note that the script must be placed after the <blockquote> and <iframe> due to a regexp parsing issue in
|
|
|
|
* `wp_filter_oembed_result()`. Because of the regex pattern starts with `|(<blockquote>.*?</blockquote>)?.*|`
|
|
|
|
* wherein the <blockquote> is marked as being optional, if it is not at the beginning of the string then the group
|
|
|
|
* will fail to match and everything will be matched by `.*` and not included in the group. This regex issue goes
|
|
|
|
* back to WordPress 4.4, so in order to not break older installs this script must come at the end.
|
|
|
|
*/
|
2021-11-13 08:28:00 +01:00
|
|
|
$output .= wp_get_inline_script_tag(
|
|
|
|
file_get_contents( ABSPATH . WPINC . '/js/wp-embed' . wp_scripts_get_suffix() . '.js' )
|
|
|
|
);
|
|
|
|
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the embed HTML output for a given post.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2017-06-25 23:46:39 +02:00
|
|
|
* @param string $output The default iframe tag to display embedded content.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
* @param WP_Post $post Current post object.
|
|
|
|
* @param int $width Width of the response.
|
|
|
|
* @param int $height Height of the response.
|
|
|
|
*/
|
2015-10-17 03:21:25 +02:00
|
|
|
return apply_filters( 'embed_html', $output, $post, $width, $height );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 00:50:25 +02:00
|
|
|
* Retrieves the oEmbed response data for a given post.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
Posts, Post Types: Standardize on `$post` parameter name where appropriate.
This renames the `$post_id` or `$id` parameters to `$post` for functions that accept a post ID or post object:
* `get_sample_permalink()`
* `get_sample_permalink_html()`
* `wp_check_post_lock()`
* `wp_set_post_lock()`
* `get_the_tags()`
* `comment_class()`
* `get_comment_class()`
* `get_comments_link()`
* `get_comments_number()`
* `comments_number()`
* `get_comments_number_text()`
* `comments_open()`
* `pings_open()`
* `comment_form()`
* `do_trackbacks()`
* `pingback()`
* `post_permalink()`
* `get_post_permalink()`
* `get_edit_post_link()`
* `edit_post_link()`
* `get_delete_post_link()`
* `post_class()`
* `get_post_class()`
* `the_attachment_link()`
* `wp_get_attachment_link()`
* `wp_list_post_revisions()`
* `check_and_publish_future_post()`
* `add_ping()`
* `get_pung()`
* `get_to_ping()`
* `wp_get_post_revisions()`
* `wp_get_post_revisions_url()`
Additionally, `$revision_id` is renamed to `$revision` in:
* `wp_restore_post_revision()`
* `wp_delete_post_revision()`
Includes minor documentation improvements for consistency and code layout fixes for better readability.
Follow-up to [1599], [1794], [2881], [3303], [3851], [5302], [6633], [6716], [6985], [7103], [7149], [7747], [8011], [8638], [8643], [8695], [9138], [9273], [11425], [11922], [11956], [12284], [12810], [12923], [13023], [13171], [25567], [27156], [27473], [28558], [28602], [33659], [38852], [47276], [47366], [48622], [49544], [49597], [52095].
See #56243, #55647.
Built from https://develop.svn.wordpress.org/trunk@53715
git-svn-id: http://core.svn.wordpress.org/trunk@53274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-18 19:37:17 +02:00
|
|
|
* @param WP_Post|int $post Post ID or post object.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
* @param int $width The requested width.
|
2021-02-22 14:23:04 +01:00
|
|
|
* @return array|false Response data on success, false if post doesn't exist
|
|
|
|
* or is not publicly viewable.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*/
|
2015-10-31 16:42:25 +01:00
|
|
|
function get_oembed_response_data( $post, $width ) {
|
2016-05-24 08:15:28 +02:00
|
|
|
$post = get_post( $post );
|
|
|
|
$width = absint( $width );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
|
|
|
|
if ( ! $post ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-02-22 14:23:04 +01:00
|
|
|
if ( ! is_post_publicly_viewable( $post ) ) {
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the allowed minimum and maximum widths for the oEmbed response.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
2015-10-09 00:55:25 +02:00
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2015-10-09 01:09:23 +02:00
|
|
|
* @param array $min_max_width {
|
|
|
|
* Minimum and maximum widths for the oEmbed response.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
2015-10-09 01:09:23 +02:00
|
|
|
* @type int $min Minimum width. Default 200.
|
|
|
|
* @type int $max Maximum width. Default 600.
|
|
|
|
* }
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*/
|
2018-12-14 04:25:40 +01:00
|
|
|
$min_max_width = apply_filters(
|
|
|
|
'oembed_min_max_width',
|
|
|
|
array(
|
|
|
|
'min' => 200,
|
|
|
|
'max' => 600,
|
|
|
|
)
|
|
|
|
);
|
2015-10-09 01:09:23 +02:00
|
|
|
|
2015-10-29 23:51:24 +01:00
|
|
|
$width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] );
|
2024-02-17 16:24:08 +01:00
|
|
|
$height = max( (int) ceil( $width / 16 * 9 ), 200 );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
|
|
|
|
$data = array(
|
|
|
|
'version' => '1.0',
|
|
|
|
'provider_name' => get_bloginfo( 'name' ),
|
|
|
|
'provider_url' => get_home_url(),
|
|
|
|
'author_name' => get_bloginfo( 'name' ),
|
|
|
|
'author_url' => get_home_url(),
|
2019-03-15 17:42:54 +01:00
|
|
|
'title' => get_the_title( $post ),
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
'type' => 'link',
|
|
|
|
);
|
|
|
|
|
|
|
|
$author = get_userdata( $post->post_author );
|
|
|
|
|
|
|
|
if ( $author ) {
|
|
|
|
$data['author_name'] = $author->display_name;
|
|
|
|
$data['author_url'] = get_author_posts_url( $author->ID );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the oEmbed response data.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param array $data The response data.
|
|
|
|
* @param WP_Post $post The post object.
|
|
|
|
* @param int $width The requested width.
|
|
|
|
* @param int $height The calculated height.
|
|
|
|
*/
|
|
|
|
return apply_filters( 'oembed_response_data', $data, $post, $width, $height );
|
|
|
|
}
|
|
|
|
|
2018-12-14 04:20:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the oEmbed response data for a given URL.
|
|
|
|
*
|
|
|
|
* @since 5.0.0
|
|
|
|
*
|
|
|
|
* @param string $url The URL that should be inspected for discovery `<link>` tags.
|
|
|
|
* @param array $args oEmbed remote get arguments.
|
|
|
|
* @return object|false oEmbed response data if the URL does belong to the current site. False otherwise.
|
|
|
|
*/
|
|
|
|
function get_oembed_response_data_for_url( $url, $args ) {
|
|
|
|
$switched_blog = false;
|
|
|
|
|
|
|
|
if ( is_multisite() ) {
|
2018-12-14 04:25:40 +01:00
|
|
|
$url_parts = wp_parse_args(
|
|
|
|
wp_parse_url( $url ),
|
|
|
|
array(
|
|
|
|
'host' => '',
|
Bootstrap/Load: Add support for custom ports in multisite site addresses.
This allows a Multisite network to use an address that includes a port name, such as `example.com:1234`, and adds support for this to the local development environment too. You can now run a Multisite installation on the local development environment, for example at `localhost:8889`.
This also fixes some bugs with running a single site installation on a port, and updates the testing infrastructure so that the whole test suite runs both with and without a port number.
Props djzone, scribu, nacin, ipstenu, F J Kaiser, jeremyfelt, johnjamesjacoby, spacedmonkey, PerS, Clorith, Blackbam, enrico.sorcinelli, Jules Colle, obliviousharmony, desrosj, johnbillion
Fixes #21077, #52088
Built from https://develop.svn.wordpress.org/trunk@58097
git-svn-id: http://core.svn.wordpress.org/trunk@57562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-04 21:25:10 +02:00
|
|
|
'port' => null,
|
2018-12-14 04:25:40 +01:00
|
|
|
'path' => '/',
|
|
|
|
)
|
|
|
|
);
|
2018-12-14 04:20:37 +01:00
|
|
|
|
2018-12-14 04:25:40 +01:00
|
|
|
$qv = array(
|
Bootstrap/Load: Add support for custom ports in multisite site addresses.
This allows a Multisite network to use an address that includes a port name, such as `example.com:1234`, and adds support for this to the local development environment too. You can now run a Multisite installation on the local development environment, for example at `localhost:8889`.
This also fixes some bugs with running a single site installation on a port, and updates the testing infrastructure so that the whole test suite runs both with and without a port number.
Props djzone, scribu, nacin, ipstenu, F J Kaiser, jeremyfelt, johnjamesjacoby, spacedmonkey, PerS, Clorith, Blackbam, enrico.sorcinelli, Jules Colle, obliviousharmony, desrosj, johnbillion
Fixes #21077, #52088
Built from https://develop.svn.wordpress.org/trunk@58097
git-svn-id: http://core.svn.wordpress.org/trunk@57562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-04 21:25:10 +02:00
|
|
|
'domain' => $url_parts['host'] . ( $url_parts['port'] ? ':' . $url_parts['port'] : '' ),
|
2019-03-18 16:56:51 +01:00
|
|
|
'path' => '/',
|
|
|
|
'update_site_meta_cache' => false,
|
2018-12-14 04:25:40 +01:00
|
|
|
);
|
2018-12-14 04:20:37 +01:00
|
|
|
|
|
|
|
// 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 );
|
|
|
|
|
2020-10-29 19:02:05 +01:00
|
|
|
// Do not allow embeds for deleted/archived/spam sites.
|
|
|
|
if ( ! empty( $site->deleted ) || ! empty( $site->spam ) || ! empty( $site->archived ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-02-09 17:55:09 +01:00
|
|
|
if ( $site && get_current_blog_id() !== (int) $site->blog_id ) {
|
2018-12-14 04:20:37 +01:00
|
|
|
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 = isset( $args['width'] ) ? $args['width'] : 0;
|
|
|
|
|
|
|
|
$data = get_oembed_response_data( $post_id, $width );
|
|
|
|
|
|
|
|
if ( $switched_blog ) {
|
|
|
|
restore_current_blog();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data ? (object) $data : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
/**
|
|
|
|
* Filters the oEmbed response data to return an iframe embed code.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param array $data The response data.
|
|
|
|
* @param WP_Post $post The post object.
|
|
|
|
* @param int $width The requested width.
|
|
|
|
* @param int $height The calculated height.
|
|
|
|
* @return array The modified response data.
|
|
|
|
*/
|
|
|
|
function get_oembed_response_data_rich( $data, $post, $width, $height ) {
|
|
|
|
$data['width'] = absint( $width );
|
|
|
|
$data['height'] = absint( $height );
|
|
|
|
$data['type'] = 'rich';
|
2015-10-31 16:51:25 +01:00
|
|
|
$data['html'] = get_post_embed_html( $width, $height, $post );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
|
|
|
|
// Add post thumbnail to response if available.
|
|
|
|
$thumbnail_id = false;
|
|
|
|
|
|
|
|
if ( has_post_thumbnail( $post->ID ) ) {
|
|
|
|
$thumbnail_id = get_post_thumbnail_id( $post->ID );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( 'attachment' === get_post_type( $post ) ) {
|
|
|
|
if ( wp_attachment_is_image( $post ) ) {
|
|
|
|
$thumbnail_id = $post->ID;
|
2018-12-14 04:25:40 +01:00
|
|
|
} elseif ( wp_attachment_is( 'video', $post ) ) {
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
$thumbnail_id = get_post_thumbnail_id( $post );
|
|
|
|
$data['type'] = 'video';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $thumbnail_id ) {
|
2024-12-05 22:21:17 +01:00
|
|
|
list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 0 ) );
|
2018-12-14 04:25:40 +01:00
|
|
|
$data['thumbnail_url'] = $thumbnail_url;
|
|
|
|
$data['thumbnail_width'] = $thumbnail_width;
|
|
|
|
$data['thumbnail_height'] = $thumbnail_height;
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures that the specified format is either 'json' or 'xml'.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2015-10-09 00:50:25 +02:00
|
|
|
* @param string $format The oEmbed response format. Accepts 'json' or 'xml'.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
* @return string The format, either 'xml' or 'json'. Default 'json'.
|
|
|
|
*/
|
|
|
|
function wp_oembed_ensure_format( $format ) {
|
|
|
|
if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) {
|
|
|
|
return 'json';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $format;
|
|
|
|
}
|
|
|
|
|
2015-10-29 23:51:24 +01:00
|
|
|
/**
|
|
|
|
* Hooks into the REST API output to print XML instead of JSON.
|
|
|
|
*
|
|
|
|
* This is only done for the oEmbed API endpoint,
|
|
|
|
* which supports both formats.
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2021-07-01 23:02:57 +02:00
|
|
|
* @param bool $served Whether the request has already been served.
|
|
|
|
* @param WP_HTTP_Response $result Result to send to the client. Usually a `WP_REST_Response`.
|
|
|
|
* @param WP_REST_Request $request Request used to generate the response.
|
|
|
|
* @param WP_REST_Server $server Server instance.
|
2015-10-29 23:51:24 +01:00
|
|
|
* @return true
|
|
|
|
*/
|
|
|
|
function _oembed_rest_pre_serve_request( $served, $result, $request, $server ) {
|
|
|
|
$params = $request->get_params();
|
|
|
|
|
|
|
|
if ( '/oembed/1.0/embed' !== $request->get_route() || 'GET' !== $request->get_method() ) {
|
|
|
|
return $served;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! isset( $params['format'] ) || 'xml' !== $params['format'] ) {
|
|
|
|
return $served;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Embed links inside the request.
|
|
|
|
$data = $server->response_to_data( $result, false );
|
|
|
|
|
|
|
|
if ( ! class_exists( 'SimpleXMLElement' ) ) {
|
|
|
|
status_header( 501 );
|
|
|
|
die( get_status_header_desc( 501 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = _oembed_create_xml( $data );
|
|
|
|
|
|
|
|
// Bail if there's no XML.
|
|
|
|
if ( ! $result ) {
|
|
|
|
status_header( 501 );
|
|
|
|
return get_status_header_desc( 501 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! headers_sent() ) {
|
|
|
|
$server->send_header( 'Content-Type', 'text/xml; charset=' . get_option( 'blog_charset' ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $result;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
/**
|
|
|
|
* Creates an XML string from a given array.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
* @access private
|
|
|
|
*
|
|
|
|
* @param array $data The original oEmbed response data.
|
|
|
|
* @param SimpleXMLElement $node Optional. XML node to append the result to recursively.
|
|
|
|
* @return string|false XML string on success, false on error.
|
|
|
|
*/
|
|
|
|
function _oembed_create_xml( $data, $node = null ) {
|
|
|
|
if ( ! is_array( $data ) || empty( $data ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( null === $node ) {
|
|
|
|
$node = new SimpleXMLElement( '<oembed></oembed>' );
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ( $data as $key => $value ) {
|
|
|
|
if ( is_numeric( $key ) ) {
|
|
|
|
$key = 'oembed';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( is_array( $value ) ) {
|
|
|
|
$item = $node->addChild( $key );
|
|
|
|
_oembed_create_xml( $value, $item );
|
|
|
|
} else {
|
|
|
|
$node->addChild( $key, esc_html( $value ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $node->asXML();
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:22:51 +01:00
|
|
|
/**
|
|
|
|
* Filters the given oEmbed HTML to make sure iframes have a title attribute.
|
|
|
|
*
|
|
|
|
* @since 5.2.0
|
|
|
|
*
|
|
|
|
* @param string $result The oEmbed HTML result.
|
|
|
|
* @param object $data A data object result from an oEmbed provider.
|
|
|
|
* @param string $url The URL of the content to be embedded.
|
|
|
|
* @return string The filtered oEmbed result.
|
|
|
|
*/
|
|
|
|
function wp_filter_oembed_iframe_title_attribute( $result, $data, $url ) {
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ), true ) ) {
|
2019-03-20 18:22:51 +01:00
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = ! empty( $data->title ) ? $data->title : '';
|
|
|
|
|
2020-06-10 19:20:10 +02:00
|
|
|
$pattern = '`<iframe([^>]*)>`i';
|
|
|
|
if ( preg_match( $pattern, $result, $matches ) ) {
|
|
|
|
$attrs = wp_kses_hair( $matches[1], wp_allowed_protocols() );
|
|
|
|
|
|
|
|
foreach ( $attrs as $attr => $item ) {
|
|
|
|
$lower_attr = strtolower( $attr );
|
|
|
|
if ( $lower_attr === $attr ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( ! isset( $attrs[ $lower_attr ] ) ) {
|
|
|
|
$attrs[ $lower_attr ] = $item;
|
|
|
|
unset( $attrs[ $attr ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-20 18:22:51 +01:00
|
|
|
|
2020-06-10 19:20:10 +02:00
|
|
|
if ( ! empty( $attrs['title']['value'] ) ) {
|
|
|
|
$title = $attrs['title']['value'];
|
2019-03-20 18:22:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters the title attribute of the given oEmbed HTML iframe.
|
|
|
|
*
|
|
|
|
* @since 5.2.0
|
|
|
|
*
|
|
|
|
* @param string $title The title attribute.
|
|
|
|
* @param string $result The oEmbed HTML result.
|
|
|
|
* @param object $data A data object result from an oEmbed provider.
|
|
|
|
* @param string $url The URL of the content to be embedded.
|
|
|
|
*/
|
|
|
|
$title = apply_filters( 'oembed_iframe_title_attribute', $title, $result, $data, $url );
|
|
|
|
|
|
|
|
if ( '' === $title ) {
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2020-06-10 19:20:10 +02:00
|
|
|
if ( isset( $attrs['title'] ) ) {
|
|
|
|
unset( $attrs['title'] );
|
2020-10-18 19:27:06 +02:00
|
|
|
$attr_string = implode( ' ', wp_list_pluck( $attrs, 'whole' ) );
|
2020-06-10 19:20:10 +02:00
|
|
|
$result = str_replace( $matches[0], '<iframe ' . trim( $attr_string ) . '>', $result );
|
2019-03-20 18:22:51 +01:00
|
|
|
}
|
|
|
|
return str_ireplace( '<iframe ', sprintf( '<iframe title="%s" ', esc_attr( $title ) ), $result );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
/**
|
2015-10-09 00:50:25 +02:00
|
|
|
* Filters the given oEmbed HTML.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
2015-10-09 01:22:24 +02:00
|
|
|
* If the `$url` isn't on the trusted providers list,
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
* we need to filter the HTML heavily for security.
|
|
|
|
*
|
2019-03-27 18:14:52 +01:00
|
|
|
* Only filters 'rich' and 'video' response types.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2015-10-09 01:22:24 +02:00
|
|
|
* @param string $result The oEmbed HTML result.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
* @param object $data A data object result from an oEmbed provider.
|
|
|
|
* @param string $url The URL of the content to be embedded.
|
|
|
|
* @return string The filtered and sanitized oEmbed result.
|
|
|
|
*/
|
2015-10-09 01:22:24 +02:00
|
|
|
function wp_filter_oembed_result( $result, $data, $url ) {
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ), true ) ) {
|
2015-10-09 01:22:24 +02:00
|
|
|
return $result;
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$wp_oembed = _wp_oembed_get_object();
|
|
|
|
|
|
|
|
// Don't modify the HTML for trusted providers.
|
|
|
|
if ( false !== $wp_oembed->get_provider( $url, array( 'discover' => false ) ) ) {
|
2015-10-09 01:22:24 +02:00
|
|
|
return $result;
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$allowed_html = array(
|
2015-10-30 00:11:24 +01:00
|
|
|
'a' => array(
|
2018-12-14 04:25:40 +01:00
|
|
|
'href' => true,
|
2015-10-30 00:11:24 +01:00
|
|
|
),
|
|
|
|
'blockquote' => array(),
|
|
|
|
'iframe' => array(
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
'src' => true,
|
|
|
|
'width' => true,
|
|
|
|
'height' => true,
|
|
|
|
'frameborder' => true,
|
|
|
|
'marginwidth' => true,
|
|
|
|
'marginheight' => true,
|
|
|
|
'scrolling' => true,
|
|
|
|
'title' => true,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2015-10-09 01:22:24 +02:00
|
|
|
$html = wp_kses( $result, $allowed_html );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
|
2015-10-30 00:11:24 +01:00
|
|
|
preg_match( '|(<blockquote>.*?</blockquote>)?.*(<iframe.*?></iframe>)|ms', $html, $content );
|
|
|
|
// We require at least the iframe to exist.
|
|
|
|
if ( empty( $content[2] ) ) {
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
return false;
|
|
|
|
}
|
2015-10-30 00:11:24 +01:00
|
|
|
$html = $content[1] . $content[2];
|
|
|
|
|
2017-09-19 15:43:05 +02:00
|
|
|
preg_match( '/ src=([\'"])(.*?)\1/', $html, $results );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
|
|
|
|
if ( ! empty( $results ) ) {
|
|
|
|
$secret = wp_generate_password( 10, false );
|
|
|
|
|
2017-09-19 15:43:05 +02:00
|
|
|
$url = esc_url( "{$results[2]}#?secret=$secret" );
|
2018-12-14 04:25:40 +01:00
|
|
|
$q = $results[1];
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
|
2017-09-19 15:43:05 +02:00
|
|
|
$html = str_replace( $results[0], ' src=' . $q . $url . $q . ' data-secret=' . $q . $secret . $q, $html );
|
2015-10-30 00:11:24 +01:00
|
|
|
$html = str_replace( '<blockquote', "<blockquote data-secret=\"$secret\"", $html );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
2017-09-19 15:43:05 +02:00
|
|
|
$allowed_html['blockquote']['data-secret'] = true;
|
2018-12-14 04:25:40 +01:00
|
|
|
$allowed_html['iframe']['data-secret'] = true;
|
2017-09-19 15:43:05 +02:00
|
|
|
|
|
|
|
$html = wp_kses( $html, $allowed_html );
|
|
|
|
|
|
|
|
if ( ! empty( $content[1] ) ) {
|
|
|
|
// We have a blockquote to fall back on. Hide the iframe by default.
|
Embeds: Enable lazy-loading of post embeds and fix keyboard a11y for hidden iframes.
Chrome unreliably loads a lazy-loaded iframe when it is hidden using `clip: rect(1px, 1px, 1px, 1px)`. Instead of using `clip`, a lazy-loaded iframe can also be hidden with `visibility:hidden` which results in it loading not only in Chrome but all other browsers. With this change applied, the hard-coded check to prevent lazy-loading post embeds is now removed. An added benefit to using `visibility:hidden` is that the entire iframe in this case is not interactable, meaning that users navigating the document with the keyboard will not unexpectedly encounter tab stops inside of the hidden iframe, as can happen now with `clip` when the JS fails to reveal the loaded iframe. Note also that the `clip` property is deprecated.
Lastly, when such a post embed iframe is rendered in an RSS feed, the `style` attribute is now removed using the HTML Tag Processor as opposed to using string replacement.
Fixes #58773.
Props westonruter, joemcgill, swissspidy, joedolson, adamsilverstein.
Built from https://develop.svn.wordpress.org/trunk@58143
git-svn-id: http://core.svn.wordpress.org/trunk@57608 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-14 00:39:16 +02:00
|
|
|
$html = str_replace( '<iframe', '<iframe style="position: absolute; visibility: hidden;"', $html );
|
2017-09-19 15:43:05 +02:00
|
|
|
$html = str_replace( '<blockquote', '<blockquote class="wp-embedded-content"', $html );
|
|
|
|
}
|
|
|
|
|
|
|
|
$html = str_ireplace( '<iframe', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $html );
|
|
|
|
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-29 14:21:26 +01:00
|
|
|
* Filters the string in the 'more' link displayed after a trimmed excerpt.
|
|
|
|
*
|
|
|
|
* Replaces '[...]' (appended to automatically generated excerpts) with an
|
|
|
|
* ellipsis and a "Continue reading" link in the embed template.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2015-10-29 14:21:26 +01:00
|
|
|
* @param string $more_string Default 'more' string.
|
|
|
|
* @return string 'Continue reading' link prepended with an ellipsis.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*/
|
2015-10-17 03:21:25 +02:00
|
|
|
function wp_embed_excerpt_more( $more_string ) {
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
if ( ! is_embed() ) {
|
|
|
|
return $more_string;
|
|
|
|
}
|
|
|
|
|
2018-12-14 04:25:40 +01:00
|
|
|
$link = sprintf(
|
|
|
|
'<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>',
|
2015-10-29 14:21:26 +01:00
|
|
|
esc_url( get_permalink() ),
|
2019-09-03 02:41:05 +02:00
|
|
|
/* translators: %s: Post title. */
|
2015-10-29 14:21:26 +01:00
|
|
|
sprintf( __( 'Continue reading %s' ), '<span class="screen-reader-text">' . get_the_title() . '</span>' )
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
);
|
2015-10-29 14:21:26 +01:00
|
|
|
return ' … ' . $link;
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-09 00:50:25 +02:00
|
|
|
* Displays the post excerpt for the embed template.
|
|
|
|
*
|
|
|
|
* Intended to be used in 'The Loop'.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function the_excerpt_embed() {
|
|
|
|
$output = get_the_excerpt();
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the post excerpt for the embed template.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
2015-10-09 01:25:24 +02:00
|
|
|
* @since 4.4.0
|
|
|
|
*
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
* @param string $output The current post excerpt.
|
|
|
|
*/
|
|
|
|
echo apply_filters( 'the_excerpt_embed', $output );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters the post excerpt for the embed template.
|
|
|
|
*
|
|
|
|
* Shows players for video and audio attachments.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param string $content The current post excerpt.
|
|
|
|
* @return string The modified post excerpt.
|
|
|
|
*/
|
2015-10-17 03:21:25 +02:00
|
|
|
function wp_embed_excerpt_attachment( $content ) {
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
if ( is_attachment() ) {
|
|
|
|
return prepend_attachment( '' );
|
|
|
|
}
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
2015-10-31 05:38:25 +01:00
|
|
|
/**
|
2020-07-30 21:14:03 +02:00
|
|
|
* Enqueues embed iframe default CSS and JS.
|
2015-10-31 05:38:25 +01:00
|
|
|
*
|
|
|
|
* Enqueue PNG fallback CSS for embed iframe for legacy versions of IE.
|
|
|
|
*
|
|
|
|
* Allows plugins to queue scripts for the embed iframe end using wp_enqueue_script().
|
|
|
|
* Runs first in oembed_head().
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function enqueue_embed_scripts() {
|
|
|
|
wp_enqueue_style( 'wp-embed-template-ie' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fires when scripts and styles are enqueued for the embed iframe.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
do_action( 'enqueue_embed_scripts' );
|
|
|
|
}
|
|
|
|
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
/**
|
Script Loader: Replace hardcoded output of style tags with calls to `wp_add_inline_style`.
In this commit, enhancements have been made by replacing manually constructed style tags with calls to `wp_add_inline_style`. Previously, numerous style tags were generated and output directly in the header, resulting in redundant code and bypassing the core's style enqueueing system. This approach made it challenging for third-party developers to manage and control the output of these style tags.
To ensure backward compatibility, the following functions have been deprecated and replaced:
- print_embed_styles
- print_emoji_styles
- wp_admin_bar_header
- _admin_bar_bump_cb
Backward compatibility shims have also been added, ensuring that if these functions were previously unhooked from there actions, they will continue to not output a style tag.
However, for the following functions, conversion to use inline styles was not feasible due to the potential disruption it might cause by changing the style tag IDs, potentially breaking JavaScript functionality for a number of plugins in the repository:
- custom-background
- wp-custom
These changes improve code maintainability and enhance the flexibility and control available to developers when managing style outputs within WordPress core.
Props spacedmonkey, hlunter, westonruter, flixos90.
Fixes #58775.
Built from https://develop.svn.wordpress.org/trunk@56682
git-svn-id: http://core.svn.wordpress.org/trunk@56194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 19:06:34 +02:00
|
|
|
* Enqueues the CSS in the embed iframe header.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
Script Loader: Replace hardcoded output of style tags with calls to `wp_add_inline_style`.
In this commit, enhancements have been made by replacing manually constructed style tags with calls to `wp_add_inline_style`. Previously, numerous style tags were generated and output directly in the header, resulting in redundant code and bypassing the core's style enqueueing system. This approach made it challenging for third-party developers to manage and control the output of these style tags.
To ensure backward compatibility, the following functions have been deprecated and replaced:
- print_embed_styles
- print_emoji_styles
- wp_admin_bar_header
- _admin_bar_bump_cb
Backward compatibility shims have also been added, ensuring that if these functions were previously unhooked from there actions, they will continue to not output a style tag.
However, for the following functions, conversion to use inline styles was not feasible due to the potential disruption it might cause by changing the style tag IDs, potentially breaking JavaScript functionality for a number of plugins in the repository:
- custom-background
- wp-custom
These changes improve code maintainability and enhance the flexibility and control available to developers when managing style outputs within WordPress core.
Props spacedmonkey, hlunter, westonruter, flixos90.
Fixes #58775.
Built from https://develop.svn.wordpress.org/trunk@56682
git-svn-id: http://core.svn.wordpress.org/trunk@56194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 19:06:34 +02:00
|
|
|
* @since 6.4.0
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*/
|
Script Loader: Replace hardcoded output of style tags with calls to `wp_add_inline_style`.
In this commit, enhancements have been made by replacing manually constructed style tags with calls to `wp_add_inline_style`. Previously, numerous style tags were generated and output directly in the header, resulting in redundant code and bypassing the core's style enqueueing system. This approach made it challenging for third-party developers to manage and control the output of these style tags.
To ensure backward compatibility, the following functions have been deprecated and replaced:
- print_embed_styles
- print_emoji_styles
- wp_admin_bar_header
- _admin_bar_bump_cb
Backward compatibility shims have also been added, ensuring that if these functions were previously unhooked from there actions, they will continue to not output a style tag.
However, for the following functions, conversion to use inline styles was not feasible due to the potential disruption it might cause by changing the style tag IDs, potentially breaking JavaScript functionality for a number of plugins in the repository:
- custom-background
- wp-custom
These changes improve code maintainability and enhance the flexibility and control available to developers when managing style outputs within WordPress core.
Props spacedmonkey, hlunter, westonruter, flixos90.
Fixes #58775.
Built from https://develop.svn.wordpress.org/trunk@56682
git-svn-id: http://core.svn.wordpress.org/trunk@56194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 19:06:34 +02:00
|
|
|
function wp_enqueue_embed_styles() {
|
|
|
|
// Back-compat for plugins that disable functionality by unhooking this action.
|
|
|
|
if ( ! has_action( 'embed_head', 'print_embed_styles' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
remove_action( 'embed_head', 'print_embed_styles' );
|
|
|
|
|
|
|
|
$suffix = wp_scripts_get_suffix();
|
|
|
|
$handle = 'wp-embed-template';
|
|
|
|
wp_register_style( $handle, false );
|
|
|
|
wp_add_inline_style( $handle, file_get_contents( ABSPATH . WPINC . "/css/wp-embed-template$suffix.css" ) );
|
|
|
|
wp_enqueue_style( $handle );
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-26 06:19:26 +01:00
|
|
|
* Prints the JavaScript in the embed iframe header.
|
Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.
In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.
For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.
Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia
Fixes #32522.
Built from https://develop.svn.wordpress.org/trunk@34903
git-svn-id: http://core.svn.wordpress.org/trunk@34868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 12:36:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
2015-10-17 03:21:25 +02:00
|
|
|
function print_embed_scripts() {
|
2021-11-13 01:58:59 +01:00
|
|
|
wp_print_inline_script_tag(
|
|
|
|
file_get_contents( ABSPATH . WPINC . '/js/wp-embed-template' . wp_scripts_get_suffix() . '.js' )
|
|
|
|
);
|
2015-10-07 23:43:25 +02:00
|
|
|
}
|
2015-10-30 00:11:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare the oembed HTML to be displayed in an RSS feed.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
* @access private
|
|
|
|
*
|
|
|
|
* @param string $content The content to filter.
|
|
|
|
* @return string The filtered content.
|
|
|
|
*/
|
|
|
|
function _oembed_filter_feed_content( $content ) {
|
Embeds: Enable lazy-loading of post embeds and fix keyboard a11y for hidden iframes.
Chrome unreliably loads a lazy-loaded iframe when it is hidden using `clip: rect(1px, 1px, 1px, 1px)`. Instead of using `clip`, a lazy-loaded iframe can also be hidden with `visibility:hidden` which results in it loading not only in Chrome but all other browsers. With this change applied, the hard-coded check to prevent lazy-loading post embeds is now removed. An added benefit to using `visibility:hidden` is that the entire iframe in this case is not interactable, meaning that users navigating the document with the keyboard will not unexpectedly encounter tab stops inside of the hidden iframe, as can happen now with `clip` when the JS fails to reveal the loaded iframe. Note also that the `clip` property is deprecated.
Lastly, when such a post embed iframe is rendered in an RSS feed, the `style` attribute is now removed using the HTML Tag Processor as opposed to using string replacement.
Fixes #58773.
Props westonruter, joemcgill, swissspidy, joedolson, adamsilverstein.
Built from https://develop.svn.wordpress.org/trunk@58143
git-svn-id: http://core.svn.wordpress.org/trunk@57608 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-14 00:39:16 +02:00
|
|
|
$p = new WP_HTML_Tag_Processor( $content );
|
|
|
|
while ( $p->next_tag( array( 'tag_name' => 'iframe' ) ) ) {
|
|
|
|
if ( $p->has_class( 'wp-embedded-content' ) ) {
|
|
|
|
$p->remove_attribute( 'style' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $p->get_updated_html();
|
2015-10-30 00:11:24 +01:00
|
|
|
}
|
2015-11-18 21:51:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints the necessary markup for the embed comments button.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function print_embed_comments_button() {
|
|
|
|
if ( is_404() || ! ( get_comments_number() || comments_open() ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<div class="wp-embed-comments">
|
|
|
|
<a href="<?php comments_link(); ?>" target="_top">
|
|
|
|
<span class="dashicons dashicons-admin-comments"></span>
|
|
|
|
<?php
|
|
|
|
printf(
|
2019-09-03 02:41:05 +02:00
|
|
|
/* translators: %s: Number of comments. */
|
2015-11-18 21:51:26 +01:00
|
|
|
_n(
|
|
|
|
'%s <span class="screen-reader-text">Comment</span>',
|
|
|
|
'%s <span class="screen-reader-text">Comments</span>',
|
|
|
|
get_comments_number()
|
|
|
|
),
|
|
|
|
number_format_i18n( get_comments_number() )
|
|
|
|
);
|
|
|
|
?>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints the necessary markup for the embed sharing button.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function print_embed_sharing_button() {
|
|
|
|
if ( is_404() ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<div class="wp-embed-share">
|
|
|
|
<button type="button" class="wp-embed-share-dialog-open" aria-label="<?php esc_attr_e( 'Open sharing dialog' ); ?>">
|
|
|
|
<span class="dashicons dashicons-share"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints the necessary markup for the embed sharing dialog.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function print_embed_sharing_dialog() {
|
|
|
|
if ( is_404() ) {
|
|
|
|
return;
|
|
|
|
}
|
2022-08-20 00:06:09 +02:00
|
|
|
|
|
|
|
$unique_suffix = get_the_ID() . '-' . wp_rand();
|
|
|
|
$share_tab_wordpress_id = 'wp-embed-share-tab-wordpress-' . $unique_suffix;
|
|
|
|
$share_tab_html_id = 'wp-embed-share-tab-html-' . $unique_suffix;
|
|
|
|
$description_wordpress_id = 'wp-embed-share-description-wordpress-' . $unique_suffix;
|
|
|
|
$description_html_id = 'wp-embed-share-description-html-' . $unique_suffix;
|
2015-11-18 21:51:26 +01:00
|
|
|
?>
|
|
|
|
<div class="wp-embed-share-dialog hidden" role="dialog" aria-label="<?php esc_attr_e( 'Sharing options' ); ?>">
|
|
|
|
<div class="wp-embed-share-dialog-content">
|
|
|
|
<div class="wp-embed-share-dialog-text">
|
|
|
|
<ul class="wp-embed-share-tabs" role="tablist">
|
|
|
|
<li class="wp-embed-share-tab-button wp-embed-share-tab-button-wordpress" role="presentation">
|
2022-08-20 00:06:09 +02:00
|
|
|
<button type="button" role="tab" aria-controls="<?php echo $share_tab_wordpress_id; ?>" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button>
|
2015-11-18 21:51:26 +01:00
|
|
|
</li>
|
|
|
|
<li class="wp-embed-share-tab-button wp-embed-share-tab-button-html" role="presentation">
|
2022-08-20 00:06:09 +02:00
|
|
|
<button type="button" role="tab" aria-controls="<?php echo $share_tab_html_id; ?>" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button>
|
2015-11-18 21:51:26 +01:00
|
|
|
</li>
|
|
|
|
</ul>
|
2022-08-20 00:06:09 +02:00
|
|
|
<div id="<?php echo $share_tab_wordpress_id; ?>" class="wp-embed-share-tab" role="tabpanel" aria-hidden="false">
|
|
|
|
<input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" aria-label="<?php esc_attr_e( 'URL' ); ?>" aria-describedby="<?php echo $description_wordpress_id; ?>" tabindex="0" readonly/>
|
2015-11-18 21:51:26 +01:00
|
|
|
|
2022-08-20 00:06:09 +02:00
|
|
|
<p class="wp-embed-share-description" id="<?php echo $description_wordpress_id; ?>">
|
2015-11-18 21:51:26 +01:00
|
|
|
<?php _e( 'Copy and paste this URL into your WordPress site to embed' ); ?>
|
|
|
|
</p>
|
|
|
|
</div>
|
2022-08-20 00:06:09 +02:00
|
|
|
<div id="<?php echo $share_tab_html_id; ?>" class="wp-embed-share-tab" role="tabpanel" aria-hidden="true">
|
|
|
|
<textarea class="wp-embed-share-input" aria-label="<?php esc_attr_e( 'HTML' ); ?>" aria-describedby="<?php echo $description_html_id; ?>" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( 600, 400 ) ); ?></textarea>
|
2015-11-18 21:51:26 +01:00
|
|
|
|
2022-08-20 00:06:09 +02:00
|
|
|
<p class="wp-embed-share-description" id="<?php echo $description_html_id; ?>">
|
2015-11-18 21:51:26 +01:00
|
|
|
<?php _e( 'Copy and paste this code into your site to embed' ); ?>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button type="button" class="wp-embed-share-dialog-close" aria-label="<?php esc_attr_e( 'Close sharing dialog' ); ?>">
|
|
|
|
<span class="dashicons dashicons-no"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
2016-02-24 21:57:26 +01:00
|
|
|
|
|
|
|
/**
|
2016-03-10 06:37:27 +01:00
|
|
|
* Prints the necessary markup for the site title in an embed template.
|
2016-02-24 21:57:26 +01:00
|
|
|
*
|
|
|
|
* @since 4.5.0
|
|
|
|
*/
|
|
|
|
function the_embed_site_title() {
|
|
|
|
$site_title = sprintf(
|
2021-03-20 19:30:08 +01:00
|
|
|
'<a href="%s" target="_top"><img src="%s" srcset="%s 2x" width="32" height="32" alt="" class="wp-embed-site-icon" /><span>%s</span></a>',
|
2016-02-24 21:57:26 +01:00
|
|
|
esc_url( home_url() ),
|
2020-05-20 12:36:09 +02:00
|
|
|
esc_url( get_site_icon_url( 32, includes_url( 'images/w-logo-blue.png' ) ) ),
|
|
|
|
esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
|
2016-02-24 21:57:26 +01:00
|
|
|
esc_html( get_bloginfo( 'name' ) )
|
|
|
|
);
|
|
|
|
|
|
|
|
$site_title = '<div class="wp-embed-site-title">' . $site_title . '</div>';
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:42:27 +02:00
|
|
|
* Filters the site title HTML in the embed footer.
|
2016-02-24 21:57:26 +01:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param string $site_title The site title HTML.
|
|
|
|
*/
|
|
|
|
echo apply_filters( 'embed_site_title_html', $site_title );
|
|
|
|
}
|
2016-06-15 13:23:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters the oEmbed result before any HTTP requests are made.
|
|
|
|
*
|
|
|
|
* If the URL belongs to the current site, the result is fetched directly instead of
|
|
|
|
* going through the oEmbed discovery process.
|
|
|
|
*
|
|
|
|
* @since 4.5.3
|
|
|
|
*
|
|
|
|
* @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null.
|
|
|
|
* @param string $url The URL that should be inspected for discovery `<link>` tags.
|
|
|
|
* @param array $args oEmbed remote get arguments.
|
|
|
|
* @return null|string The UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
|
|
|
|
* Null if the URL does not belong to the current site.
|
|
|
|
*/
|
|
|
|
function wp_filter_pre_oembed_result( $result, $url, $args ) {
|
2018-12-14 04:20:37 +01:00
|
|
|
$data = get_oembed_response_data_for_url( $url, $args );
|
2017-09-27 10:36:48 +02:00
|
|
|
|
2018-12-14 04:20:37 +01:00
|
|
|
if ( $data ) {
|
|
|
|
return _wp_oembed_get_object()->data2html( $data, $url );
|
2017-09-26 10:40:47 +02:00
|
|
|
}
|
|
|
|
|
2018-12-14 04:20:37 +01:00
|
|
|
return $result;
|
2016-06-15 13:23:28 +02:00
|
|
|
}
|