Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_delete_site ›

Seit5.0.0
Veraltetn/v
wp_delete_site ( $site_id )
Parameter:
  • (int) $site_id ID of the site that should be deleted.
    Erforderlich: Ja
Gibt zurück:
  • (WP_Site|WP_Error) The deleted site object on success, or error object on failure.
Definiert in:
Codex:

Deletes a site from the database.



Quellcode

function wp_delete_site( $site_id ) {
	global $wpdb;

	if ( empty( $site_id ) ) {
		return new WP_Error( 'site_empty_id', __( 'Site ID must not be empty.' ) );
	}

	$old_site = get_site( $site_id );
	if ( ! $old_site ) {
		return new WP_Error( 'site_not_exist', __( 'Site does not exist.' ) );
	}

	if ( false === $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $old_site->id ) ) ) {
		return new WP_Error( 'db_delete_error', __( 'Could not delete site from the database.' ), $wpdb->last_error );
	}

	clean_blog_cache( $old_site );

	/**
	 * Fires once a site has been deleted from the database.
	 *
	 * @since 5.0.0
	 *
	 * @param WP_Site $old_site Deleted site object.
	 */
	do_action( 'wp_delete_site', $old_site );

	return $old_site;
}