Make WordPress Core

Changeset 52353


Ignore:
Timestamp:
12/10/2021 08:31:57 PM (3 years ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/themes.php

    r52346 r52353  
    308308
    309309if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
     310    $forbidden_paths = array(
     311        'themes.php',
     312        'theme-editor.php',
     313        'site-editor.php',
     314        'edit.php?post_type=wp_navigation',
     315    );
     316
    310317    foreach ( (array) $submenu['themes.php'] as $item ) {
    311318        $class = '';
    312         if ( 'themes.php' === $item[2] || 'theme-editor.php' === $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) {
     319
     320        if ( in_array( $item[2], $forbidden_paths, true ) || str_starts_with( $item[2], 'customize.php' ) ) {
    313321            continue;
    314322        }
     
    542550            <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
    543551            <?php
    544             if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
     552            if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
    545553                /* translators: %s: Theme name. */
    546554                $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
     
    554562            ?>
    555563            <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
    556             <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
     564            <?php if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
    557565                <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
    558566            <?php } ?>
     
    914922                    ?>
    915923                    <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
    916                     <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
     924                    <# if ( ! data.blockTheme ) { #>
     925                        <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
     926                    <# } #>
    917927                <# } #>
    918928            <# } #>
     
    11221132                        <a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
    11231133                    <# } #>
    1124                     <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
     1134                    <# if ( ! data.blockTheme ) { #>
     1135                        <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
     1136                    <# } #>
    11251137                <# } else { #>
    11261138                    <?php
     
    11311143                        <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
    11321144                    <# } #>
    1133                     <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
     1145                    <# if ( ! data.blockTheme ) { #>
     1146                        <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
     1147                    <# } #>
    11341148                <# } #>
    11351149            </div>
Note: See TracChangeset for help on using the changeset viewer.