# install_plugin_install_status()

URL: https://chugunov.pro/api-wordpress/functions/install_plugin_install_status/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.0.0.

## Сигнатура

```php
install_plugin_install_status( array|object $api, bool $loop = false ): array
```

## Описание

Определяет, какое действие можно выполнить с плагином.

## Параметры

- `$api` `array|object` — обязательный. Данные о плагине, полученные из API.
- `$loop` `bool` — необязательный, по умолчанию `false`. Отключить дальнейшие циклы.

## Возвращаемое значение

`array` — status stringСтатус плагина. Может принимать одно из значений 'install', 'update_available', 'latest_installed' или 'newer_installed'. url stringURL установки плагина. version stringСамая последняя версия плагина. file stringИмя файла плагина относительно каталога плагинов.

## Исходный код

Файл: `wp-admin/includes/plugin-install.php:436`

```php
function install_plugin_install_status( $api, $loop = false ) {
	// This function is called recursively, $loop prevents further loops.
	if ( is_array( $api ) ) {
		$api = (object) $api;
	}

	// Default to a "new" plugin.
	$status      = 'install';
	$url         = false;
	$update_file = false;
	$version     = '';

	/*
	 * Check to see if this plugin is known to be installed,
	 * and has an update awaiting it.
	 */
	$update_plugins = get_site_transient( 'update_plugins' );
	if ( isset( $update_plugins->response ) ) {
		foreach ( (array) $update_plugins->response as $file => $plugin ) {
			if ( $plugin->slug === $api->slug ) {
				$status      = 'update_available';
				$update_file = $file;
				$version     = $plugin->new_version;
				if ( current_user_can( 'update_plugins' ) ) {
					$url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $update_file ), 'upgrade-plugin_' . $update_file );
				}
				break;
			}
		}
	}

	if ( 'install' === $status ) {
		if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
			$installed_plugin = get_plugins( '/' . $api->slug );
			if ( empty( $installed_plugin ) ) {
				if ( current_user_can( 'install_plugins' ) ) {
					$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug );
				}
			} else {
				$key = array_keys( $installed_plugin );
				/*
				 * Use the first plugin regardless of the name.
				 * Could have issues for multiple plugins in one directory if they share different version numbers.
				 */
				$key = reset( $key );

				$update_file = $api->slug . '/' . $key;
				if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) {
					$status = 'latest_installed';
				} elseif ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '<' ) ) {
					$status  = 'newer_installed';
					$version = $installed_plugin[ $key ]['Version'];
				} else {
					// If the above update check failed, then that probably means that the update checker has out-of-date information, force a refresh.
					if ( ! $loop ) {
						delete_site_transient( 'update_plugins' );
						wp_update_plugins();
						return install_plugin_install_status( $api, true );
					}
				}
			}
		} else {
			// "install" & no directory with that slug.
			if ( current_user_can( 'install_plugins' ) ) {
				$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug );
			}
		}
	}
	if ( isset( $_GET['from'] ) ) {
		$url .= '&amp;from=' . urlencode( wp_unslash( $_GET['from'] ) );
	}

	$file = $update_file;
	return compact( 'status', 'url', 'version', 'file' );
}
```

## История изменений

- 3.0.0 — Introduced.

## Связанные

Использует: [`install_plugin_install_status`](https://chugunov.pro/api-wordpress/functions/install_plugin_install_status/), [`get_plugins`](https://chugunov.pro/api-wordpress/functions/get_plugins/), [`self_admin_url`](https://chugunov.pro/api-wordpress/functions/self_admin_url/), [`wp_update_plugins`](https://chugunov.pro/api-wordpress/functions/wp_update_plugins/), [`delete_site_transient`](https://chugunov.pro/api-wordpress/functions/delete_site_transient/), [`current_user_can`](https://chugunov.pro/api-wordpress/functions/current_user_can/), [`wp_unslash`](https://chugunov.pro/api-wordpress/functions/wp_unslash/), [`wp_nonce_url`](https://chugunov.pro/api-wordpress/functions/wp_nonce_url/), [`get_site_transient`](https://chugunov.pro/api-wordpress/functions/get_site_transient/).
Используется в: [`wp_get_plugin_action_button`](https://chugunov.pro/api-wordpress/functions/wp_get_plugin_action_button/), [`wp_ajax_install_plugin`](https://chugunov.pro/api-wordpress/functions/wp_ajax_install_plugin/), [`install_plugin_install_status`](https://chugunov.pro/api-wordpress/functions/install_plugin_install_status/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/install_plugin_install_status/
