Index: wp-includes/theme.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/theme.php	(date 1555691334000)
+++ wp-includes/theme.php	(date 1556169665417)
@@ -370,7 +370,7 @@
 function get_theme_roots() {
 	global $wp_theme_directories;
 
-	if ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories ) <= 1 ) {
+	if ( ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories ) <= 1 ) and ! has_filter( 'theme_root' ) ) {
 		return '/themes';
 	}
 
@@ -658,7 +658,7 @@
 function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) {
 	global $wp_theme_directories;
 
-	if ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories ) <= 1 ) {
+	if ( ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories ) <= 1 ) and ! has_filter( 'theme_root' ) ) {
 		return '/themes';
 	}

Index: wp-admin/includes/upgrade.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-admin/includes/upgrade.php	(date 1555691334000)
+++ wp-admin/includes/upgrade.php	(date 1556169376863)
@@ -2931,7 +2931,7 @@
  */
 function make_site_theme_from_oldschool( $theme_name, $template ) {
 	$home_path = get_home_path();
-	$site_dir  = WP_CONTENT_DIR . "/themes/$template";
+	$site_dir = path_join( get_theme_root(), $template );
 
 	if ( ! file_exists( "$home_path/index.php" ) ) {
 		return false;
@@ -2959,7 +2959,7 @@
 		if ( $oldfile == 'index.php' ) {
 			$index = implode( '', file( "$oldpath/$oldfile" ) );
 			if ( strpos( $index, 'WP_USE_THEMES' ) !== false ) {
-				if ( ! @copy( WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile" ) ) {
+				if ( ! @copy( path_join( get_theme_root(), WP_DEFAULT_THEME . '/index.php' ), "$site_dir/$newfile" ) ) {
 					return false;
 				}
 
@@ -3023,8 +3023,8 @@
  * @return false|void
  */
 function make_site_theme_from_default( $theme_name, $template ) {
-	$site_dir    = WP_CONTENT_DIR . "/themes/$template";
-	$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
+	$site_dir    = path_join( get_theme_root(), $template );
+	$default_dir = path_join( get_theme_root(), WP_DEFAULT_THEME );
 
 	// Copy files from the default theme to the site theme.
 	//$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
@@ -3099,7 +3099,7 @@
 	// Name the theme after the blog.
 	$theme_name = __get_option( 'blogname' );
 	$template   = sanitize_title( $theme_name );
-	$site_dir   = WP_CONTENT_DIR . "/themes/$template";
+	$site_dir = path_join( get_theme_root(), $template );
 
 	// If the theme already exists, nothing to do.
 	if ( is_dir( $site_dir ) ) {
@@ -3107,7 +3107,7 @@
 	}
 
 	// We must be able to write to the themes dir.
-	if ( ! is_writable( WP_CONTENT_DIR . '/themes' ) ) {
+	if ( ! is_writable( get_theme_root() ) ) {
 		return false;
 	}
 
Index: wp-admin/includes/class-wp-upgrader.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-admin/includes/class-wp-upgrader.php	(date 1555691334000)
+++ wp-admin/includes/class-wp-upgrader.php	(date 1556169377003)
@@ -533,7 +533,7 @@
 		 * to copy the directory into the directory, whilst they pass the source
 		 * as the actual files to copy.
 		 */
-		$protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' );
+		$protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, get_theme_root() );
 
 		if ( is_array( $wp_theme_directories ) ) {
 			$protected_directories = array_merge( $protected_directories, $wp_theme_directories );
 
