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-includes/ms-default-filters.php

    r42343 r43548  
    4242add_action( 'wpmu_activate_blog', 'wpmu_welcome_notification', 10, 5 );
    4343add_action( 'after_signup_site', 'wpmu_signup_blog_notification', 10, 7 );
     44add_filter( 'wp_normalize_site_data', 'wp_normalize_site_data', 10, 1 );
     45add_action( 'wp_validate_site_data', 'wp_validate_site_data', 10, 3 );
     46add_action( 'wp_insert_site', 'wp_maybe_update_network_site_counts_on_update', 10, 1 );
     47add_action( 'wp_update_site', 'wp_maybe_update_network_site_counts_on_update', 10, 2 );
     48add_action( 'wp_delete_site', 'wp_maybe_update_network_site_counts_on_update', 10, 1 );
     49add_action( 'wp_insert_site', 'wp_maybe_transition_site_statuses_on_update', 10, 1 );
     50add_action( 'wp_update_site', 'wp_maybe_transition_site_statuses_on_update', 10, 2 );
     51add_action( 'wp_update_site', 'wp_maybe_clean_new_site_cache_on_update', 10, 2 );
     52add_action( 'update_blog_public', 'wp_update_blog_public_option_on_site_update', 1, 2 );
    4453
    4554// Register Nonce
Note: See TracChangeset for help on using the changeset viewer.