Summery Summery
Deactivates a plugin before it is upgraded.
Syntax Syntax
Description Description
Hooked to the ‘upgrader_pre_install’ filter by Plugin_Upgrader::upgrade().
Parameters Parameters
- $return
-
(Required) Upgrade offer return.
- $plugin
-
(Required) Plugin package arguments.
Return Return
Source Source
File: wp-admin/includes/class-plugin-upgrader.php
$working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source );
if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation.
return $source;
}
// Check that the folder contains at least 1 valid plugin.
$files = glob( $working_directory . '*.php' );
if ( $files ) {
foreach ( $files as $file ) {
$info = get_plugin_data( $file, false, false );
if ( ! empty( $info['Name'] ) ) {
$this->new_plugin_data = $info;
break;
}
}
}
if ( empty( $this->new_plugin_data ) ) {
return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) );
}
$requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null;
Advertisement
Changelog Changelog
| Version | Description |
|---|---|
| 4.1.0 | Added a return value. |
| 2.8.0 | Introduced. |