diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php
index 6bc220e9ad..0d2147f2b8 100644
a
|
b
|
function get_oembed_response_data_for_url( $url, $args ) { |
597 | 597 | $path = reset( $path ); |
598 | 598 | |
599 | 599 | if ( $path ) { |
600 | | $qv['path'] = get_network()->path . $path . '/'; |
| 600 | // A blog prefix is added to the main site, we need to remove it. |
| 601 | $qv['path'] = str_replace( '/blog/', '/', get_network()->path . $path . '/' ); |
601 | 602 | } |
602 | 603 | } |
603 | 604 | |
diff --git a/tests/phpunit/tests/oembed/wpOembed.php b/tests/phpunit/tests/oembed/wpOembed.php
index c148dd555c..5fa95b2682 100644
a
|
b
|
class Tests_WP_oEmbed extends WP_UnitTestCase { |
234 | 234 | $this->assertFalse( $actual ); |
235 | 235 | $this->assertSame( $current_blog_id, get_current_blog_id() ); |
236 | 236 | } |
| 237 | |
| 238 | /** |
| 239 | * @ticket 45052 |
| 240 | * @group multisite |
| 241 | * @group ms-required |
| 242 | */ |
| 243 | public function test_wp_filter_pre_oembed_result_multisite_sub_main_pretty_permalink() { |
| 244 | $this->set_permalink_structure( '/blog/%postname%/' ); |
| 245 | |
| 246 | $post_id = self::factory()->post->create(); |
| 247 | $permalink = get_permalink( $post_id ); |
| 248 | $user_id = self::factory()->user->create(); |
| 249 | $blog_id = self::factory()->blog->create( |
| 250 | [ |
| 251 | 'user_id' => $user_id, |
| 252 | ] |
| 253 | ); |
| 254 | |
| 255 | switch_to_blog( $blog_id ); |
| 256 | |
| 257 | $this->set_permalink_structure( '/%postname%/' ); |
| 258 | |
| 259 | add_filter( 'pre_oembed_result', [ $this, '_filter_pre_oembed_result' ] ); |
| 260 | $actual = $this->oembed->get_html( $permalink ); |
| 261 | remove_filter( 'pre_oembed_result', [ $this, '_filter_pre_oembed_result' ] ); |
| 262 | |
| 263 | restore_current_blog(); |
| 264 | |
| 265 | $this->assertNotNull( $this->pre_oembed_result_filtered ); |
| 266 | $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); |
| 267 | } |
237 | 268 | } |