Make WordPress Core

Changeset 36693


Ignore:
Timestamp:
02/24/2016 08:56:18 PM (8 years ago)
Author:
DrewAPicture
Message:

Embeds: Introduce embed templates into the template hierarchy via theme-compat.

Splits wp-includes/embed-template.php, introduced in 4.4, into five new templates that can be individually overridden by themes:

  • embed.php
  • embed-404.php
  • embed-content.php
  • header-embed.php
  • footer-embed.php

Also introduces a new template tag for outputting the site title, the_embed_site_title().

The five new templates live in theme-compat, allowing for graceful fallbacks should themes prefer not to override any or all of them.

Props swissspidy, imath, ocean90, DrewAPicture.
See #34561.

Location:
trunk/src/wp-includes
Files:
5 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/embed-template.php

    r36635 r36693  
    11<?php
    22/**
    3  * Contains the post embed template.
    4  *
    5  * When a post is embedded in an iframe, this file is used to
    6  * create the output.
     3 * Back-compat placeholder for the base embed template
    74 *
    85 * @package WordPress
    96 * @subpackage oEmbed
    107 * @since 4.4.0
     8 * @deprecated 4.5.0 Moved to wp-includes/theme-compat/embed-template.php
    119 */
    1210
    13 if ( ! headers_sent() ) {
    14     header( 'X-WP-embed: true' );
    15 }
     11_deprecated_file( basename( __FILE__ ), '4.5', 'wp-includes/theme-compat/embed.php' );
    1612
    17 ?>
    18 <!DOCTYPE html>
    19 <html <?php language_attributes(); ?> class="no-js">
    20 <head>
    21     <title><?php echo wp_get_document_title(); ?></title>
    22     <meta http-equiv="X-UA-Compatible" content="IE=edge">
    23     <?php
    24     /**
    25      * Print scripts or data in the embed template <head> tag.
    26      *
    27      * @since 4.4.0
    28      */
    29     do_action( 'embed_head' );
    30     ?>
    31 </head>
    32 <body <?php body_class(); ?>>
    33 <?php
    34 if ( have_posts() ) :
    35     while ( have_posts() ) : the_post();
    36         // Add post thumbnail to response if available.
    37         $thumbnail_id = false;
    38 
    39         if ( has_post_thumbnail() ) {
    40             $thumbnail_id = get_post_thumbnail_id();
    41         }
    42 
    43         if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) {
    44             $thumbnail_id = get_the_ID();
    45         }
    46 
    47         if ( $thumbnail_id ) {
    48             $aspect_ratio = 1;
    49             $measurements = array( 1, 1 );
    50             $image_size   = 'full'; // Fallback.
    51 
    52             $meta = wp_get_attachment_metadata( $thumbnail_id );
    53             if ( ! empty( $meta['sizes'] ) ) {
    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'] );
    58                         $image_size   = $size;
    59                     }
    60                 }
    61             }
    62 
    63             /**
    64              * Filter the thumbnail image size for use in the embed template.
    65              *
    66              * @since 4.4.0
    67              *
    68              * @param string $image_size Thumbnail image size.
    69              */
    70             $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size );
    71 
    72             $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
    73 
    74             /**
    75              * Filter the thumbnail shape for use in the embed template.
    76              *
    77              * Rectangular images are shown above the title
    78              * while square images are shown next to the content.
    79              *
    80              * @since 4.4.0
    81              *
    82              * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'.
    83              */
    84             $shape = apply_filters( 'embed_thumbnail_image_shape', $shape );
    85         }
    86         ?>
    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 ); ?>
    92                     </a>
    93                 </div>
    94             <?php endif; ?>
    95 
    96             <p class="wp-embed-heading">
    97                 <a href="<?php the_permalink(); ?>" target="_top">
    98                     <?php the_title(); ?>
    99                 </a>
    100             </p>
    101 
    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 ); ?>
    106                     </a>
    107                 </div>
    108             <?php endif; ?>
    109 
    110             <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>
    111 
    112             <?php
    113             /**
    114              * Print additional content after the embed excerpt.
    115              *
    116              * @since 4.4.0
    117              */
    118             do_action( 'embed_content' );
    119             ?>
    120 
    121             <div class="wp-embed-footer">
    122                 <div class="wp-embed-site-title">
    123                     <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    128                         esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    129                         esc_html( get_bloginfo( 'name' ) )
    130                     );
    131 
    132                     /**
    133                      * Filter the site title HTML in the embed footer.
    134                      *
    135                      * @since 4.4.0
    136                      *
    137                      * @param string $site_title The site title HTML.
    138                      */
    139                     echo apply_filters( 'embed_site_title_html', $site_title );
    140                     ?>
    141                 </div>
    142 
    143                 <div class="wp-embed-meta">
    144                     <?php
    145                     /**
    146                      * Print additional meta content in the embed template.
    147                      *
    148                      * @since 4.4.0
    149                      */
    150                     do_action( 'embed_content_meta');
    151                     ?>
    152                 </div>
    153             </div>
    154         </div>
    155         <?php
    156     endwhile;
    157 else :
    158     ?>
    159     <div class="wp-embed">
    160         <p class="wp-embed-heading"><?php _e( 'Oops! That embed can&#8217;t be found.' ); ?></p>
    161 
    162         <div class="wp-embed-excerpt">
    163             <p>
    164                 <?php
    165                 printf(
    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>'
    169                 );
    170                 ?>
    171             </p>
    172         </div>
    173 
    174         <div class="wp-embed-footer">
    175             <div class="wp-embed-site-title">
    176                 <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    181                     esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    182                     esc_html( get_bloginfo( 'name' ) )
    183                 );
    184 
    185                 /** This filter is documented in wp-includes/embed-template.php */
    186                 echo apply_filters( 'embed_site_title_html', $site_title );
    187                 ?>
    188             </div>
    189         </div>
    190     </div>
    191     <?php
    192 endif;
    193 
    194 /**
    195  * Print scripts or data before the closing body tag in the embed template.
    196  *
    197  * @since 4.4.0
    198  */
    199 do_action( 'embed_footer' );
    200 ?>
    201 </body>
    202 </html>
     13include( ABSPATH . WPINC . '/theme-compat/embed.php' );
  • trunk/src/wp-includes/embed.php

    r36307 r36693  
    10471047    <?php
    10481048}
     1049
     1050/**
     1051 * Prints the necessary markup for the site title.
     1052 *
     1053 * @since 4.5.0
     1054 */
     1055function the_embed_site_title() {
     1056    $site_title = sprintf(
     1057        '<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>',
     1058        esc_url( home_url() ),
     1059        esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ),
     1060        esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ),
     1061        esc_html( get_bloginfo( 'name' ) )
     1062    );
     1063
     1064    $site_title = '<div class="wp-embed-site-title">' . $site_title . '</div>';
     1065
     1066    /**
     1067     * Filter the site title HTML in the embed footer.
     1068     *
     1069     * @since 4.4.0
     1070     *
     1071     * @param string $site_title The site title HTML.
     1072     */
     1073    echo apply_filters( 'embed_site_title_html', $site_title );
     1074}
  • trunk/src/wp-includes/general-template.php

    r36671 r36693  
    3737    $templates = array();
    3838    $name = (string) $name;
    39     if ( '' !== $name )
     39    if ( '' !== $name ) {
    4040        $templates[] = "header-{$name}.php";
     41    }
    4142
    4243    $templates[] = 'header.php';
    4344
    44     // Backward compat code will be removed in a future release
    45     if ('' == locate_template($templates, true))
    46         load_template( ABSPATH . WPINC . '/theme-compat/header.php');
     45    locate_template( $templates, true );
    4746}
    4847
     
    7776    $templates = array();
    7877    $name = (string) $name;
    79     if ( '' !== $name )
     78    if ( '' !== $name ) {
    8079        $templates[] = "footer-{$name}.php";
    81 
    82     $templates[] = 'footer.php';
    83 
    84     // Backward compat code will be removed in a future release
    85     if ('' == locate_template($templates, true))
    86         load_template( ABSPATH . WPINC . '/theme-compat/footer.php');
     80    }
     81
     82    $templates[]    = 'footer.php';
     83
     84    locate_template( $templates, true );
    8785}
    8886
     
    122120    $templates[] = 'sidebar.php';
    123121
    124     // Backward compat code will be removed in a future release
    125     if ('' == locate_template($templates, true))
    126         load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php');
     122    locate_template( $templates, true );
    127123}
    128124
  • trunk/src/wp-includes/template-loader.php

    r36344 r36693  
    4141    return;
    4242elseif ( is_embed() ) :
    43     $template = ABSPATH . WPINC . '/embed-template.php';
     43    $template = ABSPATH . WPINC . '/theme-compat/embed.php';
    4444
    4545    /**
     
    4747     *
    4848     * @since 4.4.0
     49     * @since 4.5.0 The default template path changed to wp-includes/theme-compat/embed.php
    4950     *
    5051     * @param string $template Path to the template file.
  • trunk/src/wp-includes/template.php

    r35848 r36693  
    469469 * Retrieve the name of the highest priority template file that exists.
    470470 *
    471  * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which
    472  * inherit from a parent theme can just overload one file.
     471 * Searches in the STYLESHEETPATH before TEMPLATEPATH and wp-includes/theme-compat
     472 * so that themes which inherit from a parent theme can just overload one file.
    473473 *
    474474 * @since 2.7.0
     
    490490            $located = TEMPLATEPATH . '/' . $template_name;
    491491            break;
     492        } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {
     493            $located = ABSPATH . WPINC . '/theme-compat/' . $template_name;
     494            break;
    492495        }
    493496    }
  • trunk/src/wp-includes/theme-compat/embed-404.php

    r36689 r36693  
    11<?php
    22/**
    3  * Contains the post embed template.
     3 * Contains the post embed content template part.
    44 *
    55 * When a post is embedded in an iframe, this file is used to
    6  * create the output.
     6 * create the content template part output if the active theme does not include
     7 * a content-embed.php template.
    78 *
    89 * @package WordPress
    9  * @subpackage oEmbed
    10  * @since 4.4.0
     10 * @subpackage Theme_Compat
     11 * @since 4.5.0
    1112 */
     13?>
     14<div class="wp-embed">
     15    <p class="wp-embed-heading"><?php _e( 'Oops! That embed can&#8217;t be found.' ); ?></p>
    1216
    13 if ( ! headers_sent() ) {
    14     header( 'X-WP-embed: true' );
    15 }
     17    <div class="wp-embed-excerpt">
     18        <p>
     19            <?php
     20            printf(
     21                /* translators: %s: a link to the embedded site */
     22                __( 'It looks like nothing was found at this location. Maybe try visiting %s directly?' ),
     23                '<strong><a href="' . esc_url( home_url() ) . '">' . esc_html( get_bloginfo( 'name' ) ) . '</a></strong>'
     24            );
     25            ?>
     26        </p>
     27    </div>
    1628
    17 ?>
    18 <!DOCTYPE html>
    19 <html <?php language_attributes(); ?> class="no-js">
    20 <head>
    21     <title><?php echo wp_get_document_title(); ?></title>
    22     <meta http-equiv="X-UA-Compatible" content="IE=edge">
    2329    <?php
    24     /**
    25      * Print scripts or data in the embed template <head> tag.
    26      *
    27      * @since 4.4.0
    28      */
    29     do_action( 'embed_head' );
     30    /** This filter is documented in wp-includes/theme-compat/embed-content.php */
     31    do_action( 'embed_content' );
    3032    ?>
    31 </head>
    32 <body <?php body_class(); ?>>
    33 <?php
    34 if ( have_posts() ) :
    35     while ( have_posts() ) : the_post();
    36         // Add post thumbnail to response if available.
    37         $thumbnail_id = false;
    3833
    39         if ( has_post_thumbnail() ) {
    40             $thumbnail_id = get_post_thumbnail_id();
    41         }
    42 
    43         if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) {
    44             $thumbnail_id = get_the_ID();
    45         }
    46 
    47         if ( $thumbnail_id ) {
    48             $aspect_ratio = 1;
    49             $measurements = array( 1, 1 );
    50             $image_size   = 'full'; // Fallback.
    51 
    52             $meta = wp_get_attachment_metadata( $thumbnail_id );
    53             if ( ! empty( $meta['sizes'] ) ) {
    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'] );
    58                         $image_size   = $size;
    59                     }
    60                 }
    61             }
    62 
    63             /**
    64              * Filter the thumbnail image size for use in the embed template.
    65              *
    66              * @since 4.4.0
    67              *
    68              * @param string $image_size Thumbnail image size.
    69              */
    70             $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size );
    71 
    72             $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
    73 
    74             /**
    75              * Filter the thumbnail shape for use in the embed template.
    76              *
    77              * Rectangular images are shown above the title
    78              * while square images are shown next to the content.
    79              *
    80              * @since 4.4.0
    81              *
    82              * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'.
    83              */
    84             $shape = apply_filters( 'embed_thumbnail_image_shape', $shape );
    85         }
    86         ?>
    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 ); ?>
    92                     </a>
    93                 </div>
    94             <?php endif; ?>
    95 
    96             <p class="wp-embed-heading">
    97                 <a href="<?php the_permalink(); ?>" target="_top">
    98                     <?php the_title(); ?>
    99                 </a>
    100             </p>
    101 
    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 ); ?>
    106                     </a>
    107                 </div>
    108             <?php endif; ?>
    109 
    110             <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>
    111 
    112             <?php
    113             /**
    114              * Print additional content after the embed excerpt.
    115              *
    116              * @since 4.4.0
    117              */
    118             do_action( 'embed_content' );
    119             ?>
    120 
    121             <div class="wp-embed-footer">
    122                 <div class="wp-embed-site-title">
    123                     <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    128                         esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    129                         esc_html( get_bloginfo( 'name' ) )
    130                     );
    131 
    132                     /**
    133                      * Filter the site title HTML in the embed footer.
    134                      *
    135                      * @since 4.4.0
    136                      *
    137                      * @param string $site_title The site title HTML.
    138                      */
    139                     echo apply_filters( 'embed_site_title_html', $site_title );
    140                     ?>
    141                 </div>
    142 
    143                 <div class="wp-embed-meta">
    144                     <?php
    145                     /**
    146                      * Print additional meta content in the embed template.
    147                      *
    148                      * @since 4.4.0
    149                      */
    150                     do_action( 'embed_content_meta');
    151                     ?>
    152                 </div>
    153             </div>
    154         </div>
    155         <?php
    156     endwhile;
    157 else :
    158     ?>
    159     <div class="wp-embed">
    160         <p class="wp-embed-heading"><?php _e( 'Oops! That embed can&#8217;t be found.' ); ?></p>
    161 
    162         <div class="wp-embed-excerpt">
    163             <p>
    164                 <?php
    165                 printf(
    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>'
    169                 );
    170                 ?>
    171             </p>
    172         </div>
    173 
    174         <div class="wp-embed-footer">
    175             <div class="wp-embed-site-title">
    176                 <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    181                     esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    182                     esc_html( get_bloginfo( 'name' ) )
    183                 );
    184 
    185                 /** This filter is documented in wp-includes/embed-template.php */
    186                 echo apply_filters( 'embed_site_title_html', $site_title );
    187                 ?>
    188             </div>
    189         </div>
     34    <div class="wp-embed-footer">
     35        <?php the_embed_site_title() ?>
    19036    </div>
    191     <?php
    192 endif;
    193 
    194 /**
    195  * Print scripts or data before the closing body tag in the embed template.
    196  *
    197  * @since 4.4.0
    198  */
    199 do_action( 'embed_footer' );
    200 ?>
    201 </body>
    202 </html>
     37</div>
  • trunk/src/wp-includes/theme-compat/embed-content.php

    r36689 r36693  
    11<?php
    22/**
    3  * Contains the post embed template.
     3 * Contains the post embed content template part.
    44 *
    55 * When a post is embedded in an iframe, this file is used to
    6  * create the output.
     6 * create the content template part output if the active theme does not include
     7 * a content-embed.php template.
    78 *
    89 * @package WordPress
    9  * @subpackage oEmbed
    10  * @since 4.4.0
     10 * @subpackage Theme_Compat
     11 * @since 4.5.0
    1112 */
    12 
    13 if ( ! headers_sent() ) {
    14     header( 'X-WP-embed: true' );
    15 }
    16 
    1713?>
    18 <!DOCTYPE html>
    19 <html <?php language_attributes(); ?> class="no-js">
    20 <head>
    21     <title><?php echo wp_get_document_title(); ?></title>
    22     <meta http-equiv="X-UA-Compatible" content="IE=edge">
    23     <?php
    24     /**
    25      * Print scripts or data in the embed template <head> tag.
    26      *
    27      * @since 4.4.0
    28      */
    29     do_action( 'embed_head' );
    30     ?>
    31 </head>
    32 <body <?php body_class(); ?>>
    33 <?php
    34 if ( have_posts() ) :
    35     while ( have_posts() ) : the_post();
    36         // Add post thumbnail to response if available.
    37         $thumbnail_id = false;
     14    <div <?php post_class( 'wp-embed' ); ?>>
     15        <?php
     16        $thumbnail_id = 0;
    3817
    3918        if ( has_post_thumbnail() ) {
     
    4524        }
    4625
    47         if ( $thumbnail_id ) {
    48             $aspect_ratio = 1;
    49             $measurements = array( 1, 1 );
    50             $image_size   = 'full'; // Fallback.
     26        $aspect_ratio = 1;
     27        $measurements = array( 1, 1 );
     28        $image_size   = 'full'; // Fallback.
    5129
    52             $meta = wp_get_attachment_metadata( $thumbnail_id );
    53             if ( ! empty( $meta['sizes'] ) ) {
    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'] );
    58                         $image_size   = $size;
    59                     }
     30        $meta = wp_get_attachment_metadata( $thumbnail_id );
     31        if ( is_array( $meta ) ) {
     32            foreach ( $meta['sizes'] as $size => $data ) {
     33                if ( $data['width'] / $data['height'] > $aspect_ratio ) {
     34                    $aspect_ratio = $data['width'] / $data['height'];
     35                    $measurements = array( $data['width'], $data['height'] );
     36                    $image_size   = $size;
    6037                }
    6138            }
     39        }
    6240
    63             /**
    64              * Filter the thumbnail image size for use in the embed template.
    65              *
    66              * @since 4.4.0
    67              *
    68              * @param string $image_size Thumbnail image size.
    69              */
    70             $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size );
     41        /**
     42         * Filter the thumbnail image size for use in the embed template.
     43         *
     44         * @since 4.4.0
     45         * @since 4.5.0 Added `$thumbnail_id` parameter.
     46         *
     47         * @param string $image_size   Thumbnail image size.
     48         * @param int    $thumbnail_id Attachment ID.
     49         */
     50        $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size, $thumbnail_id );
    7151
    72             $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
     52        $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
    7353
    74             /**
    75              * Filter the thumbnail shape for use in the embed template.
    76              *
    77              * Rectangular images are shown above the title
    78              * while square images are shown next to the content.
    79              *
    80              * @since 4.4.0
    81              *
    82              * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'.
    83              */
    84             $shape = apply_filters( 'embed_thumbnail_image_shape', $shape );
    85         }
     54        /**
     55         * Filter the thumbnail shape for use in the embed template.
     56         *
     57         * Rectangular images are shown above the title while square images
     58         * are shown next to the content.
     59         *
     60         * @since 4.4.0
     61         * @since 4.5.0 Added `$thumbnail_id` parameter.
     62         *
     63         * @param string $shape        Thumbnail image shape. Either 'rectangular' or 'square'.
     64         * @param int    $thumbnail_id Attachment ID.
     65         */
     66        $shape = apply_filters( 'embed_thumbnail_image_shape', $shape, $thumbnail_id );
     67
     68        if ( 'rectangular' === $shape ) : ?>
     69            <div class="wp-embed-featured-image rectangular">
     70                <a href="<?php the_permalink(); ?>" target="_top">
     71                    <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?>
     72                </a>
     73            </div>
     74        <?php endif; ?>
     75
     76        <p class="wp-embed-heading">
     77            <a href="<?php the_permalink(); ?>" target="_top">
     78                <?php the_title(); ?>
     79            </a>
     80        </p>
     81
     82        <?php if ( 'square' === $shape ) : ?>
     83            <div class="wp-embed-featured-image square">
     84                <a href="<?php the_permalink(); ?>" target="_top">
     85                    <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?>
     86                </a>
     87            </div>
     88        <?php endif; ?>
     89
     90        <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>
     91
     92        <?php
     93        /**
     94         * Print additional content after the embed excerpt.
     95         *
     96         * @since 4.4.0
     97         */
     98        do_action( 'embed_content' );
    8699        ?>
    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 ); ?>
    92                     </a>
    93                 </div>
    94             <?php endif; ?>
    95 
    96             <p class="wp-embed-heading">
    97                 <a href="<?php the_permalink(); ?>" target="_top">
    98                     <?php the_title(); ?>
    99                 </a>
    100             </p>
    101 
    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 ); ?>
    106                     </a>
    107                 </div>
    108             <?php endif; ?>
    109 
    110             <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>
    111 
    112             <?php
    113             /**
    114              * Print additional content after the embed excerpt.
    115              *
    116              * @since 4.4.0
    117              */
    118             do_action( 'embed_content' );
    119             ?>
    120 
    121             <div class="wp-embed-footer">
    122                 <div class="wp-embed-site-title">
    123                     <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    128                         esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    129                         esc_html( get_bloginfo( 'name' ) )
    130                     );
    131 
    132                     /**
    133                      * Filter the site title HTML in the embed footer.
    134                      *
    135                      * @since 4.4.0
    136                      *
    137                      * @param string $site_title The site title HTML.
    138                      */
    139                     echo apply_filters( 'embed_site_title_html', $site_title );
    140                     ?>
    141                 </div>
    142 
    143                 <div class="wp-embed-meta">
    144                     <?php
    145                     /**
    146                      * Print additional meta content in the embed template.
    147                      *
    148                      * @since 4.4.0
    149                      */
    150                     do_action( 'embed_content_meta');
    151                     ?>
    152                 </div>
    153             </div>
    154         </div>
    155         <?php
    156     endwhile;
    157 else :
    158     ?>
    159     <div class="wp-embed">
    160         <p class="wp-embed-heading"><?php _e( 'Oops! That embed can&#8217;t be found.' ); ?></p>
    161 
    162         <div class="wp-embed-excerpt">
    163             <p>
    164                 <?php
    165                 printf(
    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>'
    169                 );
    170                 ?>
    171             </p>
    172         </div>
    173100
    174101        <div class="wp-embed-footer">
    175             <div class="wp-embed-site-title">
     102            <?php the_embed_site_title() ?>
     103
     104            <div class="wp-embed-meta">
    176105                <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    181                     esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    182                     esc_html( get_bloginfo( 'name' ) )
    183                 );
    184 
    185                 /** This filter is documented in wp-includes/embed-template.php */
    186                 echo apply_filters( 'embed_site_title_html', $site_title );
     106                /**
     107                 * Print additional meta content in the embed template.
     108                 *
     109                 * @since 4.4.0
     110                 */
     111                do_action( 'embed_content_meta');
    187112                ?>
    188113            </div>
    189114        </div>
    190115    </div>
    191     <?php
    192 endif;
    193 
    194 /**
    195  * Print scripts or data before the closing body tag in the embed template.
    196  *
    197  * @since 4.4.0
    198  */
    199 do_action( 'embed_footer' );
    200 ?>
    201 </body>
    202 </html>
     116<?php
  • trunk/src/wp-includes/theme-compat/embed.php

    r36689 r36693  
    1111 */
    1212
    13 if ( ! headers_sent() ) {
    14     header( 'X-WP-embed: true' );
    15 }
     13get_header( 'embed' );
    1614
    17 ?>
    18 <!DOCTYPE html>
    19 <html <?php language_attributes(); ?> class="no-js">
    20 <head>
    21     <title><?php echo wp_get_document_title(); ?></title>
    22     <meta http-equiv="X-UA-Compatible" content="IE=edge">
    23     <?php
    24     /**
    25      * Print scripts or data in the embed template <head> tag.
    26      *
    27      * @since 4.4.0
    28      */
    29     do_action( 'embed_head' );
    30     ?>
    31 </head>
    32 <body <?php body_class(); ?>>
    33 <?php
    3415if ( have_posts() ) :
    3516    while ( have_posts() ) : the_post();
    36         // Add post thumbnail to response if available.
    37         $thumbnail_id = false;
    38 
    39         if ( has_post_thumbnail() ) {
    40             $thumbnail_id = get_post_thumbnail_id();
    41         }
    42 
    43         if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) {
    44             $thumbnail_id = get_the_ID();
    45         }
    46 
    47         if ( $thumbnail_id ) {
    48             $aspect_ratio = 1;
    49             $measurements = array( 1, 1 );
    50             $image_size   = 'full'; // Fallback.
    51 
    52             $meta = wp_get_attachment_metadata( $thumbnail_id );
    53             if ( ! empty( $meta['sizes'] ) ) {
    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'] );
    58                         $image_size   = $size;
    59                     }
    60                 }
    61             }
    62 
    63             /**
    64              * Filter the thumbnail image size for use in the embed template.
    65              *
    66              * @since 4.4.0
    67              *
    68              * @param string $image_size Thumbnail image size.
    69              */
    70             $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size );
    71 
    72             $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
    73 
    74             /**
    75              * Filter the thumbnail shape for use in the embed template.
    76              *
    77              * Rectangular images are shown above the title
    78              * while square images are shown next to the content.
    79              *
    80              * @since 4.4.0
    81              *
    82              * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'.
    83              */
    84             $shape = apply_filters( 'embed_thumbnail_image_shape', $shape );
    85         }
    86         ?>
    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 ); ?>
    92                     </a>
    93                 </div>
    94             <?php endif; ?>
    95 
    96             <p class="wp-embed-heading">
    97                 <a href="<?php the_permalink(); ?>" target="_top">
    98                     <?php the_title(); ?>
    99                 </a>
    100             </p>
    101 
    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 ); ?>
    106                     </a>
    107                 </div>
    108             <?php endif; ?>
    109 
    110             <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>
    111 
    112             <?php
    113             /**
    114              * Print additional content after the embed excerpt.
    115              *
    116              * @since 4.4.0
    117              */
    118             do_action( 'embed_content' );
    119             ?>
    120 
    121             <div class="wp-embed-footer">
    122                 <div class="wp-embed-site-title">
    123                     <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    128                         esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    129                         esc_html( get_bloginfo( 'name' ) )
    130                     );
    131 
    132                     /**
    133                      * Filter the site title HTML in the embed footer.
    134                      *
    135                      * @since 4.4.0
    136                      *
    137                      * @param string $site_title The site title HTML.
    138                      */
    139                     echo apply_filters( 'embed_site_title_html', $site_title );
    140                     ?>
    141                 </div>
    142 
    143                 <div class="wp-embed-meta">
    144                     <?php
    145                     /**
    146                      * Print additional meta content in the embed template.
    147                      *
    148                      * @since 4.4.0
    149                      */
    150                     do_action( 'embed_content_meta');
    151                     ?>
    152                 </div>
    153             </div>
    154         </div>
    155         <?php
     17        get_template_part( 'embed', 'content' );
    15618    endwhile;
    15719else :
    158     ?>
    159     <div class="wp-embed">
    160         <p class="wp-embed-heading"><?php _e( 'Oops! That embed can&#8217;t be found.' ); ?></p>
    161 
    162         <div class="wp-embed-excerpt">
    163             <p>
    164                 <?php
    165                 printf(
    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>'
    169                 );
    170                 ?>
    171             </p>
    172         </div>
    173 
    174         <div class="wp-embed-footer">
    175             <div class="wp-embed-site-title">
    176                 <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    181                     esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    182                     esc_html( get_bloginfo( 'name' ) )
    183                 );
    184 
    185                 /** This filter is documented in wp-includes/embed-template.php */
    186                 echo apply_filters( 'embed_site_title_html', $site_title );
    187                 ?>
    188             </div>
    189         </div>
    190     </div>
    191     <?php
     20    get_template_part( 'embed', '404' );
    19221endif;
    19322
    194 /**
    195  * Print scripts or data before the closing body tag in the embed template.
    196  *
    197  * @since 4.4.0
    198  */
    199 do_action( 'embed_footer' );
    200 ?>
    201 </body>
    202 </html>
     23get_footer( 'embed' );
  • trunk/src/wp-includes/theme-compat/footer-embed.php

    r36689 r36693  
    11<?php
    22/**
    3  * Contains the post embed template.
     3 * Contains the post embed footer template.
    44 *
    55 * When a post is embedded in an iframe, this file is used to
    6  * create the output.
     6 * create the footer output if the active theme does not include
     7 * a footer-embed.php template.
    78 *
    89 * @package WordPress
    9  * @subpackage oEmbed
    10  * @since 4.4.0
     10 * @subpackage Theme_Compat
     11 * @since 4.5.0
    1112 */
    12 
    13 if ( ! headers_sent() ) {
    14     header( 'X-WP-embed: true' );
    15 }
    16 
    17 ?>
    18 <!DOCTYPE html>
    19 <html <?php language_attributes(); ?> class="no-js">
    20 <head>
    21     <title><?php echo wp_get_document_title(); ?></title>
    22     <meta http-equiv="X-UA-Compatible" content="IE=edge">
    23     <?php
    24     /**
    25      * Print scripts or data in the embed template <head> tag.
    26      *
    27      * @since 4.4.0
    28      */
    29     do_action( 'embed_head' );
    30     ?>
    31 </head>
    32 <body <?php body_class(); ?>>
    33 <?php
    34 if ( have_posts() ) :
    35     while ( have_posts() ) : the_post();
    36         // Add post thumbnail to response if available.
    37         $thumbnail_id = false;
    38 
    39         if ( has_post_thumbnail() ) {
    40             $thumbnail_id = get_post_thumbnail_id();
    41         }
    42 
    43         if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) {
    44             $thumbnail_id = get_the_ID();
    45         }
    46 
    47         if ( $thumbnail_id ) {
    48             $aspect_ratio = 1;
    49             $measurements = array( 1, 1 );
    50             $image_size   = 'full'; // Fallback.
    51 
    52             $meta = wp_get_attachment_metadata( $thumbnail_id );
    53             if ( ! empty( $meta['sizes'] ) ) {
    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'] );
    58                         $image_size   = $size;
    59                     }
    60                 }
    61             }
    62 
    63             /**
    64              * Filter the thumbnail image size for use in the embed template.
    65              *
    66              * @since 4.4.0
    67              *
    68              * @param string $image_size Thumbnail image size.
    69              */
    70             $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size );
    71 
    72             $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
    73 
    74             /**
    75              * Filter the thumbnail shape for use in the embed template.
    76              *
    77              * Rectangular images are shown above the title
    78              * while square images are shown next to the content.
    79              *
    80              * @since 4.4.0
    81              *
    82              * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'.
    83              */
    84             $shape = apply_filters( 'embed_thumbnail_image_shape', $shape );
    85         }
    86         ?>
    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 ); ?>
    92                     </a>
    93                 </div>
    94             <?php endif; ?>
    95 
    96             <p class="wp-embed-heading">
    97                 <a href="<?php the_permalink(); ?>" target="_top">
    98                     <?php the_title(); ?>
    99                 </a>
    100             </p>
    101 
    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 ); ?>
    106                     </a>
    107                 </div>
    108             <?php endif; ?>
    109 
    110             <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>
    111 
    112             <?php
    113             /**
    114              * Print additional content after the embed excerpt.
    115              *
    116              * @since 4.4.0
    117              */
    118             do_action( 'embed_content' );
    119             ?>
    120 
    121             <div class="wp-embed-footer">
    122                 <div class="wp-embed-site-title">
    123                     <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    128                         esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    129                         esc_html( get_bloginfo( 'name' ) )
    130                     );
    131 
    132                     /**
    133                      * Filter the site title HTML in the embed footer.
    134                      *
    135                      * @since 4.4.0
    136                      *
    137                      * @param string $site_title The site title HTML.
    138                      */
    139                     echo apply_filters( 'embed_site_title_html', $site_title );
    140                     ?>
    141                 </div>
    142 
    143                 <div class="wp-embed-meta">
    144                     <?php
    145                     /**
    146                      * Print additional meta content in the embed template.
    147                      *
    148                      * @since 4.4.0
    149                      */
    150                     do_action( 'embed_content_meta');
    151                     ?>
    152                 </div>
    153             </div>
    154         </div>
    155         <?php
    156     endwhile;
    157 else :
    158     ?>
    159     <div class="wp-embed">
    160         <p class="wp-embed-heading"><?php _e( 'Oops! That embed can&#8217;t be found.' ); ?></p>
    161 
    162         <div class="wp-embed-excerpt">
    163             <p>
    164                 <?php
    165                 printf(
    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>'
    169                 );
    170                 ?>
    171             </p>
    172         </div>
    173 
    174         <div class="wp-embed-footer">
    175             <div class="wp-embed-site-title">
    176                 <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    181                     esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    182                     esc_html( get_bloginfo( 'name' ) )
    183                 );
    184 
    185                 /** This filter is documented in wp-includes/embed-template.php */
    186                 echo apply_filters( 'embed_site_title_html', $site_title );
    187                 ?>
    188             </div>
    189         </div>
    190     </div>
    191     <?php
    192 endif;
    19313
    19414/**
  • trunk/src/wp-includes/theme-compat/header-embed.php

    r36689 r36693  
    11<?php
    22/**
    3  * Contains the post embed template.
     3 * Contains the post embed header template.
    44 *
    55 * When a post is embedded in an iframe, this file is used to
    6  * create the output.
     6 * create the header output if the active theme does not include
     7 * a header-embed.php template.
    78 *
    89 * @package WordPress
    9  * @subpackage oEmbed
    10  * @since 4.4.0
     10 * @subpackage Theme_Compat
     11 * @since 4.5.0
    1112 */
    1213
     
    3132</head>
    3233<body <?php body_class(); ?>>
    33 <?php
    34 if ( have_posts() ) :
    35     while ( have_posts() ) : the_post();
    36         // Add post thumbnail to response if available.
    37         $thumbnail_id = false;
    38 
    39         if ( has_post_thumbnail() ) {
    40             $thumbnail_id = get_post_thumbnail_id();
    41         }
    42 
    43         if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) {
    44             $thumbnail_id = get_the_ID();
    45         }
    46 
    47         if ( $thumbnail_id ) {
    48             $aspect_ratio = 1;
    49             $measurements = array( 1, 1 );
    50             $image_size   = 'full'; // Fallback.
    51 
    52             $meta = wp_get_attachment_metadata( $thumbnail_id );
    53             if ( ! empty( $meta['sizes'] ) ) {
    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'] );
    58                         $image_size   = $size;
    59                     }
    60                 }
    61             }
    62 
    63             /**
    64              * Filter the thumbnail image size for use in the embed template.
    65              *
    66              * @since 4.4.0
    67              *
    68              * @param string $image_size Thumbnail image size.
    69              */
    70             $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size );
    71 
    72             $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
    73 
    74             /**
    75              * Filter the thumbnail shape for use in the embed template.
    76              *
    77              * Rectangular images are shown above the title
    78              * while square images are shown next to the content.
    79              *
    80              * @since 4.4.0
    81              *
    82              * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'.
    83              */
    84             $shape = apply_filters( 'embed_thumbnail_image_shape', $shape );
    85         }
    86         ?>
    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 ); ?>
    92                     </a>
    93                 </div>
    94             <?php endif; ?>
    95 
    96             <p class="wp-embed-heading">
    97                 <a href="<?php the_permalink(); ?>" target="_top">
    98                     <?php the_title(); ?>
    99                 </a>
    100             </p>
    101 
    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 ); ?>
    106                     </a>
    107                 </div>
    108             <?php endif; ?>
    109 
    110             <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>
    111 
    112             <?php
    113             /**
    114              * Print additional content after the embed excerpt.
    115              *
    116              * @since 4.4.0
    117              */
    118             do_action( 'embed_content' );
    119             ?>
    120 
    121             <div class="wp-embed-footer">
    122                 <div class="wp-embed-site-title">
    123                     <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    128                         esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    129                         esc_html( get_bloginfo( 'name' ) )
    130                     );
    131 
    132                     /**
    133                      * Filter the site title HTML in the embed footer.
    134                      *
    135                      * @since 4.4.0
    136                      *
    137                      * @param string $site_title The site title HTML.
    138                      */
    139                     echo apply_filters( 'embed_site_title_html', $site_title );
    140                     ?>
    141                 </div>
    142 
    143                 <div class="wp-embed-meta">
    144                     <?php
    145                     /**
    146                      * Print additional meta content in the embed template.
    147                      *
    148                      * @since 4.4.0
    149                      */
    150                     do_action( 'embed_content_meta');
    151                     ?>
    152                 </div>
    153             </div>
    154         </div>
    155         <?php
    156     endwhile;
    157 else :
    158     ?>
    159     <div class="wp-embed">
    160         <p class="wp-embed-heading"><?php _e( 'Oops! That embed can&#8217;t be found.' ); ?></p>
    161 
    162         <div class="wp-embed-excerpt">
    163             <p>
    164                 <?php
    165                 printf(
    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>'
    169                 );
    170                 ?>
    171             </p>
    172         </div>
    173 
    174         <div class="wp-embed-footer">
    175             <div class="wp-embed-site-title">
    176                 <?php
    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, includes_url( 'images/w-logo-blue.png' ) ) ),
    181                     esc_url( get_site_icon_url( 64, includes_url( 'images/w-logo-blue.png' ) ) ),
    182                     esc_html( get_bloginfo( 'name' ) )
    183                 );
    184 
    185                 /** This filter is documented in wp-includes/embed-template.php */
    186                 echo apply_filters( 'embed_site_title_html', $site_title );
    187                 ?>
    188             </div>
    189         </div>
    190     </div>
    191     <?php
    192 endif;
    193 
    194 /**
    195  * Print scripts or data before the closing body tag in the embed template.
    196  *
    197  * @since 4.4.0
    198  */
    199 do_action( 'embed_footer' );
    200 ?>
    201 </body>
    202 </html>
Note: See TracChangeset for help on using the changeset viewer.