Edit File by line
/home/barbar84/www/wp-inclu...
File: embed.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* oEmbed API: Top-level oEmbed functionality
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage oEmbed
[5] Fix | Delete
* @since 4.4.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Registers an embed handler.
[10] Fix | Delete
*
[11] Fix | Delete
* Should probably only be used for sites that do not support oEmbed.
[12] Fix | Delete
*
[13] Fix | Delete
* @since 2.9.0
[14] Fix | Delete
*
[15] Fix | Delete
* @global WP_Embed $wp_embed
[16] Fix | Delete
*
[17] Fix | Delete
* @param string $id An internal ID/name for the handler. Needs to be unique.
[18] Fix | Delete
* @param string $regex The regex that will be used to see if this handler should be used for a URL.
[19] Fix | Delete
* @param callable $callback The callback function that will be called if the regex is matched.
[20] Fix | Delete
* @param int $priority Optional. Used to specify the order in which the registered handlers will
[21] Fix | Delete
* be tested. Default 10.
[22] Fix | Delete
*/
[23] Fix | Delete
function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) {
[24] Fix | Delete
global $wp_embed;
[25] Fix | Delete
$wp_embed->register_handler( $id, $regex, $callback, $priority );
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Unregisters a previously-registered embed handler.
[30] Fix | Delete
*
[31] Fix | Delete
* @since 2.9.0
[32] Fix | Delete
*
[33] Fix | Delete
* @global WP_Embed $wp_embed
[34] Fix | Delete
*
[35] Fix | Delete
* @param string $id The handler ID that should be removed.
[36] Fix | Delete
* @param int $priority Optional. The priority of the handler to be removed. Default 10.
[37] Fix | Delete
*/
[38] Fix | Delete
function wp_embed_unregister_handler( $id, $priority = 10 ) {
[39] Fix | Delete
global $wp_embed;
[40] Fix | Delete
$wp_embed->unregister_handler( $id, $priority );
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Creates default array of embed parameters.
[45] Fix | Delete
*
[46] Fix | Delete
* The width defaults to the content width as specified by the theme. If the
[47] Fix | Delete
* theme does not specify a content width, then 500px is used.
[48] Fix | Delete
*
[49] Fix | Delete
* The default height is 1.5 times the width, or 1000px, whichever is smaller.
[50] Fix | Delete
*
[51] Fix | Delete
* The {@see 'embed_defaults'} filter can be used to adjust either of these values.
[52] Fix | Delete
*
[53] Fix | Delete
* @since 2.9.0
[54] Fix | Delete
*
[55] Fix | Delete
* @global int $content_width
[56] Fix | Delete
*
[57] Fix | Delete
* @param string $url Optional. The URL that should be embedded. Default empty.
[58] Fix | Delete
* @return array {
[59] Fix | Delete
* Indexed array of the embed width and height in pixels.
[60] Fix | Delete
*
[61] Fix | Delete
* @type int $0 The embed width.
[62] Fix | Delete
* @type int $1 The embed height.
[63] Fix | Delete
* }
[64] Fix | Delete
*/
[65] Fix | Delete
function wp_embed_defaults( $url = '' ) {
[66] Fix | Delete
if ( ! empty( $GLOBALS['content_width'] ) ) {
[67] Fix | Delete
$width = (int) $GLOBALS['content_width'];
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
if ( empty( $width ) ) {
[71] Fix | Delete
$width = 500;
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
$height = min( ceil( $width * 1.5 ), 1000 );
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Filters the default array of embed dimensions.
[78] Fix | Delete
*
[79] Fix | Delete
* @since 2.9.0
[80] Fix | Delete
*
[81] Fix | Delete
* @param int[] $size {
[82] Fix | Delete
* Indexed array of the embed width and height in pixels.
[83] Fix | Delete
*
[84] Fix | Delete
* @type int $0 The embed width.
[85] Fix | Delete
* @type int $1 The embed height.
[86] Fix | Delete
* }
[87] Fix | Delete
* @param string $url The URL that should be embedded.
[88] Fix | Delete
*/
[89] Fix | Delete
return apply_filters( 'embed_defaults', compact( 'width', 'height' ), $url );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Attempts to fetch the embed HTML for a provided URL using oEmbed.
[94] Fix | Delete
*
[95] Fix | Delete
* @since 2.9.0
[96] Fix | Delete
*
[97] Fix | Delete
* @see WP_oEmbed
[98] Fix | Delete
*
[99] Fix | Delete
* @param string $url The URL that should be embedded.
[100] Fix | Delete
* @param array|string $args {
[101] Fix | Delete
* Optional. Additional arguments for retrieving embed HTML. Default empty.
[102] Fix | Delete
*
[103] Fix | Delete
* @type int|string $width Optional. The `maxwidth` value passed to the provider URL.
[104] Fix | Delete
* @type int|string $height Optional. The `maxheight` value passed to the provider URL.
[105] Fix | Delete
* @type bool $discover Optional. Determines whether to attempt to discover link tags
[106] Fix | Delete
* at the given URL for an oEmbed provider when the provider URL
[107] Fix | Delete
* is not found in the built-in providers list. Default true.
[108] Fix | Delete
* }
[109] Fix | Delete
* @return string|false The embed HTML on success, false on failure.
[110] Fix | Delete
*/
[111] Fix | Delete
function wp_oembed_get( $url, $args = '' ) {
[112] Fix | Delete
$oembed = _wp_oembed_get_object();
[113] Fix | Delete
return $oembed->get_html( $url, $args );
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Returns the initialized WP_oEmbed object.
[118] Fix | Delete
*
[119] Fix | Delete
* @since 2.9.0
[120] Fix | Delete
* @access private
[121] Fix | Delete
*
[122] Fix | Delete
* @return WP_oEmbed object.
[123] Fix | Delete
*/
[124] Fix | Delete
function _wp_oembed_get_object() {
[125] Fix | Delete
static $wp_oembed = null;
[126] Fix | Delete
[127] Fix | Delete
if ( is_null( $wp_oembed ) ) {
[128] Fix | Delete
$wp_oembed = new WP_oEmbed();
[129] Fix | Delete
}
[130] Fix | Delete
return $wp_oembed;
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
/**
[134] Fix | Delete
* Adds a URL format and oEmbed provider URL pair.
[135] Fix | Delete
*
[136] Fix | Delete
* @since 2.9.0
[137] Fix | Delete
*
[138] Fix | Delete
* @see WP_oEmbed
[139] Fix | Delete
*
[140] Fix | Delete
* @param string $format The format of URL that this provider can handle. You can use asterisks
[141] Fix | Delete
* as wildcards.
[142] Fix | Delete
* @param string $provider The URL to the oEmbed provider.
[143] Fix | Delete
* @param bool $regex Optional. Whether the `$format` parameter is in a RegEx format. Default false.
[144] Fix | Delete
*/
[145] Fix | Delete
function wp_oembed_add_provider( $format, $provider, $regex = false ) {
[146] Fix | Delete
if ( did_action( 'plugins_loaded' ) ) {
[147] Fix | Delete
$oembed = _wp_oembed_get_object();
[148] Fix | Delete
$oembed->providers[ $format ] = array( $provider, $regex );
[149] Fix | Delete
} else {
[150] Fix | Delete
WP_oEmbed::_add_provider_early( $format, $provider, $regex );
[151] Fix | Delete
}
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
/**
[155] Fix | Delete
* Removes an oEmbed provider.
[156] Fix | Delete
*
[157] Fix | Delete
* @since 3.5.0
[158] Fix | Delete
*
[159] Fix | Delete
* @see WP_oEmbed
[160] Fix | Delete
*
[161] Fix | Delete
* @param string $format The URL format for the oEmbed provider to remove.
[162] Fix | Delete
* @return bool Was the provider removed successfully?
[163] Fix | Delete
*/
[164] Fix | Delete
function wp_oembed_remove_provider( $format ) {
[165] Fix | Delete
if ( did_action( 'plugins_loaded' ) ) {
[166] Fix | Delete
$oembed = _wp_oembed_get_object();
[167] Fix | Delete
[168] Fix | Delete
if ( isset( $oembed->providers[ $format ] ) ) {
[169] Fix | Delete
unset( $oembed->providers[ $format ] );
[170] Fix | Delete
return true;
[171] Fix | Delete
}
[172] Fix | Delete
} else {
[173] Fix | Delete
WP_oEmbed::_remove_provider_early( $format );
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
return false;
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* Determines if default embed handlers should be loaded.
[181] Fix | Delete
*
[182] Fix | Delete
* Checks to make sure that the embeds library hasn't already been loaded. If
[183] Fix | Delete
* it hasn't, then it will load the embeds library.
[184] Fix | Delete
*
[185] Fix | Delete
* @since 2.9.0
[186] Fix | Delete
*
[187] Fix | Delete
* @see wp_embed_register_handler()
[188] Fix | Delete
*/
[189] Fix | Delete
function wp_maybe_load_embeds() {
[190] Fix | Delete
/**
[191] Fix | Delete
* Filters whether to load the default embed handlers.
[192] Fix | Delete
*
[193] Fix | Delete
* Returning a falsey value will prevent loading the default embed handlers.
[194] Fix | Delete
*
[195] Fix | Delete
* @since 2.9.0
[196] Fix | Delete
*
[197] Fix | Delete
* @param bool $maybe_load_embeds Whether to load the embeds library. Default true.
[198] Fix | Delete
*/
[199] Fix | Delete
if ( ! apply_filters( 'load_default_embeds', true ) ) {
[200] Fix | Delete
return;
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' );
[204] Fix | Delete
[205] Fix | Delete
/**
[206] Fix | Delete
* Filters the audio embed handler callback.
[207] Fix | Delete
*
[208] Fix | Delete
* @since 3.6.0
[209] Fix | Delete
*
[210] Fix | Delete
* @param callable $handler Audio embed handler callback function.
[211] Fix | Delete
*/
[212] Fix | Delete
wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . implode( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 );
[213] Fix | Delete
[214] Fix | Delete
/**
[215] Fix | Delete
* Filters the video embed handler callback.
[216] Fix | Delete
*
[217] Fix | Delete
* @since 3.6.0
[218] Fix | Delete
*
[219] Fix | Delete
* @param callable $handler Video embed handler callback function.
[220] Fix | Delete
*/
[221] Fix | Delete
wp_embed_register_handler( 'video', '#^https?://.+?\.(' . implode( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 );
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
/**
[225] Fix | Delete
* YouTube iframe embed handler callback.
[226] Fix | Delete
*
[227] Fix | Delete
* Catches YouTube iframe embed URLs that are not parsable by oEmbed but can be translated into a URL that is.
[228] Fix | Delete
*
[229] Fix | Delete
* @since 4.0.0
[230] Fix | Delete
*
[231] Fix | Delete
* @global WP_Embed $wp_embed
[232] Fix | Delete
*
[233] Fix | Delete
* @param array $matches The RegEx matches from the provided regex when calling
[234] Fix | Delete
* wp_embed_register_handler().
[235] Fix | Delete
* @param array $attr Embed attributes.
[236] Fix | Delete
* @param string $url The original URL that was matched by the regex.
[237] Fix | Delete
* @param array $rawattr The original unmodified attributes.
[238] Fix | Delete
* @return string The embed HTML.
[239] Fix | Delete
*/
[240] Fix | Delete
function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
[241] Fix | Delete
global $wp_embed;
[242] Fix | Delete
$embed = $wp_embed->autoembed( sprintf( 'https://youtube.com/watch?v=%s', urlencode( $matches[2] ) ) );
[243] Fix | Delete
[244] Fix | Delete
/**
[245] Fix | Delete
* Filters the YoutTube embed output.
[246] Fix | Delete
*
[247] Fix | Delete
* @since 4.0.0
[248] Fix | Delete
*
[249] Fix | Delete
* @see wp_embed_handler_youtube()
[250] Fix | Delete
*
[251] Fix | Delete
* @param string $embed YouTube embed output.
[252] Fix | Delete
* @param array $attr An array of embed attributes.
[253] Fix | Delete
* @param string $url The original URL that was matched by the regex.
[254] Fix | Delete
* @param array $rawattr The original unmodified attributes.
[255] Fix | Delete
*/
[256] Fix | Delete
return apply_filters( 'wp_embed_handler_youtube', $embed, $attr, $url, $rawattr );
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
/**
[260] Fix | Delete
* Audio embed handler callback.
[261] Fix | Delete
*
[262] Fix | Delete
* @since 3.6.0
[263] Fix | Delete
*
[264] Fix | Delete
* @param array $matches The RegEx matches from the provided regex when calling wp_embed_register_handler().
[265] Fix | Delete
* @param array $attr Embed attributes.
[266] Fix | Delete
* @param string $url The original URL that was matched by the regex.
[267] Fix | Delete
* @param array $rawattr The original unmodified attributes.
[268] Fix | Delete
* @return string The embed HTML.
[269] Fix | Delete
*/
[270] Fix | Delete
function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) {
[271] Fix | Delete
$audio = sprintf( '[audio src="%s" /]', esc_url( $url ) );
[272] Fix | Delete
[273] Fix | Delete
/**
[274] Fix | Delete
* Filters the audio embed output.
[275] Fix | Delete
*
[276] Fix | Delete
* @since 3.6.0
[277] Fix | Delete
*
[278] Fix | Delete
* @param string $audio Audio embed output.
[279] Fix | Delete
* @param array $attr An array of embed attributes.
[280] Fix | Delete
* @param string $url The original URL that was matched by the regex.
[281] Fix | Delete
* @param array $rawattr The original unmodified attributes.
[282] Fix | Delete
*/
[283] Fix | Delete
return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr );
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
/**
[287] Fix | Delete
* Video embed handler callback.
[288] Fix | Delete
*
[289] Fix | Delete
* @since 3.6.0
[290] Fix | Delete
*
[291] Fix | Delete
* @param array $matches The RegEx matches from the provided regex when calling wp_embed_register_handler().
[292] Fix | Delete
* @param array $attr Embed attributes.
[293] Fix | Delete
* @param string $url The original URL that was matched by the regex.
[294] Fix | Delete
* @param array $rawattr The original unmodified attributes.
[295] Fix | Delete
* @return string The embed HTML.
[296] Fix | Delete
*/
[297] Fix | Delete
function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) {
[298] Fix | Delete
$dimensions = '';
[299] Fix | Delete
if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) {
[300] Fix | Delete
$dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] );
[301] Fix | Delete
$dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] );
[302] Fix | Delete
}
[303] Fix | Delete
$video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) );
[304] Fix | Delete
[305] Fix | Delete
/**
[306] Fix | Delete
* Filters the video embed output.
[307] Fix | Delete
*
[308] Fix | Delete
* @since 3.6.0
[309] Fix | Delete
*
[310] Fix | Delete
* @param string $video Video embed output.
[311] Fix | Delete
* @param array $attr An array of embed attributes.
[312] Fix | Delete
* @param string $url The original URL that was matched by the regex.
[313] Fix | Delete
* @param array $rawattr The original unmodified attributes.
[314] Fix | Delete
*/
[315] Fix | Delete
return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr );
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
/**
[319] Fix | Delete
* Registers the oEmbed REST API route.
[320] Fix | Delete
*
[321] Fix | Delete
* @since 4.4.0
[322] Fix | Delete
*/
[323] Fix | Delete
function wp_oembed_register_route() {
[324] Fix | Delete
$controller = new WP_oEmbed_Controller();
[325] Fix | Delete
$controller->register_routes();
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
/**
[329] Fix | Delete
* Adds oEmbed discovery links in the website <head>.
[330] Fix | Delete
*
[331] Fix | Delete
* @since 4.4.0
[332] Fix | Delete
*/
[333] Fix | Delete
function wp_oembed_add_discovery_links() {
[334] Fix | Delete
$output = '';
[335] Fix | Delete
[336] Fix | Delete
if ( is_singular() ) {
[337] Fix | Delete
$output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
[338] Fix | Delete
[339] Fix | Delete
if ( class_exists( 'SimpleXMLElement' ) ) {
[340] Fix | Delete
$output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
[341] Fix | Delete
}
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
/**
[345] Fix | Delete
* Filters the oEmbed discovery links HTML.
[346] Fix | Delete
*
[347] Fix | Delete
* @since 4.4.0
[348] Fix | Delete
*
[349] Fix | Delete
* @param string $output HTML of the discovery links.
[350] Fix | Delete
*/
[351] Fix | Delete
echo apply_filters( 'oembed_discovery_links', $output );
[352] Fix | Delete
}
[353] Fix | Delete
[354] Fix | Delete
/**
[355] Fix | Delete
* Adds the necessary JavaScript to communicate with the embedded iframes.
[356] Fix | Delete
*
[357] Fix | Delete
* @since 4.4.0
[358] Fix | Delete
*/
[359] Fix | Delete
function wp_oembed_add_host_js() {
[360] Fix | Delete
wp_enqueue_script( 'wp-embed' );
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
/**
[364] Fix | Delete
* Retrieves the URL to embed a specific post in an iframe.
[365] Fix | Delete
*
[366] Fix | Delete
* @since 4.4.0
[367] Fix | Delete
*
[368] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post.
[369] Fix | Delete
* @return string|false The post embed URL on success, false if the post doesn't exist.
[370] Fix | Delete
*/
[371] Fix | Delete
function get_post_embed_url( $post = null ) {
[372] Fix | Delete
$post = get_post( $post );
[373] Fix | Delete
[374] Fix | Delete
if ( ! $post ) {
[375] Fix | Delete
return false;
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
$embed_url = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' );
[379] Fix | Delete
$path_conflict = get_page_by_path( str_replace( home_url(), '', $embed_url ), OBJECT, get_post_types( array( 'public' => true ) ) );
[380] Fix | Delete
[381] Fix | Delete
if ( ! get_option( 'permalink_structure' ) || $path_conflict ) {
[382] Fix | Delete
$embed_url = add_query_arg( array( 'embed' => 'true' ), get_permalink( $post ) );
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
/**
[386] Fix | Delete
* Filters the URL to embed a specific post.
[387] Fix | Delete
*
[388] Fix | Delete
* @since 4.4.0
[389] Fix | Delete
*
[390] Fix | Delete
* @param string $embed_url The post embed URL.
[391] Fix | Delete
* @param WP_Post $post The corresponding post object.
[392] Fix | Delete
*/
[393] Fix | Delete
return esc_url_raw( apply_filters( 'post_embed_url', $embed_url, $post ) );
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
/**
[397] Fix | Delete
* Retrieves the oEmbed endpoint URL for a given permalink.
[398] Fix | Delete
*
[399] Fix | Delete
* Pass an empty string as the first argument to get the endpoint base URL.
[400] Fix | Delete
*
[401] Fix | Delete
* @since 4.4.0
[402] Fix | Delete
*
[403] Fix | Delete
* @param string $permalink Optional. The permalink used for the `url` query arg. Default empty.
[404] Fix | Delete
* @param string $format Optional. The requested response format. Default 'json'.
[405] Fix | Delete
* @return string The oEmbed endpoint URL.
[406] Fix | Delete
*/
[407] Fix | Delete
function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) {
[408] Fix | Delete
$url = rest_url( 'oembed/1.0/embed' );
[409] Fix | Delete
[410] Fix | Delete
if ( '' !== $permalink ) {
[411] Fix | Delete
$url = add_query_arg(
[412] Fix | Delete
array(
[413] Fix | Delete
'url' => urlencode( $permalink ),
[414] Fix | Delete
'format' => ( 'json' !== $format ) ? $format : false,
[415] Fix | Delete
),
[416] Fix | Delete
$url
[417] Fix | Delete
);
[418] Fix | Delete
}
[419] Fix | Delete
[420] Fix | Delete
/**
[421] Fix | Delete
* Filters the oEmbed endpoint URL.
[422] Fix | Delete
*
[423] Fix | Delete
* @since 4.4.0
[424] Fix | Delete
*
[425] Fix | Delete
* @param string $url The URL to the oEmbed endpoint.
[426] Fix | Delete
* @param string $permalink The permalink used for the `url` query arg.
[427] Fix | Delete
* @param string $format The requested response format.
[428] Fix | Delete
*/
[429] Fix | Delete
return apply_filters( 'oembed_endpoint_url', $url, $permalink, $format );
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
/**
[433] Fix | Delete
* Retrieves the embed code for a specific post.
[434] Fix | Delete
*
[435] Fix | Delete
* @since 4.4.0
[436] Fix | Delete
*
[437] Fix | Delete
* @param int $width The width for the response.
[438] Fix | Delete
* @param int $height The height for the response.
[439] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`.
[440] Fix | Delete
* @return string|false Embed code on success, false if post doesn't exist.
[441] Fix | Delete
*/
[442] Fix | Delete
function get_post_embed_html( $width, $height, $post = null ) {
[443] Fix | Delete
$post = get_post( $post );
[444] Fix | Delete
[445] Fix | Delete
if ( ! $post ) {
[446] Fix | Delete
return false;
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
$embed_url = get_post_embed_url( $post );
[450] Fix | Delete
[451] Fix | Delete
$output = '<blockquote class="wp-embedded-content"><a href="' . esc_url( get_permalink( $post ) ) . '">' . get_the_title( $post ) . "</a></blockquote>\n";
[452] Fix | Delete
[453] Fix | Delete
$output .= "<script type='text/javascript'>\n";
[454] Fix | Delete
$output .= "<!--//--><![CDATA[//><!--\n";
[455] Fix | Delete
if ( SCRIPT_DEBUG ) {
[456] Fix | Delete
$output .= file_get_contents( ABSPATH . WPINC . '/js/wp-embed.js' );
[457] Fix | Delete
} else {
[458] Fix | Delete
/*
[459] Fix | Delete
* If you're looking at a src version of this file, you'll see an "include"
[460] Fix | Delete
* statement below. This is used by the `npm run build` process to directly
[461] Fix | Delete
* include a minified version of wp-embed.js, instead of using the
[462] Fix | Delete
* file_get_contents() method from above.
[463] Fix | Delete
*
[464] Fix | Delete
* If you're looking at a build version of this file, you'll see a string of
[465] Fix | Delete
* minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
[466] Fix | Delete
* and edit wp-embed.js directly.
[467] Fix | Delete
*/
[468] Fix | Delete
$output .= <<<JS
[469] Fix | Delete
/*! This file is auto-generated */
[470] Fix | Delete
!function(d,l){"use strict";var e=!1,n=!1;if(l.querySelector)if(d.addEventListener)e=!0;if(d.wp=d.wp||{},!d.wp.receiveEmbedMessage)if(d.wp.receiveEmbedMessage=function(e){var t=e.data;if(t)if(t.secret||t.message||t.value)if(!/[^a-zA-Z0-9]/.test(t.secret)){for(var r,i,a,s=l.querySelectorAll('iframe[data-secret="'+t.secret+'"]'),n=l.querySelectorAll('blockquote[data-secret="'+t.secret+'"]'),o=new RegExp("^https?:$","i"),c=0;c<n.length;c++)n[c].style.display="none";for(c=0;c<s.length;c++)if(r=s[c],e.source===r.contentWindow){if(r.removeAttribute("style"),"height"===t.message){if(1e3<(a=parseInt(t.value,10)))a=1e3;else if(~~a<200)a=200;r.height=a}if("link"===t.message)if(i=l.createElement("a"),a=l.createElement("a"),i.href=r.getAttribute("src"),a.href=t.value,o.test(a.protocol))if(a.host===i.host)if(l.activeElement===r)d.top.location.href=t.value}}},e)d.addEventListener("message",d.wp.receiveEmbedMessage,!1),l.addEventListener("DOMContentLoaded",t,!1),d.addEventListener("load",t,!1);function t(){if(!n){n=!0;for(var e,t,r=-1!==navigator.appVersion.indexOf("MSIE 10"),i=!!navigator.userAgent.match(/Trident.*rv:11\./),a=l.querySelectorAll("iframe.wp-embedded-content"),s=0;s<a.length;s++){if(!(e=a[s]).getAttribute("data-secret"))t=Math.random().toString(36).substr(2,10),e.src+="#?secret="+t,e.setAttribute("data-secret",t);if(r||i)(t=e.cloneNode(!0)).removeAttribute("security"),e.parentNode.replaceChild(t,e)}}}}(window,document);
[471] Fix | Delete
JS;
[472] Fix | Delete
}
[473] Fix | Delete
$output .= "\n//--><!]]>";
[474] Fix | Delete
$output .= "\n</script>";
[475] Fix | Delete
[476] Fix | Delete
$output .= sprintf(
[477] Fix | Delete
'<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>',
[478] Fix | Delete
esc_url( $embed_url ),
[479] Fix | Delete
absint( $width ),
[480] Fix | Delete
absint( $height ),
[481] Fix | Delete
esc_attr(
[482] Fix | Delete
sprintf(
[483] Fix | Delete
/* translators: 1: Post title, 2: Site title. */
[484] Fix | Delete
__( '&#8220;%1$s&#8221; &#8212; %2$s' ),
[485] Fix | Delete
get_the_title( $post ),
[486] Fix | Delete
get_bloginfo( 'name' )
[487] Fix | Delete
)
[488] Fix | Delete
)
[489] Fix | Delete
);
[490] Fix | Delete
[491] Fix | Delete
/**
[492] Fix | Delete
* Filters the embed HTML output for a given post.
[493] Fix | Delete
*
[494] Fix | Delete
* @since 4.4.0
[495] Fix | Delete
*
[496] Fix | Delete
* @param string $output The default iframe tag to display embedded content.
[497] Fix | Delete
* @param WP_Post $post Current post object.
[498] Fix | Delete
* @param int $width Width of the response.
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function