diff --git wp-admin/theme-editor.php wp-admin/theme-editor.php
index 03b91944ea..24de2991f2 100644
--- wp-admin/theme-editor.php
+++ wp-admin/theme-editor.php
@@ -81,16 +81,16 @@ $file_types = array_unique( array_merge( $file_types, $default_types ) );
 foreach ( $file_types as $type ) {
 	switch ( $type ) {
 		case 'php':
-			$allowed_files += $theme->get_files( 'php', 1 );
+			$allowed_files += $theme->get_files( 'php', apply_filters( 'wp_theme_scandir_depth', 1, 'php', $theme ) );
 			$has_templates = ! empty( $allowed_files );
 			break;
 		case 'css':
-			$style_files = $theme->get_files( 'css' );
+			$style_files = $theme->get_files( 'css', apply_filters( 'wp_theme_scandir_depth', 0, 'css', $theme ) );
 			$allowed_files['style.css'] = $style_files['style.css'];
 			$allowed_files += $style_files;
 			break;
 		default:
-			$allowed_files += $theme->get_files( $type );
+			$allowed_files += $theme->get_files( $type, apply_filters( 'wp_theme_scandir_depth', 0, $type, $theme ) );
 			break;
 	}
 }
diff --git wp-includes/class-wp-theme.php wp-includes/class-wp-theme.php
index 0da9b5ea11..8fe2e9f72c 100644
--- wp-includes/class-wp-theme.php
+++ wp-includes/class-wp-theme.php
@@ -468,9 +468,9 @@ final class WP_Theme implements ArrayAccess {
 			case 'Stylesheet' :
 				return $this->get_stylesheet();
 			case 'Template Files' :
-				return $this->get_files( 'php', 1, true );
+				return $this->get_files( 'php', apply_filters('wp_theme_scandir_depth', 1, 'php', $this ), true );
 			case 'Stylesheet Files' :
-				return $this->get_files( 'css', 0, false );
+				return $this->get_files( 'css', apply_filters('wp_theme_scandir_depth', 0, 'css', $this ), false );
 			case 'Template Dir' :
 				return $this->get_template_directory();
 			case 'Stylesheet Dir' :
@@ -1003,7 +1003,7 @@ final class WP_Theme implements ArrayAccess {
 		if ( ! is_array( $post_templates ) ) {
 			$post_templates = array();
 
-			$files = (array) $this->get_files( 'php', 1 );
+			$files = (array) $this->get_files( 'php', apply_filters('wp_theme_scandir_depth', 1, $type, $this ) );
 
 			foreach ( $files as $file => $full_path ) {
 				if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) ) {
