Make WordPress Core

Ticket #45052: 45052.patch

File 45052.patch, 1.8 KB (added by imath, 6 years ago)
  • src/wp-includes/embed.php

    diff --git src/wp-includes/embed.php src/wp-includes/embed.php
    index f2fa9d67b5..967f5d18c8 100644
    function wp_filter_pre_oembed_result( $result, $url, $args ) { 
    11021102                        $path = reset( $path );
    11031103
    11041104                        if ( $path ) {
    1105                                 $qv['path'] = get_network()->path . $path . '/';
     1105                                // A blog prefix is added to the main site, we need to remove it.
     1106                                $qv['path'] = str_replace( '/blog/', '/', get_network()->path . $path . '/' );
    11061107                        }
    11071108                }
    11081109
  • tests/phpunit/tests/oembed/wpOembed.php

    diff --git tests/phpunit/tests/oembed/wpOembed.php tests/phpunit/tests/oembed/wpOembed.php
    index c148dd555c..a77dc46385 100644
    class Tests_WP_oEmbed extends WP_UnitTestCase { 
    180180                $this->assertEquals( $this->pre_oembed_result_filtered, $actual );
    181181        }
    182182
     183        /**
     184         * @ticket 45052
     185         * @group multisite
     186         * @group ms-required
     187         */
     188        public function test_wp_filter_pre_oembed_result_multisite_sub_main_pretty_permalink() {
     189                $this->set_permalink_structure( '/blog/%postname%/' );
     190
     191                $post_id   = self::factory()->post->create();
     192                $permalink = get_permalink( $post_id );
     193                $user_id   = self::factory()->user->create();
     194                $blog_id   = self::factory()->blog->create(
     195                        array(
     196                                'user_id' => $user_id,
     197                        )
     198                );
     199
     200                switch_to_blog( $blog_id );
     201
     202                $this->set_permalink_structure( '/%postname%/' );
     203
     204                add_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
     205                $actual = $this->oembed->get_html( $permalink );
     206                remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
     207
     208                restore_current_blog();
     209
     210                $this->assertNotNull( $this->pre_oembed_result_filtered );
     211                $this->assertEquals( $this->pre_oembed_result_filtered, $actual );
     212        }
     213
    183214        /**
    184215         * @ticket 40673
    185216         * @group multisite