Ticket #27679: 27679.diff
File 27679.diff, 3.2 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', 61 'save-user-color-scheme', 'update-widget', 'parse-content' 62 62 ); 63 63 64 64 // Register core Ajax calls. -
src/wp-admin/includes/ajax-actions.php
2204 2204 update_user_meta( get_current_user_id(), 'admin_color', $color_scheme ); 2205 2205 wp_send_json_success(); 2206 2206 } 2207 2208 function wp_ajax_parse_content() { 2209 global $post; 2210 2211 if ( ! $post = get_post( (int) $_REQUEST['post_ID'] ) ) { 2212 wp_send_json_error(); 2213 2214 if ( ! current_user_can( 'read_post', $post->ID ) ) 2215 wp_send_json_error(); 2216 } 2217 2218 setup_postdata( $post ); 2219 2220 $content = wp_unslash( $_POST['oembed_content'] ); 2221 $parsed = apply_filters( 'the_content', $content ); 2222 2223 wp_send_json( array( 'content' => $parsed ) ); 2224 } 2225 No newline at end of file -
src/wp-includes/js/mce-view.js
673 673 View: wp.mce.media.PlaylistView 674 674 } ); 675 675 wp.mce.views.register( 'playlist', wp.mce.playlist ); 676 677 wp.mce.embed = { 678 toView: function( content ) { 679 var match = wp.shortcode.next( 'embed', content ); 680 681 if ( ! match ) { 682 return; 683 } 684 return { 685 index: match.index, 686 content: match.content, 687 options: { 688 content: match.content, 689 shortcode: match.shortcode 690 } 691 }; 692 }, 693 View: wp.mce.View.extend({ 694 className: 'oembed-data', 695 initialize: function( options ) { 696 this.content = options.content; 697 this.parsed = false; 698 _.bindAll( this, 'setHtml', 'setNode', 'fetch' ); 699 $(this).on( 'ready', this.setNode ); 700 }, 701 702 setNode: function (e, node) { 703 this.node = node; 704 if ( ! this.parsed ) { 705 this.fetch(); 706 } else { 707 this.parseMediaShortcodes(); 708 } 709 }, 710 711 fetch: function () { 712 $.ajax( { 713 url : ajaxurl, 714 type : 'post', 715 data : { 716 action: 'parse-content', 717 post_ID: $( '#post_ID' ).val(), 718 oembed_content: this.content 719 } 720 } ).done( this.setHtml ); 721 }, 722 723 setHtml: function (data) { 724 this.parsed = data.content; 725 $( this.node ).html( this.parsed ); 726 727 this.parseMediaShortcodes(); 728 }, 729 730 parseMediaShortcodes: function () { 731 $( '.wp-audio-shortcode, .wp-video-shortcode', this.node ).mediaelementplayer(); 732 }, 733 734 getHtml: function() { 735 if ( ! this.parsed ) { 736 return ''; 737 } 738 return this.parsed; 739 } 740 }), 741 742 edit: function() {} 743 }; 744 wp.mce.views.register( 'embed', wp.mce.embed ); 676 745 }(jQuery));