Customizer: Prevent erroneously directing user to login screen when closing.
Fixes issue where user gets stuck at login screen after trying to close the app if previously they had to first login to access the Customizer. Prevents `WP_Customize_Manager::get_return_url()` from using `wp-login.php` as a referer. Props chandrapatel. See #32637. Fixes #35355. git-svn-id: https://develop.svn.wordpress.org/trunk@36261 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
68d4b23608
commit
2fa620e4c3
@ -1579,9 +1579,11 @@ final class WP_Customize_Manager {
|
|||||||
*/
|
*/
|
||||||
public function get_return_url() {
|
public function get_return_url() {
|
||||||
$referer = wp_get_referer();
|
$referer = wp_get_referer();
|
||||||
|
$excluded_referer_basenames = array( 'customize.php', 'wp-login.php' );
|
||||||
|
|
||||||
if ( $this->return_url ) {
|
if ( $this->return_url ) {
|
||||||
$return_url = $this->return_url;
|
$return_url = $this->return_url;
|
||||||
} else if ( $referer && 'customize.php' !== basename( parse_url( $referer, PHP_URL_PATH ) ) ) {
|
} else if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
|
||||||
$return_url = $referer;
|
$return_url = $referer;
|
||||||
} else if ( $this->preview_url ) {
|
} else if ( $this->preview_url ) {
|
||||||
$return_url = $this->preview_url;
|
$return_url = $this->preview_url;
|
||||||
|
@ -322,6 +322,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
|||||||
$_SERVER['HTTP_REFERER'] = wp_slash( admin_url( 'customize.php' ) );
|
$_SERVER['HTTP_REFERER'] = wp_slash( admin_url( 'customize.php' ) );
|
||||||
$this->assertEquals( $preview_url, $this->manager->get_return_url() );
|
$this->assertEquals( $preview_url, $this->manager->get_return_url() );
|
||||||
|
|
||||||
|
// See #35355.
|
||||||
|
$_SERVER['HTTP_REFERER'] = wp_slash( admin_url( 'wp-login.php' ) );
|
||||||
|
$this->assertEquals( $preview_url, $this->manager->get_return_url() );
|
||||||
|
|
||||||
$url = home_url( '/referred/' );
|
$url = home_url( '/referred/' );
|
||||||
$_SERVER['HTTP_REFERER'] = wp_slash( $url );
|
$_SERVER['HTTP_REFERER'] = wp_slash( $url );
|
||||||
$this->assertEquals( $url, $this->manager->get_return_url() );
|
$this->assertEquals( $url, $this->manager->get_return_url() );
|
||||||
|
Loading…
Reference in New Issue
Block a user