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
This commit is contained in:
hellofromTonya 2021-12-10 20:33:00 +00:00
parent 3beb1d25ab
commit f847144952
2 changed files with 21 additions and 7 deletions

View File

@ -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 ) :
?>
<a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
<?php
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
/* translators: %s: Theme name. */
$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
?>
@ -553,7 +561,7 @@ foreach ( $themes as $theme ) :
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
?>
<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
<?php if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
<?php } ?>
<?php } ?>
@ -913,7 +921,9 @@ function wp_theme_auto_update_setting_template() {
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
?>
<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
<# if ( ! data.blockTheme ) { #>
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
<# } #>
<# } #>
<# } #>
</div>
@ -1121,7 +1131,9 @@ function wp_theme_auto_update_setting_template() {
<# if ( data.actions.activate ) { #>
<a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
<# } #>
<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
<# if ( ! data.blockTheme ) { #>
<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
<# } #>
<# } else { #>
<?php
/* translators: %s: Theme name. */
@ -1130,7 +1142,9 @@ function wp_theme_auto_update_setting_template() {
<# if ( data.actions.activate ) { #>
<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
<# } #>
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
<# if ( ! data.blockTheme ) { #>
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
<# } #>
<# } #>
</div>

View File

@ -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.