From 6a32aeaf8c0a0b783d93d20d306852521383d838 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 10 Nov 2025 21:08:05 +0000 Subject: [PATCH] Themes: Restore 'Live Preview' button for block themes. Note that the `return` query parameter is not yet functional in the Site Editor. See [https://github.com/WordPress/gutenberg/issues/47934 Gutenberg#47934]. Follow-up to [52341], [52346], [52353], [52802]. Props ninomiho, mcsf, dhruval04, praful2111, mlaetitia1986. See #54578. Fixes #64159. Built from https://develop.svn.wordpress.org/trunk@61195 git-svn-id: http://core.svn.wordpress.org/trunk@60531 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-theme-installer-skin.php | 26 +++++++--- wp-admin/themes.php | 52 ++++++++----------- wp-includes/version.php | 2 +- 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/wp-admin/includes/class-theme-installer-skin.php b/wp-admin/includes/class-theme-installer-skin.php index 2f1fa344c9..7e734fce2f 100644 --- a/wp-admin/includes/class-theme-installer-skin.php +++ b/wp-admin/includes/class-theme-installer-skin.php @@ -121,14 +121,24 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin { $install_actions = array(); - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) && ! $theme_info->is_block_theme() ) { - $customize_url = add_query_arg( - array( - 'theme' => urlencode( $stylesheet ), - 'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ), - ), - admin_url( 'customize.php' ) - ); + if ( current_user_can( 'edit_theme_options' ) && ( $theme_info->is_block_theme() || current_user_can( 'customize' ) ) ) { + if ( $theme_info->is_block_theme() ) { + $customize_url = add_query_arg( + array( + 'wp_theme_preview' => urlencode( $stylesheet ), + 'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ), + ), + admin_url( 'site-editor.php' ) + ); + } else { + $customize_url = add_query_arg( + array( + 'theme' => urlencode( $stylesheet ), + 'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ), + ), + admin_url( 'customize.php' ) + ); + } $install_actions['preview'] = sprintf( '' . diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 08245a0971..ca9f52b2a1 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -645,7 +645,7 @@ foreach ( $themes as $theme ) : > @@ -1034,15 +1034,13 @@ function wp_theme_auto_update_setting_template() { aria-label="" > - <# if ( ! data.blockTheme ) { #> - - - <# } #> + + <# } #> <# } #> @@ -1261,16 +1259,14 @@ function wp_theme_auto_update_setting_template() {
<# if ( data.compatibleWP && data.compatiblePHP ) { #> - <# if ( ! data.blockTheme ) { #> - - - <# } #> + + <# if ( data.actions.activate ) { #> <# } #> <# } else { #> - <# if ( ! data.blockTheme ) { #> - - - <# } #> + + <# if ( data.actions.activate ) { #>