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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52353 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork 2021-12-10 20:31:57 +00:00
parent 882687a54a
commit d3f13613d7

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>