WP_CLI\Fetchers

Site::get_siteprivateWP-CLI 1.0

Get site (blog) data for a given id.

Method of the class: Site{}

No Hooks.

Returns

Array|false. The item if found; false otherwise.

Usage

// private - for code of main (parent) class only
$result = $this->get_site( $arg );
$arg(string) (required)
The raw CLI argument.

Notes

  • Global. wpdb. $wpdb WordPress database abstraction object.

Site::get_site() code WP-CLI 2.13.0-alpha

private function get_site( $arg ) {
	global $wpdb;

	// Load site data
	$site = $wpdb->get_row(
		$wpdb->prepare(
			"SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d",
			$arg
		)
	);

	if ( ! empty( $site ) ) {
		// Only care about domain and path which are set here
		return $site;
	}

	return false;
}