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. git-svn-id: https://develop.svn.wordpress.org/trunk@46754 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
071030b793
commit
3b54ab37ed
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2829,6 +2829,14 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
|||||||
$this->assertEquals( admin_url( 'edit.php' ), $this->manager->get_return_url() );
|
$this->assertEquals( admin_url( 'edit.php' ), $this->manager->get_return_url() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 46686
|
||||||
|
*/
|
||||||
|
function test_return_url_with_deactivated_theme() {
|
||||||
|
$this->manager->set_return_url( admin_url( 'themes.php?page=mytheme_documentation' ) );
|
||||||
|
$this->assertEquals( admin_url( 'themes.php' ), $this->manager->get_return_url() );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test get_autofocus()/set_autofocus() methods.
|
* Test get_autofocus()/set_autofocus() methods.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user