Ticket #34561: 34561.9.patch
File 34561.9.patch, 16.0 KB (added by , 9 years ago) |
---|
-
src/wp-includes/embed-template.php
diff --git src/wp-includes/embed-template.php src/wp-includes/embed-template.php index fab8c84..ae72352 100644
10 10 * @since 4.4.0 11 11 */ 12 12 13 if ( ! headers_sent() ) { 14 header( 'X-WP-embed: true' ); 15 } 13 get_header( 'embed' ); 16 14 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 15 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 16 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, admin_url( 'images/w-logo-blue.png' ) ) ), 128 esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ), 129 esc_html( get_bloginfo( 'name' ) ) 130 ); 17 while ( have_posts() ) : the_post(); 131 18 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> 19 get_embed_template_part(); 142 20 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 21 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 22 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> 23 else : 173 24 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, admin_url( 'images/w-logo-blue.png' ) ) ), 181 esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ), 182 esc_html( get_bloginfo( 'name' ) ) 183 ); 25 get_embed_template_part( 'none' ); 184 26 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 27 endif; 193 28 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> 29 get_footer( 'embed' ); -
src/wp-includes/embed.php
diff --git src/wp-includes/embed.php src/wp-includes/embed.php index 17b9ac4..b0711de 100644
function print_embed_sharing_dialog() { 1045 1045 </div> 1046 1046 <?php 1047 1047 } 1048 1049 /** 1050 * Prints the necessary markup for the embed thumbnail. 1051 * 1052 * @since 4.5.0 1053 */ 1054 function the_post_embed_thumbnail( $type = 'rectangular' ) { 1055 $thumbnail_id = false; 1056 1057 if ( has_post_thumbnail() ) { 1058 $thumbnail_id = get_post_thumbnail_id(); 1059 } 1060 1061 if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) { 1062 $thumbnail_id = get_the_ID(); 1063 } 1064 1065 if ( ! $thumbnail_id ) { 1066 return; 1067 } 1068 1069 $aspect_ratio = 1; 1070 $measurements = array( 1, 1 ); 1071 $image_size = 'full'; // Fallback. 1072 1073 $meta = wp_get_attachment_metadata( $thumbnail_id ); 1074 if ( is_array( $meta ) ) { 1075 foreach ( $meta['sizes'] as $size => $data ) { 1076 if ( $data['width'] / $data['height'] > $aspect_ratio ) { 1077 $aspect_ratio = $data['width'] / $data['height']; 1078 $measurements = array( $data['width'], $data['height'] ); 1079 $image_size = $size; 1080 } 1081 } 1082 } 1083 1084 /** 1085 * Filter the thumbnail image size for use in the embed template. 1086 * 1087 * @since 4.4.0 1088 * @since 4.5.0 Added `$thumbnail_id` parameter. 1089 * 1090 * @param string $image_size Thumbnail image size. 1091 * @param int $thumbnail_id Attachment ID. 1092 */ 1093 $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size, $thumbnail_id ); 1094 1095 $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square'; 1096 1097 /** 1098 * Filter the thumbnail shape for use in the embed template. 1099 * 1100 * Rectangular images are shown above the title while square images 1101 * are shown next to the content. 1102 * 1103 * @since 4.4.0 1104 * @since 4.5.0 Added `$thumbnail_id` parameter. 1105 * 1106 * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'. 1107 * @param int $thumbnail_id Attachment ID. 1108 */ 1109 $shape = apply_filters( 'embed_thumbnail_image_shape', $shape, $thumbnail_id ); 1110 1111 if ( 'rectangular' === $type && $shape === $type ) : ?> 1112 <div class="wp-embed-featured-image rectangular"> 1113 <a href="<?php the_permalink(); ?>" target="_top"> 1114 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?> 1115 </a> 1116 </div> 1117 <?php endif; 1118 1119 if ( 'square' === $type && $shape === $type ) : ?> 1120 <div class="wp-embed-featured-image square"> 1121 <a href="<?php the_permalink(); ?>" target="_top"> 1122 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?> 1123 </a> 1124 </div> 1125 <?php endif; 1126 } 1127 1128 /** 1129 * Prints the necessary markup for the site title. 1130 * 1131 * @since 4.5.0 1132 */ 1133 function the_embed_site_title() { 1134 $site_title = sprintf( 1135 '<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>', 1136 esc_url( home_url() ), 1137 esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ), 1138 esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ), 1139 esc_html( get_bloginfo( 'name' ) ) 1140 ); 1141 1142 $site_title = '<div class="wp-embed-site-title">' . $site_title . '</div>'; 1143 1144 /** 1145 * Filter the site title HTML in the embed footer. 1146 * 1147 * @since 4.4.0 1148 * 1149 * @param string $site_title The site title HTML. 1150 */ 1151 echo apply_filters( 'embed_site_title_html', $site_title ); 1152 } -
src/wp-includes/general-template.php
diff --git src/wp-includes/general-template.php src/wp-includes/general-template.php index 3e13925..c37b688 100644
function get_header( $name = null ) { 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 $templates[] = 'header.php'; 43 if ( 'embed' === $name ) { 44 $backcompat_dir = ABSPATH . WPINC . '/theme-compat/embed'; 45 } else { 46 $templates[] = 'header.php'; 47 $backcompat_dir = ABSPATH . WPINC . '/theme-compat'; 48 } 43 49 44 50 // 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'); 51 if ( '' == locate_template( $templates, true ) ) { 52 load_template( $backcompat_dir . '/header.php'); 53 } 47 54 } 48 55 49 56 /** … … function get_footer( $name = null ) { 76 83 77 84 $templates = array(); 78 85 $name = (string) $name; 79 if ( '' !== $name ) 86 if ( '' !== $name ) { 80 87 $templates[] = "footer-{$name}.php"; 88 } 81 89 82 $templates[] = 'footer.php'; 90 if ( 'embed' === $name ) { 91 $backcompat_dir = ABSPATH . WPINC . '/theme-compat/embed'; 92 } else { 93 $templates[] = 'footer.php'; 94 $backcompat_dir = ABSPATH . WPINC . '/theme-compat'; 95 } 83 96 84 97 // 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'); 98 if ( '' == locate_template( $templates, true ) ) { 99 load_template( $backcompat_dir . '/footer.php' ); 100 } 87 101 } 88 102 89 103 /** … … function get_template_part( $slug, $name = null ) { 166 180 if ( '' !== $name ) 167 181 $templates[] = "{$slug}-{$name}.php"; 168 182 169 $templates[] = "{$slug}.php"; 183 if ( false === strpos( $name, 'embed' ) ) { 184 $templates[] = "{$slug}.php"; 185 } 170 186 171 187 locate_template($templates, true, false); 172 188 } 173 189 174 190 /** 191 * Load an embed template part into a template 192 * 193 * @since 4.5.0 194 * 195 * @param string $name The name of the specialised template. 196 */ 197 function get_embed_template_part( $name = 'embed' ) { 198 $default_template = "content.php"; 199 200 if ( 'none' === $name ) { 201 $name = 'embed-none'; 202 $default_template = "content-none.php"; 203 } 204 205 // First try to use the content-$name.php template part provided by the theme 206 if ( null !== get_template_part( 'content', $name ) ) { 207 return; 208 } 209 210 // Nothing found, let's use the default output 211 load_template( ABSPATH . WPINC . '/theme-compat/embed/' . $default_template ); 212 } 213 214 /** 175 215 * Display search form. 176 216 * 177 217 * Will first attempt to locate the searchform.php file in either the child or -
src/wp-includes/theme-compat/embed/content-none.php
diff --git src/wp-includes/theme-compat/embed/content-none.php src/wp-includes/theme-compat/embed/content-none.php index e69de29..eadcfcb 100644
1 <?php 2 /** 3 * Contains the post embed content template part. 4 * 5 * When a post is embedded in an iframe, this file is used to 6 * create the content template part output if the active theme does not include 7 * a content-embed.php template. 8 * 9 * @package WordPress 10 * @subpackage Theme_Compat 11 * @since 4.5.0 12 */ 13 ?> 14 <div class="wp-embed"> 15 <p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p> 16 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> 28 29 <?php 30 /** This filter is documented in wp-includes/theme-compat/embed/content.php */ 31 do_action( 'embed_content' ); 32 ?> 33 34 <div class="wp-embed-footer"> 35 36 <?php the_embed_site_title() ?> 37 38 </div> 39 </div> -
src/wp-includes/theme-compat/embed/content.php
diff --git src/wp-includes/theme-compat/embed/content.php src/wp-includes/theme-compat/embed/content.php index e69de29..6e80bea 100644
1 <?php 2 /** 3 * Contains the post embed content template part. 4 * 5 * When a post is embedded in an iframe, this file is used to 6 * create the content template part output if the active theme does not include 7 * a content-embed.php template. 8 * 9 * @package WordPress 10 * @subpackage Theme_Compat 11 * @since 4.5.0 12 */ 13 ?> 14 <div <?php post_class( 'wp-embed' ); ?>> 15 <?php 16 /** 17 * Display rectangular thumbnail above the Post Embed Title 18 */ 19 the_post_embed_thumbnail( 'rectangular' ) ?> 20 21 <p class="wp-embed-heading"> 22 <a href="<?php the_permalink(); ?>" target="_top"> 23 <?php the_title(); ?> 24 </a> 25 </p> 26 27 <?php 28 /** 29 * Display square thumbnail above the Post Embed Title 30 */ 31 the_post_embed_thumbnail( 'square' ) ?> 32 33 <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div> 34 35 <?php 36 /** 37 * Print additional content after the embed excerpt. 38 * 39 * @since 4.4.0 40 */ 41 do_action( 'embed_content' ); 42 ?> 43 44 <div class="wp-embed-footer"> 45 46 <?php the_embed_site_title() ?> 47 48 <div class="wp-embed-meta"> 49 <?php 50 /** 51 * Print additional meta content in the embed template. 52 * 53 * @since 4.4.0 54 */ 55 do_action( 'embed_content_meta'); 56 ?> 57 </div> 58 </div> 59 </div> 60 <?php -
src/wp-includes/theme-compat/embed/footer.php
diff --git src/wp-includes/theme-compat/embed/footer.php src/wp-includes/theme-compat/embed/footer.php index e69de29..05e9f4f 100644
1 <?php 2 /** 3 * Contains the post embed footer template. 4 * 5 * When a post is embedded in an iframe, this file is used to 6 * create the footer output if the active theme does not include 7 * a footer-embed.php template. 8 * 9 * @package WordPress 10 * @subpackage Theme_Compat 11 * @since 4.5.0 12 */ 13 14 /** 15 * Print scripts or data before the closing body tag in the embed template. 16 * 17 * @since 4.4.0 18 */ 19 do_action( 'embed_footer' ); 20 ?> 21 </body> 22 </html> -
src/wp-includes/theme-compat/embed/header.php
diff --git src/wp-includes/theme-compat/embed/header.php src/wp-includes/theme-compat/embed/header.php index e69de29..a95bdb3 100644
1 <?php 2 /** 3 * Contains the post embed header template. 4 * 5 * When a post is embedded in an iframe, this file is used to 6 * create the header output if the active theme does not include 7 * a header-embed.php template. 8 * 9 * @package WordPress 10 * @subpackage Theme_Compat 11 * @since 4.5.0 12 */ 13 14 if ( ! headers_sent() ) { 15 header( 'X-WP-embed: true' ); 16 } 17 18 ?> 19 <!DOCTYPE html> 20 <html <?php language_attributes(); ?> class="no-js"> 21 <head> 22 <title><?php echo wp_get_document_title(); ?></title> 23 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 24 <?php 25 /** 26 * Print scripts or data in the embed template <head> tag. 27 * 28 * @since 4.4.0 29 */ 30 do_action( 'embed_head' ); 31 ?> 32 </head> 33 <body <?php body_class(); ?>>