3
* Contains the post embed template.
5
* When a post is embedded in an iframe, this file is used to
13
if ( ! headers_sent() ) {
14
header( 'X-WP-embed: true' );
19
<html <?php language_attributes(); ?> class="no-js">
21
<title><?php echo wp_get_document_title(); ?></title>
22
<meta http-equiv="X-UA-Compatible" content="IE=edge">
25
* Print scripts or data in the embed template <head> tag.
29
do_action( 'embed_head' );
32
<body <?php body_class(); ?>>
35
while ( have_posts() ) : the_post();
36
// Add post thumbnail to response if available.
37
$thumbnail_id = false;
39
if ( has_post_thumbnail() ) {
40
$thumbnail_id = get_post_thumbnail_id();
43
if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) {
44
$thumbnail_id = get_the_ID();
47
if ( $thumbnail_id ) {
49
$measurements = array( 1, 1 );
50
$image_size = 'full'; // Fallback.
52
$meta = wp_get_attachment_metadata( $thumbnail_id );
53
if ( is_array( $meta ) ) {
54
foreach ( $meta['sizes'] as $size => $data ) {
55
if ( $data['width'] / $data['height'] > $aspect_ratio ) {
56
$aspect_ratio = $data['width'] / $data['height'];
57
$measurements = array( $data['width'], $data['height'] );
64
* Filter the thumbnail image size for use in the embed template.
68
* @param string $image_size Thumbnail image size.
70
$image_size = apply_filters( 'embed_thumbnail_image_size', $image_size );
72
$shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
75
* Filter the thumbnail shape for use in the embed template.
77
* Rectangular images are shown above the title
78
* while square images are shown next to the content.
82
* @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'.
84
$shape = apply_filters( 'embed_thumbnail_image_shape', $shape );
87
<div <?php post_class( 'wp-embed' ); ?>>
88
<?php if ( $thumbnail_id && 'rectangular' === $shape ) : ?>
89
<div class="wp-embed-featured-image rectangular">
90
<a href="<?php the_permalink(); ?>" target="_top">
91
<?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?>
96
<p class="wp-embed-heading">
97
<a href="<?php the_permalink(); ?>" target="_top">
102
<?php if ( $thumbnail_id && 'square' === $shape ) : ?>
103
<div class="wp-embed-featured-image square">
104
<a href="<?php the_permalink(); ?>" target="_top">
105
<?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?>
110
<div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>
114
* Print additional content after the embed excerpt.
118
do_action( 'embed_content' );
121
<div class="wp-embed-footer">
122
<div class="wp-embed-site-title">
124
$site_title = sprintf(
125
'<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>',
126
esc_url( home_url() ),
127
esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ),
128
esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ),
129
esc_html( get_bloginfo( 'name' ) )
133
* Filter the site title HTML in the embed footer.
137
* @param string $site_title The site title HTML.
139
echo apply_filters( 'embed_site_title_html', $site_title );
143
<div class="wp-embed-meta">
146
* Print additional meta content in the embed template.
150
do_action( 'embed_content_meta');
159
<div class="wp-embed">
160
<p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p>
162
<div class="wp-embed-excerpt">
166
/* translators: %s: a link to the embedded site */
167
__( 'It looks like nothing was found at this location. Maybe try visiting %s directly?' ),
168
'<strong><a href="' . esc_url( home_url() ) . '">' . esc_html( get_bloginfo( 'name' ) ) . '</a></strong>'
174
<div class="wp-embed-footer">
175
<div class="wp-embed-site-title">
177
$site_title = sprintf(
178
'<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>',
179
esc_url( home_url() ),
180
esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ),
181
esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ),
182
esc_html( get_bloginfo( 'name' ) )
185
/** This filter is documented in wp-includes/embed-template.php */
186
echo apply_filters( 'embed_site_title_html', $site_title );
195
* Print scripts or data before the closing body tag in the embed template.
199
do_action( 'embed_footer' );