Summery Summery
Install a plugin package.
Syntax Syntax
Parameters Parameters
- $package
-
(Required) The full local path or URI of the package.
- $args
-
(Optional) Other arguments for installing a plugin package.
- 'clear_update_cache'
(bool) Whether to clear the plugin updates cache if successful. Default true.
Default value: array()
- 'clear_update_cache'
Return Return
(bool|WP_Error) True if the installation was successful, false or a WP_Error otherwise.
Source Source
File: wp-admin/includes/class-plugin-upgrader.php
$this->strings['installing_package'] = __( 'Updating the plugin…' );
$this->strings['process_failed'] = __( 'Plugin update failed.' );
$this->strings['process_success'] = __( 'Plugin updated successfully.' );
}
if ( 'downgrade-plugin' === $this->skin->overwrite ) {
$this->strings['installing_package'] = __( 'Downgrading the plugin…' );
$this->strings['process_failed'] = __( 'Plugin downgrade failed.' );
$this->strings['process_success'] = __( 'Plugin downgraded successfully.' );
}
}
}
/**
* Install a plugin package.
*
* @since 2.8.0
* @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional.
*
* @param string $package The full local path or URI of the package.
* @param array $args {
* Optional. Other arguments for installing a plugin package. Default empty array.
*
* @type bool $clear_update_cache Whether to clear the plugin updates cache if successful.
* Default true.
* }
* @return bool|WP_Error True if the installation was successful, false or a WP_Error otherwise.
*/
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' ) );
if ( $parsed_args['clear_update_cache'] ) {
Advertisement
Changelog Changelog
| Version | Description |
|---|---|
| 3.7.0 | The $args parameter was added, making clearing the plugin update cache optional. |
| 2.8.0 | Introduced. |