Title: install_plugin_install_status
Published: April 25, 2014
Last modified: February 24, 2026

---

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

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#wp--skip-link--target)

Determines the status we can perform on a plugin.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#parameters)󠁿

 `$api`array|objectrequired

Data about the plugin retrieved from the API.

`$loop`booloptional

Disable further loops.

Default:`false`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#return)󠁿

 array Plugin installation status data.

 * `status` string
 * Status of a plugin. Could be one of `'install'`, `'update_available'`, `'latest_installed'`
   or `'newer_installed'`.
 * `url` string
 * Plugin installation URL.
 * `version` string
 * The most recent version of the plugin.
 * `file` string
 * Plugin filename relative to the plugins directory.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#source)󠁿

    ```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' );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/plugin-install.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/plugin-install.php#L436)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/plugin-install.php#L436-L510)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#related)󠁿

| Uses | Description | 
| [install_plugin_install_status()](https://developer.wordpress.org/reference/functions/install_plugin_install_status/)`wp-admin/includes/plugin-install.php` |

Determines the status we can perform on a plugin.

  | 
| [get_plugins()](https://developer.wordpress.org/reference/functions/get_plugins/)`wp-admin/includes/plugin.php` |

Checks the plugins directory and retrieve all plugin files with plugin data.

  | 
| [self_admin_url()](https://developer.wordpress.org/reference/functions/self_admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for either the current site or the network depending on context.

  | 
| [wp_update_plugins()](https://developer.wordpress.org/reference/functions/wp_update_plugins/)`wp-includes/update.php` |

Checks for available updates to plugins based on the latest versions hosted on WordPress.org.

  | 
| [delete_site_transient()](https://developer.wordpress.org/reference/functions/delete_site_transient/)`wp-includes/option.php` |

Deletes a site transient.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [wp_unslash()](https://developer.wordpress.org/reference/functions/wp_unslash/)`wp-includes/formatting.php` |

Removes slashes from a string or recursively removes slashes from strings within an array.

  | 
| [wp_nonce_url()](https://developer.wordpress.org/reference/functions/wp_nonce_url/)`wp-includes/functions.php` |

Retrieves URL with nonce added to URL query.

  | 
| [get_site_transient()](https://developer.wordpress.org/reference/functions/get_site_transient/)`wp-includes/option.php` |

Retrieves the value of a site transient.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#)

| Used by | Description | 
| [wp_get_plugin_action_button()](https://developer.wordpress.org/reference/functions/wp_get_plugin_action_button/)`wp-admin/includes/plugin-install.php` |

Gets the markup for the plugin install action button.

  | 
| [wp_ajax_install_plugin()](https://developer.wordpress.org/reference/functions/wp_ajax_install_plugin/)`wp-admin/includes/ajax-actions.php` |

Handles installing a plugin via AJAX.

  | 
| [install_plugin_install_status()](https://developer.wordpress.org/reference/functions/install_plugin_install_status/)`wp-admin/includes/plugin-install.php` |

Determines the status we can perform on a plugin.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/install_plugin_install_status/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Finstall_plugin_install_status%2F)
before being able to contribute a note or feedback.