wp/wp-admin/includes/class-plugin-upgrader.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
   160 			 * Fires when the upgrader has successfully overwritten a currently installed
   160 			 * Fires when the upgrader has successfully overwritten a currently installed
   161 			 * plugin or theme with an uploaded zip package.
   161 			 * plugin or theme with an uploaded zip package.
   162 			 *
   162 			 *
   163 			 * @since 5.5.0
   163 			 * @since 5.5.0
   164 			 *
   164 			 *
   165 			 * @param string  $package          The package file.
   165 			 * @param string  $package      The package file.
   166 			 * @param array   $new_plugin_data  The new plugin data.
   166 			 * @param array   $data         The new plugin or theme data.
   167 			 * @param string  $package_type     The package type (plugin or theme).
   167 			 * @param string  $package_type The package type ('plugin' or 'theme').
   168 			 */
   168 			 */
   169 			do_action( 'upgrader_overwrote_package', $package, $this->new_plugin_data, 'plugin' );
   169 			do_action( 'upgrader_overwrote_package', $package, $this->new_plugin_data, 'plugin' );
   170 		}
   170 		}
   171 
   171 
   172 		return true;
   172 		return true;
   396 
   396 
   397 		return $results;
   397 		return $results;
   398 	}
   398 	}
   399 
   399 
   400 	/**
   400 	/**
   401 	 * Check a source package to be sure it contains a plugin.
   401 	 * Checks that the source package contains a valid plugin.
   402 	 *
   402 	 *
   403 	 * This function is added to the {@see 'upgrader_source_selection'} filter by
   403 	 * Hooked to the {@see 'upgrader_source_selection'} filter by Plugin_Upgrader::install().
   404 	 * Plugin_Upgrader::install().
       
   405 	 *
   404 	 *
   406 	 * @since 3.3.0
   405 	 * @since 3.3.0
   407 	 *
   406 	 *
   408 	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
   407 	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
       
   408 	 * @global string             $wp_version    The WordPress version string.
   409 	 *
   409 	 *
   410 	 * @param string $source The path to the downloaded package source.
   410 	 * @param string $source The path to the downloaded package source.
   411 	 * @return string|WP_Error The source as passed, or a WP_Error object
   411 	 * @return string|WP_Error The source as passed, or a WP_Error object on failure.
   412 	 *                         if no plugins were found.
       
   413 	 */
   412 	 */
   414 	public function check_package( $source ) {
   413 	public function check_package( $source ) {
   415 		global $wp_filesystem;
   414 		global $wp_filesystem, $wp_version;
   416 
   415 
   417 		$this->new_plugin_data = array();
   416 		$this->new_plugin_data = array();
   418 
   417 
   419 		if ( is_wp_error( $source ) ) {
   418 		if ( is_wp_error( $source ) ) {
   420 			return $source;
   419 			return $source;
   457 
   456 
   458 		if ( ! is_wp_version_compatible( $requires_wp ) ) {
   457 		if ( ! is_wp_version_compatible( $requires_wp ) ) {
   459 			$error = sprintf(
   458 			$error = sprintf(
   460 				/* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */
   459 				/* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */
   461 				__( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ),
   460 				__( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ),
   462 				$GLOBALS['wp_version'],
   461 				$wp_version,
   463 				$requires_wp
   462 				$requires_wp
   464 			);
   463 			);
   465 
   464 
   466 			return new WP_Error( 'incompatible_wp_required_version', $this->strings['incompatible_archive'], $error );
   465 			return new WP_Error( 'incompatible_wp_required_version', $this->strings['incompatible_archive'], $error );
   467 		}
   466 		}