Make WordPress Core

Opened 4 years ago

Last modified 7 months ago

#54533 new enhancement

State more clearly that an active theme can't be deleted

Reported by: tobifjellner's profile tobifjellner Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch has-screenshots
Focuses: ui, administration Cc:

Description

A post in the forums https://wordpress.org/support/topic/theres-no-delete-button/ by @dmcohen pointed out a thing that should be better shown:

In wp-admnin/themes.php when a user with capability delete/install themes (i.e. usually an administrator) hits the "Theme details" button that is visible on hover and opens the theme details pop-up, they'll see the "Delete theme" link in the pop-up. But for the currently active theme (and its parent theme, where applicable) that link is "missing".

Suggestion: Instead of nothing, show a short message "This theme is currently active and therefore cannot be deleted."

Attachments (2)

active_theme.png (10.2 KB) - added by Presskopp 8 months ago.
parent_theme.png (10.3 KB) - added by Presskopp 8 months ago.

Download all attachments as: .zip

Change History (9)

#1 @SergeyBiryukov
4 years ago

  • Component changed from Administration to Themes
  • Focuses ui administration added

Related: #51832

#2 @Presskopp
4 years ago

It is already shown if a theme is the "Current Theme" so in my opinion this is not neccesary

[Edit] Oh, but in case it's a parent theme nothing is shown. This could indeed be improved

Last edited 4 years ago by Presskopp (previous) (diff)

#3 @tobifjellner
4 years ago

It is already shown if a theme is the "Current Theme" so in my opinion this is not neccesary

Still: Still, we'd get less confusion if we in clear mentioned that "this theme can't be deleted right now, since it's currently active/currently used as parent theme".

This ticket was mentioned in PR #8676 on WordPress/wordpress-develop by @Presskopp.


8 months ago
#4

  • Keywords has-patch added

#5 @Presskopp
8 months ago

  • Keywords has-screenshots added

#6 @Presskopp
8 months ago

There is no direct way to determine if a theme is a parent theme. However, indirectly, if a theme is not active and data.actions['delete'] is not set, it is most likely a parent theme (although this is not guaranteed). That's why the patch is working. In a perfect world we would have a has_active_child_theme() method,

#7 @Presskopp
7 months ago

somehow my patch vanished.

Here is the code:

<?php
        <# if ( data.active ) { #>
                <?php
                /* translators: %s: Theme name. */
                $aria_label = sprintf( _x( 'Active: %s', 'theme' ), '{{ data.name }}' );
                ?>
                <span class="cannot-delete-active-theme" aria-label="<?php echo esc_attr( $aria_label ); ?>">
                        <?php _e( 'You cannot delete an active theme.' ); ?>
                </span>
        <# } else if ( data.actions['delete'] ) { #>
                <?php
                /* translators: %s: Theme name. */
                $aria_label = sprintf( _x( 'Delete %s', 'theme' ), '{{ data.name }}' );
                ?>
                <a class="button delete-theme"
                        href="{{{ data.actions['delete'] }}}"
                        aria-label="<?php echo esc_attr( $aria_label ); ?>"
                ><?php _e( 'Delete' ); ?></a>
        <# } else { #>
                <?php
                /* translators: %s: Theme name. */
                $aria_label = sprintf( _x( 'Cannot Delete %s', 'theme' ), '{{ data.name }}' );
                ?>
                <span class="parent-theme-notice" aria-label="<?php echo esc_attr( $aria_label ); ?>">
                        <?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?>
                </span>
        <# } #>
Note: See TracTickets for help on using tickets.