Ticket #34561: 34561.2.diff
File 34561.2.diff, 14.9 KB (added by , 9 years ago) |
---|
-
src/wp-includes/default-filters.php
diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php index e4ac939..e9c09c5 100644
add_action( 'embed_head', 'wp_no_robots' ); 458 458 add_action( 'embed_head', 'rel_canonical' ); 459 459 add_action( 'embed_head', 'locale_stylesheet' ); 460 460 461 add_action( 'embed_footer', 'print_embed_sharing_dialog' ); 461 462 add_action( 'embed_footer', 'print_embed_scripts' ); 462 463 add_action( 'embed_footer', 'wp_print_footer_scripts', 20 ); 463 464 -
src/wp-includes/embed-functions.php
diff --git src/wp-includes/embed-functions.php src/wp-includes/embed-functions.php index 24604c1..be647ba 100644
function print_embed_scripts() { 958 958 function _oembed_filter_feed_content( $content ) { 959 959 return str_replace( '<iframe sandbox="allow-scripts" security="restricted" style="display:none;"', '<iframe sandbox="allow-scripts" security="restricted"', $content ); 960 960 } 961 962 /** 963 * Prints the heading area of the embed template. 964 * 965 * This includes the post's title and the featured image 966 * if available. On 404, it only displays a 'Not found' heading. 967 * 968 * @since 4.4.0 969 */ 970 function the_embed_header() { 971 if ( is_404() ) { 972 ?> 973 <p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p> 974 <?php 975 return; 976 } 977 978 // Add post thumbnail to response if available. 979 $thumbnail_id = $shape = $image_size = false; 980 981 if ( has_post_thumbnail() ) { 982 $thumbnail_id = get_post_thumbnail_id(); 983 } 984 985 if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) { 986 $thumbnail_id = get_the_ID(); 987 } 988 989 if ( $thumbnail_id ) { 990 $aspect_ratio = 1; 991 $measurements = array( 1, 1 ); 992 $image_size = 'full'; // Fallback. 993 994 $meta = wp_get_attachment_metadata( $thumbnail_id ); 995 if ( is_array( $meta ) ) { 996 foreach ( $meta['sizes'] as $size => $data ) { 997 if ( $data['width'] / $data['height'] > $aspect_ratio ) { 998 $aspect_ratio = $data['width'] / $data['height']; 999 $measurements = array( $data['width'], $data['height'] ); 1000 $image_size = $size; 1001 } 1002 } 1003 } 1004 1005 /** 1006 * Filter the thumbnail image size for use in the embed template. 1007 * 1008 * @since 4.4.0 1009 * 1010 * @param string $image_size Thumbnail image size. 1011 */ 1012 $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size ); 1013 1014 $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square'; 1015 1016 /** 1017 * Filter the thumbnail shape for use in the embed template. 1018 * 1019 * Rectangular images are shown above the title 1020 * while square images are shown next to the content. 1021 * 1022 * @since 4.4.0 1023 * 1024 * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'. 1025 */ 1026 $shape = apply_filters( 'embed_thumbnail_image_shape', $shape ); 1027 } 1028 1029 if ( $thumbnail_id && 'rectangular' === $shape ) { 1030 ?> 1031 <div class="wp-embed-featured-image rectangular"> 1032 <a href="<?php the_permalink(); ?>" target="_top"> 1033 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?> 1034 </a> 1035 </div> 1036 <?php } ?> 1037 1038 <p class="wp-embed-heading"><a href="<?php the_permalink(); ?>" target="_top"><?php the_title(); ?></a></p> 1039 1040 <?php if ( $thumbnail_id && 'square' === $shape ) { ?> 1041 <div class="wp-embed-featured-image square"> 1042 <a href="<?php the_permalink(); ?>" target="_top"> 1043 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?> 1044 </a> 1045 </div> 1046 <?php } 1047 } 1048 1049 /** 1050 * Prints the footer area of the embed template. 1051 * 1052 * This includes the site's title and 1053 * sharing options if available. 1054 * 1055 * @since 4.4.0 1056 */ 1057 function the_embed_footer() { 1058 $site_title = sprintf( 1059 '<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>', 1060 esc_url( home_url() ), 1061 esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ), 1062 esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ), 1063 esc_html( get_bloginfo( 'name' ) ) 1064 ); 1065 1066 /** 1067 * Filter the site title in the embed footer. 1068 * 1069 * @since 4.4.0 1070 * 1071 * @param string $site_title The site title markup. 1072 */ 1073 $site_title = apply_filters( 'embed_site_title', $site_title ); 1074 ?> 1075 <div class="wp-embed-footer"> 1076 <div class="wp-embed-site-title"> 1077 <?php echo $site_title; ?> 1078 </div> 1079 <?php if ( ! is_404() ) : ?> 1080 <div class="wp-embed-meta"> 1081 <?php 1082 /** 1083 * Print additional meta content in the embed template. 1084 * 1085 * @since 4.4.0 1086 */ 1087 do_action( 'embed_content_meta' ); 1088 ?> 1089 <?php if ( get_comments_number() || comments_open() ) : ?> 1090 <div class="wp-embed-comments"> 1091 <a href="<?php comments_link(); ?>" target="_top"> 1092 <span class="dashicons dashicons-admin-comments"></span> 1093 <?php 1094 printf( 1095 _n( 1096 '%s <span class="screen-reader-text">Comment</span>', 1097 '%s <span class="screen-reader-text">Comments</span>', 1098 get_comments_number() 1099 ), 1100 number_format_i18n( get_comments_number() ) 1101 ); 1102 ?> 1103 </a> 1104 </div> 1105 <?php endif; ?> 1106 <div class="wp-embed-share"> 1107 <button type="button" class="wp-embed-share-dialog-open" aria-label="<?php esc_attr_e( 'Open sharing dialog' ); ?>"> 1108 <span class="dashicons dashicons-share"></span> 1109 </button> 1110 </div> 1111 </div> 1112 <?php endif; ?> 1113 </div> 1114 <?php 1115 } 1116 1117 /** 1118 * Prints the necessary markup for the embed sharing dialog. 1119 * 1120 * @since 4.4.0 1121 */ 1122 function print_embed_sharing_dialog() { 1123 if ( is_404() ) { 1124 return; 1125 } 1126 ?> 1127 <div class="wp-embed-share-dialog hidden" role="dialog" aria-label="<?php esc_attr_e( 'Sharing options' ); ?>"> 1128 <div class="wp-embed-share-dialog-content"> 1129 <div class="wp-embed-share-dialog-text"> 1130 <ul class="wp-embed-share-tabs" role="tablist"> 1131 <li class="wp-embed-share-tab-button wp-embed-share-tab-button-wordpress" role="presentation"> 1132 <button type="button" role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button> 1133 </li> 1134 <li class="wp-embed-share-tab-button wp-embed-share-tab-button-html" role="presentation"> 1135 <button type="button" role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button> 1136 </li> 1137 </ul> 1138 <div id="wp-embed-share-tab-wordpress" class="wp-embed-share-tab" role="tabpanel" aria-hidden="false"> 1139 <input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" aria-describedby="wp-embed-share-description-wordpress" tabindex="0" readonly/> 1140 1141 <p class="wp-embed-share-description" id="wp-embed-share-description-wordpress"> 1142 <?php _e( 'Copy and paste this URL into your WordPress site to embed' ); ?> 1143 </p> 1144 </div> 1145 <div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-hidden="true"> 1146 <textarea class="wp-embed-share-input" aria-describedby="wp-embed-share-description-html" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( 600, 400 ) ); ?></textarea> 1147 1148 <p class="wp-embed-share-description" id="wp-embed-share-description-html"> 1149 <?php _e( 'Copy and paste this code into your site to embed' ); ?> 1150 </p> 1151 </div> 1152 </div> 1153 1154 <button type="button" class="wp-embed-share-dialog-close" aria-label="<?php esc_attr_e( 'Close sharing dialog' ); ?>"> 1155 <span class="dashicons dashicons-no"></span> 1156 </button> 1157 </div> 1158 </div> 1159 <?php 1160 } -
src/wp-includes/embed-template.php
diff --git src/wp-includes/embed-template.php src/wp-includes/embed-template.php index ce33832..80294c0 100644
if ( ! headers_sent() ) { 33 33 <?php 34 34 if ( have_posts() ) : 35 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 ( is_array( $meta ) ) {54 foreach ( $meta['sizes'] as $size => $data ) {55 if ( $data['width'] / $data['height'] > $aspect_ratio ) {56 $aspect_ratio = $data['width'] / $data['height'];57 $measurements = array( $data['width'], $data['height'] );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 36 ?> 87 37 <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> 38 <?php the_embed_header(); ?> 101 39 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> 40 <div class="wp-embed-excerpt"> 41 <?php the_excerpt_embed(); ?> 42 </div> 111 43 112 44 <?php 113 45 /** … … if ( have_posts() ) : 118 50 do_action( 'embed_content' ); 119 51 ?> 120 52 121 <div class="wp-embed-footer"> 122 <div class="wp-embed-site-title"> 123 <?php 124 printf( 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 ); 131 ?> 132 </div> 133 134 <div class="wp-embed-meta"> 135 <?php 136 /** 137 * Print additional meta content in the embed template. 138 * 139 * @since 4.4.0 140 */ 141 do_action( 'embed_content_meta'); 142 ?> 143 <?php if ( get_comments_number() || comments_open() ) : ?> 144 <div class="wp-embed-comments"> 145 <a href="<?php comments_link(); ?>" target="_top"> 146 <span class="dashicons dashicons-admin-comments"></span> 147 <?php 148 printf( 149 _n( 150 '%s <span class="screen-reader-text">Comment</span>', 151 '%s <span class="screen-reader-text">Comments</span>', 152 get_comments_number() 153 ), 154 number_format_i18n( get_comments_number() ) 155 ); 156 ?> 157 </a> 158 </div> 159 <?php endif; ?> 160 <div class="wp-embed-share"> 161 <button type="button" class="wp-embed-share-dialog-open" aria-label="<?php esc_attr_e( 'Open sharing dialog' ); ?>"> 162 <span class="dashicons dashicons-share"></span> 163 </button> 164 </div> 165 </div> 166 </div> 167 <div class="wp-embed-share-dialog hidden" role="dialog" aria-label="<?php esc_attr_e( 'Sharing options' ); ?>"> 168 <div class="wp-embed-share-dialog-content"> 169 <div class="wp-embed-share-dialog-text"> 170 <ul class="wp-embed-share-tabs" role="tablist"> 171 <li class="wp-embed-share-tab-button wp-embed-share-tab-button-wordpress" role="presentation"> 172 <button type="button" role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button> 173 </li> 174 <li class="wp-embed-share-tab-button wp-embed-share-tab-button-html" role="presentation"> 175 <button type="button" role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button> 176 </li> 177 </ul> 178 <div id="wp-embed-share-tab-wordpress" class="wp-embed-share-tab" role="tabpanel" aria-hidden="false"> 179 <input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" aria-describedby="wp-embed-share-description-wordpress" tabindex="0" readonly /> 180 181 <p class="wp-embed-share-description" id="wp-embed-share-description-wordpress"> 182 <?php _e( 'Copy and paste this URL into your WordPress site to embed' ); ?> 183 </p> 184 </div> 185 <div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-hidden="true"> 186 <textarea class="wp-embed-share-input" aria-describedby="wp-embed-share-description-html" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( 600, 400 ) ); ?></textarea> 187 188 <p class="wp-embed-share-description" id="wp-embed-share-description-html"> 189 <?php _e( 'Copy and paste this code into your site to embed' ); ?> 190 </p> 191 </div> 192 </div> 193 194 <button type="button" class="wp-embed-share-dialog-close" aria-label="<?php esc_attr_e( 'Close sharing dialog' ); ?>"> 195 <span class="dashicons dashicons-no"></span> 196 </button> 197 </div> 198 </div> 53 <?php the_embed_footer(); ?> 199 54 </div> 200 55 <?php 201 56 endwhile; 202 57 else : 203 58 ?> 204 59 <div class="wp-embed"> 205 < p class="wp-embed-heading"><?php _e( 'Oops! That embed can’t be found.' ); ?></p>60 <?php the_embed_header(); ?> 206 61 207 62 <div class="wp-embed-excerpt"> 208 63 <p> … … else : 216 71 </p> 217 72 </div> 218 73 219 <div class="wp-embed-footer"> 220 <div class="wp-embed-site-title"> 221 <?php 222 printf( 223 '<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>', 224 esc_url( home_url() ), 225 esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ), 226 esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ), 227 esc_html( get_bloginfo( 'name' ) ) 228 ); 229 ?> 230 </div> 231 </div> 74 <?php the_embed_footer(); ?> 232 75 </div> 233 76 <?php 234 77 endif;