WordPress.org

Make WordPress Core

Changeset 28580


Ignore:
Timestamp:
05/26/2014 11:42:08 PM (4 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.

Location:
trunk/src
Files:
3 edited

Legend:

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

    r28478 r28580  
    6161    'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
    6262    'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
    63     'save-user-color-scheme', 'update-widget', 'query-themes', 'filter-content'
     63    'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed'
    6464);
    6565
  • 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}
  • trunk/src/wp-includes/js/mce-view.js

    r28364 r28580  
    709709            },
    710710            fetch: function () {
    711                 wp.ajax.send( 'filter-content', {
     711                wp.ajax.send( 'parse-embed', {
    712712                    data: {
    713713                        post_ID: $( '#post_ID' ).val(),
Note: See TracChangeset for help on using the changeset viewer.