Edit File by line
/home/barbar84/www/wp-inclu...
File: class-wp-embed.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* API for easily embedding rich media such as videos and images into content.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Embed
[5] Fix | Delete
* @since 2.9.0
[6] Fix | Delete
*/
[7] Fix | Delete
class WP_Embed {
[8] Fix | Delete
public $handlers = array();
[9] Fix | Delete
public $post_ID;
[10] Fix | Delete
public $usecache = true;
[11] Fix | Delete
public $linkifunknown = true;
[12] Fix | Delete
public $last_attr = array();
[13] Fix | Delete
public $last_url = '';
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* When a URL cannot be embedded, return false instead of returning a link
[17] Fix | Delete
* or the URL.
[18] Fix | Delete
*
[19] Fix | Delete
* Bypasses the {@see 'embed_maybe_make_link'} filter.
[20] Fix | Delete
*
[21] Fix | Delete
* @var bool
[22] Fix | Delete
*/
[23] Fix | Delete
public $return_false_on_fail = false;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Constructor
[27] Fix | Delete
*/
[28] Fix | Delete
public function __construct() {
[29] Fix | Delete
// Hack to get the [embed] shortcode to run before wpautop().
[30] Fix | Delete
add_filter( 'the_content', array( $this, 'run_shortcode' ), 8 );
[31] Fix | Delete
add_filter( 'widget_text_content', array( $this, 'run_shortcode' ), 8 );
[32] Fix | Delete
[33] Fix | Delete
// Shortcode placeholder for strip_shortcodes().
[34] Fix | Delete
add_shortcode( 'embed', '__return_false' );
[35] Fix | Delete
[36] Fix | Delete
// Attempts to embed all URLs in a post.
[37] Fix | Delete
add_filter( 'the_content', array( $this, 'autoembed' ), 8 );
[38] Fix | Delete
add_filter( 'widget_text_content', array( $this, 'autoembed' ), 8 );
[39] Fix | Delete
[40] Fix | Delete
// After a post is saved, cache oEmbed items via Ajax.
[41] Fix | Delete
add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) );
[42] Fix | Delete
add_action( 'edit_page_form', array( $this, 'maybe_run_ajax_cache' ) );
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Process the [embed] shortcode.
[47] Fix | Delete
*
[48] Fix | Delete
* Since the [embed] shortcode needs to be run earlier than other shortcodes,
[49] Fix | Delete
* this function removes all existing shortcodes, registers the [embed] shortcode,
[50] Fix | Delete
* calls do_shortcode(), and then re-registers the old shortcodes.
[51] Fix | Delete
*
[52] Fix | Delete
* @global array $shortcode_tags
[53] Fix | Delete
*
[54] Fix | Delete
* @param string $content Content to parse
[55] Fix | Delete
* @return string Content with shortcode parsed
[56] Fix | Delete
*/
[57] Fix | Delete
public function run_shortcode( $content ) {
[58] Fix | Delete
global $shortcode_tags;
[59] Fix | Delete
[60] Fix | Delete
// Back up current registered shortcodes and clear them all out.
[61] Fix | Delete
$orig_shortcode_tags = $shortcode_tags;
[62] Fix | Delete
remove_all_shortcodes();
[63] Fix | Delete
[64] Fix | Delete
add_shortcode( 'embed', array( $this, 'shortcode' ) );
[65] Fix | Delete
[66] Fix | Delete
// Do the shortcode (only the [embed] one is registered).
[67] Fix | Delete
$content = do_shortcode( $content, true );
[68] Fix | Delete
[69] Fix | Delete
// Put the original shortcodes back.
[70] Fix | Delete
$shortcode_tags = $orig_shortcode_tags;
[71] Fix | Delete
[72] Fix | Delete
return $content;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* If a post/page was saved, then output JavaScript to make
[77] Fix | Delete
* an Ajax request that will call WP_Embed::cache_oembed().
[78] Fix | Delete
*/
[79] Fix | Delete
public function maybe_run_ajax_cache() {
[80] Fix | Delete
$post = get_post();
[81] Fix | Delete
[82] Fix | Delete
if ( ! $post || empty( $_GET['message'] ) ) {
[83] Fix | Delete
return;
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
?>
[87] Fix | Delete
<script type="text/javascript">
[88] Fix | Delete
jQuery(document).ready(function($){
[89] Fix | Delete
$.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post->ID, 'relative' ); ?>");
[90] Fix | Delete
});
[91] Fix | Delete
</script>
[92] Fix | Delete
<?php
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Registers an embed handler.
[97] Fix | Delete
*
[98] Fix | Delete
* Do not use this function directly, use wp_embed_register_handler() instead.
[99] Fix | Delete
*
[100] Fix | Delete
* This function should probably also only be used for sites that do not support oEmbed.
[101] Fix | Delete
*
[102] Fix | Delete
* @param string $id An internal ID/name for the handler. Needs to be unique.
[103] Fix | Delete
* @param string $regex The regex that will be used to see if this handler should be used for a URL.
[104] Fix | Delete
* @param callable $callback The callback function that will be called if the regex is matched.
[105] Fix | Delete
* @param int $priority Optional. Used to specify the order in which the registered handlers will be tested.
[106] Fix | Delete
* Lower numbers correspond with earlier testing, and handlers with the same priority are
[107] Fix | Delete
* tested in the order in which they were added to the action. Default 10.
[108] Fix | Delete
*/
[109] Fix | Delete
public function register_handler( $id, $regex, $callback, $priority = 10 ) {
[110] Fix | Delete
$this->handlers[ $priority ][ $id ] = array(
[111] Fix | Delete
'regex' => $regex,
[112] Fix | Delete
'callback' => $callback,
[113] Fix | Delete
);
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Unregisters a previously-registered embed handler.
[118] Fix | Delete
*
[119] Fix | Delete
* Do not use this function directly, use wp_embed_unregister_handler() instead.
[120] Fix | Delete
*
[121] Fix | Delete
* @param string $id The handler ID that should be removed.
[122] Fix | Delete
* @param int $priority Optional. The priority of the handler to be removed (default: 10).
[123] Fix | Delete
*/
[124] Fix | Delete
public function unregister_handler( $id, $priority = 10 ) {
[125] Fix | Delete
unset( $this->handlers[ $priority ][ $id ] );
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
/**
[129] Fix | Delete
* Returns embed HTML for a given URL from embed handlers.
[130] Fix | Delete
*
[131] Fix | Delete
* Attempts to convert a URL into embed HTML by checking the URL
[132] Fix | Delete
* against the regex of the registered embed handlers.
[133] Fix | Delete
*
[134] Fix | Delete
* @since 5.5.0
[135] Fix | Delete
*
[136] Fix | Delete
* @param array $attr {
[137] Fix | Delete
* Shortcode attributes. Optional.
[138] Fix | Delete
*
[139] Fix | Delete
* @type int $width Width of the embed in pixels.
[140] Fix | Delete
* @type int $height Height of the embed in pixels.
[141] Fix | Delete
* }
[142] Fix | Delete
* @param string $url The URL attempting to be embedded.
[143] Fix | Delete
* @return string|false The embed HTML on success, false otherwise.
[144] Fix | Delete
*/
[145] Fix | Delete
public function get_embed_handler_html( $attr, $url ) {
[146] Fix | Delete
$rawattr = $attr;
[147] Fix | Delete
$attr = wp_parse_args( $attr, wp_embed_defaults( $url ) );
[148] Fix | Delete
[149] Fix | Delete
ksort( $this->handlers );
[150] Fix | Delete
foreach ( $this->handlers as $priority => $handlers ) {
[151] Fix | Delete
foreach ( $handlers as $id => $handler ) {
[152] Fix | Delete
if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
[153] Fix | Delete
$return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr );
[154] Fix | Delete
if ( false !== $return ) {
[155] Fix | Delete
/**
[156] Fix | Delete
* Filters the returned embed HTML.
[157] Fix | Delete
*
[158] Fix | Delete
* @since 2.9.0
[159] Fix | Delete
*
[160] Fix | Delete
* @see WP_Embed::shortcode()
[161] Fix | Delete
*
[162] Fix | Delete
* @param string|false $return The HTML result of the shortcode, or false on failure.
[163] Fix | Delete
* @param string $url The embed URL.
[164] Fix | Delete
* @param array $attr An array of shortcode attributes.
[165] Fix | Delete
*/
[166] Fix | Delete
return apply_filters( 'embed_handler_html', $return, $url, $attr );
[167] Fix | Delete
}
[168] Fix | Delete
}
[169] Fix | Delete
}
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
return false;
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
/**
[176] Fix | Delete
* The do_shortcode() callback function.
[177] Fix | Delete
*
[178] Fix | Delete
* Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of
[179] Fix | Delete
* the registered embed handlers. If none of the regex matches and it's enabled, then the URL
[180] Fix | Delete
* will be given to the WP_oEmbed class.
[181] Fix | Delete
*
[182] Fix | Delete
* @param array $attr {
[183] Fix | Delete
* Shortcode attributes. Optional.
[184] Fix | Delete
*
[185] Fix | Delete
* @type int $width Width of the embed in pixels.
[186] Fix | Delete
* @type int $height Height of the embed in pixels.
[187] Fix | Delete
* }
[188] Fix | Delete
* @param string $url The URL attempting to be embedded.
[189] Fix | Delete
* @return string|false The embed HTML on success, otherwise the original URL.
[190] Fix | Delete
* `->maybe_make_link()` can return false on failure.
[191] Fix | Delete
*/
[192] Fix | Delete
public function shortcode( $attr, $url = '' ) {
[193] Fix | Delete
$post = get_post();
[194] Fix | Delete
[195] Fix | Delete
if ( empty( $url ) && ! empty( $attr['src'] ) ) {
[196] Fix | Delete
$url = $attr['src'];
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
$this->last_url = $url;
[200] Fix | Delete
[201] Fix | Delete
if ( empty( $url ) ) {
[202] Fix | Delete
$this->last_attr = $attr;
[203] Fix | Delete
return '';
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
$rawattr = $attr;
[207] Fix | Delete
$attr = wp_parse_args( $attr, wp_embed_defaults( $url ) );
[208] Fix | Delete
[209] Fix | Delete
$this->last_attr = $attr;
[210] Fix | Delete
[211] Fix | Delete
// KSES converts & into &amp; and we need to undo this.
[212] Fix | Delete
// See https://core.trac.wordpress.org/ticket/11311
[213] Fix | Delete
$url = str_replace( '&amp;', '&', $url );
[214] Fix | Delete
[215] Fix | Delete
// Look for known internal handlers.
[216] Fix | Delete
$embed_handler_html = $this->get_embed_handler_html( $rawattr, $url );
[217] Fix | Delete
if ( false !== $embed_handler_html ) {
[218] Fix | Delete
return $embed_handler_html;
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
$post_ID = ( ! empty( $post->ID ) ) ? $post->ID : null;
[222] Fix | Delete
[223] Fix | Delete
// Potentially set by WP_Embed::cache_oembed().
[224] Fix | Delete
if ( ! empty( $this->post_ID ) ) {
[225] Fix | Delete
$post_ID = $this->post_ID;
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
// Check for a cached result (stored as custom post or in the post meta).
[229] Fix | Delete
$key_suffix = md5( $url . serialize( $attr ) );
[230] Fix | Delete
$cachekey = '_oembed_' . $key_suffix;
[231] Fix | Delete
$cachekey_time = '_oembed_time_' . $key_suffix;
[232] Fix | Delete
[233] Fix | Delete
/**
[234] Fix | Delete
* Filters the oEmbed TTL value (time to live).
[235] Fix | Delete
*
[236] Fix | Delete
* @since 4.0.0
[237] Fix | Delete
*
[238] Fix | Delete
* @param int $time Time to live (in seconds).
[239] Fix | Delete
* @param string $url The attempted embed URL.
[240] Fix | Delete
* @param array $attr An array of shortcode attributes.
[241] Fix | Delete
* @param int $post_ID Post ID.
[242] Fix | Delete
*/
[243] Fix | Delete
$ttl = apply_filters( 'oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_ID );
[244] Fix | Delete
[245] Fix | Delete
$cache = '';
[246] Fix | Delete
$cache_time = 0;
[247] Fix | Delete
[248] Fix | Delete
$cached_post_id = $this->find_oembed_post_id( $key_suffix );
[249] Fix | Delete
[250] Fix | Delete
if ( $post_ID ) {
[251] Fix | Delete
$cache = get_post_meta( $post_ID, $cachekey, true );
[252] Fix | Delete
$cache_time = get_post_meta( $post_ID, $cachekey_time, true );
[253] Fix | Delete
[254] Fix | Delete
if ( ! $cache_time ) {
[255] Fix | Delete
$cache_time = 0;
[256] Fix | Delete
}
[257] Fix | Delete
} elseif ( $cached_post_id ) {
[258] Fix | Delete
$cached_post = get_post( $cached_post_id );
[259] Fix | Delete
[260] Fix | Delete
$cache = $cached_post->post_content;
[261] Fix | Delete
$cache_time = strtotime( $cached_post->post_modified_gmt );
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
$cached_recently = ( time() - $cache_time ) < $ttl;
[265] Fix | Delete
[266] Fix | Delete
if ( $this->usecache || $cached_recently ) {
[267] Fix | Delete
// Failures are cached. Serve one if we're using the cache.
[268] Fix | Delete
if ( '{{unknown}}' === $cache ) {
[269] Fix | Delete
return $this->maybe_make_link( $url );
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
if ( ! empty( $cache ) ) {
[273] Fix | Delete
/**
[274] Fix | Delete
* Filters the cached oEmbed HTML.
[275] Fix | Delete
*
[276] Fix | Delete
* @since 2.9.0
[277] Fix | Delete
*
[278] Fix | Delete
* @see WP_Embed::shortcode()
[279] Fix | Delete
*
[280] Fix | Delete
* @param string|false $cache The cached HTML result, stored in post meta.
[281] Fix | Delete
* @param string $url The attempted embed URL.
[282] Fix | Delete
* @param array $attr An array of shortcode attributes.
[283] Fix | Delete
* @param int $post_ID Post ID.
[284] Fix | Delete
*/
[285] Fix | Delete
return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID );
[286] Fix | Delete
}
[287] Fix | Delete
}
[288] Fix | Delete
[289] Fix | Delete
/**
[290] Fix | Delete
* Filters whether to inspect the given URL for discoverable link tags.
[291] Fix | Delete
*
[292] Fix | Delete
* @since 2.9.0
[293] Fix | Delete
* @since 4.4.0 The default value changed to true.
[294] Fix | Delete
*
[295] Fix | Delete
* @see WP_oEmbed::discover()
[296] Fix | Delete
*
[297] Fix | Delete
* @param bool $enable Whether to enable `<link>` tag discovery. Default true.
[298] Fix | Delete
*/
[299] Fix | Delete
$attr['discover'] = apply_filters( 'embed_oembed_discover', true );
[300] Fix | Delete
[301] Fix | Delete
// Use oEmbed to get the HTML.
[302] Fix | Delete
$html = wp_oembed_get( $url, $attr );
[303] Fix | Delete
[304] Fix | Delete
if ( $post_ID ) {
[305] Fix | Delete
if ( $html ) {
[306] Fix | Delete
update_post_meta( $post_ID, $cachekey, $html );
[307] Fix | Delete
update_post_meta( $post_ID, $cachekey_time, time() );
[308] Fix | Delete
} elseif ( ! $cache ) {
[309] Fix | Delete
update_post_meta( $post_ID, $cachekey, '{{unknown}}' );
[310] Fix | Delete
}
[311] Fix | Delete
} else {
[312] Fix | Delete
$has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' );
[313] Fix | Delete
[314] Fix | Delete
if ( $has_kses ) {
[315] Fix | Delete
// Prevent KSES from corrupting JSON in post_content.
[316] Fix | Delete
kses_remove_filters();
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
$insert_post_args = array(
[320] Fix | Delete
'post_name' => $key_suffix,
[321] Fix | Delete
'post_status' => 'publish',
[322] Fix | Delete
'post_type' => 'oembed_cache',
[323] Fix | Delete
);
[324] Fix | Delete
[325] Fix | Delete
if ( $html ) {
[326] Fix | Delete
if ( $cached_post_id ) {
[327] Fix | Delete
wp_update_post(
[328] Fix | Delete
wp_slash(
[329] Fix | Delete
array(
[330] Fix | Delete
'ID' => $cached_post_id,
[331] Fix | Delete
'post_content' => $html,
[332] Fix | Delete
)
[333] Fix | Delete
)
[334] Fix | Delete
);
[335] Fix | Delete
} else {
[336] Fix | Delete
wp_insert_post(
[337] Fix | Delete
wp_slash(
[338] Fix | Delete
array_merge(
[339] Fix | Delete
$insert_post_args,
[340] Fix | Delete
array(
[341] Fix | Delete
'post_content' => $html,
[342] Fix | Delete
)
[343] Fix | Delete
)
[344] Fix | Delete
)
[345] Fix | Delete
);
[346] Fix | Delete
}
[347] Fix | Delete
} elseif ( ! $cache ) {
[348] Fix | Delete
wp_insert_post(
[349] Fix | Delete
wp_slash(
[350] Fix | Delete
array_merge(
[351] Fix | Delete
$insert_post_args,
[352] Fix | Delete
array(
[353] Fix | Delete
'post_content' => '{{unknown}}',
[354] Fix | Delete
)
[355] Fix | Delete
)
[356] Fix | Delete
)
[357] Fix | Delete
);
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
if ( $has_kses ) {
[361] Fix | Delete
kses_init_filters();
[362] Fix | Delete
}
[363] Fix | Delete
}
[364] Fix | Delete
[365] Fix | Delete
// If there was a result, return it.
[366] Fix | Delete
if ( $html ) {
[367] Fix | Delete
/** This filter is documented in wp-includes/class-wp-embed.php */
[368] Fix | Delete
return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_ID );
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
// Still unknown.
[372] Fix | Delete
return $this->maybe_make_link( $url );
[373] Fix | Delete
}
[374] Fix | Delete
[375] Fix | Delete
/**
[376] Fix | Delete
* Delete all oEmbed caches. Unused by core as of 4.0.0.
[377] Fix | Delete
*
[378] Fix | Delete
* @param int $post_ID Post ID to delete the caches for.
[379] Fix | Delete
*/
[380] Fix | Delete
public function delete_oembed_caches( $post_ID ) {
[381] Fix | Delete
$post_metas = get_post_custom_keys( $post_ID );
[382] Fix | Delete
if ( empty( $post_metas ) ) {
[383] Fix | Delete
return;
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
foreach ( $post_metas as $post_meta_key ) {
[387] Fix | Delete
if ( '_oembed_' === substr( $post_meta_key, 0, 8 ) ) {
[388] Fix | Delete
delete_post_meta( $post_ID, $post_meta_key );
[389] Fix | Delete
}
[390] Fix | Delete
}
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
/**
[394] Fix | Delete
* Triggers a caching of all oEmbed results.
[395] Fix | Delete
*
[396] Fix | Delete
* @param int $post_ID Post ID to do the caching for.
[397] Fix | Delete
*/
[398] Fix | Delete
public function cache_oembed( $post_ID ) {
[399] Fix | Delete
$post = get_post( $post_ID );
[400] Fix | Delete
[401] Fix | Delete
$post_types = get_post_types( array( 'show_ui' => true ) );
[402] Fix | Delete
[403] Fix | Delete
/**
[404] Fix | Delete
* Filters the array of post types to cache oEmbed results for.
[405] Fix | Delete
*
[406] Fix | Delete
* @since 2.9.0
[407] Fix | Delete
*
[408] Fix | Delete
* @param string[] $post_types Array of post type names to cache oEmbed results for. Defaults to post types with `show_ui` set to true.
[409] Fix | Delete
*/
[410] Fix | Delete
$cache_oembed_types = apply_filters( 'embed_cache_oembed_types', $post_types );
[411] Fix | Delete
[412] Fix | Delete
if ( empty( $post->ID ) || ! in_array( $post->post_type, $cache_oembed_types, true ) ) {
[413] Fix | Delete
return;
[414] Fix | Delete
}
[415] Fix | Delete
[416] Fix | Delete
// Trigger a caching.
[417] Fix | Delete
if ( ! empty( $post->post_content ) ) {
[418] Fix | Delete
$this->post_ID = $post->ID;
[419] Fix | Delete
$this->usecache = false;
[420] Fix | Delete
[421] Fix | Delete
$content = $this->run_shortcode( $post->post_content );
[422] Fix | Delete
$this->autoembed( $content );
[423] Fix | Delete
[424] Fix | Delete
$this->usecache = true;
[425] Fix | Delete
}
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
/**
[429] Fix | Delete
* Passes any unlinked URLs that are on their own line to WP_Embed::shortcode() for potential embedding.
[430] Fix | Delete
*
[431] Fix | Delete
* @see WP_Embed::autoembed_callback()
[432] Fix | Delete
*
[433] Fix | Delete
* @param string $content The content to be searched.
[434] Fix | Delete
* @return string Potentially modified $content.
[435] Fix | Delete
*/
[436] Fix | Delete
public function autoembed( $content ) {
[437] Fix | Delete
// Replace line breaks from all HTML elements with placeholders.
[438] Fix | Delete
$content = wp_replace_in_html_tags( $content, array( "\n" => '<!-- wp-line-break -->' ) );
[439] Fix | Delete
[440] Fix | Delete
if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
[441] Fix | Delete
// Find URLs on their own line.
[442] Fix | Delete
$content = preg_replace_callback( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content );
[443] Fix | Delete
// Find URLs in their own paragraph.
[444] Fix | Delete
$content = preg_replace_callback( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', array( $this, 'autoembed_callback' ), $content );
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
// Put the line breaks back.
[448] Fix | Delete
return str_replace( '<!-- wp-line-break -->', "\n", $content );
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
/**
[452] Fix | Delete
* Callback function for WP_Embed::autoembed().
[453] Fix | Delete
*
[454] Fix | Delete
* @param array $match A regex match array.
[455] Fix | Delete
* @return string The embed HTML on success, otherwise the original URL.
[456] Fix | Delete
*/
[457] Fix | Delete
public function autoembed_callback( $match ) {
[458] Fix | Delete
$oldval = $this->linkifunknown;
[459] Fix | Delete
$this->linkifunknown = false;
[460] Fix | Delete
$return = $this->shortcode( array(), $match[2] );
[461] Fix | Delete
$this->linkifunknown = $oldval;
[462] Fix | Delete
[463] Fix | Delete
return $match[1] . $return . $match[3];
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
/**
[467] Fix | Delete
* Conditionally makes a hyperlink based on an internal class variable.
[468] Fix | Delete
*
[469] Fix | Delete
* @param string $url URL to potentially be linked.
[470] Fix | Delete
* @return string|false Linked URL or the original URL. False if 'return_false_on_fail' is true.
[471] Fix | Delete
*/
[472] Fix | Delete
public function maybe_make_link( $url ) {
[473] Fix | Delete
if ( $this->return_false_on_fail ) {
[474] Fix | Delete
return false;
[475] Fix | Delete
}
[476] Fix | Delete
[477] Fix | Delete
$output = ( $this->linkifunknown ) ? '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>' : $url;
[478] Fix | Delete
[479] Fix | Delete
/**
[480] Fix | Delete
* Filters the returned, maybe-linked embed URL.
[481] Fix | Delete
*
[482] Fix | Delete
* @since 2.9.0
[483] Fix | Delete
*
[484] Fix | Delete
* @param string $output The linked or original URL.
[485] Fix | Delete
* @param string $url The original URL.
[486] Fix | Delete
*/
[487] Fix | Delete
return apply_filters( 'embed_maybe_make_link', $output, $url );
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
/**
[491] Fix | Delete
* Find the oEmbed cache post ID for a given cache key.
[492] Fix | Delete
*
[493] Fix | Delete
* @since 4.9.0
[494] Fix | Delete
*
[495] Fix | Delete
* @param string $cache_key oEmbed cache key.
[496] Fix | Delete
* @return int|null Post ID on success, null on failure.
[497] Fix | Delete
*/
[498] Fix | Delete
public function find_oembed_post_id( $cache_key ) {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function