diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index c4b8b0c3bf..0a0ea9e9c5 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -525,6 +525,16 @@ function wp_prepare_themes_for_js( $themes = null ) { $parents[ $slug ] = $theme->parent()->get_stylesheet(); } + $customize_action = null; + if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { + $customize_action = esc_url( add_query_arg( + array( + 'return' => urlencode( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), + ), + wp_customize_url( $slug ) + ) ); + } + $prepared_themes[ $slug ] = array( 'id' => $slug, 'name' => $theme->display( 'Name' ), @@ -540,7 +550,7 @@ function wp_prepare_themes_for_js( $themes = null ) { 'update' => get_theme_update_available( $theme ), 'actions' => array( 'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null, - 'customize' => ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) ? wp_customize_url( $slug ) : null, + 'customize' => $customize_action, 'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null, ), ); diff --git a/wp-admin/themes.php b/wp-admin/themes.php index edbe97ab3f..bf65884fb2 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -387,7 +387,7 @@ $can_install = current_user_can( 'install_themes' ); <# if ( data.active ) { #> <# if ( data.actions.customize ) { #> - + <# } #> <# } else { #> diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index dd71ede82d..55acd10f56 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -1473,14 +1473,15 @@ final class WP_Customize_Manager { * @return string URL for link to close Customizer. */ public function get_return_url() { + $referer = wp_get_referer(); if ( $this->return_url ) { $return_url = $this->return_url; + } else if ( $referer ) { + $return_url = $referer; } else if ( $this->preview_url ) { $return_url = $this->preview_url; - } else if ( current_user_can( 'edit_theme_options' ) || current_user_can( 'switch_themes' ) ) { - $return_url = admin_url( 'themes.php' ); } else { - $return_url = admin_url(); + $return_url = home_url( '/' ); } return $return_url; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 5c87a1225b..603b22cef9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-beta2-35482'; +$wp_version = '4.4-beta2-35483'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.