wp/wp-admin/includes/class-theme-upgrader.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
   268 
   268 
   269 		// Refresh the Theme Update information.
   269 		// Refresh the Theme Update information.
   270 		wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
   270 		wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
   271 
   271 
   272 		if ( $parsed_args['overwrite_package'] ) {
   272 		if ( $parsed_args['overwrite_package'] ) {
   273 			/**
   273 			/** This action is documented in wp-admin/includes/class-plugin-upgrader.php */
   274 			 * Fires when the upgrader has successfully overwritten a currently installed
       
   275 			 * plugin or theme with an uploaded zip package.
       
   276 			 *
       
   277 			 * @since 5.5.0
       
   278 			 *
       
   279 			 * @param string  $package        The package file.
       
   280 			 * @param array   $new_theme_data The new theme data.
       
   281 			 * @param string  $package_type   The package type (plugin or theme).
       
   282 			 */
       
   283 			do_action( 'upgrader_overwrote_package', $package, $this->new_theme_data, 'theme' );
   274 			do_action( 'upgrader_overwrote_package', $package, $this->new_theme_data, 'theme' );
   284 		}
   275 		}
   285 
   276 
   286 		return true;
   277 		return true;
   287 	}
   278 	}
   508 
   499 
   509 		return $results;
   500 		return $results;
   510 	}
   501 	}
   511 
   502 
   512 	/**
   503 	/**
   513 	 * Check that the package source contains a valid theme.
   504 	 * Checks that the package source contains a valid theme.
   514 	 *
   505 	 *
   515 	 * Hooked to the {@see 'upgrader_source_selection'} filter by Theme_Upgrader::install().
   506 	 * Hooked to the {@see 'upgrader_source_selection'} filter by Theme_Upgrader::install().
   516 	 * It will return an error if the theme doesn't have style.css or index.php
       
   517 	 * files.
       
   518 	 *
   507 	 *
   519 	 * @since 3.3.0
   508 	 * @since 3.3.0
   520 	 *
   509 	 *
   521 	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
   510 	 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
   522 	 *
   511 	 * @global string             $wp_version    The WordPress version string.
   523 	 * @param string $source The full path to the package source.
   512 	 *
   524 	 * @return string|WP_Error The source or a WP_Error.
   513 	 * @param string $source The path to the downloaded package source.
       
   514 	 * @return string|WP_Error The source as passed, or a WP_Error object on failure.
   525 	 */
   515 	 */
   526 	public function check_package( $source ) {
   516 	public function check_package( $source ) {
   527 		global $wp_filesystem;
   517 		global $wp_filesystem, $wp_version;
   528 
   518 
   529 		$this->new_theme_data = array();
   519 		$this->new_theme_data = array();
   530 
   520 
   531 		if ( is_wp_error( $source ) ) {
   521 		if ( is_wp_error( $source ) ) {
   532 			return $source;
   522 			return $source;
   604 		}
   594 		}
   605 		if ( ! is_wp_version_compatible( $requires_wp ) ) {
   595 		if ( ! is_wp_version_compatible( $requires_wp ) ) {
   606 			$error = sprintf(
   596 			$error = sprintf(
   607 				/* translators: 1: Current WordPress version, 2: Version required by the uploaded theme. */
   597 				/* translators: 1: Current WordPress version, 2: Version required by the uploaded theme. */
   608 				__( 'Your WordPress version is %1$s, however the uploaded theme requires %2$s.' ),
   598 				__( 'Your WordPress version is %1$s, however the uploaded theme requires %2$s.' ),
   609 				$GLOBALS['wp_version'],
   599 				$wp_version,
   610 				$requires_wp
   600 				$requires_wp
   611 			);
   601 			);
   612 
   602 
   613 			return new WP_Error( 'incompatible_wp_required_version', $this->strings['incompatible_archive'], $error );
   603 			return new WP_Error( 'incompatible_wp_required_version', $this->strings['incompatible_archive'], $error );
   614 		}
   604 		}