Make WordPress Core

Ticket #34272: 34272.diff

File 34272.diff, 27.7 KB (added by swissspidy, 10 years ago)
  • Gruntfile.js

    diff --git Gruntfile.js Gruntfile.js
    index b8dd5f8..3d02881 100644
    module.exports = function(grunt) { 
    233233
    234234                                        // Exceptions
    235235                                        '!wp-includes/css/dashicons.css',
    236                                         '!wp-includes/css/wp-oembed-embed.css'
     236                                        '!wp-includes/css/wp-embed-template.css'
    237237                                ]
    238238                        },
    239239                        colors: {
    module.exports = function(grunt) { 
    530530                                src: BUILD_DIR + 'wp-includes/formatting.php',
    531531                                dest: '.'
    532532                        },
    533                         oembed: {
     533                        embed: {
    534534                                src: BUILD_DIR + 'wp-includes/embed-functions.php',
    535535                                dest: '.'
    536536                        }
    module.exports = function(grunt) { 
    642642                'clean:tinymce',
    643643                'concat:emoji',
    644644                'includes:emoji',
    645                 'includes:oembed',
     645                'includes:embed',
    646646                'jsvalidate:build'
    647647        ] );
    648648
  • 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
    - +  
     1html, body {
     2        padding: 0;
     3        margin: 0;
     4}
     5
     6body {
     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
     101p.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
     291p.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
     313textarea.wp-embed-share-input {
     314        height: 72px;
     315}
     316
     317html[dir="rtl"] .wp-embed-featured-image.square {
     318        float: right;
     319        margin-right: 0;
     320
     321        margin-left: 20px;
     322}
     323
     324html[dir="rtl"] .wp-embed-site-title a {
     325        padding-left: 0;
     326        padding-right: 35px;
     327}
     328
     329html[dir="rtl"] .wp-embed-site-icon {
     330        margin-right: 0;
     331        margin-left: 10px;
     332        left: auto;
     333        right: 0;
     334}
     335
     336html[dir="rtl"] .wp-embed-meta {
     337        text-align: left;
     338}
     339
     340html[dir="rtl"] .wp-embed-footer {
     341}
     342
     343html[dir="rtl"] .wp-embed-share {
     344        margin-left: 0;
     345        margin-right: 10px;
     346}
     347
     348html[dir="rtl"] .wp-embed-share-dialog-close {
     349        right: auto;
     350        left: 20px;
     351}
     352
     353html[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' ); 
    446446add_action( 'wp_head',              'wp_oembed_add_discovery_links'        );
    447447add_action( 'wp_head',              'wp_oembed_add_host_js'                );
    448448
    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'                    );
     449add_action( 'embed_head',           'print_emoji_detection_script'         );
     450add_action( 'embed_head',           'print_emoji_styles'                   );
     451add_action( 'embed_head',           'print_embed_styles'                   );
     452add_action( 'embed_head',           'print_embed_scripts'                  );
     453add_action( 'embed_head',           'wp_print_head_scripts',         20    );
     454add_action( 'embed_head',           'wp_print_styles',               20    );
     455add_action( 'embed_head',           'wp_no_robots'                         );
     456add_action( 'embed_head',           'rel_canonical'                        );
     457add_action( 'embed_head',           'locale_stylesheet'                    );
    458458
    459459add_action( 'oembed_footer',        'wp_print_footer_scripts',       20    );
    460460
    461 add_filter( 'excerpt_more',         'wp_oembed_excerpt_more',        20    );
     461add_filter( 'excerpt_more',         'wp_embed_excerpt_more',         20    );
    462462add_filter( 'the_excerpt_embed',    'wptexturize'                          );
    463463add_filter( 'the_excerpt_embed',    'convert_chars'                        );
    464464add_filter( 'the_excerpt_embed',    'wpautop'                              );
    465465add_filter( 'the_excerpt_embed',    'shortcode_unautop'                    );
    466 add_filter( 'the_excerpt_embed',    'wp_oembed_excerpt_attachment'         );
     466add_filter( 'the_excerpt_embed',    'wp_embed_excerpt_attachment'          );
    467467
    468468add_filter( 'oembed_dataparse',     'wp_filter_oembed_result',       10, 3 );
    469469add_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 ) { 
    464464
    465465        $output = "<script type='text/javascript'>\n";
    466466        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' );
    468468        } else {
    469469                /*
    470470                 * If you're looking at a src version of this file, you'll see an "include"
    471471                 * statement below. This is used by the `grunt build` process to directly
    472                  * include a minified version of wp-oembed.js, instead of using the
     472                 * include a minified version of wp-embed.js, instead of using the
    473473                 * file_get_contents() method from above.
    474474                 *
    475475                 * If you're looking at a build version of this file, you'll see a string of
    476476                 * 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.
    478478                 */
    479479                $output .=<<<JS
    480                 include "js/wp-oembed.min.js"
     480                include "js/wp-embed.min.js"
    481481JS;
    482482        }
    483483        $output .= "\n</script>";
    JS; 
    491491        );
    492492
    493493        /**
    494          * Filter the oEmbed HTML output.
     494         * Filter the embed HTML output for a given post.
    495495         *
    496496         * @since 4.4.0
    497497         *
    JS; 
    500500         * @param int     $width  Width of the response.
    501501         * @param int     $height Height of the response.
    502502         */
    503         return apply_filters( 'oembed_html', $output, $post, $width, $height );
     503        return apply_filters( 'embed_html', $output, $post, $width, $height );
    504504}
    505505
    506506/**
    function wp_filter_oembed_result( $result, $data, $url ) { 
    748748 * @param string $more_string The string shown within the more link.
    749749 * @return string The modified excerpt.
    750750 */
    751 function wp_oembed_excerpt_more( $more_string ) {
     751function wp_embed_excerpt_more( $more_string ) {
    752752        if ( ! is_embed() ) {
    753753                return $more_string;
    754754        }
    function the_excerpt_embed() { 
    793793 * @param string $content The current post excerpt.
    794794 * @return string The modified post excerpt.
    795795 */
    796 function wp_oembed_excerpt_attachment( $content ) {
     796function wp_embed_excerpt_attachment( $content ) {
    797797        if ( is_attachment() ) {
    798798                return prepend_attachment( '' );
    799799        }
    function wp_oembed_excerpt_attachment( $content ) { 
    806806 *
    807807 * @since 4.4.0
    808808 */
    809 function print_oembed_embed_styles() {
     809function print_embed_styles() {
    810810        ?>
    811811        <style type="text/css">
    812812        <?php
    813813                if ( WP_DEBUG ) {
    814                         readfile( ABSPATH . WPINC . "/css/wp-oembed-embed.css" );
     814                        readfile( ABSPATH . WPINC . "/css/wp-embed-template.css" );
    815815                } else {
    816816                        /*
    817817                         * If you're looking at a src version of this file, you'll see an "include"
    function print_oembed_embed_styles() { 
    821821                         *
    822822                         * If you're looking at a build version of this file, you'll see a string of
    823823                         * 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.
    825825                         */
    826826                        ?>
    827                         include "css/wp-oembed-embed.min.css"
     827                        include "css/wp-embed-template.min.css"
    828828                        <?php
    829829                }
    830830        ?>
    function print_oembed_embed_styles() { 
    837837 *
    838838 * @since 4.4.0
    839839 */
    840 function print_oembed_embed_scripts() {
     840function print_embed_scripts() {
    841841        ?>
    842842        <script type="text/javascript">
    843843        <?php
    844844                if ( SCRIPT_DEBUG ) {
    845                         readfile( ABSPATH . WPINC . "/js/wp-oembed-embed.js" );
     845                        readfile( ABSPATH . WPINC . "/js/wp-embed-template.js" );
    846846                } else {
    847847                        /*
    848848                         * If you're looking at a src version of this file, you'll see an "include"
    849849                         * 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 the
     850                         * include a minified version of wp-embed-template.js, instead of using the
    851851                         * readfile() method from above.
    852852                         *
    853853                         * If you're looking at a build version of this file, you'll see a string of
    854854                         * 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.
    856856                         */
    857857                        ?>
    858                         include "js/wp-oembed-embed.min.js"
     858                        include "js/wp-embed-template.min.js"
    859859                        <?php
    860860                }
    861861        ?>
  • src/wp-includes/embed-template.php

    diff --git src/wp-includes/embed-template.php src/wp-includes/embed-template.php
    index 9d5371c2..d7bda9f 100644
     
    1111 */
    1212
    1313if ( ! headers_sent() ) {
    14         header( 'X-WP-oembed: true' );
     14        header( 'X-WP-embed: true' );
    1515}
    1616
    1717wp_enqueue_style( 'open-sans' );
    wp_enqueue_style( 'open-sans' ); 
    2828         *
    2929         * @since 4.4.0
    3030         */
    31         do_action( 'oembed_head' );
     31        do_action( 'embed_head' );
    3232        ?>
    3333</head>
    3434<body <?php body_class(); ?>>
    if ( have_posts() ) : 
    6666                         * Filter the thumbnail image size for use in the embed template.
    6767                         *
    6868                         * @since 4.4.0
    69                          * 
     69                         *
    7070                         * @param string $image_size Thumbnail image size.
    7171                         */
    72                         $image_size = apply_filters( 'oembed_thumbnail_image_size', $image_size );
     72                        $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size );
    7373
    7474                        $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
    7575
    if ( have_posts() ) : 
    8383                         *
    8484                         * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'.
    8585                         */
    86                         $shape = apply_filters( 'oembed_thumbnail_image_shape', $shape );
     86                        $shape = apply_filters( 'embed_thumbnail_image_shape', $shape );
    8787                }
    8888                ?>
    8989                <div <?php post_class( 'wp-embed' ); ?>>
    if ( have_posts() ) : 
    117117                         *
    118118                         * @since 4.4.0
    119119                         */
    120                         do_action( 'oembed_content' );
     120                        do_action( 'embed_content' );
    121121                        ?>
    122122
    123123                        <div class="wp-embed-footer">
    if ( have_posts() ) : 
    132132                                         *
    133133                                         * @param string $site_icon_url The site icon URL.
    134134                                         */
    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 );
    136136
    137137                                        printf(
    138138                                                '<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() ) : 
    150150                                         *
    151151                                         * @since 4.4.0
    152152                                         */
    153                                         do_action( 'oembed_content_meta');
     153                                        do_action( 'embed_content_meta');
    154154                                        ?>
    155155                                        <?php if ( get_comments_number() || comments_open() ) : ?>
    156156                                                <div class="wp-embed-comments">
    else : 
    233233                                 *
    234234                                 * @param string $site_icon_url The site icon URL.
    235235                                 */
    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 );
    237237
    238238                                printf(
    239239                                        '<a href="%s" target="_top"><img src="%s" width="32" height="32" alt="" class="wp-embed-site-icon"/><span>%s</span></a>',
    endif; 
    253253 *
    254254 * @since 4.4.0
    255255 */
    256 do_action( 'oembed_footer' );
     256do_action( 'embed_footer' );
    257257?>
    258258</body>
    259259</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
     
    88                        var scriptElm = editor.dom.create( 'script', {
    99                                id: scriptId,
    1010                                type: 'text/javascript',
    11                                 src: url + '/../../../wp-oembed.js'
     11                                src: url + '/../../../wp-embed.js'
    1212                        } );
    1313
    1414                        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 { 
    186186                $this->assertTrue( false !== strpos( $actual, 'Hello World' ) );
    187187        }
    188188
    189         function test_wp_oembed_excerpt_more_no_embed() {
     189        function test_wp_embed_excerpt_more_no_embed() {
    190190                $GLOBALS['wp_query'] = new WP_Query();
    191191
    192                 $this->assertEquals( 'foo bar', wp_oembed_excerpt_more( 'foo bar' ) );
     192                $this->assertEquals( 'foo bar', wp_embed_excerpt_more( 'foo bar' ) );
    193193        }
    194194
    195         function test_wp_oembed_excerpt_more() {
     195        function test_wp_embed_excerpt_more() {
    196196                $post_id = $this->factory->post->create( array(
    197197                        'post_content' => 'Foo Bar',
    198198                ) );
    199199
    200                 $this->assertEquals( '', wp_oembed_excerpt_more( '' ) );
     200                $this->assertEquals( '', wp_embed_excerpt_more( '' ) );
    201201
    202202                $this->go_to( get_post_embed_url( $post_id ) );
    203203
    204                 $actual = wp_oembed_excerpt_more( '' );
     204                $actual = wp_embed_excerpt_more( '' );
    205205
    206206                $expected = sprintf(
    207207                        '&hellip; <a class="wp-embed-more" href="%s" target="_top">Read more</a>',