From 81a8f1cffe8dbac24a768f04f5928eb25d45d74a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 27 Sep 2017 08:36:48 +0000 Subject: [PATCH] Embeds: Maintain switched state when embedding a post on Multisite. Props bor0. Fixes #40673. Built from https://develop.svn.wordpress.org/trunk@41606 git-svn-id: http://core.svn.wordpress.org/trunk@41441 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/embed.php | 5 ++++- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/embed.php b/wp-includes/embed.php index 8ca7f80d5b..19b3f9cb4d 100644 --- a/wp-includes/embed.php +++ b/wp-includes/embed.php @@ -1071,6 +1071,8 @@ function the_embed_site_title() { * Null if the URL does not belong to the current site. */ function wp_filter_pre_oembed_result( $result, $url, $args ) { + $switched_blog = false; + if ( is_multisite() ) { $url_parts = wp_parse_args( wp_parse_url( $url ), array( 'host' => '', @@ -1094,6 +1096,7 @@ function wp_filter_pre_oembed_result( $result, $url, $args ) { if ( $site && (int) $site->blog_id !== get_current_blog_id() ) { switch_to_blog( $site->blog_id ); + $switched_blog = true; } } @@ -1111,7 +1114,7 @@ function wp_filter_pre_oembed_result( $result, $url, $args ) { $data = get_oembed_response_data( $post_id, $width ); $data = _wp_oembed_get_object()->data2html( (object) $data, $url ); - if ( is_multisite() && ms_is_switched() ) { + if ( $switched_blog ) { restore_current_blog(); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 55511f19ef..63bc371518 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41605'; +$wp_version = '4.9-alpha-41606'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.