'<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>',
esc_url( get_permalink() ),
/* translators: %s: Post title. */
sprintf( __( 'Continue reading %s' ), '<span class="screen-reader-text">' . get_the_title() . '</span>' )
return ' … ' . $link;
* Displays the post excerpt for the embed template.
* Intended to be used in 'The Loop'.
function the_excerpt_embed() {
$output = get_the_excerpt();
* Filters the post excerpt for the embed template.
* @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.
* @param string $content The current post excerpt.
* @return string The modified post excerpt.
function wp_embed_excerpt_attachment( $content ) {
return prepend_attachment( '' );
* Enqueues embed iframe default CSS and JS.
* 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().
function enqueue_embed_scripts() {
wp_enqueue_style( 'wp-embed-template-ie' );
* Fires when scripts and styles are enqueued for the embed iframe.
do_action( 'enqueue_embed_scripts' );
* Enqueues the CSS in the embed iframe header.
function wp_enqueue_embed_styles() {
// Back-compat for plugins that disable functionality by unhooking this action.
if ( ! has_action( 'embed_head', 'print_embed_styles' ) ) {
remove_action( 'embed_head', 'print_embed_styles' );
$suffix = wp_scripts_get_suffix();
$handle = 'wp-embed-template';
wp_register_style( $handle, false );
wp_add_inline_style( $handle, file_get_contents( ABSPATH . WPINC . "/css/wp-embed-template$suffix.css" ) );
wp_enqueue_style( $handle );
* Prints the JavaScript in the embed iframe header.
function print_embed_scripts() {
wp_print_inline_script_tag(
file_get_contents( ABSPATH . WPINC . '/js/wp-embed-template' . wp_scripts_get_suffix() . '.js' )
* Prepare the oembed HTML to be displayed in an RSS feed.
* @param string $content The content to filter.
* @return string The filtered content.
function _oembed_filter_feed_content( $content ) {
$p = new WP_HTML_Tag_Processor( $content );
while ( $p->next_tag( array( 'tag_name' => 'iframe' ) ) ) {
if ( $p->has_class( 'wp-embedded-content' ) ) {
$p->remove_attribute( 'style' );
return $p->get_updated_html();
* Prints the necessary markup for the embed comments button.
function print_embed_comments_button() {
if ( is_404() || ! ( get_comments_number() || comments_open() ) ) {
<div class="wp-embed-comments">
<a href="<?php comments_link(); ?>" target="_top">
<span class="dashicons dashicons-admin-comments"></span>
/* translators: %s: Number of comments. */
'%s <span class="screen-reader-text">Comment</span>',
'%s <span class="screen-reader-text">Comments</span>',
number_format_i18n( get_comments_number() )
* Prints the necessary markup for the embed sharing button.
function print_embed_sharing_button() {
<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>
* Prints the necessary markup for the embed sharing dialog.
function print_embed_sharing_dialog() {
$unique_suffix = get_the_ID() . '-' . wp_rand();
$share_tab_wordpress_id = 'wp-embed-share-tab-wordpress-' . $unique_suffix;
$share_tab_html_id = 'wp-embed-share-tab-html-' . $unique_suffix;
$description_wordpress_id = 'wp-embed-share-description-wordpress-' . $unique_suffix;
$description_html_id = 'wp-embed-share-description-html-' . $unique_suffix;
<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="<?php echo $share_tab_wordpress_id; ?>" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button>
<li class="wp-embed-share-tab-button wp-embed-share-tab-button-html" role="presentation">
<button type="button" role="tab" aria-controls="<?php echo $share_tab_html_id; ?>" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button>
<div id="<?php echo $share_tab_wordpress_id; ?>" class="wp-embed-share-tab" role="tabpanel" aria-hidden="false">
<input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" aria-label="<?php esc_attr_e( 'URL' ); ?>" aria-describedby="<?php echo $description_wordpress_id; ?>" tabindex="0" readonly/>
<p class="wp-embed-share-description" id="<?php echo $description_wordpress_id; ?>">
<?php _e( 'Copy and paste this URL into your WordPress site to embed' ); ?>
<div id="<?php echo $share_tab_html_id; ?>" class="wp-embed-share-tab" role="tabpanel" aria-hidden="true">
<textarea class="wp-embed-share-input" aria-label="<?php esc_attr_e( 'HTML' ); ?>" aria-describedby="<?php echo $description_html_id; ?>" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( 600, 400 ) ); ?></textarea>
<p class="wp-embed-share-description" id="<?php echo $description_html_id; ?>">
<?php _e( 'Copy and paste this code into your site to embed' ); ?>
<button type="button" class="wp-embed-share-dialog-close" aria-label="<?php esc_attr_e( 'Close sharing dialog' ); ?>">
<span class="dashicons dashicons-no"></span>
* Prints the necessary markup for the site title in an embed template.
function the_embed_site_title() {
'<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( get_site_icon_url( 32, includes_url( 'images/w-logo-blue.png' ) ) ),
esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
esc_html( get_bloginfo( 'name' ) )
$site_title = '<div class="wp-embed-site-title">' . $site_title . '</div>';
* Filters the site title HTML in the embed footer.
* @param string $site_title The site title HTML.
echo apply_filters( 'embed_site_title_html', $site_title );
* 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.
* @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 ) {
$data = get_oembed_response_data_for_url( $url, $args );
return _wp_oembed_get_object()->data2html( $data, $url );