diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js
index 818c201496..b3821246d9 100644
--- a/src/js/_enqueues/wp/theme.js
+++ b/src/js/_enqueues/wp/theme.js
@@ -622,6 +622,9 @@ themes.view.Theme = wp.Backbone.View.extend({
if ( _this.model.get( 'id' ) === response.slug ) {
_this.model.set( { 'installed': true } );
}
+ if ( response.blockTheme ) {
+ _this.model.set( { 'block_theme': true } );
+ }
} );
wp.updates.installTheme( {
diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
index 191e5b54dd..ecea223667 100644
--- a/src/wp-admin/includes/ajax-actions.php
+++ b/src/wp-admin/includes/ajax-actions.php
@@ -3568,6 +3568,19 @@ function wp_ajax_query_themes() {
$update_php = network_admin_url( 'update.php?action=install-theme' );
+ $installed_themes = search_theme_directories();
+
+ if ( false === $installed_themes ) {
+ $installed_themes = array();
+ }
+
+ foreach ( $installed_themes as $theme_slug => $theme_data ) {
+ // Ignore child themes.
+ if ( str_contains( $theme_slug, '/' ) ) {
+ unset( $installed_themes[ $theme_slug ] );
+ }
+ }
+
foreach ( $api->themes as &$theme ) {
$theme->install_url = add_query_arg(
array(
@@ -3599,12 +3612,19 @@ function wp_ajax_query_themes() {
}
}
+ $is_theme_installed = array_key_exists( $theme->slug, $installed_themes );
+
+ // We only care about installed themes.
+ $theme->block_theme = $is_theme_installed && wp_get_theme( $theme->slug )->is_block_theme();
+
if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
+ $customize_url = $theme->block_theme ? admin_url( 'site-editor.php' ) : wp_customize_url( $theme->slug );
+
$theme->customize_url = add_query_arg(
array(
'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
),
- wp_customize_url( $theme->slug )
+ $customize_url
);
}
@@ -4139,6 +4159,9 @@ function wp_ajax_install_theme() {
}
}
+ $theme = wp_get_theme( $slug );
+ $status['blockTheme'] = $theme->is_block_theme();
+
if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
$status['customizeUrl'] = add_query_arg(
array(
diff --git a/src/wp-admin/theme-install.php b/src/wp-admin/theme-install.php
index cd3a607ea9..7d592dda65 100644
--- a/src/wp-admin/theme-install.php
+++ b/src/wp-admin/theme-install.php
@@ -35,9 +35,10 @@ if ( false === $installed_themes ) {
$installed_themes = array();
}
-foreach ( $installed_themes as $k => $v ) {
- if ( false !== strpos( $k, '/' ) ) {
- unset( $installed_themes[ $k ] );
+foreach ( $installed_themes as $theme_slug => $theme_data ) {
+ // Ignore child themes.
+ if ( str_contains( $theme_slug, '/' ) ) {
+ unset( $installed_themes[ $theme_slug ] );
}
}
@@ -373,7 +374,9 @@ if ( $tab ) {
<# } #>
<# if ( data.customize_url ) { #>
<# if ( ! data.active ) { #>
-
+ <# if ( ! data.block_theme ) { #>
+
+ <# } #>
<# } else { #>
<# } #>