WordPress.org

Make WordPress Core

Ticket #45052: 45052.1.diff

File 45052.1.diff, 1.8 KB (added by killua99, 7 months ago)

Refresh. Also to mention that the original patch was applied directly on the function wp_filter_pre_oembed_resultthis has change from the current core state to get_oembed_response_data_for_url

  • src/wp-includes/embed.php

    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 ) { 
    597597                        $path = reset( $path );
    598598
    599599                        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 . '/' );
    601602                        }
    602603                }
    603604
  • tests/phpunit/tests/oembed/wpOembed.php

    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 { 
    234234                $this->assertFalse( $actual );
    235235                $this->assertSame( $current_blog_id, get_current_blog_id() );
    236236        }
     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        }
    237268}