Make WordPress Core

Changeset 33470


Ignore:
Timestamp:
07/29/2015 12:01:22 AM (11 years ago)
Author:
azaozz
Message:

Use the embed_maybe_make_link filter to test WP_Embed::autoembed().
See #33106.

Location:
trunk
Files:
2 edited

Legend:

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

    r33469 r33470  
    130130         */
    131131        public function shortcode( $attr, $url = '' ) {
    132                 // This filter can be used to output custom HTML instead of allowing oEmbed to run.
    133                 $custom = apply_filters( 'wp_embed_shortcode_custom', false, $attr, $url );
    134                 if ( false !== $custom ) {
    135                         return $custom;
    136                 }
    137                
    138132                $post = get_post();
    139133
  • trunk/tests/phpunit/tests/media.php

    r33469 r33470  
    656656         * @ticket 33016
    657657         */
    658         function filter_wp_embed_shortcode_custom( $custom, $attr, $url ) {
     658        function filter_wp_embed_shortcode_custom( $content, $url ) {
    659659                if ( 'https://www.example.com/?video=1' == $url ) {
    660                         $custom = "<iframe src='$url'></iframe>";
     660                        $content = '@embed URL was replaced@';
    661661                }
    662                 return $custom;
     662                return $content;
    663663        }
    664664
     
    668668        function test_oembed_explicit_media_link() {
    669669                global $wp_embed;
    670                 add_filter( 'wp_embed_shortcode_custom', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 3 );
     670                add_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 2 );
    671671
    672672                $content = <<<EOF
     
    675675
    676676                $expected = <<<EOF
    677 <iframe src='https://www.example.com/?video=1'></iframe>
     677@embed URL was replaced@
    678678EOF;
    679679
     
    687687myvar = 'Hello world
    688688https://www.example.com/?video=1
    689 don't break this';
     689do not break this';
    690690// ]]>
    691691</script>
     
    695695                $this->assertEquals( $content, $result );
    696696
    697                 remove_filter( 'wp_embed_shortcode_custom', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 );
     697                remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 );
    698698        }
    699699}
Note: See TracChangeset for help on using the changeset viewer.