Customize: Exclude referer URL from being used for Close link if it is customize.php.

This fixes an edge case where the Close button could never link the user out of the Customizer, if the user initially accessed it without a `url` param and then clicked a link (provided by a plugin) that took them to another `customize.php` URL.

See #32637.


git-svn-id: https://develop.svn.wordpress.org/trunk@35635 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2015-11-13 05:24:28 +00:00
parent 70bb2173c0
commit 0068d161b3
2 changed files with 4 additions and 1 deletions

View File

@ -1476,7 +1476,7 @@ final class WP_Customize_Manager {
$referer = wp_get_referer();
if ( $this->return_url ) {
$return_url = $this->return_url;
} else if ( $referer ) {
} else if ( $referer && 'customize.php' !== basename( parse_url( $referer, PHP_URL_PATH ) ) ) {
$return_url = $referer;
} else if ( $this->preview_url ) {
$return_url = $this->preview_url;

View File

@ -262,6 +262,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$this->manager->set_preview_url( $preview_url );
$this->assertEquals( $preview_url, $this->manager->get_return_url() );
$_SERVER['HTTP_REFERER'] = wp_slash( admin_url( 'customize.php' ) );
$this->assertEquals( $preview_url, $this->manager->get_return_url() );
$url = home_url( '/referred/' );
$_SERVER['HTTP_REFERER'] = wp_slash( $url );
$this->assertEquals( $url, $this->manager->get_return_url() );