Ticket #34272: 34272.diff
| File 34272.diff, 27.7 KB (added by , 10 years ago) |
|---|
-
Gruntfile.js
diff --git Gruntfile.js Gruntfile.js index b8dd5f8..3d02881 100644
module.exports = function(grunt) { 233 233 234 234 // Exceptions 235 235 '!wp-includes/css/dashicons.css', 236 '!wp-includes/css/wp- oembed-embed.css'236 '!wp-includes/css/wp-embed-template.css' 237 237 ] 238 238 }, 239 239 colors: { … … module.exports = function(grunt) { 530 530 src: BUILD_DIR + 'wp-includes/formatting.php', 531 531 dest: '.' 532 532 }, 533 oembed: {533 embed: { 534 534 src: BUILD_DIR + 'wp-includes/embed-functions.php', 535 535 dest: '.' 536 536 } … … module.exports = function(grunt) { 642 642 'clean:tinymce', 643 643 'concat:emoji', 644 644 'includes:emoji', 645 'includes: oembed',645 'includes:embed', 646 646 'jsvalidate:build' 647 647 ] ); 648 648 -
new file src/wp-includes/css/wp-embed-template.css
diff --git src/wp-includes/css/wp-embed-template.css src/wp-includes/css/wp-embed-template.css new file mode 100644 index 0000000..9ea586b
- + 1 html, body { 2 padding: 0; 3 margin: 0; 4 } 5 6 body { 7 font-family: sans-serif; 8 } 9 10 /* Text meant only for screen readers */ 11 .screen-reader-text { 12 clip: rect(1px, 1px, 1px, 1px); 13 height: 1px; 14 overflow: hidden; 15 position: absolute !important; 16 width: 1px; 17 } 18 19 /* Dashicons */ 20 .dashicons { 21 display: inline-block; 22 width: 20px; 23 height: 20px; 24 background-color: transparent; 25 background-repeat: no-repeat; 26 -webkit-background-size: 20px 20px; 27 background-size: 20px; 28 background-position: center; 29 -webkit-transition: background .1s ease-in; 30 transition: background .1s ease-in; 31 position: relative; 32 top: 5px; 33 } 34 35 .dashicons-no { 36 background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M15.55%2013.7l-2.19%202.06-3.42-3.65-3.64%203.43-2.06-2.18%203.64-3.43-3.42-3.64%202.18-2.06%203.43%203.64%203.64-3.42%202.05%202.18-3.64%203.43z%27%20fill%3D%27%23fff%27%2F%3E%3C%2Fsvg%3E"); 37 } 38 39 .dashicons-admin-comments { 40 background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E"); 41 } 42 43 .wp-embed-comments a:hover .dashicons-admin-comments { 44 background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E"); 45 } 46 47 .dashicons-share { 48 background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E"); 49 } 50 51 .wp-embed-share-dialog-open:hover .dashicons-share { 52 background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E"); 53 } 54 55 .wp-embed { 56 width: 100%; 57 padding: 25px; 58 font: 400 14px/1.5 'Open Sans', sans-serif; 59 color: #82878c; 60 background: white; 61 border: 1px solid #e5e5e5; 62 -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05); 63 box-shadow: 0 1px 1px rgba(0, 0, 0, .05); 64 -webkit-box-sizing: border-box; 65 -moz-box-sizing: border-box; 66 box-sizing: border-box; 67 /* Clearfix */ 68 overflow: auto; 69 zoom: 1; 70 } 71 72 .wp-embed a { 73 color: #82878c; 74 text-decoration: none; 75 } 76 77 .wp-embed a:hover { 78 text-decoration: underline; 79 } 80 81 .wp-embed-featured-image { 82 margin-bottom: 20px; 83 } 84 85 .wp-embed-featured-image img { 86 width: 100%; 87 height: auto; 88 border: none; 89 } 90 91 .wp-embed-featured-image.square { 92 float: left; 93 max-width: 160px; 94 margin-right: 20px; 95 } 96 97 .wp-embed p { 98 margin: 0; 99 } 100 101 p.wp-embed-heading { 102 margin: 0 0 15px; 103 font-weight: bold; 104 font-size: 22px; 105 line-height: 1.3; 106 } 107 108 .wp-embed-heading a { 109 color: #32373c; 110 } 111 112 .wp-embed .wp-embed-more { 113 color: #b4b9be; 114 } 115 116 .wp-embed-footer { 117 display: table; 118 width: 100%; 119 margin-top: 30px; 120 } 121 122 .wp-embed-site-icon { 123 position: absolute; 124 top: 50%; 125 left: 0; 126 -webkit-transform: translateY(-50%); 127 -ms-transform: translateY(-50%); 128 transform: translateY(-50%); 129 height: 25px; 130 width: 25px; 131 border: 0; 132 } 133 134 .wp-embed-site-title { 135 font-weight: bold; 136 line-height: 25px; 137 } 138 139 .wp-embed-site-title a { 140 position: relative; 141 display: inline-block; 142 padding-left: 35px; 143 } 144 145 .wp-embed-site-title, 146 .wp-embed-meta { 147 display: table-cell; 148 } 149 150 .wp-embed-meta { 151 text-align: right; 152 white-space: nowrap; 153 vertical-align: middle; 154 } 155 156 .wp-embed-comments, 157 .wp-embed-share { 158 display: inline; 159 } 160 161 .wp-embed-meta a:hover { 162 text-decoration: none; 163 color: #0073aa; 164 } 165 166 .wp-embed-comments a { 167 line-height: 25px; 168 display: inline-block; 169 } 170 171 .wp-embed-comments + .wp-embed-share { 172 margin-left: 10px; 173 } 174 175 .wp-embed-share-dialog { 176 position: absolute; 177 top: 0; 178 left: 0; 179 right: 0; 180 bottom: 0; 181 background-color: rgba(10, 10, 10, 0.9); 182 color: #fff; 183 opacity: 1; 184 -webkit-transition: opacity .25s ease-in-out; 185 transition: opacity .25s ease-in-out; 186 } 187 188 .wp-embed-share-dialog.hidden { 189 opacity: 0; 190 visibility: hidden; 191 } 192 193 .wp-embed-share-dialog-open, 194 .wp-embed-share-dialog-close { 195 margin: -8px 0 0; 196 padding: 0; 197 background: transparent; 198 border: none; 199 cursor: pointer; 200 outline: none; 201 } 202 203 .wp-embed-share-dialog-open .dashicons, 204 .wp-embed-share-dialog-close .dashicons { 205 padding: 4px; 206 } 207 208 .wp-embed-share-dialog-open .dashicons { 209 top: 8px; 210 } 211 212 .wp-embed-share-dialog-open:focus .dashicons, 213 .wp-embed-share-dialog-close:focus .dashicons { 214 -webkit-box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); 215 box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); 216 -webkit-border-radius: 100%; 217 border-radius: 100%; 218 } 219 220 .wp-embed-share-dialog-close { 221 position: absolute; 222 top: 20px; 223 right: 20px; 224 font-size: 22px; 225 } 226 227 .wp-embed-share-dialog-close:hover { 228 text-decoration: none; 229 } 230 231 .wp-embed-share-dialog-close .dashicons { 232 height: 24px; 233 width: 24px; 234 -webkit-background-size: 24px 24px; 235 background-size: 24px; 236 } 237 238 .wp-embed-share-dialog-content { 239 height: 100%; 240 -webkit-transform-style: preserve-3d; 241 transform-style: preserve-3d; 242 overflow: hidden; 243 } 244 245 .wp-embed-share-dialog-text { 246 margin-top: 25px; 247 padding: 20px; 248 } 249 250 .wp-embed-share-tabs { 251 margin: 0 0 20px; 252 padding: 0; 253 list-style: none; 254 } 255 256 .wp-embed-share-tab-button { 257 display: inline; 258 } 259 260 .wp-embed-share-tab-button button { 261 margin: 0; 262 padding: 0; 263 border: none; 264 background: transparent; 265 font-size: 16px; 266 line-height: 1.3; 267 color: #aaa; 268 cursor: pointer; 269 -webkit-transition: color .1s ease-in; 270 transition: color .1s ease-in; 271 } 272 273 .wp-embed-share-tab-button [aria-selected="true"] { 274 color: #fff; 275 } 276 277 .wp-embed-share-tab-button button:hover { 278 color: #fff; 279 } 280 281 .wp-embed-share-tab-button + .wp-embed-share-tab-button { 282 margin: 0 0 0 10px; 283 padding: 0 0 0 11px; 284 border-left: 1px solid #aaa; 285 } 286 287 .wp-embed-share-tab[aria-hidden="true"] { 288 display: none; 289 } 290 291 p.wp-embed-share-description { 292 margin: 0; 293 font-size: 14px; 294 line-height: 1; 295 font-style: italic; 296 color: #aaa; 297 } 298 299 .wp-embed-share-input { 300 -webkit-box-sizing: border-box; 301 -moz-box-sizing: border-box; 302 box-sizing: border-box; 303 width: 100%; 304 border: none; 305 height: 28px; 306 margin: 0 0 10px 0; 307 padding: 0 5px; 308 font: 400 14px/1.5 'Open Sans', sans-serif; 309 resize: none; 310 cursor: text; 311 } 312 313 textarea.wp-embed-share-input { 314 height: 72px; 315 } 316 317 html[dir="rtl"] .wp-embed-featured-image.square { 318 float: right; 319 margin-right: 0; 320 321 margin-left: 20px; 322 } 323 324 html[dir="rtl"] .wp-embed-site-title a { 325 padding-left: 0; 326 padding-right: 35px; 327 } 328 329 html[dir="rtl"] .wp-embed-site-icon { 330 margin-right: 0; 331 margin-left: 10px; 332 left: auto; 333 right: 0; 334 } 335 336 html[dir="rtl"] .wp-embed-meta { 337 text-align: left; 338 } 339 340 html[dir="rtl"] .wp-embed-footer { 341 } 342 343 html[dir="rtl"] .wp-embed-share { 344 margin-left: 0; 345 margin-right: 10px; 346 } 347 348 html[dir="rtl"] .wp-embed-share-dialog-close { 349 right: auto; 350 left: 20px; 351 } 352 353 html[dir="rtl"] .wp-embed-share-tab-button + .wp-embed-share-tab-button { 354 margin: 0 10px 0 0; 355 padding: 0 11px 0 0; 356 border-left: none; 357 border-right: 1px solid #aaa; 358 } -
src/wp-includes/default-filters.php
diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php index 75dadfc..31284d5 100644
add_action( 'parse_query', 'wp_oembed_parse_query' ); 446 446 add_action( 'wp_head', 'wp_oembed_add_discovery_links' ); 447 447 add_action( 'wp_head', 'wp_oembed_add_host_js' ); 448 448 449 add_action( ' oembed_head','print_emoji_detection_script' );450 add_action( ' oembed_head','print_emoji_styles' );451 add_action( ' oembed_head', 'print_oembed_embed_styles');452 add_action( ' oembed_head', 'print_oembed_embed_scripts');453 add_action( ' oembed_head','wp_print_head_scripts', 20 );454 add_action( ' oembed_head','wp_print_styles', 20 );455 add_action( ' oembed_head','wp_no_robots' );456 add_action( ' oembed_head','rel_canonical' );457 add_action( ' oembed_head','locale_stylesheet' );449 add_action( 'embed_head', 'print_emoji_detection_script' ); 450 add_action( 'embed_head', 'print_emoji_styles' ); 451 add_action( 'embed_head', 'print_embed_styles' ); 452 add_action( 'embed_head', 'print_embed_scripts' ); 453 add_action( 'embed_head', 'wp_print_head_scripts', 20 ); 454 add_action( 'embed_head', 'wp_print_styles', 20 ); 455 add_action( 'embed_head', 'wp_no_robots' ); 456 add_action( 'embed_head', 'rel_canonical' ); 457 add_action( 'embed_head', 'locale_stylesheet' ); 458 458 459 459 add_action( 'oembed_footer', 'wp_print_footer_scripts', 20 ); 460 460 461 add_filter( 'excerpt_more', 'wp_ oembed_excerpt_more',20 );461 add_filter( 'excerpt_more', 'wp_embed_excerpt_more', 20 ); 462 462 add_filter( 'the_excerpt_embed', 'wptexturize' ); 463 463 add_filter( 'the_excerpt_embed', 'convert_chars' ); 464 464 add_filter( 'the_excerpt_embed', 'wpautop' ); 465 465 add_filter( 'the_excerpt_embed', 'shortcode_unautop' ); 466 add_filter( 'the_excerpt_embed', 'wp_ oembed_excerpt_attachment');466 add_filter( 'the_excerpt_embed', 'wp_embed_excerpt_attachment' ); 467 467 468 468 add_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10, 3 ); 469 469 add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 ); -
src/wp-includes/embed-functions.php
diff --git src/wp-includes/embed-functions.php src/wp-includes/embed-functions.php index 094d8cd..251ffb4 100644
function get_post_embed_html( $post = null, $width, $height ) { 464 464 465 465 $output = "<script type='text/javascript'>\n"; 466 466 if ( SCRIPT_DEBUG ) { 467 $output .= file_get_contents( ABSPATH . WPINC . '/js/wp- oembed.js' );467 $output .= file_get_contents( ABSPATH . WPINC . '/js/wp-embed.js' ); 468 468 } else { 469 469 /* 470 470 * If you're looking at a src version of this file, you'll see an "include" 471 471 * statement below. This is used by the `grunt build` process to directly 472 * include a minified version of wp- oembed.js, instead of using the472 * include a minified version of wp-embed.js, instead of using the 473 473 * file_get_contents() method from above. 474 474 * 475 475 * If you're looking at a build version of this file, you'll see a string of 476 476 * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG 477 * and edit wp- oembed.js directly.477 * and edit wp-embed.js directly. 478 478 */ 479 479 $output .=<<<JS 480 include "js/wp- oembed.min.js"480 include "js/wp-embed.min.js" 481 481 JS; 482 482 } 483 483 $output .= "\n</script>"; … … JS; 491 491 ); 492 492 493 493 /** 494 * Filter the oEmbed HTML output.494 * Filter the embed HTML output for a given post. 495 495 * 496 496 * @since 4.4.0 497 497 * … … JS; 500 500 * @param int $width Width of the response. 501 501 * @param int $height Height of the response. 502 502 */ 503 return apply_filters( ' oembed_html', $output, $post, $width, $height );503 return apply_filters( 'embed_html', $output, $post, $width, $height ); 504 504 } 505 505 506 506 /** … … function wp_filter_oembed_result( $result, $data, $url ) { 748 748 * @param string $more_string The string shown within the more link. 749 749 * @return string The modified excerpt. 750 750 */ 751 function wp_ oembed_excerpt_more( $more_string ) {751 function wp_embed_excerpt_more( $more_string ) { 752 752 if ( ! is_embed() ) { 753 753 return $more_string; 754 754 } … … function the_excerpt_embed() { 793 793 * @param string $content The current post excerpt. 794 794 * @return string The modified post excerpt. 795 795 */ 796 function wp_ oembed_excerpt_attachment( $content ) {796 function wp_embed_excerpt_attachment( $content ) { 797 797 if ( is_attachment() ) { 798 798 return prepend_attachment( '' ); 799 799 } … … function wp_oembed_excerpt_attachment( $content ) { 806 806 * 807 807 * @since 4.4.0 808 808 */ 809 function print_ oembed_embed_styles() {809 function print_embed_styles() { 810 810 ?> 811 811 <style type="text/css"> 812 812 <?php 813 813 if ( WP_DEBUG ) { 814 readfile( ABSPATH . WPINC . "/css/wp- oembed-embed.css" );814 readfile( ABSPATH . WPINC . "/css/wp-embed-template.css" ); 815 815 } else { 816 816 /* 817 817 * If you're looking at a src version of this file, you'll see an "include" … … function print_oembed_embed_styles() { 821 821 * 822 822 * If you're looking at a build version of this file, you'll see a string of 823 823 * minified CSS. If you need to debug it, please turn on WP_DEBUG 824 * and edit wp- oembed-embed.css directly.824 * and edit wp-embed-template.css directly. 825 825 */ 826 826 ?> 827 include "css/wp- oembed-embed.min.css"827 include "css/wp-embed-template.min.css" 828 828 <?php 829 829 } 830 830 ?> … … function print_oembed_embed_styles() { 837 837 * 838 838 * @since 4.4.0 839 839 */ 840 function print_ oembed_embed_scripts() {840 function print_embed_scripts() { 841 841 ?> 842 842 <script type="text/javascript"> 843 843 <?php 844 844 if ( SCRIPT_DEBUG ) { 845 readfile( ABSPATH . WPINC . "/js/wp- oembed-embed.js" );845 readfile( ABSPATH . WPINC . "/js/wp-embed-template.js" ); 846 846 } else { 847 847 /* 848 848 * If you're looking at a src version of this file, you'll see an "include" 849 849 * statement below. This is used by the `grunt build` process to directly 850 * include a minified version of wp- oembed-embed.js, instead of using the850 * include a minified version of wp-embed-template.js, instead of using the 851 851 * readfile() method from above. 852 852 * 853 853 * If you're looking at a build version of this file, you'll see a string of 854 854 * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG 855 * and edit wp- oembed-embed.js directly.855 * and edit wp-embed-template.js directly. 856 856 */ 857 857 ?> 858 include "js/wp- oembed-embed.min.js"858 include "js/wp-embed-template.min.js" 859 859 <?php 860 860 } 861 861 ?> -
src/wp-includes/embed-template.php
diff --git src/wp-includes/embed-template.php src/wp-includes/embed-template.php index 9d5371c2..d7bda9f 100644
11 11 */ 12 12 13 13 if ( ! headers_sent() ) { 14 header( 'X-WP- oembed: true' );14 header( 'X-WP-embed: true' ); 15 15 } 16 16 17 17 wp_enqueue_style( 'open-sans' ); … … wp_enqueue_style( 'open-sans' ); 28 28 * 29 29 * @since 4.4.0 30 30 */ 31 do_action( ' oembed_head' );31 do_action( 'embed_head' ); 32 32 ?> 33 33 </head> 34 34 <body <?php body_class(); ?>> … … if ( have_posts() ) : 66 66 * Filter the thumbnail image size for use in the embed template. 67 67 * 68 68 * @since 4.4.0 69 * 69 * 70 70 * @param string $image_size Thumbnail image size. 71 71 */ 72 $image_size = apply_filters( ' oembed_thumbnail_image_size', $image_size );72 $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size ); 73 73 74 74 $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square'; 75 75 … … if ( have_posts() ) : 83 83 * 84 84 * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'. 85 85 */ 86 $shape = apply_filters( ' oembed_thumbnail_image_shape', $shape );86 $shape = apply_filters( 'embed_thumbnail_image_shape', $shape ); 87 87 } 88 88 ?> 89 89 <div <?php post_class( 'wp-embed' ); ?>> … … if ( have_posts() ) : 117 117 * 118 118 * @since 4.4.0 119 119 */ 120 do_action( ' oembed_content' );120 do_action( 'embed_content' ); 121 121 ?> 122 122 123 123 <div class="wp-embed-footer"> … … if ( have_posts() ) : 132 132 * 133 133 * @param string $site_icon_url The site icon URL. 134 134 */ 135 $site_icon_url = apply_filters( ' oembed_site_icon_url', $site_icon_url );135 $site_icon_url = apply_filters( 'embed_site_icon_url', $site_icon_url ); 136 136 137 137 printf( 138 138 '<a href="%s" target="_top"><img src="%s" width="32" height="32" alt="" class="wp-embed-site-icon"/><span>%s</span></a>', … … if ( have_posts() ) : 150 150 * 151 151 * @since 4.4.0 152 152 */ 153 do_action( ' oembed_content_meta');153 do_action( 'embed_content_meta'); 154 154 ?> 155 155 <?php if ( get_comments_number() || comments_open() ) : ?> 156 156 <div class="wp-embed-comments"> … … else : 233 233 * 234 234 * @param string $site_icon_url The site icon URL. 235 235 */ 236 $site_icon_url = apply_filters( ' oembed_site_icon_url', $site_icon_url );236 $site_icon_url = apply_filters( 'embed_site_icon_url', $site_icon_url ); 237 237 238 238 printf( 239 239 '<a href="%s" target="_top"><img src="%s" width="32" height="32" alt="" class="wp-embed-site-icon"/><span>%s</span></a>', … … endif; 253 253 * 254 254 * @since 4.4.0 255 255 */ 256 do_action( ' oembed_footer' );256 do_action( 'embed_footer' ); 257 257 ?> 258 258 </body> 259 259 </html> -
src/wp-includes/js/tinymce/plugins/wpoembed/plugin.js
diff --git src/wp-includes/js/tinymce/plugins/wpoembed/plugin.js src/wp-includes/js/tinymce/plugins/wpoembed/plugin.js index 3572426..26427c5 100644
8 8 var scriptElm = editor.dom.create( 'script', { 9 9 id: scriptId, 10 10 type: 'text/javascript', 11 src: url + '/../../../wp- oembed.js'11 src: url + '/../../../wp-embed.js' 12 12 } ); 13 13 14 14 editor.getDoc().getElementsByTagName( 'head' )[ 0 ].appendChild( scriptElm ); -
new file src/wp-includes/js/wp-embed-template.js
diff --git src/wp-includes/js/wp-embed-template.js src/wp-includes/js/wp-embed-template.js new file mode 100644 index 0000000..847ebcf
- + 1 (function ( window, document ) { 2 'use strict'; 3 4 var secret = window.location.hash.replace( /.*secret=([\d\w]{10}).*/, '$1' ), 5 resizing; 6 7 function sendEmbedMessage( message, value ) { 8 window.parent.postMessage( { 9 message: message, 10 value: value, 11 secret: secret 12 }, '*' ); 13 } 14 15 function onLoad() { 16 var share_dialog = document.querySelector( '.wp-embed-share-dialog' ), 17 share_dialog_open = document.querySelector( '.wp-embed-share-dialog-open' ), 18 share_dialog_close = document.querySelector( '.wp-embed-share-dialog-close' ), 19 share_input = document.querySelectorAll( '.wp-embed-share-input' ), 20 share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ), 21 links = document.getElementsByTagName( 'a' ), 22 i; 23 24 if ( share_input ) { 25 for ( i = 0; i < share_input.length; i++ ) { 26 share_input[ i ].addEventListener( 'click', function ( e ) { 27 e.target.select(); 28 } ); 29 } 30 } 31 32 function openSharingDialog() { 33 share_dialog.className = share_dialog.className.replace( 'hidden', '' ); 34 share_input[ 0 ].select(); 35 } 36 37 function closeSharingDialog() { 38 share_dialog.className += ' hidden'; 39 document.querySelector( '.wp-embed-share-dialog-open' ).focus(); 40 } 41 42 if ( share_dialog_open ) { 43 share_dialog_open.addEventListener( 'click', function ( e ) { 44 openSharingDialog(); 45 e.preventDefault(); 46 } ); 47 } 48 49 if ( share_dialog_close ) { 50 share_dialog_close.addEventListener( 'click', function ( e ) { 51 closeSharingDialog(); 52 e.preventDefault(); 53 } ); 54 } 55 56 function shareClickHandler( e ) { 57 var currentTab = document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' ); 58 currentTab.setAttribute( 'aria-selected', 'false' ); 59 document.querySelector( '#' + currentTab.getAttribute( 'aria-controls' ) ).setAttribute( 'aria-hidden', 'true' ); 60 61 e.target.setAttribute( 'aria-selected', 'true' ); 62 document.querySelector( '#' + e.target.getAttribute( 'aria-controls' ) ).setAttribute( 'aria-hidden', 'false' ); 63 } 64 65 function shareKeyHandler( e ) { 66 var target = e.target, 67 previousSibling = target.parentElement.previousElementSibling, 68 nextSibling = target.parentElement.nextElementSibling, 69 newTab, newTabChild; 70 71 if ( 37 === e.keyCode ) { 72 newTab = previousSibling; 73 } else if ( 39 === e.keyCode ) { 74 newTab = nextSibling; 75 } else { 76 return false; 77 } 78 79 if ( 'rtl' === document.documentElement.getAttribute( 'dir' ) ) { 80 newTab = ( newTab === previousSibling ) ? nextSibling : previousSibling; 81 } 82 83 if ( newTab ) { 84 newTabChild = newTab.firstElementChild; 85 86 target.setAttribute( 'tabindex', '-1' ); 87 target.setAttribute( 'aria-selected', false ); 88 document.querySelector( '#' + target.getAttribute( 'aria-controls' ) ).setAttribute( 'aria-hidden', 'true' ); 89 90 newTabChild.setAttribute( 'tabindex', '0' ); 91 newTabChild.setAttribute( 'aria-selected', 'true' ); 92 newTabChild.focus(); 93 document.querySelector( '#' + newTabChild.getAttribute( 'aria-controls' ) ).setAttribute( 'aria-hidden', 'false' ); 94 } 95 } 96 97 if ( share_dialog_tabs ) { 98 for ( i = 0; i < share_dialog_tabs.length; i++ ) { 99 share_dialog_tabs[ i ].addEventListener( 'click', shareClickHandler ); 100 101 share_dialog_tabs[ i ].addEventListener( 'keydown', shareKeyHandler ); 102 } 103 } 104 105 document.addEventListener( 'keydown', function ( e ) { 106 if ( e.keyCode === 27 && -1 === share_dialog.className.indexOf( 'hidden' ) ) { 107 closeSharingDialog(); 108 } 109 }, false ); 110 111 if ( window.self === window.top ) { 112 return; 113 } 114 115 /** 116 * Send this document's height to the parent (embedding) site. 117 */ 118 sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) ); 119 120 /** 121 * Detect clicks to external (_top) links. 122 */ 123 function linkClickHandler( e ) { 124 var target = e.target, 125 href; 126 if ( target.hasAttribute( 'href' ) ) { 127 href = target.getAttribute( 'href' ); 128 } else { 129 href = target.parentElement.getAttribute( 'href' ); 130 } 131 132 /** 133 * Send link target to the parent (embedding) site. 134 */ 135 sendEmbedMessage( 'link', href ); 136 e.preventDefault(); 137 } 138 139 for ( i = 0; i < links.length; i++ ) { 140 links[ i ].addEventListener( 'click', linkClickHandler ); 141 } 142 } 143 144 document.addEventListener( 'DOMContentLoaded', onLoad, false ); 145 146 /** 147 * Iframe resize handler. 148 */ 149 function onResize() { 150 if ( window.self === window.top ) { 151 return; 152 } 153 154 clearTimeout( resizing ); 155 156 resizing = setTimeout( function () { 157 sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) ); 158 }, 100 ); 159 } 160 161 window.addEventListener( 'resize', onResize, false ); 162 })( window, document ); -
new file src/wp-includes/js/wp-embed.js
diff --git src/wp-includes/js/wp-embed.js src/wp-includes/js/wp-embed.js new file mode 100644 index 0000000..dd03bc0
- + 1 (function ( window, document ) { 2 'use strict'; 3 4 window.wp = window.wp || {}; 5 6 if ( !! window.wp.receiveEmbedMessage ) { 7 return; 8 } 9 10 window.wp.receiveEmbedMessage = function( e ) { 11 var data = e.data; 12 if ( ! ( data.secret || data.message || data.value ) ) { 13 return; 14 } 15 16 var iframes = document.querySelectorAll( '.wp-embedded-content[data-secret="' + data.secret + '"]' ); 17 18 for ( var i = 0; i < iframes.length; i++ ) { 19 var source = iframes[ i ]; 20 21 /* Resize the iframe on request. */ 22 if ( 'height' === data.message ) { 23 var height = data.value; 24 if ( height > 1000 ) { 25 height = 1000; 26 } else if ( height < 200 ) { 27 height = 200; 28 } 29 30 source.height = (height) + 'px'; 31 } 32 33 /* Link to a specific URL on request. */ 34 if ( 'link' === data.message ) { 35 var sourceURL = document.createElement( 'a' ), targetURL = document.createElement( 'a' ); 36 sourceURL.href = source.getAttribute( 'src' ); 37 targetURL.href = data.value; 38 39 /* Only continue if link hostname matches iframe's hostname. */ 40 if ( targetURL.host === sourceURL.host && document.activeElement === source ) { 41 window.top.location.href = data.value; 42 } 43 } 44 } 45 }; 46 47 window.addEventListener( 'message', window.wp.receiveEmbedMessage, false ); 48 49 function onLoad() { 50 var isIE10 = -1 !== navigator.appVersion.indexOf( 'MSIE 10' ), 51 isIE11 = !!navigator.userAgent.match( /Trident.*rv\:11\./ ); 52 53 /* Remove security attribute from iframes in IE10 and IE11. */ 54 if ( isIE10 || isIE11 ) { 55 var iframes = document.querySelectorAll( '.wp-embedded-content[security]' ), iframeClone; 56 57 for ( var i = 0; i < iframes.length; i++ ) { 58 iframeClone = iframes[ i ].cloneNode( true ); 59 iframeClone.removeAttribute( 'security' ); 60 iframes[ i ].parentNode.insertBefore( iframeClone, iframes[ i ].nextSibling ); 61 iframes[ i ].parentNode.removeChild( iframes[ i ] ); 62 } 63 } 64 } 65 66 document.addEventListener( 'DOMContentLoaded', onLoad, false ); 67 })( window, document ); -
tests/phpunit/tests/oembed/template.php
diff --git tests/phpunit/tests/oembed/template.php tests/phpunit/tests/oembed/template.php index 2c97d2c..c9132d2 100644
class Tests_Embed_Template extends WP_UnitTestCase { 186 186 $this->assertTrue( false !== strpos( $actual, 'Hello World' ) ); 187 187 } 188 188 189 function test_wp_ oembed_excerpt_more_no_embed() {189 function test_wp_embed_excerpt_more_no_embed() { 190 190 $GLOBALS['wp_query'] = new WP_Query(); 191 191 192 $this->assertEquals( 'foo bar', wp_ oembed_excerpt_more( 'foo bar' ) );192 $this->assertEquals( 'foo bar', wp_embed_excerpt_more( 'foo bar' ) ); 193 193 } 194 194 195 function test_wp_ oembed_excerpt_more() {195 function test_wp_embed_excerpt_more() { 196 196 $post_id = $this->factory->post->create( array( 197 197 'post_content' => 'Foo Bar', 198 198 ) ); 199 199 200 $this->assertEquals( '', wp_ oembed_excerpt_more( '' ) );200 $this->assertEquals( '', wp_embed_excerpt_more( '' ) ); 201 201 202 202 $this->go_to( get_post_embed_url( $post_id ) ); 203 203 204 $actual = wp_ oembed_excerpt_more( '' );204 $actual = wp_embed_excerpt_more( '' ); 205 205 206 206 $expected = sprintf( 207 207 '… <a class="wp-embed-more" href="%s" target="_top">Read more</a>',