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

WC_Install::theme_background_installer() public WC 3.1.0

Install a theme from .org in the background via a cron job (used by installer - opt in).

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

Хуков нет.

Возвращает

Null. Ничего.

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

$result = WC_Install::theme_background_installer( $theme_slug );
$theme_slug(строка) (обязательный)
Theme slug.

Список изменений

С версии 3.1.0 Введена.

Код WC_Install::theme_background_installer() WC 5.0.0

<?php
public static function theme_background_installer( $theme_slug ) {
	// Explicitly clear the event.
	$args = func_get_args();

	if ( ! empty( $theme_slug ) ) {
		// Suppress feedback.
		ob_start();

		try {
			$theme = wp_get_theme( $theme_slug );

			if ( ! $theme->exists() ) {
				require_once ABSPATH . 'wp-admin/includes/file.php';
				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
				include_once ABSPATH . 'wp-admin/includes/theme.php';

				WP_Filesystem();

				$skin     = new Automatic_Upgrader_Skin();
				$upgrader = new Theme_Upgrader( $skin );
				$api      = themes_api(
					'theme_information',
					array(
						'slug'   => $theme_slug,
						'fields' => array( 'sections' => false ),
					)
				);
				$result   = $upgrader->install( $api->download_link );

				if ( is_wp_error( $result ) ) {
					throw new Exception( $result->get_error_message() );
				} elseif ( is_wp_error( $skin->result ) ) {
					throw new Exception( $skin->result->get_error_message() );
				} elseif ( is_null( $result ) ) {
					throw new Exception( 'Unable to connect to the filesystem. Please confirm your credentials.' );
				}
			}

			switch_theme( $theme_slug );
		} catch ( Exception $e ) {
			WC_Admin_Notices::add_custom_notice(
				$theme_slug . '_install_error',
				sprintf(
					// translators: 1: theme slug, 2: error message, 3: URL to install theme manually.
					__( '%1$s could not be installed (%2$s). <a href="%3$s">Please install it manually by clicking here.</a>', 'woocommerce' ),
					$theme_slug,
					$e->getMessage(),
					esc_url( admin_url( 'update.php?action=install-theme&theme=' . $theme_slug . '&_wpnonce=' . wp_create_nonce( 'install-theme_' . $theme_slug ) ) )
				)
			);
		}

		// Discard feedback.
		ob_end_clean();
	}
}