Ticket #28905: 28905.4.diff
File 28905.4.diff, 28.6 KB (added by , 10 years ago) |
---|
-
src/wp-admin/admin-ajax.php
60 60 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 61 61 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 62 62 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs', 63 'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail' 63 'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail', 64 'parse-playlist-shortcode', 'parse-media-shortcode' 64 65 ); 65 66 66 67 // Register core Ajax calls. -
src/wp-admin/includes/ajax-actions.php
2666 2666 2667 2667 wp_send_json_success( $parsed ); 2668 2668 } 2669 2670 function wp_ajax_parse_playlist_shortcode() { 2671 global $post; 2672 2673 if ( ! $post = get_post( (int) $_REQUEST['post_ID'] ) ) { 2674 wp_send_json_error(); 2675 } 2676 2677 setup_postdata( $post ); 2678 2679 ob_start(); 2680 2681 wp_media_mce_styles(); 2682 2683 echo do_shortcode( wp_unslash( $_REQUEST['shortcode'] ) ); 2684 2685 wp_underscore_playlist_templates(); 2686 2687 wp_print_scripts( 'wp-playlist' ); 2688 2689 wp_send_json_success( ob_get_clean() ); 2690 } 2691 2692 function wp_ajax_parse_media_shortcode() { 2693 global $post; 2694 2695 if ( ! $post = get_post( (int) $_REQUEST['post_ID'] ) ) { 2696 wp_send_json_error(); 2697 } 2698 2699 setup_postdata( $post ); 2700 2701 ob_start(); 2702 2703 wp_media_mce_styles(); 2704 2705 echo do_shortcode( wp_unslash( $_REQUEST['shortcode'] ) ); 2706 2707 wp_print_scripts( 'wp-mediaelement' ); 2708 2709 wp_send_json_success( ob_get_clean() ); 2710 } 2711 No newline at end of file -
src/wp-includes/class-wp-editor.php
503 503 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 504 504 $version = 'ver=' . $GLOBALS['wp_version']; 505 505 $dashicons = includes_url( "css/dashicons$suffix.css?$version" ); 506 $mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" );507 $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" );508 506 509 507 // WordPress default stylesheet and dashicons 510 508 $mce_css = array( 511 509 $dashicons, 512 $mediaelement,513 $wpmediaelement,514 510 self::$baseurl . '/skins/wordpress/wp-content.css?' . $version 515 511 ); 516 512 517 513 // load editor_style.css if the current theme supports it 518 514 if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) { 519 $editor_styles = $GLOBALS['editor_styles']; 520 521 $editor_styles = array_unique( array_filter( $editor_styles ) ); 522 $style_uri = get_stylesheet_directory_uri(); 523 $style_dir = get_stylesheet_directory(); 524 525 // Support externally referenced styles (like, say, fonts). 526 foreach ( $editor_styles as $key => $file ) { 527 if ( preg_match( '~^(https?:)?//~', $file ) ) { 528 $mce_css[] = esc_url_raw( $file ); 529 unset( $editor_styles[ $key ] ); 515 $editor_styles = get_editor_stylesheets(); 516 if ( ! empty( $editor_styles ) ) { 517 foreach ( $editor_styles as $style ) { 518 $mce_css[] = $style; 530 519 } 531 520 } 532 533 // Look in a parent theme first, that way child theme CSS overrides.534 if ( is_child_theme() ) {535 $template_uri = get_template_directory_uri();536 $template_dir = get_template_directory();537 538 foreach ( $editor_styles as $key => $file ) {539 if ( $file && file_exists( "$template_dir/$file" ) )540 $mce_css[] = "$template_uri/$file";541 }542 }543 544 foreach ( $editor_styles as $file ) {545 if ( $file && file_exists( "$style_dir/$file" ) )546 $mce_css[] = "$style_uri/$file";547 }548 521 } 549 522 550 523 /** -
src/wp-includes/js/mce-view.js
104 104 } 105 105 }, this ); 106 106 }, 107 108 /* jshint scripturl: true */ 109 createIframe: function ( content ) { 110 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, 111 iframe, iframeDoc, i, resize, 112 dom = tinymce.DOM; 113 114 if ( content.indexOf( '<script' ) !== -1 ) { 115 iframe = dom.create( 'iframe', { 116 src: tinymce.Env.ie ? 'javascript:""' : '', 117 frameBorder: '0', 118 allowTransparency: 'true', 119 scrolling: 'no', 120 style: { 121 width: '100%', 122 display: 'block' 123 } 124 } ); 125 126 this.setContent( iframe ); 127 iframeDoc = iframe.contentWindow.document; 128 129 iframeDoc.open(); 130 iframeDoc.write( 131 '<!DOCTYPE html>' + 132 '<html>' + 133 '<head>' + 134 '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' + 135 '</head>' + 136 '<body style="padding: 0; margin: 0;">' + 137 content + 138 '</body>' + 139 '</html>' 140 ); 141 iframeDoc.close(); 142 143 resize = function() { 144 $( iframe ).height( $( iframeDoc.body ).height() ); 145 }; 146 147 if ( MutationObserver ) { 148 new MutationObserver( _.debounce( function() { 149 resize(); 150 }, 100 ) ) 151 .observe( iframeDoc.body, { 152 attributes: true, 153 childList: true, 154 subtree: true 155 } ); 156 } else { 157 for ( i = 1; i < 6; i++ ) { 158 setTimeout( resize, i * 700 ); 159 } 160 } 161 } else { 162 this.setContent( content ); 163 } 164 }, 165 107 166 setError: function( message, dashicon ) { 108 167 this.setContent( 109 168 '<div class="wpview-error">' + … … 421 480 wp.mce.av = { 422 481 loaded: false, 423 482 424 View: _.extend( {}, wp.media.mixin,{483 View: { 425 484 overlay: true, 426 485 486 action: 'parse-media-shortcode', 487 427 488 initialize: function( options ) { 428 this.players = []; 429 this.shortcode = options.shortcode; 430 _.bindAll( this, 'setPlayer', 'pausePlayers' ); 431 $( this ).on( 'ready', this.setPlayer ); 432 $( this ).on( 'ready', function( event, editor ) { 433 editor.on( 'hide', this.pausePlayers ); 434 } ); 435 $( document ).on( 'media:edit', this.pausePlayers ); 489 this.shortcode = options.shortcode.string(); 490 this.fetching = false; 491 492 _.bindAll( this, 'createIframe', 'setNode', 'fetch' ); 493 $( this ).on( 'ready', this.setNode ); 436 494 }, 437 495 438 /** 439 * Creates the player instance for the current node 440 * 441 * @global MediaElementPlayer 442 * 443 * @param {Event} event 444 * @param {Object} editor 445 * @param {HTMLElement} node 446 */ 447 setPlayer: function( event, editor, node ) { 448 var self = this, 449 media; 496 setNode: function () { 497 if ( this.parsed ) { 498 this.createIframe( this.parsed ); 499 } else if ( ! this.fetching ) { 500 this.fetch(); 501 } 502 }, 450 503 451 media = $( node ).find( '.wp-' + this.shortcode.tag + '-shortcode' ); 504 fetch: function () { 505 var self = this; 506 this.fetching = true; 452 507 453 if ( ! this.isCompatible( media ) ) { 454 media.closest( '.wpview-wrap' ).addClass( 'wont-play' ); 455 media.replaceWith( '<p>' + media.find( 'source' ).eq(0).prop( 'src' ) + '</p>' ); 456 return; 457 } else { 458 media.closest( '.wpview-wrap' ).removeClass( 'wont-play' ); 459 if ( this.ua.is( 'ff' ) ) { 460 media.prop( 'preload', 'metadata' ); 461 } else { 462 media.prop( 'preload', 'none' ); 508 wp.ajax.send( this.action, { 509 data: { 510 post_ID: $( '#post_ID' ).val() || 0, 511 shortcode: this.shortcode 463 512 } 464 } 513 } ) 514 .always( function() { 515 self.fetching = false; 516 } ) 517 .done( function( response ) { 518 if ( response ) { 519 self.parsed = response; 520 self.createIframe( response ); 521 } 522 } ) 523 .fail( function( response ) { 524 if ( response && response.message ) { 525 if ( ( response.type === 'not-embeddable' && self.type === 'embed' ) || 526 response.type === 'not-ssl' ) { 465 527 466 media = wp.media.view.MediaDetails.prepareSrc( media.get(0) ); 467 468 setTimeout( function() { 469 wp.mce.av.loaded = true; 470 self.players.push( new MediaElementPlayer( media, self.mejsSettings ) ); 471 }, wp.mce.av.loaded ? 10 : 500 ); 528 self.setError( response.message, 'admin-media' ); 529 } else { 530 self.setContent( '<p>' + self.original + '</p>', null, 'replace' ); 531 } 532 } else if ( response && response.statusText ) { 533 self.setError( response.statusText, 'admin-media' ); 534 } 535 } ); 472 536 }, 473 537 474 538 /** … … 477 541 * @returns {string} 478 542 */ 479 543 getHtml: function() { 480 var attrs = this.shortcode.attrs.named; 481 attrs.content = this.shortcode.content; 482 483 return this.template({ model: _.defaults( 484 attrs, 485 wp.media[ this.shortcode.tag ].defaults ) 486 }); 487 }, 488 489 unbind: function() { 490 this.unsetPlayers(); 544 if ( ! this.parsed ) { 545 return ''; 546 } 547 return this.parsed; 491 548 } 492 } ),549 }, 493 550 494 551 /** 495 552 * Called when a TinyMCE view is clicked for editing. … … 537 594 * @mixes wp.mce.av 538 595 */ 539 596 wp.mce.views.register( 'video', _.extend( {}, wp.mce.av, { 540 state: 'video-details', 541 View: _.extend( {}, wp.mce.av.View, { 542 template: media.template( 'editor-video' ) 543 } ) 597 state: 'video-details' 544 598 } ) ); 545 599 546 600 /** … … 549 603 * @mixes wp.mce.av 550 604 */ 551 605 wp.mce.views.register( 'audio', _.extend( {}, wp.mce.av, { 552 state: 'audio-details', 553 View: _.extend( {}, wp.mce.av.View, { 554 template: media.template( 'editor-audio' ) 555 } ) 606 state: 'audio-details' 556 607 } ) ); 557 608 558 609 /** … … 562 613 */ 563 614 wp.mce.views.register( 'playlist', _.extend( {}, wp.mce.av, { 564 615 state: ['playlist-edit', 'video-playlist-edit'], 565 View: _.extend( {}, wp.media.mixin, { 566 template: media.template( 'editor-playlist' ), 567 overlay: true, 568 569 initialize: function( options ) { 570 this.players = []; 571 this.data = {}; 572 this.attachments = []; 573 this.shortcode = options.shortcode; 574 575 $( this ).on( 'ready', function( event, editor ) { 576 editor.on( 'hide', this.pausePlayers ); 577 } ); 578 $( document ).on( 'media:edit', this.pausePlayers ); 579 580 this.fetch(); 581 582 $( this ).on( 'ready', this.setPlaylist ); 583 }, 584 585 /** 586 * Asynchronously fetch the shortcode's attachments 587 */ 588 fetch: function() { 589 this.attachments = wp.media.playlist.attachments( this.shortcode ); 590 this.dfd = this.attachments.more().done( _.bind( this.render, this ) ); 591 }, 592 593 setPlaylist: function( event, editor, element ) { 594 if ( ! this.data.tracks ) { 595 return; 596 } 597 598 this.players.push( new WPPlaylistView( { 599 el: $( element ).find( '.wp-playlist' ).get( 0 ), 600 metadata: this.data 601 } ).player ); 602 }, 603 604 /** 605 * Set the data that will be used to compile the Underscore template, 606 * compile the template, and then return it. 607 * 608 * @returns {string} 609 */ 610 getHtml: function() { 611 var data = this.shortcode.attrs.named, 612 model = wp.media.playlist, 613 options, 614 attachments, 615 tracks = []; 616 617 // Don't render errors while still fetching attachments 618 if ( this.dfd && 'pending' === this.dfd.state() && ! this.attachments.length ) { 619 return ''; 620 } 621 622 _.each( model.defaults, function( value, key ) { 623 data[ key ] = model.coerce( data, key ); 624 }); 625 626 options = { 627 type: data.type, 628 style: data.style, 629 tracklist: data.tracklist, 630 tracknumbers: data.tracknumbers, 631 images: data.images, 632 artists: data.artists 633 }; 634 635 if ( ! this.attachments.length ) { 636 return this.template( options ); 637 } 638 639 attachments = this.attachments.toJSON(); 640 641 _.each( attachments, function( attachment ) { 642 var size = {}, resize = {}, track = { 643 src : attachment.url, 644 type : attachment.mime, 645 title : attachment.title, 646 caption : attachment.caption, 647 description : attachment.description, 648 meta : attachment.meta 649 }; 650 651 if ( 'video' === data.type ) { 652 size.width = attachment.width; 653 size.height = attachment.height; 654 if ( media.view.settings.contentWidth ) { 655 resize.width = media.view.settings.contentWidth - 22; 656 resize.height = Math.ceil( ( size.height * resize.width ) / size.width ); 657 if ( ! options.width ) { 658 options.width = resize.width; 659 options.height = resize.height; 660 } 661 } else { 662 if ( ! options.width ) { 663 options.width = attachment.width; 664 options.height = attachment.height; 665 } 666 } 667 track.dimensions = { 668 original : size, 669 resized : _.isEmpty( resize ) ? size : resize 670 }; 671 } else { 672 options.width = 400; 673 } 674 675 track.image = attachment.image; 676 track.thumb = attachment.thumb; 677 678 tracks.push( track ); 679 } ); 680 681 options.tracks = tracks; 682 this.data = options; 683 684 return this.template( options ); 685 }, 686 687 unbind: function() { 688 this.unsetPlayers(); 689 } 616 View: _.extend( {}, wp.mce.av.View, { 617 action: 'parse-playlist-shortcode' 690 618 } ) 691 619 } ) ); 692 620 … … 693 621 /** 694 622 * TinyMCE handler for the embed shortcode 695 623 */ 696 wp.mce.embedView = _.extend( {}, wp.m edia.mixin, {624 wp.mce.embedView = _.extend( {}, wp.mce.av.View, { 697 625 overlay: true, 626 action: 'parse-embed', 698 627 initialize: function( options ) { 699 this.players = [];700 628 this.content = options.content; 701 629 this.fetching = false; 702 630 this.parsed = false; … … 708 636 this.shortcode = options.shortcode.string(); 709 637 } 710 638 711 _.bindAll( this, ' setHtml', 'setNode', 'fetch' );639 _.bindAll( this, 'createIframe', 'setNode', 'fetch' ); 712 640 $( this ).on( 'ready', this.setNode ); 713 },714 unbind: function() {715 var self = this;716 _.each( this.players, function ( player ) {717 player.pause();718 self.removePlayer( player );719 } );720 this.players = [];721 },722 setNode: function () {723 if ( this.parsed ) {724 this.setHtml( this.parsed );725 this.parseMediaShortcodes();726 } else if ( ! this.fetching ) {727 this.fetch();728 }729 },730 fetch: function () {731 var self = this;732 733 this.fetching = true;734 735 wp.ajax.send( 'parse-embed', {736 data: {737 post_ID: $( '#post_ID' ).val() || 0,738 shortcode: this.shortcode739 }740 } )741 .always( function() {742 self.fetching = false;743 } )744 .done( function( response ) {745 if ( response ) {746 self.parsed = response;747 self.setHtml( response );748 }749 } )750 .fail( function( response ) {751 if ( response && response.message ) {752 if ( ( response.type === 'not-embeddable' && self.type === 'embed' ) ||753 response.type === 'not-ssl' ) {754 755 self.setError( response.message, 'admin-media' );756 } else {757 self.setContent( '<p>' + self.original + '</p>', null, 'replace' );758 }759 } else if ( response && response.statusText ) {760 self.setError( response.statusText, 'admin-media' );761 }762 } );763 },764 /* jshint scripturl: true */765 setHtml: function ( content ) {766 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,767 iframe, iframeDoc, i, resize,768 dom = tinymce.DOM;769 770 if ( content.indexOf( '<script' ) !== -1 ) {771 iframe = dom.create( 'iframe', {772 src: tinymce.Env.ie ? 'javascript:""' : '',773 frameBorder: '0',774 allowTransparency: 'true',775 style: {776 width: '100%',777 display: 'block'778 }779 } );780 781 this.setContent( iframe );782 iframeDoc = iframe.contentWindow.document;783 784 iframeDoc.open();785 iframeDoc.write(786 '<!DOCTYPE html>' +787 '<html>' +788 '<head>' +789 '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' +790 '</head>' +791 '<body>' +792 content +793 '</body>' +794 '</html>'795 );796 iframeDoc.close();797 798 resize = function() {799 $( iframe ).height( $( iframeDoc ).height() );800 };801 802 if ( MutationObserver ) {803 new MutationObserver( _.debounce( function() {804 resize();805 }, 100 ) )806 .observe( iframeDoc.body, {807 attributes: true,808 childList: true,809 subtree: true810 } );811 } else {812 for ( i = 1; i < 6; i++ ) {813 setTimeout( resize, i * 700 );814 }815 }816 } else {817 this.setContent( content );818 }819 820 this.parseMediaShortcodes();821 },822 parseMediaShortcodes: function () {823 var self = this;824 $( '.wp-audio-shortcode, .wp-video-shortcode', this.node ).each( function ( i, element ) {825 self.players.push( new MediaElementPlayer( element, self.mejsSettings ) );826 } );827 641 } 828 642 } ); 829 643 -
src/wp-includes/js/media-audiovideo.js
47 47 }, 48 48 49 49 /** 50 * Utility to identify the user's browser51 */52 ua: {53 is : function( browser ) {54 var passes = false, ua = window.navigator.userAgent;55 56 switch ( browser ) {57 case 'oldie':58 passes = ua.match(/MSIE [6-8]/gi) !== null;59 break;60 case 'ie':61 passes = /MSIE /.test( ua ) || ( /Trident\//.test( ua ) && /rv:\d/.test( ua ) ); // IE1162 break;63 case 'ff':64 passes = ua.match(/firefox/gi) !== null;65 break;66 case 'opera':67 passes = ua.match(/OPR/) !== null;68 break;69 case 'safari':70 passes = ua.match(/safari/gi) !== null && ua.match(/chrome/gi) === null;71 break;72 case 'chrome':73 passes = ua.match(/safari/gi) !== null && ua.match(/chrome/gi) !== null;74 break;75 }76 77 return passes;78 }79 },80 81 /**82 * Specify compatibility for native playback by browser83 */84 compat :{85 'opera' : {86 audio: ['ogg', 'wav'],87 video: ['ogg', 'webm']88 },89 'chrome' : {90 audio: ['ogg', 'mpeg'],91 video: ['ogg', 'webm', 'mp4', 'm4v', 'mpeg']92 },93 'ff' : {94 audio: ['ogg', 'mpeg'],95 video: ['ogg', 'webm']96 },97 'safari' : {98 audio: ['mpeg', 'wav'],99 video: ['mp4', 'm4v', 'mpeg', 'x-ms-wmv', 'quicktime']100 },101 'ie' : {102 audio: ['mpeg'],103 video: ['mp4', 'm4v', 'mpeg']104 }105 },106 107 /**108 * Determine if the passed media contains a <source> that provides109 * native playback in the user's browser110 *111 * @param {jQuery} media112 * @returns {Boolean}113 */114 isCompatible: function( media ) {115 if ( ! media.find( 'source' ).length ) {116 return false;117 }118 119 var ua = this.ua, test = false, found = false, sources;120 121 if ( ua.is( 'oldIE' ) ) {122 return false;123 }124 125 sources = media.find( 'source' );126 127 _.find( this.compat, function( supports, browser ) {128 if ( ua.is( browser ) ) {129 found = true;130 _.each( sources, function( elem ) {131 var audio = new RegExp( 'audio\/(' + supports.audio.join('|') + ')', 'gi' ),132 video = new RegExp( 'video\/(' + supports.video.join('|') + ')', 'gi' );133 134 if ( elem.type.match( video ) !== null || elem.type.match( audio ) !== null ) {135 test = true;136 }137 } );138 }139 140 return test || found;141 } );142 143 return test;144 },145 146 /**147 50 * Override the MediaElement method for removing a player. 148 51 * MediaElement tries to pull the audio/video tag out of 149 52 * its container and re-add it to the DOM. -
src/wp-includes/js/mediaelement/wp-playlist.js
7 7 initialize : function (options) { 8 8 this.index = 0; 9 9 this.settings = {}; 10 this.compatMode = $( 'body' ).hasClass( 'wp-admin' ) && $( '#content_ifr' ).length;11 10 this.data = options.metadata || $.parseJSON( this.$('script').html() ); 12 11 this.playerNode = this.$( this.data.type ); 13 12 … … 27 26 this.renderTracks(); 28 27 } 29 28 30 if ( this.isCompatibleSrc() ) { 31 this.playerNode.attr( 'src', this.current.get( 'src' ) ); 32 } 29 this.playerNode.attr( 'src', this.current.get( 'src' ) ); 33 30 34 31 _.bindAll( this, 'bindPlayer', 'bindResetPlayer', 'setPlayer', 'ended', 'clickTrack' ); 35 32 … … 47 44 48 45 bindResetPlayer : function (mejs) { 49 46 this.bindPlayer( mejs ); 50 if ( this.isCompatibleSrc() ) { 51 this.playCurrentSrc(); 52 } 47 this.playCurrentSrc(); 53 48 }, 54 49 55 isCompatibleSrc: function () {56 var testNode;57 58 if ( this.compatMode ) {59 testNode = $( '<span><source type="' + this.current.get( 'type' ) + '" /></span>' );60 61 if ( ! wp.media.mixin.isCompatible( testNode ) ) {62 this.playerNode.removeAttr( 'src' );63 this.playerNode.removeAttr( 'poster' );64 return;65 }66 }67 68 return true;69 },70 71 50 setPlayer: function (force) { 72 51 if ( this.player ) { 73 52 this.player.pause(); … … 76 55 } 77 56 78 57 if (force) { 79 if ( this.isCompatibleSrc() ) { 80 this.playerNode.attr( 'src', this.current.get( 'src' ) ); 81 } 58 this.playerNode.attr( 'src', this.current.get( 'src' ) ); 82 59 this.settings.success = this.bindResetPlayer; 83 60 } 84 61 … … 188 165 }); 189 166 190 167 $(document).ready(function () { 191 if ( ! $( 'body' ).hasClass( 'wp-admin' ) || $( 'body' ).hasClass( 'about-php' ) ) { 192 $('.wp-playlist').each(function () { 193 return new WPPlaylistView({ el: this }); 194 }); 195 } 168 $('.wp-playlist').each( function() { 169 return new WPPlaylistView({ el: this }); 170 } ); 196 171 }); 197 172 198 173 window.WPPlaylistView = WPPlaylistView; -
src/wp-includes/media.php
1531 1531 'src' => '', 1532 1532 'loop' => '', 1533 1533 'autoplay' => '', 1534 'preload' => 'none' 1534 'preload' => 'none', 1535 'scripts' => false 1535 1536 ); 1536 1537 foreach ( $default_types as $type ) { 1537 1538 $defaults_atts[$type] = ''; … … 1573 1574 array_unshift( $default_types, 'src' ); 1574 1575 } 1575 1576 1577 $scripts = ''; 1576 1578 /** 1577 1579 * Filter the media library used for the audio shortcode. 1578 1580 * … … 1582 1584 */ 1583 1585 $library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' ); 1584 1586 if ( 'mediaelement' === $library && did_action( 'init' ) ) { 1585 wp_enqueue_style( 'wp-mediaelement' ); 1586 wp_enqueue_script( 'wp-mediaelement' ); 1587 if ( $atts['scripts'] ) { 1588 ob_start(); 1589 wp_print_styles( 'wp-mediaelement' ); 1590 wp_print_scripts( 'wp-mediaelement' ); 1591 $scripts = ob_get_clean(); 1592 } else { 1593 wp_enqueue_style( 'wp-mediaelement' ); 1594 wp_enqueue_script( 'wp-mediaelement' ); 1595 } 1587 1596 } 1588 1597 1589 1598 /** … … 1637 1646 $html .= wp_mediaelement_fallback( $fileurl ); 1638 1647 } 1639 1648 $html .= '</audio>'; 1640 1649 if ( ! empty( $scripts ) ) { 1650 $html .= $scripts; 1651 } 1641 1652 /** 1642 1653 * Filter the audio shortcode output. 1643 1654 * … … 1736 1747 'preload' => 'metadata', 1737 1748 'width' => 640, 1738 1749 'height' => 360, 1750 'scripts' => false, 1739 1751 ); 1740 1752 1741 1753 foreach ( $default_types as $type ) { … … 1796 1808 array_unshift( $default_types, 'src' ); 1797 1809 } 1798 1810 1811 $scripts = ''; 1799 1812 /** 1800 1813 * Filter the media library used for the video shortcode. 1801 1814 * … … 1805 1818 */ 1806 1819 $library = apply_filters( 'wp_video_shortcode_library', 'mediaelement' ); 1807 1820 if ( 'mediaelement' === $library && did_action( 'init' ) ) { 1808 wp_enqueue_style( 'wp-mediaelement' ); 1809 wp_enqueue_script( 'wp-mediaelement' ); 1821 if ( $atts['scripts'] ) { 1822 ob_start(); 1823 wp_print_styles( 'wp-mediaelement' ); 1824 wp_print_scripts( 'wp-mediaelement' ); 1825 $scripts = ob_get_clean(); 1826 } else { 1827 wp_enqueue_style( 'wp-mediaelement' ); 1828 wp_enqueue_script( 'wp-mediaelement' ); 1829 } 1810 1830 } 1811 1831 1812 1832 /** … … 1873 1893 $html .= wp_mediaelement_fallback( $fileurl ); 1874 1894 } 1875 1895 $html .= '</video>'; 1896 if ( ! empty( $scripts ) ) { 1897 $html .= $scripts; 1898 } 1876 1899 1877 1900 $output = sprintf( '<div style="width: %dpx; max-width: 100%%;" class="wp-video">%s</div>', $atts['width'], $html ); 1878 1901 … … 2324 2347 * @return string The embed HTML. 2325 2348 */ 2326 2349 function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) { 2327 $audio = sprintf( '[audio src="%s" /]', esc_url( $url ) ); 2350 if ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'parse-embed' === $_REQUEST['action'] ) { 2351 $audio = sprintf( '[audio scripts="1" src="%s"]', esc_url( $url ) ); 2352 } else { 2353 $audio = sprintf( '[audio src="%s"]', esc_url( $url ) ); 2354 } 2328 2355 2329 2356 /** 2330 2357 * Filter the audio embed output. … … 2356 2383 $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); 2357 2384 $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); 2358 2385 } 2359 $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) ); 2386 if ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'parse-embed' === $_REQUEST['action'] ) { 2387 $video = sprintf( '[video scripts="1" %s src="%s"]', $dimensions, esc_url( $url ) ); 2388 } else { 2389 $video = sprintf( '[video %s src="%s"]', $dimensions, esc_url( $url ) ); 2390 } 2360 2391 2361 2392 /** 2362 2393 * Filter the video embed output. … … 3256 3287 return (int) $post_id; 3257 3288 } 3258 3289 } 3290 3291 function wp_media_mce_styles() { 3292 $version = 'ver=' . $GLOBALS['wp_version']; 3293 $dashicons = includes_url( "css/dashicons.css?$version" ); 3294 $skin = includes_url( 'js/tinymce/skins/wordpress/wp-content.css?' . $version ); 3295 $mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" ); 3296 $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" ); 3297 3298 $styles = array( $dashicons, $skin, $mediaelement, $wpmediaelement ); 3299 foreach ( $styles as $style ) { 3300 printf( '<link rel="stylesheet" href="%s"/>', $style ); 3301 } 3302 3303 $editor_styles = get_editor_stylesheets(); 3304 if ( ! empty( $editor_styles ) ) { 3305 foreach ( $editor_styles as $style ) { 3306 printf( '<link rel="stylesheet" href="%s"/>', $style ); 3307 } 3308 } 3309 } -
src/wp-includes/script-loader.php
323 323 324 324 $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement.js", array('mediaelement'), false, 1 ); 325 325 did_action( 'init' ) && $scripts->localize( 'mediaelement', '_wpmejsSettings', array( 326 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ), 326 'audioHeight' => 30, 327 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ) 327 328 ) ); 328 329 329 330 $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 ); … … 510 511 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 ); 511 512 512 513 $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); 513 514 514 515 $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 ); 515 516 $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 ); 516 517 did_action( 'init' ) && $scripts->localize( 'media', 'attachMediaBoxL10n', array( -
src/wp-includes/theme.php
1395 1395 } 1396 1396 1397 1397 /** 1398 * 1399 * @since 4.0.0 1400 * 1401 * @return array 1402 */ 1403 function get_editor_stylesheets() { 1404 $stylesheets = array(); 1405 // load editor_style.css if the current theme supports it 1406 if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) { 1407 $editor_styles = $GLOBALS['editor_styles']; 1408 1409 $editor_styles = array_unique( array_filter( $editor_styles ) ); 1410 $style_uri = get_stylesheet_directory_uri(); 1411 $style_dir = get_stylesheet_directory(); 1412 1413 // Support externally referenced styles (like, say, fonts). 1414 foreach ( $editor_styles as $key => $file ) { 1415 if ( preg_match( '~^(https?:)?//~', $file ) ) { 1416 $stylesheets[] = esc_url_raw( $file ); 1417 unset( $editor_styles[ $key ] ); 1418 } 1419 } 1420 1421 // Look in a parent theme first, that way child theme CSS overrides. 1422 if ( is_child_theme() ) { 1423 $template_uri = get_template_directory_uri(); 1424 $template_dir = get_template_directory(); 1425 1426 foreach ( $editor_styles as $key => $file ) { 1427 if ( $file && file_exists( "$template_dir/$file" ) ) { 1428 $stylesheets[] = "$template_uri/$file"; 1429 } 1430 } 1431 } 1432 1433 foreach ( $editor_styles as $file ) { 1434 if ( $file && file_exists( "$style_dir/$file" ) ) { 1435 $stylesheets[] = "$style_uri/$file"; 1436 } 1437 } 1438 } 1439 return $stylesheets; 1440 } 1441 1442 /** 1398 1443 * Allows a theme to register its support of a certain feature 1399 1444 * 1400 1445 * Must be called in the theme's functions.php file to work.