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

Theme_Upgrader::install() public WP 2.8.0

Install a theme package.

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

Хуки из метода
Возвращает

true/false/WP_Error. True if the installation was successful, false or a WP_Error object otherwise.

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

$Theme_Upgrader = new Theme_Upgrader();
$Theme_Upgrader->install( $package, $args );
$package(строка) (обязательный)
The full local path or URI of the package.
$args(массив)

Other arguments for installing a theme package.

  • clear_update_cache(true/false)
    Whether to clear the updates cache if successful.
    По умолчанию: true

По умолчанию: empty array

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

С версии 2.8.0 Введена.
С версии 3.7.0 The $args parameter was added, making clearing the update cache optional.

Код Theme Upgrader::install: wp-admin/includes/class-theme-upgrader.php WP 5.5.1

<?php
public function install( $package, $args = array() ) {
	$defaults    = array(
		'clear_update_cache' => true,
		'overwrite_package'  => false, // Do not overwrite files.
	);
	$parsed_args = wp_parse_args( $args, $defaults );

	$this->init();
	$this->install_strings();

	add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
	add_filter( 'upgrader_post_install', array( $this, 'check_parent_theme_filter' ), 10, 3 );

	if ( $parsed_args['clear_update_cache'] ) {
		// Clear cache so wp_update_themes() knows about the new theme.
		add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
	}

	$this->run(
		array(
			'package'           => $package,
			'destination'       => get_theme_root(),
			'clear_destination' => $parsed_args['overwrite_package'],
			'clear_working'     => true,
			'hook_extra'        => array(
				'type'   => 'theme',
				'action' => 'install',
			),
		)
	);

	remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
	remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
	remove_filter( 'upgrader_post_install', array( $this, 'check_parent_theme_filter' ) );

	if ( ! $this->result || is_wp_error( $this->result ) ) {
		return $this->result;
	}

	// Refresh the Theme Update information.
	wp_clean_themes_cache( $parsed_args['clear_update_cache'] );

	if ( $parsed_args['overwrite_package'] ) {
		/**
		 * Fires when the upgrader has successfully overwritten a currently installed
		 * plugin or theme with an uploaded zip package.
		 *
		 * @since 5.5.0
		 *
		 * @param string  $package        The package file.
		 * @param array   $new_theme_data The new theme data.
		 * @param string  $package_type   The package type (plugin or theme).
		 */
		do_action( 'upgrader_overwrote_package', $package, $this->new_theme_data, 'theme' );
	}

	return true;
}