update_blog_details

Definition:
function update_blog_details( $blog_id, $details = array() {}

Update the details for a blog. Updates the blogs table for a given blog id.

Parameters

  • int $blog_id: Blog ID
  • array $details: Array of details keyed by blogs table field names.

Return values

returns:True if update succeeds, false otherwise.

Defined actions

  • make_spam_blog
    do_action( "make_spam_blog", $blog_id );
  • make_ham_blog
    do_action( "make_ham_blog", $blog_id );

Source code

function update_blog_details( $blog_id, $details = array() ) {

	global $wpdb;



	if ( empty($details) )

		return false;



	if ( is_object($details) )

		$details = get_object_vars($details);



	$current_details = get_blog_details($blog_id, false);

	if ( empty($current_details) )

		return false;



	$current_details = get_object_vars($current_details);



	$details = array_merge($current_details, $details);

	$details['last_updated'] = current_time('mysql', true);



	$update_details = array();

	$fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');

	foreach ( array_intersect( array_keys( $details ), $fields ) as $field )

		$update_details[$field] = $details[$field];



	$wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );



	// If spam status changed, issue actions.

	if ( $details[ 'spam' ] != $current_details[ 'spam' ] ) {

		if ( $details[ 'spam' ] == 1 )

			do_action( "make_spam_blog", $blog_id );

		else

			do_action( "make_ham_blog", $blog_id );

	}



	if ( isset($details[ 'public' ]) )

		update_blog_option( $blog_id, 'blog_public', $details[ 'public' ] );



	refresh_blog_details($blog_id);



	return true;

}

3155

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: