Make WordPress Core


Ignore:
Timestamp:
08/01/2018 01:05:44 PM (7 years ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ms.php

    r43177 r43548  
    5757 *
    5858 * @since 3.0.0
     59 * @since 5.0.0 Use wp_delete_site() internally to delete the site row from the database.
    5960 *
    6061 * @global wpdb $wpdb WordPress database abstraction object.
     
    143144        }
    144145
    145         $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
     146        wp_delete_site( $blog_id );
    146147
    147148        /**
Note: See TracChangeset for help on using the changeset viewer.