Core_Upgrader::get_update_directory_root( string $working_dir )

Verifies and returns the root directory entry of a ClassicPress update.


For WordPress, this was always ‘/wordpress/’. For ClassicPress, since GitHub builds our zip packages for us, the zip file (and therefore the directory where it was unpacked) will contain a single directory entry whose name starts with ‘ClassicPress-‘.

We also need to allow the root directory to be called ‘wordpress’, since this is used when migrating from WordPress to ClassicPress. If the directory is named otherwise, the WordPress updater will reject the update package for the migration.

NOTE: This function is duplicated in includes/update-core.php. This duplication is intentional, as the load order during an upgrade is quite complicated and this is the simplest way to make sure that this code is always available.



(string) (Required) The directory where a ClassicPress update package has been extracted.


(string|null) The root directory entry that contains the new files, or null if this does not look like a valid update.


File: wp-admin/includes/class-core-upgrader.php

	public static function get_update_directory_root( $working_dir ) {
		global $wp_filesystem;

		$distro = null;
		$entries = array_values( $wp_filesystem->dirlist( $working_dir ) );

		if (
			count( $entries ) === 1 &&
				substr( $entries[0]['name'], 0, 13 ) === 'ClassicPress-' ||
				$entries[0]['name'] === 'wordpress' // migration build
			) &&
			$entries[0]['type'] === 'd'
		) {
			$distro = '/' . $entries[0]['name'] . '/';
			$root = $working_dir . $distro;
			if (
				! $wp_filesystem->exists( $root . 'readme.html' ) ||
				! $wp_filesystem->exists( $root . 'wp-includes/version.php' )
			) {
				$distro = null;

		return $distro;


Version Description
1.0.0 Introduced.