wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_delete_site › WordPress Function
Seit5.1.0
Veraltetn/v
› wp_delete_site ( $site_id )
Parameter: |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Deletes a site from the database.
Ähnliche Funktionen: wp_delete_post, wp_delete_term, wp_delete_file, wp_delete_user, wpmu_delete_user
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.' ) ); } $errors = new WP_Error(); /** * Fires before a site should be deleted from the database. * * Plugins should amend the `$errors` object via its `WP_Error::add()` method. If any errors * are present, the site will not be deleted. * * @since 5.1.0 * * @param WP_Error $errors Error object to add validation errors to. * @param WP_Site $old_site The site object to be deleted. */ do_action( 'wp_validate_site_deletion', $errors, $old_site ); if ( ! empty( $errors->errors ) ) { return $errors; } /** * Fires before a site is deleted. * * @since MU (3.0.0) * @deprecated 5.1.0 * * @param int $site_id The site ID. * @param bool $drop True if site's table should be dropped. Default false. */ do_action_deprecated( 'delete_blog', array( $old_site->id, true ), '5.1.0' ); /** * Fires when a site's uninitialization routine should be executed. * * @since 5.1.0 * * @param WP_Site $old_site Deleted site object. */ do_action( 'wp_uninitialize_site', $old_site ); if ( is_site_meta_supported() ) { $blog_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->blogmeta WHERE blog_id = %d ", $old_site->id ) ); foreach ( $blog_meta_ids as $mid ) { delete_metadata_by_mid( 'blog', $mid ); } } 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.1.0 * * @param WP_Site $old_site Deleted site object. */ do_action( 'wp_delete_site', $old_site ); /** * Fires after the site is deleted from the network. * * @since 4.8.0 * @deprecated 5.1.0 * * @param int $site_id The site ID. * @param bool $drop True if site's tables should be dropped. Default false. */ do_action_deprecated( 'deleted_blog', array( $old_site->id, true ), '5.1.0' ); return $old_site; }