Don't pass embeds through `the_content()` when trying to render MCE previews, leverage `WP_Embed` and `do_shortcode()` instead.

Props kovshenin.
See #28195.


Built from https://develop.svn.wordpress.org/trunk@28580


git-svn-id: http://core.svn.wordpress.org/trunk@28405 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-05-26 23:43:15 +00:00
parent b184336927
commit 89864b4a5a
4 changed files with 11 additions and 7 deletions

View File

@ -60,7 +60,7 @@ $core_actions_post = array(
'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
'save-user-color-scheme', 'update-widget', 'query-themes', 'filter-content'
'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed'
);
// Register core Ajax calls.

View File

@ -2506,12 +2506,12 @@ function wp_ajax_query_themes() {
}
/**
* Apply `the_content` filters to a string based on the post ID.
* Apply [embed] handlers to a string.
*
* @since 4.0.0
*/
function wp_ajax_filter_content() {
global $post;
function wp_ajax_parse_embed() {
global $post, $wp_embed;
if ( ! $post = get_post( (int) $_REQUEST['post_ID'] ) ) {
wp_send_json_error();
@ -2523,5 +2523,9 @@ function wp_ajax_filter_content() {
setup_postdata( $post );
wp_send_json_success( apply_filters( 'the_content', wp_unslash( $_POST['content'] ) ) );
$parsed = $wp_embed->run_shortcode( $_POST['content'] );
if ( preg_match( '/' . get_shortcode_regex() . '/s', $parsed ) ) {
$parsed = do_shortcode( $parsed );
}
wp_send_json_success( $parsed );
}

View File

@ -708,7 +708,7 @@ window.wp = window.wp || {};
}
},
fetch: function () {
wp.ajax.send( 'filter-content', {
wp.ajax.send( 'parse-embed', {
data: {
post_ID: $( '#post_ID' ).val(),
content: this.shortcode.string()

File diff suppressed because one or more lines are too long