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: |
|
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)
Change History (9)
#2
@
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
#3
@
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
Trac ticket: https://core.trac.wordpress.org/ticket/54533
#6
@
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
@
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> <# } #>
Related: #51832