From f847144952e74a5fa2cad9ece20d24f7a7c9e714 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Fri, 10 Dec 2021 20:33:00 +0000 Subject: [PATCH] Themes: Show only "Customize" or "Activate" button in block theme's Theme Details modal. At the bottom of a block theme's "Theme Details" modal, only one button will be displayed: * "Customize" button when the block theme is activated; * Else, the "Activate" button. The "Live Preview", "Editor beta", and "Navigation Menus" buttons are removed. Follow-up to [15646], [52341], [52346]. Props poena, ryelle, kafleg, antonvlasenko, costdev, SergeyBiryukov, hellofromTonya. Fixes #54578. Built from https://develop.svn.wordpress.org/trunk@52353 git-svn-id: http://core.svn.wordpress.org/trunk@51945 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/themes.php | 26 ++++++++++++++++++++------ wp-includes/version.php | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 47aa7742b9..cc18806d28 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -307,9 +307,17 @@ if ( $current_theme->errors() && ( ! is_multisite() || current_user_can( 'manage $current_theme_actions = array(); if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) { + $forbidden_paths = array( + 'themes.php', + 'theme-editor.php', + 'site-editor.php', + 'edit.php?post_type=wp_navigation', + ); + foreach ( (array) $submenu['themes.php'] as $item ) { $class = ''; - if ( 'themes.php' === $item[2] || 'theme-editor.php' === $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) { + + if ( in_array( $item[2], $forbidden_paths, true ) || str_starts_with( $item[2], 'customize.php' ) ) { continue; } // 0 = name, 1 = capability, 2 = file. @@ -541,7 +549,7 @@ foreach ( $themes as $theme ) : ?> @@ -553,7 +561,7 @@ foreach ( $themes as $theme ) : $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' ); ?> - + @@ -913,7 +921,9 @@ function wp_theme_auto_update_setting_template() { $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' ); ?> - + <# if ( ! data.blockTheme ) { #> + + <# } #> <# } #> <# } #> @@ -1121,7 +1131,9 @@ function wp_theme_auto_update_setting_template() { <# if ( data.actions.activate ) { #> <# } #> - + <# if ( ! data.blockTheme ) { #> + + <# } #> <# } else { #> <# } #> - + <# if ( ! data.blockTheme ) { #> + + <# } #> <# } #> diff --git a/wp-includes/version.php b/wp-includes/version.php index bd58b8d279..8f1d0d7a8b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-beta2-52352'; +$wp_version = '5.9-beta2-52353'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.