Ticket #28195: 28195.patch
File 28195.patch, 5.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
2220 2220 2221 2221 wp_send_json_success( $api ); 2222 2222 } 2223 2224 /** 2225 * Apply `the_content` filters to a string based on the post ID. 2226 * 2227 * @since 4.0.0 2228 */ 2229 function wp_ajax_filter_content() { 2230 global $post; 2231 2232 if ( ! $post = get_post( (int) $_REQUEST['post_ID'] ) ) { 2233 wp_send_json_error(); 2234 } 2235 2236 if ( ! current_user_can( 'read_post', $post->ID ) ) { 2237 wp_send_json_error(); 2238 } 2239 2240 setup_postdata( $post ); 2241 2242 wp_send_json_success( apply_filters( 'the_content', wp_unslash( $_POST['content'] ) ) ); 2243 } -
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 ); 365 366 if ( ! match ) { 367 return; 368 } 369 370 return { 371 index: match.index, 372 content: match.content, 373 options: { 374 shortcode: match.shortcode 375 } 376 }; 377 }, 357 toView: wp.mce.gallery.toView, 378 358 379 359 /** 380 360 * Called when a TinyMCE view is clicked for editing. … … 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 initialize: function( options ) { 680 this.players = []; 681 this.content = options.content; 682 this.parsed = false; 683 this.shortcode = options.shortcode; 684 _.bindAll( this, 'setHtml', 'setNode', 'fetch' ); 685 $( this ).on( 'ready', this.setNode ); 686 }, 687 unbind: function() { 688 var self = this; 689 this.pauseAllPlayers(); 690 _.each( this.players, function ( player ) { 691 self.removePlayer( player ); 692 } ); 693 this.players = []; 694 }, 695 setNode: function ( e, node ) { 696 this.node = node; 697 if ( this.parsed ) { 698 this.parseMediaShortcodes(); 699 } else { 700 this.fetch(); 701 } 702 }, 703 fetch: function () { 704 wp.ajax.send( 'filter-content', { 705 data: { 706 post_ID: $( '#post_ID' ).val(), 707 content: this.shortcode.string() 708 } 709 } ).done( this.setHtml ); 710 }, 711 setHtml: function ( content ) { 712 var toolbar = '<div class="toolbar"><div class="dashicons dashicons-no-alt remove"></div></div>', 713 scripts = $( content ).find( 'script' ); 714 $( this.node ).html( toolbar + content ); 715 if ( scripts ) { 716 scripts.each( function() { 717 var element = document.createElement( 'script' ); 718 element.type = 'text/javascript'; 719 element.src = $( this ).attr( 'src' ); 720 tinymce.activeEditor.contentDocument.getElementsByTagName( 'head' )[0].appendChild( element ); 721 } ); 722 } 723 this.parseMediaShortcodes(); 724 }, 725 parseMediaShortcodes: function () { 726 var self = this; 727 $( '.wp-audio-shortcode, .wp-video-shortcode', this.node ).each( function ( i, element ) { 728 self.players.push( element, self.mejsSettings ); 729 } ); 730 }, 731 getHtml: function() { 732 if ( ! this.parsed ) { 733 return ''; 734 } 735 return this.parsed; 736 } 737 } ), 738 edit: function() {} 739 }; 740 741 _.extend( wp.mce.embed.View.prototype, wp.media.mixin ); 742 743 wp.mce.views.register( 'embed', wp.mce.embed ); 744 693 745 }(jQuery)); -
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 ) {