Make WordPress Core


Ignore:
Timestamp:
11/09/2015 12:07:03 AM (10 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/tests/phpunit/tests/oembed/filterResult.php

    r35437 r35577  
    2929        $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
    3030
    31         $this->assertEquals( '<iframe sandbox="allow-scripts" security="restricted"></iframe>', $actual );
     31        $this->assertEquals( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual );
    3232    }
    3333
     
    4242        $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
    4343
    44         $this->assertEquals( '<iframe sandbox="allow-scripts" security="restricted"></iframe>', $actual );
     44        $this->assertEquals( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual );
    4545    }
    4646
     
    8484        $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
    8585
    86         $this->assertEquals( '<blockquote></blockquote><iframe sandbox="allow-scripts" security="restricted" style="display:none;"></iframe>', $actual );
     86        $this->assertEquals( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="display:none;"></iframe>', $actual );
    8787    }
    8888
    8989    function test_filter_oembed_result_allowed_html() {
    90         $html   = '<blockquote><strong><a href="" target=""></a></strong></blockquote><iframe></iframe>';
     90        $html   = '<blockquote class="foo" id="bar"><strong><a href="" target=""></a></strong></blockquote><iframe></iframe>';
    9191        $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
    9292
    93         $this->assertEquals( '<blockquote><a href=""></a></blockquote><iframe sandbox="allow-scripts" security="restricted" style="display:none;"></iframe>', $actual );
     93        $this->assertEquals( '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="display:none;"></iframe>', $actual );
     94    }
     95
     96    /**
     97     * @group feed
     98     */
     99    function test_filter_feed_content() {
     100        $html   = '<blockquote></blockquote><iframe></iframe>';
     101        $actual = _oembed_filter_feed_content( wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ) );
     102
     103        $this->assertEquals( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual );
    94104    }
    95105}
Note: See TracChangeset for help on using the changeset viewer.