wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_update_site › WordPress Function
Since5.1.0
Deprecatedn/a
› wp_update_site ( $site_id, $data )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
Updates a site in the database.
Related Functions: wp_update_term, wp_update_user, wp_update_post, wp_update_theme, wp_update_themes
Source
function wp_update_site( $site_id, array $data ) { 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.' ) ); } $defaults = $old_site->to_array(); $defaults['network_id'] = (int) $defaults['site_id']; $defaults['last_updated'] = current_time( 'mysql', true ); unset( $defaults['blog_id'], $defaults['site_id'] ); $data = wp_prepare_site_data( $data, $defaults, $old_site ); if ( is_wp_error( $data ) ) { return $data; } if ( false === $wpdb->update( $wpdb->blogs, $data, array( 'blog_id' => $old_site->id ) ) ) { return new WP_Error( 'db_update_error', __( 'Could not update site in the database.' ), $wpdb->last_error ); } clean_blog_cache( $old_site ); $new_site = get_site( $old_site->id ); /** * Fires once a site has been updated in the database. * * @since 5.1.0 * * @param WP_Site $new_site New site object. * @param WP_Site $old_site Old site object. */ do_action( 'wp_update_site', $new_site, $old_site ); return (int) $new_site->id; }