2015-10-05 23:59:24 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2015-10-08 18:38:25 -04:00
|
|
|
* oEmbed API: Top-level oEmbed functionality
|
2015-10-05 23:59:24 -04: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
|
|
|
|
*
|
|
|
|
* @global WP_Embed $wp_embed
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
*
|
|
|
|
* @global WP_Embed $wp_embed
|
|
|
|
*
|
|
|
|
* @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 10:42:25 -05:00
|
|
|
* Creates default array of embed parameters.
|
2015-10-05 23:59:24 -04: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 15:01:27 -04:00
|
|
|
* The {@see 'embed_defaults'} filter can be used to adjust either of these values.
|
2015-10-05 23:59:24 -04:00
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
|
|
|
* @global int $content_width
|
|
|
|
*
|
|
|
|
* @param string $url Optional. The URL that should be embedded. Default empty.
|
|
|
|
*
|
|
|
|
* @return array Default embed parameters.
|
|
|
|
*/
|
|
|
|
function wp_embed_defaults( $url = '' ) {
|
|
|
|
if ( ! empty( $GLOBALS['content_width'] ) )
|
|
|
|
$width = (int) $GLOBALS['content_width'];
|
|
|
|
|
|
|
|
if ( empty( $width ) )
|
|
|
|
$width = 500;
|
|
|
|
|
|
|
|
$height = min( ceil( $width * 1.5 ), 1000 );
|
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04:00
|
|
|
* Filters the default array of embed dimensions.
|
2015-10-05 23:59:24 -04:00
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
2015-11-01 10:42:25 -05:00
|
|
|
* @param array $size An array of embed width and height values
|
|
|
|
* in pixels (in that order).
|
|
|
|
* @param string $url The URL that should be embedded.
|
2015-10-05 23:59:24 -04: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.
|
|
|
|
* @param array $args Optional. Additional arguments and parameters for retrieving embed HTML.
|
|
|
|
* Default empty.
|
|
|
|
* @return false|string False on failure or the embed HTML on success.
|
|
|
|
*/
|
|
|
|
function wp_oembed_get( $url, $args = '' ) {
|
|
|
|
$oembed = _wp_oembed_get_object();
|
|
|
|
return $oembed->get_html( $url, $args );
|
|
|
|
}
|
|
|
|
|
2016-08-26 05:49:28 -04:00
|
|
|
/**
|
|
|
|
* Returns the initialized WP_oEmbed object.
|
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
* @access private
|
|
|
|
*
|
|
|
|
* @staticvar WP_oEmbed $wp_oembed
|
|
|
|
*
|
|
|
|
* @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-05 23:59:24 -04:00
|
|
|
/**
|
|
|
|
* Adds a URL format and oEmbed provider URL pair.
|
|
|
|
*
|
|
|
|
* @since 2.9.0
|
|
|
|
*
|
|
|
|
* @see WP_oEmbed
|
|
|
|
*
|
|
|
|
* @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 boolean $regex Optional. Whether the `$format` parameter is in a RegEx format. Default false.
|
|
|
|
*/
|
|
|
|
function wp_oembed_add_provider( $format, $provider, $regex = false ) {
|
|
|
|
if ( did_action( 'plugins_loaded' ) ) {
|
|
|
|
$oembed = _wp_oembed_get_object();
|
|
|
|
$oembed->providers[$format] = array( $provider, $regex );
|
|
|
|
} 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 14:42:27 -04:00
|
|
|
* Filters whether to load the default embed handlers.
|
2015-10-05 23:59:24 -04: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 14:42:27 -04:00
|
|
|
* Filters the audio embed handler callback.
|
2015-10-05 23:59:24 -04:00
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @param callable $handler Audio embed handler callback function.
|
|
|
|
*/
|
|
|
|
wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 );
|
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04:00
|
|
|
* Filters the video embed handler callback.
|
2015-10-05 23:59:24 -04:00
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @param callable $handler Video embed handler callback function.
|
|
|
|
*/
|
|
|
|
wp_embed_register_handler( 'video', '#^https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* @global WP_Embed $wp_embed
|
|
|
|
*
|
|
|
|
* @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;
|
2017-03-06 06:42:40 -05:00
|
|
|
$embed = $wp_embed->autoembed( sprintf( "https://youtube.com/watch?v=%s", urlencode( $matches[2] ) ) );
|
2015-10-05 23:59:24 -04:00
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04:00
|
|
|
* Filters the YoutTube embed output.
|
2015-10-05 23:59:24 -04: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 14:42:27 -04:00
|
|
|
* Filters the audio embed output.
|
2015-10-05 23:59:24 -04: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 14:42:27 -04:00
|
|
|
* Filters the video embed output.
|
2015-10-05 23:59:24 -04: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 06:36:25 -04:00
|
|
|
|
|
|
|
/**
|
2015-10-29 18:51:24 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
2015-10-29 18:51:24 -04:00
|
|
|
function wp_oembed_register_route() {
|
2015-10-08 18:40:24 -04:00
|
|
|
$controller = new WP_oEmbed_Controller();
|
2015-10-29 18:51:24 -04: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 06:36:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds oEmbed discovery links in the website <head>.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function wp_oembed_add_discovery_links() {
|
|
|
|
$output = '';
|
|
|
|
|
2016-01-15 02:56:26 -05:00
|
|
|
if ( is_singular() ) {
|
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 06:36:25 -04:00
|
|
|
$output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
|
2015-10-22 12:38:26 -04:00
|
|
|
|
|
|
|
if ( class_exists( 'SimpleXMLElement' ) ) {
|
|
|
|
$output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
|
|
|
|
}
|
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 06:36:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param string $output HTML of the discovery links.
|
|
|
|
*/
|
|
|
|
echo apply_filters( 'oembed_discovery_links', $output );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-08 18:50:25 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function wp_oembed_add_host_js() {
|
2015-10-17 19:26:47 -04:00
|
|
|
wp_enqueue_script( 'wp-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 06:36:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-08 18:50:25 -04: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 06:36:25 -04: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 02:56:26 -05: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 06:36:25 -04:00
|
|
|
$embed_url = add_query_arg( array( 'embed' => 'true' ), get_permalink( $post ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param string $embed_url The post embed URL.
|
|
|
|
* @param WP_Post $post The corresponding post object.
|
|
|
|
*/
|
|
|
|
return esc_url_raw( apply_filters( 'post_embed_url', $embed_url, $post ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-08 18:50:25 -04: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 06:36:25 -04:00
|
|
|
*
|
2015-10-08 18:50:25 -04: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 06:36:25 -04: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 18:51:24 -04: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 06:36:25 -04:00
|
|
|
|
|
|
|
if ( '' !== $permalink ) {
|
|
|
|
$url = add_query_arg( array(
|
2015-10-07 17:43:25 -04:00
|
|
|
'url' => urlencode( $permalink ),
|
2016-08-22 20:05:30 -04:00
|
|
|
'format' => ( 'json' !== $format ) ? $format : 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 06:36:25 -04:00
|
|
|
), $url );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04: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 06:36:25 -04: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-08 18:50:25 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
|
|
|
* @param int $width The width for the response.
|
|
|
|
* @param int $height The height for the response.
|
2015-10-31 11:51:25 -04: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 06:36:25 -04:00
|
|
|
* @return string|false Embed code on success, false if post doesn't exist.
|
|
|
|
*/
|
2015-10-31 11:51:25 -04: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 06:36:25 -04:00
|
|
|
$post = get_post( $post );
|
|
|
|
|
|
|
|
if ( ! $post ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$embed_url = get_post_embed_url( $post );
|
|
|
|
|
2015-11-08 19:08:27 -05:00
|
|
|
$output = '<blockquote class="wp-embedded-content"><a href="' . esc_url( get_permalink( $post ) ) . '">' . get_the_title( $post ) . "</a></blockquote>\n";
|
2015-10-29 19:11:24 -04:00
|
|
|
|
|
|
|
$output .= "<script type='text/javascript'>\n";
|
2015-10-26 19:55:26 -04:00
|
|
|
$output .= "<!--//--><![CDATA[//><!--\n";
|
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 06:36:25 -04:00
|
|
|
if ( SCRIPT_DEBUG ) {
|
2015-10-16 21:21:25 -04:00
|
|
|
$output .= file_get_contents( ABSPATH . WPINC . '/js/wp-embed.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 06:36:25 -04:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If you're looking at a src version of this file, you'll see an "include"
|
|
|
|
* statement below. This is used by the `grunt build` process to directly
|
2015-10-16 21:21:25 -04:00
|
|
|
* include a minified version of wp-embed.js, instead of using the
|
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 06:36:25 -04:00
|
|
|
* file_get_contents() method from above.
|
|
|
|
*
|
|
|
|
* If you're looking at a build version of this file, you'll see a string of
|
|
|
|
* minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
|
2015-10-16 21:21:25 -04:00
|
|
|
* and edit wp-embed.js directly.
|
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 06:36:25 -04:00
|
|
|
*/
|
|
|
|
$output .=<<<JS
|
2016-11-23 08:38:33 -05:00
|
|
|
!function(a,b){"use strict";function c(){if(!e){e=!0;var a,c,d,f,g=-1!==navigator.appVersion.indexOf("MSIE 10"),h=!!navigator.userAgent.match(/Trident.*rv:11\./),i=b.querySelectorAll("iframe.wp-embedded-content");for(c=0;c<i.length;c++){if(d=i[c],!d.getAttribute("data-secret"))f=Math.random().toString(36).substr(2,10),d.src+="#?secret="+f,d.setAttribute("data-secret",f);if(g||h)a=d.cloneNode(!0),a.removeAttribute("security"),d.parentNode.replaceChild(a,d)}}}var d=!1,e=!1;if(b.querySelector)if(a.addEventListener)d=!0;if(a.wp=a.wp||{},!a.wp.receiveEmbedMessage)if(a.wp.receiveEmbedMessage=function(c){var d=c.data;if(d.secret||d.message||d.value)if(!/[^a-zA-Z0-9]/.test(d.secret)){var e,f,g,h,i,j=b.querySelectorAll('iframe[data-secret="'+d.secret+'"]'),k=b.querySelectorAll('blockquote[data-secret="'+d.secret+'"]');for(e=0;e<k.length;e++)k[e].style.display="none";for(e=0;e<j.length;e++)if(f=j[e],c.source===f.contentWindow){if(f.removeAttribute("style"),"height"===d.message){if(g=parseInt(d.value,10),g>1e3)g=1e3;else if(~~g<200)g=200;f.height=g}if("link"===d.message)if(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host)if(b.activeElement===f)a.top.location.href=d.value}else;}},d)a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)}(window,document);
|
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 06:36:25 -04:00
|
|
|
JS;
|
|
|
|
}
|
2015-10-26 19:55:26 -04:00
|
|
|
$output .= "\n//--><!]]>";
|
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 06:36:25 -04:00
|
|
|
$output .= "\n</script>";
|
|
|
|
|
|
|
|
$output .= sprintf(
|
|
|
|
'<iframe sandbox="allow-scripts" security="restricted" src="%1$s" width="%2$d" height="%3$d" title="%4$s" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>',
|
|
|
|
esc_url( $embed_url ),
|
|
|
|
absint( $width ),
|
|
|
|
absint( $height ),
|
2016-03-07 05:00:29 -05:00
|
|
|
esc_attr(
|
|
|
|
sprintf(
|
|
|
|
/* translators: 1: post title, 2: site name */
|
|
|
|
__( '“%1$s” — %2$s' ),
|
|
|
|
get_the_title( $post ),
|
|
|
|
get_bloginfo( 'name' )
|
|
|
|
)
|
|
|
|
)
|
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 06:36:25 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2017-06-25 17:46:39 -04: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 06:36:25 -04:00
|
|
|
* @param WP_Post $post Current post object.
|
|
|
|
* @param int $width Width of the response.
|
|
|
|
* @param int $height Height of the response.
|
|
|
|
*/
|
2015-10-16 21:21:25 -04: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 06:36:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-08 18:50:25 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2015-10-31 11:42:25 -04:00
|
|
|
* @param WP_Post|int $post Post object or ID.
|
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 06:36:25 -04:00
|
|
|
* @param int $width The requested width.
|
|
|
|
* @return array|false Response data on success, false if post doesn't exist.
|
|
|
|
*/
|
2015-10-31 11:42:25 -04:00
|
|
|
function get_oembed_response_data( $post, $width ) {
|
2016-05-24 02:15:28 -04: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 06:36:25 -04:00
|
|
|
|
|
|
|
if ( ! $post ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( 'publish' !== get_post_status( $post ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04: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 06:36:25 -04:00
|
|
|
*
|
2015-10-08 18:55:25 -04:00
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2015-10-08 19:09:23 -04: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 06:36:25 -04:00
|
|
|
*
|
2015-10-08 19:09:23 -04: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 06:36:25 -04:00
|
|
|
*/
|
2015-10-08 19:09:23 -04:00
|
|
|
$min_max_width = apply_filters( 'oembed_min_max_width', array(
|
|
|
|
'min' => 200,
|
|
|
|
'max' => 600
|
|
|
|
) );
|
|
|
|
|
2015-10-29 18:51:24 -04:00
|
|
|
$width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] );
|
|
|
|
$height = max( 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 06:36:25 -04: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(),
|
|
|
|
'title' => $post->post_title,
|
|
|
|
'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 14:42:27 -04: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 06:36:25 -04: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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 11:51:25 -04: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 06:36:25 -04: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;
|
|
|
|
} else if ( wp_attachment_is( 'video', $post ) ) {
|
|
|
|
$thumbnail_id = get_post_thumbnail_id( $post );
|
|
|
|
$data['type'] = 'video';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $thumbnail_id ) {
|
|
|
|
list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) );
|
|
|
|
$data['thumbnail_url'] = $thumbnail_url;
|
|
|
|
$data['thumbnail_width'] = $thumbnail_width;
|
|
|
|
$data['thumbnail_height'] = $thumbnail_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures that the specified format is either 'json' or 'xml'.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2015-10-08 18:50:25 -04: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 06:36:25 -04: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 18:51:24 -04: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
|
|
|
|
*
|
|
|
|
* @param bool $served Whether the request has already been served.
|
|
|
|
* @param WP_HTTP_ResponseInterface $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.
|
|
|
|
* @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 06:36:25 -04: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();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-08 18:50:25 -04: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 06:36:25 -04:00
|
|
|
*
|
2015-10-08 19:22:24 -04: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 06:36:25 -04:00
|
|
|
* we need to filter the HTML heavily for security.
|
|
|
|
*
|
|
|
|
* Only filters 'rich' and 'html' response types.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2015-10-08 19:22:24 -04: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 06:36:25 -04: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-08 19:22:24 -04:00
|
|
|
function wp_filter_oembed_result( $result, $data, $url ) {
|
|
|
|
if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ) ) ) {
|
|
|
|
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 06:36:25 -04: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-08 19:22:24 -04: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 06:36:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$allowed_html = array(
|
2015-10-29 19:11:24 -04:00
|
|
|
'a' => array(
|
2015-11-08 19:08:27 -05:00
|
|
|
'href' => true,
|
2015-10-29 19:11:24 -04: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 06:36:25 -04:00
|
|
|
'src' => true,
|
|
|
|
'width' => true,
|
|
|
|
'height' => true,
|
|
|
|
'frameborder' => true,
|
|
|
|
'marginwidth' => true,
|
|
|
|
'marginheight' => true,
|
|
|
|
'scrolling' => true,
|
|
|
|
'title' => true,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2015-10-08 19:22:24 -04: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 06:36:25 -04:00
|
|
|
|
2015-10-29 19:11:24 -04: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 06:36:25 -04:00
|
|
|
return false;
|
|
|
|
}
|
2015-10-29 19:11:24 -04:00
|
|
|
$html = $content[1] . $content[2];
|
|
|
|
|
2017-09-19 09:43:05 -04: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 06:36:25 -04:00
|
|
|
|
|
|
|
if ( ! empty( $results ) ) {
|
|
|
|
$secret = wp_generate_password( 10, false );
|
|
|
|
|
2017-09-19 09:43:05 -04:00
|
|
|
$url = esc_url( "{$results[2]}#?secret=$secret" );
|
|
|
|
$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 06:36:25 -04:00
|
|
|
|
2017-09-19 09:43:05 -04:00
|
|
|
$html = str_replace( $results[0], ' src=' . $q . $url . $q . ' data-secret=' . $q . $secret . $q, $html );
|
2015-10-29 19:11:24 -04: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 06:36:25 -04:00
|
|
|
}
|
|
|
|
|
2017-09-19 09:43:05 -04:00
|
|
|
$allowed_html['blockquote']['data-secret'] = true;
|
|
|
|
$allowed_html['iframe']['data-secret'] = true;
|
|
|
|
|
|
|
|
$html = wp_kses( $html, $allowed_html );
|
|
|
|
|
|
|
|
if ( ! empty( $content[1] ) ) {
|
|
|
|
// We have a blockquote to fall back on. Hide the iframe by default.
|
|
|
|
$html = str_replace( '<iframe', '<iframe style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', $html );
|
|
|
|
$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 06:36:25 -04:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-29 09:21:26 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*
|
2015-10-29 09:21:26 -04: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 06:36:25 -04:00
|
|
|
*/
|
2015-10-16 21:21:25 -04: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 06:36:25 -04:00
|
|
|
if ( ! is_embed() ) {
|
|
|
|
return $more_string;
|
|
|
|
}
|
|
|
|
|
2015-10-29 09:21:26 -04:00
|
|
|
$link = sprintf( '<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>',
|
|
|
|
esc_url( get_permalink() ),
|
|
|
|
/* translators: %s: Name of current post */
|
|
|
|
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 06:36:25 -04:00
|
|
|
);
|
2015-10-29 09:21:26 -04: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 06:36:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-08 18:50:25 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function the_excerpt_embed() {
|
|
|
|
$output = get_the_excerpt();
|
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04: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 06:36:25 -04:00
|
|
|
*
|
2015-10-08 19:25:24 -04: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 06:36:25 -04: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-16 21:21:25 -04: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 06:36:25 -04:00
|
|
|
if ( is_attachment() ) {
|
|
|
|
return prepend_attachment( '' );
|
|
|
|
}
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
2015-10-31 00:38:25 -04:00
|
|
|
/**
|
|
|
|
* Enqueue embed iframe default CSS and JS & fire do_action('enqueue_embed_scripts')
|
|
|
|
*
|
|
|
|
* 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 06:36:25 -04:00
|
|
|
/**
|
2015-10-08 18:50:25 -04:00
|
|
|
* Prints 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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
2015-10-16 21:21:25 -04:00
|
|
|
function print_embed_styles() {
|
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 06:36:25 -04:00
|
|
|
?>
|
|
|
|
<style type="text/css">
|
|
|
|
<?php
|
2015-10-16 18:43:24 -04:00
|
|
|
if ( SCRIPT_DEBUG ) {
|
2015-10-16 21:21:25 -04:00
|
|
|
readfile( ABSPATH . WPINC . "/css/wp-embed-template.css" );
|
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 06:36:25 -04:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If you're looking at a src version of this file, you'll see an "include"
|
|
|
|
* statement below. This is used by the `grunt build` process to directly
|
|
|
|
* include a minified version of wp-oembed-embed.css, instead of using the
|
|
|
|
* readfile() method from above.
|
|
|
|
*
|
|
|
|
* If you're looking at a build version of this file, you'll see a string of
|
2015-10-16 18:43:24 -04:00
|
|
|
* minified CSS. If you need to debug it, please turn on SCRIPT_DEBUG
|
2015-10-16 21:21:25 -04:00
|
|
|
* and edit wp-embed-template.css directly.
|
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 06:36:25 -04:00
|
|
|
*/
|
|
|
|
?>
|
Update autoprefixer browser support matrix
WordPress no longer supports many old old browsers: https://make.wordpress.org/core/2017/04/23/target-browser-coverage/
This also removes alot of no longer necessary CSS. It served us well, but we are never getting back together with IE8,9,10.
So, in the (paraphrased) words of Taylor Swift:
I remember when we dropped support the first time
Saying, "This is it, I've had enough, " 'cause like
We hadn't seen many users in a month
When you said you needed flexbox. (What?)
Then you postMessage again and say
"IE8, I miss you and I swear I'm gonna change, trust me."
Remember how that lasted for a day?
I say, "I hate the box model, " we break up, you call me, "I love css-grids."
Ooh, we called it off again last night
But ooh, this time I'm telling you, I'm telling you
We are never ever ever supporting IE 8,9,10,
We are never ever ever supporting IE 8,9,10,
You go talk to EDGE, talk to my FIREFOX, talk to CHROME
But we are never ever ever ever getting back together
Like, ever...
Fixes #37651.
Props stunnedbeast, netweb, jorbin.
Built from https://develop.svn.wordpress.org/trunk@41062
git-svn-id: http://core.svn.wordpress.org/trunk@40912 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-15 21:15:46 -04:00
|
|
|
body,html{padding:0;margin:0}body{font-family:sans-serif}.wp-embed,.wp-embed-share-input{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif}.screen-reader-text{clip:rect(1px,1px,1px,1px);height:1px;overflow:hidden;position:absolute!important;width:1px}.dashicons{display:inline-block;width:20px;height:20px;background-color:transparent;background-repeat:no-repeat;background-size:20px;background-position:center;transition:background .1s ease-in;position:relative;top:5px}.dashicons-no{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M15.55%2013.7l-2.19%202.06-3.42-3.65-3.64%203.43-2.06-2.18%203.64-3.43-3.42-3.64%202.18-2.06%203.43%203.64%203.64-3.42%202.05%202.18-3.64%203.43z%27%20fill%3D%27%23fff%27%2F%3E%3C%2Fsvg%3E")}.dashicons-admin-comments{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E")}.wp-embed-comments a:hover .dashicons-admin-comments{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E")}.dashicons-share{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E");display:none}.js .dashicons-share{display:inline-block}.wp-embed-share-dialog-open:hover .dashicons-share{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E")}.wp-embed{padding:25px;font-size:14px;font-weight:400;line-height:1.5;color:#82878c;background:#fff;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.05);overflow:auto;zoom:1}.wp-embed a{color:#82878c;text-decoration:none}.wp-embed a:hover{text-decoration:underline}.wp-embed-featured-image{margin-bottom:20px}.wp-embed-featured-image img{width:100%;height:auto;border:none}.wp-embed-featured-image.square{float:left;max-width:160px;margin-right:20px}.wp-embed p{margin:0}p.wp-embed-heading{margin:0 0 15px;font-weight:600;font-size:22px;line-height:1.3}.wp-embed-heading a{color:#32373c}.wp-embed .wp-embed-more{color:#b4b9be}.wp-embed-footer{display:table;width:100%;margin-top:30px}.wp-embed-site-icon{position:absolute;top:50%;left:0;-webkit-transform:translateY(-50%);transform:translateY(-50%);height:25px;width:25px;border:0}.wp-embed-site-title{font-weight:600;line-height:25px}.wp-embed-site-title a{position:relative;display:inline-block;padding-left:35px}.wp-embed-meta,.wp-embed-site-title{display:table-cell}.wp-embed-meta{text-align:right;white-space:nowrap;vertical-align:middle}.wp-embed-comments,.wp-embed-share{display:inline
|
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 06:36:25 -04:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</style>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-26 01:19:26 -04: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 06:36:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
2015-10-16 21:21:25 -04:00
|
|
|
function print_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 06:36:25 -04:00
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
|
|
<?php
|
|
|
|
if ( SCRIPT_DEBUG ) {
|
2015-10-16 21:21:25 -04:00
|
|
|
readfile( ABSPATH . WPINC . "/js/wp-embed-template.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 06:36:25 -04:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If you're looking at a src version of this file, you'll see an "include"
|
|
|
|
* statement below. This is used by the `grunt build` process to directly
|
2015-10-16 21:21:25 -04:00
|
|
|
* include a minified version of wp-embed-template.js, instead of using the
|
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 06:36:25 -04:00
|
|
|
* readfile() method from above.
|
|
|
|
*
|
|
|
|
* If you're looking at a build version of this file, you'll see a string of
|
|
|
|
* minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
|
2015-10-16 21:21:25 -04:00
|
|
|
* and edit wp-embed-template.js directly.
|
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 06:36:25 -04:00
|
|
|
*/
|
|
|
|
?>
|
2016-07-05 12:16:57 -04:00
|
|
|
!function(a,b){"use strict";function c(b,c){a.parent.postMessage({message:b,value:c,secret:g},"*")}function d(){function d(){l.className=l.className.replace("hidden",""),b.querySelector('.wp-embed-share-tab-button [aria-selected="true"]').focus()}function e(){l.className+=" hidden",b.querySelector(".wp-embed-share-dialog-open").focus()}function f(a){var c=b.querySelector('.wp-embed-share-tab-button [aria-selected="true"]');c.setAttribute("aria-selected","false"),b.querySelector("#"+c.getAttribute("aria-controls")).setAttribute("aria-hidden","true"),a.target.setAttribute("aria-selected","true"),b.querySelector("#"+a.target.getAttribute("aria-controls")).setAttribute("aria-hidden","false")}function g(a){var c,d,e=a.target,f=e.parentElement.previousElementSibling,g=e.parentElement.nextElementSibling;if(37===a.keyCode)c=f;else{if(39!==a.keyCode)return!1;c=g}"rtl"===b.documentElement.getAttribute("dir")&&(c=c===f?g:f),c&&(d=c.firstElementChild,e.setAttribute("tabindex","-1"),e.setAttribute("aria-selected",!1),b.querySelector("#"+e.getAttribute("aria-controls")).setAttribute("aria-hidden","true"),d.setAttribute("tabindex","0"),d.setAttribute("aria-selected","true"),d.focus(),b.querySelector("#"+d.getAttribute("aria-controls")).setAttribute("aria-hidden","false"))}function h(a){var c=b.querySelector('.wp-embed-share-tab-button [aria-selected="true"]');n!==a.target||a.shiftKey?c===a.target&&a.shiftKey&&(n.focus(),a.preventDefault()):(c.focus(),a.preventDefault())}function i(a){var b,d=a.target;b=d.hasAttribute("href")?d.getAttribute("href"):d.parentElement.getAttribute("href"),b&&(c("link",b),a.preventDefault())}if(!k){k=!0;var j,l=b.querySelector(".wp-embed-share-dialog"),m=b.querySelector(".wp-embed-share-dialog-open"),n=b.querySelector(".wp-embed-share-dialog-close"),o=b.querySelectorAll(".wp-embed-share-input"),p=b.querySelectorAll(".wp-embed-share-tab-button button"),q=b.querySelector(".wp-embed-featured-image img");if(o)for(j=0;j<o.length;j++)o[j].addEventListener("click",function(a){a.target.select()});if(m&&m.addEventListener("click",function(){d()}),n&&n.addEventListener("click",function(){e()}),p)for(j=0;j<p.length;j++)p[j].addEventListener("click",f),p[j].addEventListener("keydown",g);b.addEventListener("keydown",function(a){27===a.keyCode&&-1===l.className.indexOf("hidden")?e():9===a.keyCode&&h(a)},!1),a.self!==a.top&&(c("height",Math.ceil(b.body.getBoundingClientRect().height)),q&&q.addEventListener("load",function(){c("height",Math.ceil(b.body.getBoundingClientRect().height))}),b.addEventListener("click",i))}}function e(){a.self!==a.top&&(clearTimeout(i),i=setTimeout(function(){c("height",Math.ceil(b.body.getBoundingClientRect().height))},100))}function f(){a.self===a.top||g||(g=a.location.hash.replace(/.*secret=([\d\w]{10}).*/,"$1"),clearTimeout(h),h=setTimeout(function(){f()},100))}var g,h,i,j=b.querySelector&&a.addEventListener,k=!1;j&&(f(),b.documentElement.className=b.documentElement.className.replace(/\bno-js\b/,"")+" js",b.addEventListener("DOMContentLoaded",d,!1),a.addEventListener("load",d,!1),a.addEventListener("resize",e,!1))}(window,document);
|
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 06:36:25 -04:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</script>
|
|
|
|
<?php
|
2015-10-07 17:43:25 -04:00
|
|
|
}
|
2015-10-29 19:11:24 -04: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 ) {
|
2016-02-25 05:23:27 -05:00
|
|
|
return str_replace( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $content );
|
2015-10-29 19:11:24 -04:00
|
|
|
}
|
2015-11-18 15:51:26 -05: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(
|
|
|
|
_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;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<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">
|
|
|
|
<button type="button" role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button>
|
|
|
|
</li>
|
|
|
|
<li class="wp-embed-share-tab-button wp-embed-share-tab-button-html" role="presentation">
|
|
|
|
<button type="button" role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<div id="wp-embed-share-tab-wordpress" class="wp-embed-share-tab" role="tabpanel" aria-hidden="false">
|
|
|
|
<input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" aria-describedby="wp-embed-share-description-wordpress" tabindex="0" readonly/>
|
|
|
|
|
|
|
|
<p class="wp-embed-share-description" id="wp-embed-share-description-wordpress">
|
|
|
|
<?php _e( 'Copy and paste this URL into your WordPress site to embed' ); ?>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-hidden="true">
|
|
|
|
<textarea class="wp-embed-share-input" aria-describedby="wp-embed-share-description-html" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( 600, 400 ) ); ?></textarea>
|
|
|
|
|
|
|
|
<p class="wp-embed-share-description" id="wp-embed-share-description-html">
|
|
|
|
<?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 15:57:26 -05:00
|
|
|
|
|
|
|
/**
|
2016-03-10 00:37:27 -05:00
|
|
|
* Prints the necessary markup for the site title in an embed template.
|
2016-02-24 15:57:26 -05:00
|
|
|
*
|
|
|
|
* @since 4.5.0
|
|
|
|
*/
|
|
|
|
function the_embed_site_title() {
|
|
|
|
$site_title = sprintf(
|
|
|
|
'<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>',
|
|
|
|
esc_url( home_url() ),
|
|
|
|
esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ),
|
|
|
|
esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ),
|
|
|
|
esc_html( get_bloginfo( 'name' ) )
|
|
|
|
);
|
|
|
|
|
|
|
|
$site_title = '<div class="wp-embed-site-title">' . $site_title . '</div>';
|
|
|
|
|
|
|
|
/**
|
2016-05-22 14:42:27 -04:00
|
|
|
* Filters the site title HTML in the embed footer.
|
2016-02-24 15:57:26 -05: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 07:23:28 -04: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 ) {
|
2017-09-27 04:36:48 -04:00
|
|
|
$switched_blog = false;
|
|
|
|
|
2017-09-26 04:40:47 -04:00
|
|
|
if ( is_multisite() ) {
|
|
|
|
$url_parts = wp_parse_args( wp_parse_url( $url ), array(
|
|
|
|
'host' => '',
|
|
|
|
'path' => '/',
|
|
|
|
) );
|
|
|
|
|
|
|
|
$qv = array( 'domain' => $url_parts['host'], 'path' => '/' );
|
|
|
|
|
|
|
|
// 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 );
|
|
|
|
|
|
|
|
if ( $site && (int) $site->blog_id !== get_current_blog_id() ) {
|
|
|
|
switch_to_blog( $site->blog_id );
|
2017-09-27 04:36:48 -04:00
|
|
|
$switched_blog = true;
|
2017-09-26 04:40:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-15 07:23:28 -04:00
|
|
|
$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 );
|
|
|
|
|
2016-06-16 13:18:28 -04:00
|
|
|
if ( ! $post_id ) {
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2016-06-15 07:23:28 -04:00
|
|
|
$width = isset( $args['width'] ) ? $args['width'] : 0;
|
|
|
|
|
|
|
|
$data = get_oembed_response_data( $post_id, $width );
|
|
|
|
$data = _wp_oembed_get_object()->data2html( (object) $data, $url );
|
|
|
|
|
2017-09-27 04:36:48 -04:00
|
|
|
if ( $switched_blog ) {
|
2017-09-26 04:40:47 -04:00
|
|
|
restore_current_blog();
|
|
|
|
}
|
|
|
|
|
2016-06-15 07:23:28 -04:00
|
|
|
if ( ! $data ) {
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|