WP_CLI

Runner::fake_current_site_blog()private staticWP-CLI 1.0

Метод класса: Runner{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = Runner::fake_current_site_blog( $url_parts );
$url_parts (обязательный)
-

Код Runner::fake_current_site_blog() WP-CLI 2.8.0-alpha

private static function fake_current_site_blog( $url_parts ) {
	global $current_site, $current_blog;

	if ( ! isset( $url_parts['path'] ) ) {
		$url_parts['path'] = '/';
	}

	// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Intentional override.
	$current_site = (object) [
		'id'            => 1,
		'blog_id'       => 1,
		'domain'        => $url_parts['host'],
		'path'          => $url_parts['path'],
		'cookie_domain' => $url_parts['host'],
		'site_name'     => 'WordPress',
	];

	// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Intentional override.
	$current_blog = (object) [
		'blog_id'  => 1,
		'site_id'  => 1,
		'domain'   => $url_parts['host'],
		'path'     => $url_parts['path'],
		'public'   => '1',
		'archived' => '0',
		'mature'   => '0',
		'spam'     => '0',
		'deleted'  => '0',
		'lang_id'  => '0',
	];
}