Make WordPress Core


Ignore:
Timestamp:
11/09/2015 12:07:03 AM (11 years ago)
Author:
pento
Message:

Embeds: Fix support for embedding in non-WordPress sites.

This moves the last of the iframe message code from PHP to JavaScript, so it can be included in any site, without needing to rely on any of WordPress' internal behaviour.

Props swissspidy.

Fixes #34451.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/embed-functions.php

    r35485 r35577  
    461461    $embed_url = get_post_embed_url( $post );
    462462
    463     $output = '<blockquote><a href="' . get_permalink( $post ) . '">' . get_the_title( $post ) . "</a></blockquote>\n";
     463    $output = '<blockquote class="wp-embedded-content"><a href="' . esc_url( get_permalink( $post ) ) . '">' . get_the_title( $post ) . "</a></blockquote>\n";
    464464
    465465    $output .= "<script type='text/javascript'>\n";
     
    755755    $allowed_html = array(
    756756        'a'          => array(
    757                     'href' => true,
     757            'href'        => true,
    758758        ),
    759759        'blockquote' => array(),
     
    767767            'scrolling'    => true,
    768768            'title'        => true,
    769             'class'        => true,
    770769        ),
    771770    );
     
    783782        // We have a blockquote to fall back on. Hide the iframe by default.
    784783        $html = str_replace( '<iframe', '<iframe style="display:none;"', $html );
    785     }
    786 
    787     $html = str_replace( '<iframe', '<iframe sandbox="allow-scripts" security="restricted"', $html );
     784        $html = str_replace( '<blockquote', '<blockquote class="wp-embedded-content"', $html );
     785    }
     786
     787    $html = str_replace( '<iframe', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $html );
    788788
    789789    preg_match( '/ src=[\'"]([^\'"]*)[\'"]/', $html, $results );
     
    957957 */
    958958function _oembed_filter_feed_content( $content ) {
    959     return str_replace( '<iframe sandbox="allow-scripts" security="restricted" style="display:none;"', '<iframe sandbox="allow-scripts" security="restricted"', $content );
    960 }
     959    return str_replace( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="display:none;"', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $content );
     960}
Note: See TracChangeset for help on using the changeset viewer.