Opened 10 years ago
Closed 10 years ago
#29580 closed defect (bug) (fixed)
When a child-theme is active, the parent-theme should not be deletable.
Reported by: | ounziw | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 4.1 | Priority: | normal |
Severity: | normal | Version: | 4.0 |
Component: | Themes | Keywords: | needs-testing has-patch dev-feedback |
Focuses: | Cc: |
Description
In wp-admin/themes.php, we can delete non-active themes.
When a child-theme is active, the parent-theme is deletable.
But if the parent-theme is deleted, the child-theme will not work.
So, the "Delete" link should be removed from the current theme's parent-theme.
Attachments (5)
Change History (17)
#1
@
10 years ago
- Component changed from General to Themes
- Keywords needs-patch added
Confirmed. Looks like this has been around for awhile, not new to 4.0.
I started working on a patch of the wp_prepare_themes_for_js
function in wp-admin/includes/theme.php
(to remove the delete link from the UI) but then it occurred to me perhaps this should be built into the delete_theme()
function instead. For comparison, it looks like the equivalent function for deleting plugins throws an error if an attempt to delete an active plugin is made, but delete_theme()
does not.
#2
@
10 years ago
- Keywords has-patch needs-testing added; needs-patch removed
ignore my previous comment. I took a closer look at delete_plugin
and the check for active plugins isn't there after all - it's in wp-admin/plugins.php
.
in the case of a theme with an active child, the delete link is removed and the plugin deletion is blocked.
#4
@
10 years ago
- Keywords needs-patch needs-docs added; has-patch removed
@karpstrucking: Thanks for the patch.
It could do with some inline comments to explain what's going on, as well as conforming to coding standards in regard to spacing in the new string and braces ]on one of the conditionals.
#5
follow-up:
↓ 6
@
10 years ago
- Keywords has-patch dev-feedback added; needs-patch needs-docs removed
@DrewAPicture thanks for the feedback. updated patch attached. in wp-admin/themes.php
I went ahead and updated spacing for the containing if statement, not just my own additions. it's a bit of a slippery slope and I wasn't sure if there's a protocol for that - I'm happy to go further if desired.
#6
in reply to:
↑ 5
;
follow-up:
↓ 7
@
10 years ago
Replying to karpstrucking:
@DrewAPicture thanks for the feedback. updated patch attached. in
wp-admin/themes.php
I went ahead and updated spacing for the containing if statement, not just my own additions. it's a bit of a slippery slope and I wasn't sure if there's a protocol for that - I'm happy to go further if desired.
Looks pretty good. Yeah, the protocol on spacing out lines is that it should only happen on lines that you're already changing or adding. This is to prevent undue churn in the codebase. So in 29580_gowp1.diff you'd revert the spacing changes on lines 15, 17, 22, 25, and 27 for wp-admin/themes.php.
#7
in reply to:
↑ 6
@
10 years ago
Replying to DrewAPicture:
Looks pretty good. Yeah, the protocol on spacing out lines is that it should only happen on lines that you're already changing or adding. This is to prevent undue churn in the codebase. So in 29580_gowp1.diff you'd revert the spacing changes on lines 15, 17, 22, 25, and 27 for wp-admin/themes.php.
noted! updated in 29580_gowp2.diff
#8
follow-up:
↓ 10
@
10 years ago
Patch 29580.diff fixes the PHP notice undefined variable parents
... when there are no child themes.
I noticed another problem on Multisite setups. A parent theme is deletable from sites not using its child. To reproduce:
- Login as the super admin and navigate to Network Admin > Appearance > Themes.
- Network Enable a parent and its child theme.
- Login to one of the sites and Apply the child theme.
- Login to another site and delete its parent theme.
#9
@
10 years ago
We can't fix the multisite part. We can check if the theme has any children and warn them specifically, the same way we warn them a theme might be used on sites.
#10
in reply to:
↑ 8
@
10 years ago
Replying to jesin:
Patch 29580.diff fixes the PHP notice undefined variable
parents
... when there are no child themes.
Doh. Thanks!
Theme edit screen