Opened 13 years ago
Closed 9 years ago
#25584 closed enhancement (fixed)
Add an action hook at the end of wpmu_delete_blog
| Reported by: | pauldewouters | Owned by: | jeremyfelt |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.8 |
| Component: | Networks and Sites | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | Focuses: | multisite |
Description
I have the need of an additional hook in the wpmu_delete_blog function in wp-admin/includes/ms.php.
I'm maintaining a list of active blogs in a DB option which also has extra data associated. I update this list on 2 hooks currently: wpmu_new_blog and delete_blog
Unfortunately, the delete_blog occurs before the actual blog deletion, so at that point, an SQL query will return that blog too.
If there were a hook after the actual deletion, I could retrieve the list of active blogs.
Attachments (4)
Change History (24)
#5
@
13 years ago
- Keywords dev-feedback added
Worth noting that the parent function is named wpmu_delete_blog, and this hook would be preceded by a delete_blog hook. So perhaps in the name of consistency we should go with deleted_blog vs deleted_site.
If at some time in the future the parent function gets renamed to say, wp_delete_site, I'd imagine the hooks would remain in the name of posterity and back-compat. I think either situation (renaming or not renaming the function), I'd prefer the hooks match. That's just me.
#6
@
13 years ago
- Keywords commit dev-feedback removed
- Milestone 3.8 → Future Release
I'd tend to agree with keeping the hooks the same style.
#7
@
13 years ago
- Milestone Future Release → 3.9
25584.2.diff is a refresh for 3.9, goes with deleted_blog as the filter.
#8
@
13 years ago
+1 for 25584.2.diff.
#11
@
13 years ago
- Keywords commit added
25584.2.diff still applies cleanly. Adds deleted_blog filter with docs.
#12
@
13 years ago
The hook docs in 25584.2.diff look great. Let's do this thing.
#13
@
13 years ago
- Keywords 2nd-opinion added
- Milestone 3.9 → Future Release
This filter is inside a if ( $drop ) conditional which means it would only be fired when data is actually deleted.
I'll be honest, I don't see much of a purpose for this hook. The existing delete_blog action is enough, even though it is on pre-transaction. If you're trying to query only active blogs, simply exclude the blog for which the hook has fired. While we would generally provide and benefit from a post-transaction hook, I'd hesitate to bother adding one until we re-do this function at some point down the line (with better terminology and less hackery).
#16
@
9 years ago
- Keywords needs-refresh added; 2nd-opinion removed
- Milestone Future Release → 4.8
- Owner set to
- Status new → assigned
- Version → 3.0
I also just ran into a need for this.
Core already has deleted_post and deleted_user, so the proposed deleted_blog action makes sense.
I'm -1 on naming it deleted_site for the reasons @DrewAPicture stated.
@
9 years ago
Move action outside of $drop check and pass $drop as a parameter to match delete_blog usage
This ticket was mentioned in Slack in #core-multisite by jjj. View the logs.
9 years ago
#19
@
9 years ago
25584.3.diff looks good. I think it makes sense adding this to help with other cleanup related operations. If we ever redo this function, it will likely be very different and have different actions.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
25584.diff is slightly different from the original patch. I think
deleted_sitealigns with the naming of some other hooks in core. Docs for the hook have also been updated to reflect the proper version for@since.