Make WordPress Core


Ignore:
Timestamp:
05/26/2014 11:42:08 PM (12 years ago)
Author:
wonderboymusic
Message:

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

Props kovshenin.
See #28195.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r28539 r28580  
    25072507
    25082508/**
    2509  * Apply `the_content` filters to a string based on the post ID.
     2509 * Apply [embed] handlers to a string.
    25102510 *
    25112511 * @since 4.0.0
    25122512 */
    2513 function wp_ajax_filter_content() {
    2514     global $post;
     2513function wp_ajax_parse_embed() {
     2514    global $post, $wp_embed;
    25152515
    25162516    if ( ! $post = get_post( (int) $_REQUEST['post_ID'] ) ) {
     
    25242524    setup_postdata( $post );
    25252525
    2526     wp_send_json_success( apply_filters( 'the_content', wp_unslash( $_POST['content'] ) ) );
    2527 }
     2526    $parsed = $wp_embed->run_shortcode( $_POST['content'] );
     2527    if ( preg_match( '/' . get_shortcode_regex() . '/s', $parsed ) ) {
     2528        $parsed = do_shortcode( $parsed );
     2529    }
     2530    wp_send_json_success( $parsed );
     2531}
Note: See TracChangeset for help on using the changeset viewer.