Ticket #28195: 28195.diff
File 28195.diff, 6.0 KB (added by , 10 years ago) |
---|
-
src/wp-admin/admin-ajax.php
58 58 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 59 59 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 60 60 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs', 61 'save-user-color-scheme', 'update-widget', 'query-themes', 61 'save-user-color-scheme', 'update-widget', 'query-themes', 'filter-content' 62 62 ); 63 63 64 64 // Register core Ajax calls. -
src/wp-admin/includes/ajax-actions.php
2506 2506 2507 2507 wp_send_json_success( $api ); 2508 2508 } 2509 2510 /** 2511 * Apply `the_content` filters to a string based on the post ID. 2512 * 2513 * @since 4.0.0 2514 */ 2515 function wp_ajax_filter_content() { 2516 global $post; 2517 2518 if ( ! $post = get_post( (int) $_REQUEST['post_ID'] ) ) { 2519 wp_send_json_error(); 2520 } 2521 2522 if ( ! current_user_can( 'read_post', $post->ID ) ) { 2523 wp_send_json_error(); 2524 } 2525 2526 setup_postdata( $post ); 2527 2528 wp_send_json_success( apply_filters( 'the_content', wp_unslash( $_POST['content'] ) ) ); 2529 } -
src/wp-includes/js/mce-view.js
354 354 */ 355 355 wp.mce.media = { 356 356 loaded: false, 357 /** 358 * @global wp.shortcode 359 * 360 * @param {string} content 361 * @returns {Object} 362 */ 363 toView: function( content ) { 364 var match = wp.shortcode.next( this.shortcode, content ); 357 toView: wp.mce.gallery.toView, 365 358 366 if ( ! match ) {367 return;368 }369 370 return {371 index: match.index,372 content: match.content,373 options: {374 shortcode: match.shortcode375 }376 };377 },378 379 359 /** 380 360 * Called when a TinyMCE view is clicked for editing. 381 361 * - Parses the shortcode out of the element's data attribute … … 690 670 View: wp.mce.media.PlaylistView 691 671 } ); 692 672 wp.mce.views.register( 'playlist', wp.mce.playlist ); 673 674 wp.mce.embed = { 675 shortcode: 'embed', 676 toView: wp.mce.gallery.toView, 677 View: wp.mce.View.extend( { 678 className: 'editor-embed', 679 template: media.template( 'editor-embed' ), 680 initialize: function( options ) { 681 this.players = []; 682 this.content = options.content; 683 this.parsed = false; 684 this.shortcode = options.shortcode; 685 _.bindAll( this, 'setHtml', 'setNode', 'fetch' ); 686 $( this ).on( 'ready', this.setNode ); 687 }, 688 unbind: function() { 689 var self = this; 690 this.pauseAllPlayers(); 691 _.each( this.players, function ( player ) { 692 self.removePlayer( player ); 693 } ); 694 this.players = []; 695 }, 696 setNode: function ( e, node ) { 697 this.node = node; 698 if ( this.parsed ) { 699 this.parseMediaShortcodes(); 700 } else { 701 this.fetch(); 702 } 703 }, 704 fetch: function () { 705 wp.ajax.send( 'filter-content', { 706 data: { 707 post_ID: $( '#post_ID' ).val(), 708 content: this.shortcode.string() 709 } 710 } ).done( this.setHtml ); 711 }, 712 setHtml: function ( content ) { 713 var scripts = $( content ).find( 'script' ); 714 715 this.parsed = content; 716 717 $( this.node ).html( this.getHtml() ); 718 if ( scripts ) { 719 _.each( scripts, function (script) { 720 var element = document.createElement( 'script' ); 721 element.type = 'text/javascript'; 722 element.src = script.src; 723 tinymce.activeEditor.contentDocument.getElementsByTagName( 'head' )[0].appendChild( element ); 724 } ); 725 } 726 this.parseMediaShortcodes(); 727 }, 728 parseMediaShortcodes: function () { 729 var self = this; 730 $( '.wp-audio-shortcode, .wp-video-shortcode', this.node ).each( function ( i, element ) { 731 self.players.push( new MediaElementPlayer( element, self.mejsSettings ) ); 732 } ); 733 }, 734 getHtml: function() { 735 if ( ! this.parsed ) { 736 return ''; 737 } 738 return this.template({ content: this.parsed }); 739 } 740 } ), 741 edit: function() {} 742 }; 743 744 _.extend( wp.mce.embed.View.prototype, wp.media.mixin ); 745 746 wp.mce.views.register( 'embed', wp.mce.embed ); 747 693 748 }(jQuery)); -
src/wp-includes/js/media-audiovideo.js
131 131 removePlayer: function(t) { 132 132 var featureIndex, feature; 133 133 134 if ( ! t.options ) { 135 return; 136 } 137 134 138 // invoke features cleanup 135 139 for ( featureIndex in t.options.features ) { 136 140 feature = t.options.features[featureIndex]; -
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
168 168 event.content = wp.mce.views.toViews( event.content ); 169 169 }); 170 170 171 editor.on( 'PastePreProcess', function( event ) { 172 if ( event.content.match( /^\s*(https?:\/\/[^\s"]+)\s*$/im ) ) { 173 event.content = '[embed]' + event.content + '[/embed]'; 174 } 175 } ); 176 171 177 // When the editor's content has been updated and the DOM has been 172 178 // processed, render the views in the document. 173 179 editor.on( 'SetContent', function( event ) { -
src/wp-includes/media-template.php
1045 1045 <div class="upload-errors"></div> 1046 1046 </script> 1047 1047 1048 <script type="text/html" id="tmpl-editor-embed"> 1049 <div class="toolbar"> 1050 <div class="dashicons dashicons-no-alt remove"></div> 1051 </div> 1052 {{{ data.content }}} 1053 <div class="wpview-overlay"></div> 1054 </script> 1055 1048 1056 <?php 1049 1057 1050 1058 /**