WordPress.org

Make WordPress Core

Changeset 46754


Ignore:
Timestamp:
11/20/2019 06:47:08 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r46691 r46754  
    46234623     * @since 4.4.0
    46244624     *
     4625     * @global array $_registered_pages
     4626     *
    46254627     * @return string URL for link to close Customizer.
    46264628     */
    46274629    public function get_return_url() {
     4630        global $_registered_pages;
     4631
    46284632        $referer                    = wp_get_referer();
    46294633        $excluded_referer_basenames = array( 'customize.php', 'wp-login.php' );
     
    46384642            $return_url = home_url( '/' );
    46394643        }
     4644
     4645        $return_url_basename = wp_basename( parse_url( $this->return_url, PHP_URL_PATH ) );
     4646        $return_url_query    = parse_url( $this->return_url, PHP_URL_QUERY );
     4647
     4648        if ( 'themes.php' === $return_url_basename && $return_url_query ) {
     4649            parse_str( $return_url_query, $query_vars );
     4650
     4651            /*
     4652             * If the return URL is a page added by a theme to the Appearance menu via add_submenu_page(),
     4653             * verify that belongs to the active theme, otherwise fall back to the Themes screen.
     4654             */
     4655            if ( isset( $query_vars['page'] ) && ! isset( $_registered_pages[ "appearance_page_{$query_vars['page']}" ] ) ) {
     4656                $return_url = admin_url( 'themes.php' );
     4657            }
     4658        }
     4659
    46404660        return $return_url;
    46414661    }
  • trunk/tests/phpunit/tests/customize/manager.php

    r46586 r46754  
    28312831
    28322832    /**
     2833     * @ticket 46686
     2834     */
     2835    function test_return_url_with_deactivated_theme() {
     2836        $this->manager->set_return_url( admin_url( 'themes.php?page=mytheme_documentation' ) );
     2837        $this->assertEquals( admin_url( 'themes.php' ), $this->manager->get_return_url() );
     2838    }
     2839
     2840    /**
    28332841     * Test get_autofocus()/set_autofocus() methods.
    28342842     *
Note: See TracChangeset for help on using the changeset viewer.