diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php
index cabe71d211..afad31d054 100644
--- a/src/wp-includes/compat.php
+++ b/src/wp-includes/compat.php
@@ -520,7 +520,7 @@ function array_replace_recursive( $base = array(), $replacements = array() ) {
 	 * @return bool True if `$var` is countable, false otherwise.
 	 */
 	function is_countable( $var ) {
-		return ( is_array( $var ) || $var instanceof Countable );
+		return ( is_array( $var ) || ( is_object( $var ) && ( $var instanceof \Countable || $var instanceof \SimpleXMLElement || $var instanceof \ResourceBundle ) ) );
 	}
 }
 
diff --git a/tests/phpunit/tests/compat.php b/tests/phpunit/tests/compat.php
index 0f17b2d7a8..750a472889 100644
--- a/tests/phpunit/tests/compat.php
+++ b/tests/phpunit/tests/compat.php
@@ -228,6 +228,7 @@ public function countable_variable_test_data() {
 			array( array( 1, 2, 3 ), true ),
 			array( (array) 1, true ),
 			array( (object) array( 'foo', 'bar', 'baz' ), false ),
+			array( new SimpleXMLElement('<xml><tag>1</tag><tag>2</tag></xml>'), true),
 		);
 	}
 
