Make WordPress Core


Ignore:
Timestamp:
09/27/2017 08:35:16 AM (7 years ago)
Author:
swissspidy
Message:

Embeds: Maintain switched state when embedding a post on Multisite.

Props bor0.
Fixes #40673.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/oembed/wpOembed.php

    r41600 r41606  
    172172        $this->assertEquals( $this->pre_oembed_result_filtered, $actual );
    173173    }
     174
     175    /**
     176     * @ticket 40673
     177     * @group multisite
     178     * @group ms-required
     179     */
     180    public function test_wp_filter_pre_oembed_result_multisite_preserves_switched_state() {
     181        $user_id = self::factory()->user->create();
     182
     183        $blog_id = self::factory()->blog->create( array( 'user_id' => $user_id ) );
     184        switch_to_blog( $blog_id );
     185
     186        $expected_stack = $GLOBALS['_wp_switched_stack'];
     187
     188        $post_id   = self::factory()->post->create();
     189        $permalink = get_permalink( $post_id );
     190
     191        add_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
     192        $actual = $this->oembed->get_html( $permalink );
     193        remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) );
     194
     195        $actual_stack = $GLOBALS['_wp_switched_stack'];
     196
     197        restore_current_blog();
     198
     199        $this->assertNotNull( $this->pre_oembed_result_filtered );
     200        $this->assertEquals( $this->pre_oembed_result_filtered, $actual );
     201        $this->assertSame( $expected_stack, $actual_stack );
     202    }
    174203}
Note: See TracChangeset for help on using the changeset viewer.