get_blog_status

Definition:
function get_blog_status( $id, $pref ) {}

Get a blog details field.

Parameters

  • int $id: The blog id
  • string $pref: A field name

Source code

function get_blog_status( $id, $pref ) {

	global $wpdb;



	$details = get_blog_details( $id, false );

	if ( $details )

		return $details->$pref;



	return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) );

1220

get_blog_post

Definition:
function get_blog_post( $blog_id, $post_id ) {}

Get a blog post from any site on the network.

Parameters

  • int $blog_id: ID of the blog.
  • int $post_id: ID of the post you’re looking for.

Return values

returns:post.

Source code

function get_blog_post( $blog_id, $post_id ) {

	global $wpdb;



	$key = $blog_id . '-' . $post_id;

	$post = wp_cache_get( $key, 'global-posts' );

	if ( $post == false ) {

		$post = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->get_blog_prefix( $blog_id ) . 'posts WHERE ID = %d', $post_id ) );

		wp_cache_add( $key, $post, 'global-posts' );

	}



	return $post;

}

1218

get_blog_permalink

Definition:
function get_blog_permalink( $_blog_id, $post_id ) {}

Get the permalink for a post on another blog.

Parameters

  • int $_blog_id: ID of the source blog.
  • int $post_id: ID of the desired post.

Return values

returns:The post’s permalink

Source code

function get_blog_permalink( $_blog_id, $post_id ) {

	$key = "{$_blog_id}-{$post_id}-blog_permalink";

1216

get_blog_option

Definition:
function get_blog_option( $blog_id, $setting, $default = false ) {}

Retrieve option value based on setting name and blog_id.
If the option does not exist or does not have a value, then the return value will be false. This is useful to check whether you need to install an option and is commonly used during installation of plugin options and to test whether upgrading is required.

Parameters

  • int $blog_id: Optional. Blog ID, can be null to refer to the current blog.
  • string $setting: Name of option to retrieve. Should already be SQL-escaped.
  • string $default: (optional) Default value returned if option not found.

Return values

returns:Value set for the option.

Defined filters

  • blog_option_$setting
    apply_filters( 'blog_option_' . $setting, $value, $blog_id )

Source code

function get_blog_option( $blog_id, $setting, $default = false ) {

	global $wpdb;



	if ( null === $blog_id )

		$blog_id = $wpdb->blogid;



	$key = $blog_id . '-' . $setting . '-blog_option';

	$value = wp_cache_get( $key, 'site-options' );

	if ( $value == null ) {

		if ( $blog_id == $wpdb->blogid ) {

			$value = get_option( $setting, $default );

			$notoptions = wp_cache_get( 'notoptions', 'options' );

			if ( isset( $notoptions[$setting] ) ) {

				wp_cache_set( $key, 'noop', 'site-options' );

				$value = $default;

			} elseif ( $value == false ) {

				wp_cache_set( $key, 'falsevalue', 'site-options' );

			} else {

				wp_cache_set( $key, $value, 'site-options' );

			}

			return apply_filters( 'blog_option_' . $setting, $value, $blog_id );

		} else {

			$blog_prefix = $wpdb->get_blog_prefix( $blog_id );

			$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$blog_prefix}options WHERE option_name = %s", $setting ) );

			if ( is_object( $row ) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values

				$value = $row->option_value;

				if ( $value == false )

					wp_cache_set( $key, 'falsevalue', 'site-options' );

				else

					wp_cache_set( $key, $value, 'site-options' );

			} else { // option does not exist, so we must cache its non-existence

				wp_cache_set( $key, 'noop', 'site-options' );

				$value = $default;

			}

		}

	} elseif ( $value == 'noop' ) {

1214

get_blog_list

Definition:
function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {}

Parameters

  • $start
  • $num
  • $deprecated

Source code

function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {

	_deprecated_function( __FUNCTION__, '3.0' );



	global $wpdb;

	$blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );



	foreach ( (array) $blogs as $details ) {

		$blog_list[ $details['blog_id'] ] = $details;

		$blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" );

	}

	unset( $blogs );

	$blogs = $blog_list;



	if ( false == is_array( $blogs ) )

		return array();



	if ( $num == 'all' )

		return array_slice( $blogs, $start, count( $blogs ) );

	else

		return array_slice( $blogs, $start, $num );

}

1212