Customize: If the return URL for Close button is a page added to the Appearance menu by a deactivated theme, fall back to the Themes screen.

Props JarretC, Jean-David, SergeyBiryukov.
Fixes #46686.
Built from https://develop.svn.wordpress.org/trunk@46754


git-svn-id: http://core.svn.wordpress.org/trunk@46554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-11-20 18:49:03 +00:00
parent 285d38bd83
commit d5434d7cc7
2 changed files with 21 additions and 1 deletions

View File

@ -4622,9 +4622,13 @@ final class WP_Customize_Manager {
* *
* @since 4.4.0 * @since 4.4.0
* *
* @global array $_registered_pages
*
* @return string URL for link to close Customizer. * @return string URL for link to close Customizer.
*/ */
public function get_return_url() { public function get_return_url() {
global $_registered_pages;
$referer = wp_get_referer(); $referer = wp_get_referer();
$excluded_referer_basenames = array( 'customize.php', 'wp-login.php' ); $excluded_referer_basenames = array( 'customize.php', 'wp-login.php' );
@ -4637,6 +4641,22 @@ final class WP_Customize_Manager {
} else { } else {
$return_url = home_url( '/' ); $return_url = home_url( '/' );
} }
$return_url_basename = wp_basename( parse_url( $this->return_url, PHP_URL_PATH ) );
$return_url_query = parse_url( $this->return_url, PHP_URL_QUERY );
if ( 'themes.php' === $return_url_basename && $return_url_query ) {
parse_str( $return_url_query, $query_vars );
/*
* If the return URL is a page added by a theme to the Appearance menu via add_submenu_page(),
* verify that belongs to the active theme, otherwise fall back to the Themes screen.
*/
if ( isset( $query_vars['page'] ) && ! isset( $_registered_pages[ "appearance_page_{$query_vars['page']}" ] ) ) {
$return_url = admin_url( 'themes.php' );
}
}
return $return_url; return $return_url;
} }

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.4-alpha-46753'; $wp_version = '5.4-alpha-46754';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.