WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Automattic\WooCommerce\Admin\API

OnboardingThemes::install_theme() public WC 1.0

Installs the requested theme.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

{} Это метод класса: OnboardingThemes{}

Хуков нет.

Возвращает

WP_Error|Массив. Theme installation status.

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

$OnboardingThemes = new OnboardingThemes();
$OnboardingThemes->install_theme( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

Код OnboardingThemes::install_theme() WC 5.8.0

public function install_theme( $request ) {
	$allowed_themes = Onboarding::get_allowed_themes();
	$theme          = sanitize_text_field( $request['theme'] );

	if ( ! in_array( $theme, $allowed_themes, true ) ) {
		return new \WP_Error( 'woocommerce_rest_invalid_theme', __( 'Invalid theme.', 'woocommerce' ), 404 );
	}

	$installed_themes = wp_get_themes();

	if ( in_array( $theme, array_keys( $installed_themes ), true ) ) {
		return( array(
			'slug'   => $theme,
			'name'   => $installed_themes[ $theme ]->get( 'Name' ),
			'status' => 'success',
		) );
	}

	include_once ABSPATH . '/wp-admin/includes/admin.php';
	include_once ABSPATH . '/wp-admin/includes/theme-install.php';
	include_once ABSPATH . '/wp-admin/includes/theme.php';
	include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
	include_once ABSPATH . '/wp-admin/includes/class-theme-upgrader.php';

	$api = themes_api(
		'theme_information',
		array(
			'slug'   => $theme,
			'fields' => array(
				'sections' => false,
			),
		)
	);

	if ( is_wp_error( $api ) ) {
		return new \WP_Error(
			'woocommerce_rest_theme_install',
			sprintf(
				/* translators: %s: theme slug (example: woocommerce-services) */
				__( 'The requested theme `%s` could not be installed. Theme API call failed.', 'woocommerce' ),
				$theme
			),
			500
		);
	}

	$upgrader = new \Theme_Upgrader( new \Automatic_Upgrader_Skin() );
	$result   = $upgrader->install( $api->download_link );

	if ( is_wp_error( $result ) || is_null( $result ) ) {
		return new \WP_Error(
			'woocommerce_rest_theme_install',
			sprintf(
				/* translators: %s: theme slug (example: woocommerce-services) */
				__( 'The requested theme `%s` could not be installed.', 'woocommerce' ),
				$theme
			),
			500
		);
	}

	return array(
		'slug'   => $theme,
		'name'   => $api->name,
		'status' => 'success',
	);
}