diff --git a/src/wp-includes/class-wp-error.php b/src/wp-includes/class-wp-error.php
index ae8b237801..4925d11166 100644
--- a/src/wp-includes/class-wp-error.php
+++ b/src/wp-includes/class-wp-error.php
@@ -31,7 +31,7 @@ class WP_Error {
 	 *
 	 * @since 2.1.0
 	 * @var array
-	 */
+ 	 */
 	public $error_data = array();
 
 	/**
@@ -71,7 +71,7 @@ class WP_Error {
 	 * @return array List of error codes, if available.
 	 */
 	public function get_error_codes() {
-		if ( empty( $this->errors ) ) {
+		if ( ! $this->has_errors() ) {
 			return array();
 		}
 
@@ -161,6 +161,20 @@ class WP_Error {
 		}
 	}
 
+	/**
+	 * Verify if instance contains errors.
+	 *
+	 * @since 5.0.0
+	 *
+	 * @return bool
+	 */
+	public function has_errors() {
+		if ( ! empty( $this->errors ) ) {
+			return true;
+		}
+		return false;
+	}
+
 	/**
 	 * Add an error or append additional message to an existing error.
 	 *
diff --git a/tests/phpunit/tests/general/wpError.php b/tests/phpunit/tests/general/wpError.php
index 655c15a1b3..acef3ca21f 100644
--- a/tests/phpunit/tests/general/wpError.php
+++ b/tests/phpunit/tests/general/wpError.php
@@ -415,6 +415,21 @@ class Tests_WP_Error extends WP_UnitTestCase {
 		$this->assertSame( 'data2', $this->WP_Error->get_error_data( 'code' ) );
 	}
 
+	/**
+	 * @covers WP_Error::has_errors()
+	 */
+	public function test_has_errors_with_no_errors_returns_false() {
+		$this->assertFalse( $this->WP_Error->has_errors() );
+	}
+
+	/**
+	 * @covers WP_Error::has_errors()
+	 */
+	public function test_has_errors_with_errors_returns_true() {
+		$this->WP_Error->add( 'code', 'message', 'data' );
+		$this->assertTrue( $this->WP_Error->has_errors() );
+	}
+
 	/**
 	 * @covers WP_Error::add()
 	 */
