Uma área de pesquisa sobre o WordPress para devs e autores do tema



wp_delete_site ›

Desde5.0.0
Obsoleton/a
wp_delete_site ( $site_id )
Parâmetros:
  • (int) $site_id ID of the site that should be deleted.
    Required: Yes
Retorna:
  • (WP_Site|WP_Error) The deleted site object on success, or error object on failure.
Definido em:
Codex:

Deletes a site from the database.



Fonte

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;
}