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 ) { |
1102 | 1102 | $path = reset( $path ); |
1103 | 1103 | |
1104 | 1104 | 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 . '/' ); |
1106 | 1107 | } |
1107 | 1108 | } |
1108 | 1109 | |
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 { |
180 | 180 | $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); |
181 | 181 | } |
182 | 182 | |
| 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 | |
183 | 214 | /** |
184 | 215 | * @ticket 40673 |
185 | 216 | * @group multisite |