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