Multisite: Complete the new CRUD API for managing sites.
New functions `wp_insert_site( $data )`, `wp_update_site( $id, $data )` and `wp_delete_site( $id )` are introduced to manage site rows in the `wp_blogs` table, forming the new CRUD API together with the existing `get_site()` / `get_sites()`. The new API provides various benefits over the previously existing API, fixing several cache invalidation issues and being hook-driven so that normalization and validation of the passed data can be fully customized. New hooks introduced as part of this are the actions `wp_insert_site`, `wp_update_site`, `wp_delete_site`, `wp_validate_site_data` and the filter `wp_normalize_site_data`. At this point, `wp_insert_site()` does not handle setting up the site's database tables, and `wp_delete_site()` does not handle dropping the site's database tables, so the two can not yet be used directly as full replacements of `wpmu_create_blog()` and `wpmu_delete_blog()`. Managing the site's database tables will be added via hooks as part of the follow-up ticket #41333. The existing functions `wpmu_create_blog()`, `update_blog_details()`, and `wpmu_delete_blog()` make use of the respective new counterpart and will be obsolete once #41333 has been completed. Props flixos90, jeremyfelt, spacedmonkey. Fixes #40364. Built from https://develop.svn.wordpress.org/trunk@43548 git-svn-id: http://core.svn.wordpress.org/trunk@43377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -56,6 +56,7 @@ function check_upload_size( $file ) {
|
||||
* Delete a site.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @since 5.0.0 Use wp_delete_site() internally to delete the site row from the database.
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
@@ -142,7 +143,7 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
||||
}
|
||||
}
|
||||
|
||||
$wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
|
||||
wp_delete_site( $blog_id );
|
||||
|
||||
/**
|
||||
* Filters the upload base directory to delete when the site is deleted.
|
||||
|
||||
Reference in New Issue
Block a user