diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index 06e0f26aae..2771e05c2f 100644
--- a/src/wp-includes/formatting.php
+++ b/src/wp-includes/formatting.php
@@ -5000,6 +5000,10 @@ function sanitize_option( $option, $value ) {
  * @return mixed The value with the callback applied to all non-arrays and non-objects inside it.
  */
 function map_deep( $value, $callback ) {
+	if ( is_object( $value ) && $value instanceof __PHP_Incomplete_Class ) {
+		return $value;
+	}
+
 	if ( is_array( $value ) ) {
 		foreach ( $value as $index => $item ) {
 			$value[ $index ] = map_deep( $item, $callback );
