I want to change the return URL after someone cancels or closes out of their changes when using the Apperance -> Customize option within Wordpress. In the wp-admin/customize.php
file here is the code to control the return URL:
wp_reset_vars( array( 'url', 'return' ) );
$url = wp_unslash( $url );
$url = wp_validate_redirect( $url, home_url( '/' ) );
if ( $return ) {
$return = wp_unslash( $return );
$return = wp_validate_redirect( $return );
}
if ( ! $return ) {
if ( $url ) {
$return = $url;
} elseif ( current_user_can( 'edit_theme_options' ) || current_user_can( 'switch_themes' ) ) {
$return = admin_url( 'themes.php' );
} else {
$return = admin_url();
}
}
The URL is output to the screen with the following code:
<a class="customize-controls-close" href="<?php echo esc_url( $return ); ?>">
<span class="screen-reader-text"><?php _e( 'Cancel' ); ?></span>
</a>
Is there a way to control the return URL wihtout modifying the core wp-admin/customize.php
file?