Make WordPress Core


Ignore:
Timestamp:
11/01/2015 06:39:50 AM (9 years ago)
Author:
westonruter
Message:

Customize: Return user to referring URL when leaving Customizer in absence of return query param.

When referring URL is not available, default returning user to frontend URL instead of admin URL. Themes page is updated to include the return path in Customizer links.

Props McGuive7, westonruter.
Fixes #32637.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/customize/manager.php

    r35307 r35483  
    253253    function test_return_url() {
    254254        wp_set_current_user( self::factory()->user->create( array( 'role' => 'author' ) ) );
    255         $this->assertEquals( get_admin_url(), $this->manager->get_return_url() );
     255        $this->assertEquals( home_url( '/' ), $this->manager->get_return_url() );
    256256
    257257        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    258258        $this->assertTrue( current_user_can( 'edit_theme_options' ) );
    259         $this->assertEquals( admin_url( 'themes.php' ), $this->manager->get_return_url() );
     259        $this->assertEquals( home_url( '/' ), $this->manager->get_return_url() );
    260260
    261261        $preview_url = home_url( '/foo/' );
    262262        $this->manager->set_preview_url( $preview_url );
     263        $this->assertEquals( $preview_url, $this->manager->get_return_url() );
     264
     265        $url = home_url( '/referred/' );
     266        $_SERVER['HTTP_REFERER'] = wp_slash( $url );
     267        $this->assertEquals( $url, $this->manager->get_return_url() );
     268
     269        $url = 'http://badreferer.example.com/';
     270        $_SERVER['HTTP_REFERER'] = wp_slash( $url );
     271        $this->assertNotEquals( $url, $this->manager->get_return_url() );
    263272        $this->assertEquals( $preview_url, $this->manager->get_return_url() );
    264273
Note: See TracChangeset for help on using the changeset viewer.