Ticket #34561: 34561.10.diff
File 34561.10.diff, 36.7 KB (added by , 9 years ago) |
---|
-
src/wp-includes/embed-template.php
1 1 <?php 2 2 /** 3 * Contains the post embed template.3 * Back-compat placeholder for wp-includes/theme-compat/embed-template.php 4 4 * 5 * When a post is embedded in an iframe, this file is used to6 * create the output.7 *8 5 * @package WordPress 9 6 * @subpackage oEmbed 10 7 * @since 4.4.0 8 * @since 4.5.0 Moved to wp-incluudes/theme-compat/embed-template.php 11 9 */ 12 10 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’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> 11 include( ABSPATH . WPINC . '/theme-compat/embed-template.php' ); -
src/wp-includes/embed.php
1046 1046 </div> 1047 1047 <?php 1048 1048 } 1049 1050 /** 1051 * Prints the necessary markup for the site title. 1052 * 1053 * @since 4.5.0 1054 */ 1055 function 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 } -
src/wp-includes/general-template.php
36 36 37 37 $templates = array(); 38 38 $name = (string) $name; 39 if ( '' !== $name ) 39 if ( '' !== $name ) { 40 40 $templates[] = "header-{$name}.php"; 41 } 41 42 42 43 $templates[] = 'header.php'; 43 44 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 ); 47 46 } 48 47 49 48 /** … … 76 75 77 76 $templates = array(); 78 77 $name = (string) $name; 79 if ( '' !== $name ) 78 if ( '' !== $name ) { 80 79 $templates[] = "footer-{$name}.php"; 80 } 81 81 82 $templates[] = 'footer.php';82 $templates[] = 'footer.php'; 83 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'); 84 locate_template( $templates, true ); 87 85 } 88 86 89 87 /** … … 121 119 122 120 $templates[] = 'sidebar.php'; 123 121 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 ); 127 123 } 128 124 129 125 /** -
src/wp-includes/template-loader.php
40 40 include( ABSPATH . 'wp-trackback.php' ); 41 41 return; 42 42 elseif ( is_embed() ) : 43 $template = ABSPATH . WPINC . '/ embed-template.php';43 $template = ABSPATH . WPINC . '/theme-compat/embed-template.php'; 44 44 45 45 /** 46 46 * Filter the template used for embedded posts. -
src/wp-includes/template.php
468 468 /** 469 469 * Retrieve the name of the highest priority template file that exists. 470 470 * 471 * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which472 * 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. 473 473 * 474 474 * @since 2.7.0 475 475 * … … 489 489 } elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) { 490 490 $located = TEMPLATEPATH . '/' . $template_name; 491 491 break; 492 } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) { 493 $located = ABSPATH . WPINC . '/theme-compat/' . $template_name; 494 break; 492 495 } 493 496 } 494 497 -
src/wp-includes/theme-compat/embed-404.php
1 1 <?php 2 2 /** 3 * Contains the post embed template.3 * Contains the post embed content template part. 4 4 * 5 5 * 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. 7 8 * 8 9 * @package WordPress 9 * @subpackage oEmbed10 * @since 4. 4.010 * @subpackage Theme_Compat 11 * @since 4.5.0 11 12 */ 12 13 if ( ! headers_sent() ) {14 header( 'X-WP-embed: true' );15 }16 17 13 ?> 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 class="wp-embed"> 15 <p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p> 38 16 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 17 <div class="wp-embed-excerpt"> 18 <p> 112 19 <?php 113 /** 114 * Print additional content after the embed excerpt. 115 * 116 * @since 4.4.0 117 */ 118 do_action( 'embed_content' ); 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 ); 119 25 ?> 26 </p> 27 </div> 120 28 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 : 29 <?php 30 /** This filter is documented in wp-includes/theme-compat/embed-content.php */ 31 do_action( 'embed_content' ); 158 32 ?> 159 <div class="wp-embed">160 <p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p>161 33 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() ?> 190 36 </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> -
src/wp-includes/theme-compat/embed-content.php
1 1 <?php 2 2 /** 3 * Contains the post embed template.3 * Contains the post embed content template part. 4 4 * 5 5 * 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. 7 8 * 8 9 * @package WordPress 9 * @subpackage oEmbed10 * @since 4. 4.010 * @subpackage Theme_Compat 11 * @since 4.5.0 11 12 */ 12 13 if ( ! headers_sent() ) {14 header( 'X-WP-embed: true' );15 }16 17 13 ?> 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. 14 <div <?php post_class( 'wp-embed' ); ?>> 15 <?php 37 16 $thumbnail_id = false; 38 17 39 18 if ( has_post_thumbnail() ) { … … 44 23 $thumbnail_id = get_the_ID(); 45 24 } 46 25 47 if ( $thumbnail_id ) { 48 $aspect_ratio = 1; 49 $measurements = array( 1, 1 ); 50 $image_size = 'full'; // Fallback. 26 if ( ! $thumbnail_id ) { 27 return; 28 } 51 29 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 $aspect_ratio = 1; 31 $measurements = array( 1, 1 ); 32 $image_size = 'full'; // Fallback. 33 34 $meta = wp_get_attachment_metadata( $thumbnail_id ); 35 if ( is_array( $meta ) ) { 36 foreach ( $meta['sizes'] as $size => $data ) { 37 if ( $data['width'] / $data['height'] > $aspect_ratio ) { 38 $aspect_ratio = $data['width'] / $data['height']; 39 $measurements = array( $data['width'], $data['height'] ); 40 $image_size = $size; 60 41 } 61 42 } 43 } 62 44 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 ); 45 /** 46 * Filter the thumbnail image size for use in the embed template. 47 * 48 * @since 4.4.0 49 * @since 4.5.0 Added `$thumbnail_id` parameter. 50 * 51 * @param string $image_size Thumbnail image size. 52 * @param int $thumbnail_id Attachment ID. 53 */ 54 $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size, $thumbnail_id ); 71 55 72 56 $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square'; 73 57 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; ?> 58 /** 59 * Filter the thumbnail shape for use in the embed template. 60 * 61 * Rectangular images are shown above the title while square images 62 * are shown next to the content. 63 * 64 * @since 4.4.0 65 * @since 4.5.0 Added `$thumbnail_id` parameter. 66 * 67 * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'. 68 * @param int $thumbnail_id Attachment ID. 69 */ 70 $shape = apply_filters( 'embed_thumbnail_image_shape', $shape, $thumbnail_id ); 95 71 96 <p class="wp-embed-heading"> 72 if ( 'rectangular' === $shape ) : ?> 73 <div class="wp-embed-featured-image rectangular"> 97 74 <a href="<?php the_permalink(); ?>" target="_top"> 98 <?php the_title(); ?>75 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?> 99 76 </a> 100 </p> 77 </div> 78 <?php endif; ?> 101 79 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; ?> 80 <p class="wp-embed-heading"> 81 <a href="<?php the_permalink(); ?>" target="_top"> 82 <?php the_title(); ?> 83 </a> 84 </p> 109 85 110 <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div> 86 <?php if ( 'square' === $shape ) : ?> 87 <div class="wp-embed-featured-image square"> 88 <a href="<?php the_permalink(); ?>" target="_top"> 89 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?> 90 </a> 91 </div> 92 <?php endif; ?> 111 93 112 <?php 113 /** 114 * Print additional content after the embed excerpt. 115 * 116 * @since 4.4.0 117 */ 118 do_action( 'embed_content' ); 119 ?> 94 <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div> 120 95 121 <div class="wp-embed-footer">122 <div class="wp-embed-site-title">123 <?php124 $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.0136 *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 <?php145 /**146 * Print additional meta content in the embed template.147 *148 * @since 4.4.0149 */150 do_action( 'embed_content_meta');151 ?>152 </div>153 </div>154 </div>155 96 <?php 156 endwhile; 157 else : 158 ?> 159 <div class="wp-embed"> 160 <p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p> 97 /** 98 * Print additional content after the embed excerpt. 99 * 100 * @since 4.4.0 101 */ 102 do_action( 'embed_content' ); 103 ?> 161 104 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> 105 <div class="wp-embed-footer"> 106 <?php the_embed_site_title() ?> 173 107 174 <div class="wp-embed-footer"> 175 <div class="wp-embed-site-title"> 108 <div class="wp-embed-meta"> 176 109 <?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 ); 110 /** 111 * Print additional meta content in the embed template. 112 * 113 * @since 4.4.0 114 */ 115 do_action( 'embed_content_meta'); 187 116 ?> 188 117 </div> 189 118 </div> 190 119 </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> 120 <?php -
src/wp-includes/theme-compat/embed-template.php
182 182 esc_html( get_bloginfo( 'name' ) ) 183 183 ); 184 184 185 /** This filter is documented in wp-includes/ embed-template.php */185 /** This filter is documented in wp-includes/theme-compat/embed-template.php */ 186 186 echo apply_filters( 'embed_site_title_html', $site_title ); 187 187 ?> 188 188 </div> -
src/wp-includes/theme-compat/footer-embed.php
1 1 <?php 2 2 /** 3 * Contains the post embed template.3 * Contains the post embed footer template. 4 4 * 5 5 * 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. 7 8 * 8 9 * @package WordPress 9 * @subpackage oEmbed10 * @since 4. 4.010 * @subpackage Theme_Compat 11 * @since 4.5.0 11 12 */ 12 13 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 <?php24 /**25 * Print scripts or data in the embed template <head> tag.26 *27 * @since 4.4.028 */29 do_action( 'embed_head' );30 ?>31 </head>32 <body <?php body_class(); ?>>33 <?php34 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.067 *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 title78 * while square images are shown next to the content.79 *80 * @since 4.4.081 *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 <?php113 /**114 * Print additional content after the embed excerpt.115 *116 * @since 4.4.0117 */118 do_action( 'embed_content' );119 ?>120 121 <div class="wp-embed-footer">122 <div class="wp-embed-site-title">123 <?php124 $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.0136 *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 <?php145 /**146 * Print additional meta content in the embed template.147 *148 * @since 4.4.0149 */150 do_action( 'embed_content_meta');151 ?>152 </div>153 </div>154 </div>155 <?php156 endwhile;157 else :158 ?>159 <div class="wp-embed">160 <p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p>161 162 <div class="wp-embed-excerpt">163 <p>164 <?php165 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 <?php177 $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 <?php192 endif;193 194 14 /** 195 15 * Print scripts or data before the closing body tag in the embed template. 196 16 * -
src/wp-includes/theme-compat/header-embed.php
1 1 <?php 2 2 /** 3 * Contains the post embed template.3 * Contains the post embed header template. 4 4 * 5 5 * 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. 7 8 * 8 9 * @package WordPress 9 * @subpackage oEmbed10 * @since 4. 4.010 * @subpackage Theme_Compat 11 * @since 4.5.0 11 12 */ 12 13 13 14 if ( ! headers_sent() ) { … … 30 31 ?> 31 32 </head> 32 33 <body <?php body_class(); ?>> 33 <?php34 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.067 *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 title78 * while square images are shown next to the content.79 *80 * @since 4.4.081 *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 <?php113 /**114 * Print additional content after the embed excerpt.115 *116 * @since 4.4.0117 */118 do_action( 'embed_content' );119 ?>120 121 <div class="wp-embed-footer">122 <div class="wp-embed-site-title">123 <?php124 $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.0136 *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 <?php145 /**146 * Print additional meta content in the embed template.147 *148 * @since 4.4.0149 */150 do_action( 'embed_content_meta');151 ?>152 </div>153 </div>154 </div>155 <?php156 endwhile;157 else :158 ?>159 <div class="wp-embed">160 <p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p>161 162 <div class="wp-embed-excerpt">163 <p>164 <?php165 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 <?php177 $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 <?php192 endif;193 194 /**195 * Print scripts or data before the closing body tag in the embed template.196 *197 * @since 4.4.0198 */199 do_action( 'embed_footer' );200 ?>201 </body>202 </html>