WordPress at a glance
function is not described

WP_Error::copy_errors() protected WP 5.6.0

Copies errors from one WP_Error instance to another.

{} It's a method of the class: WP_Error{}

No Hooks.

Return

````. Null. Nothing.

Usage

$result = WP_Error::copy_errors( $from, $to );
$from(WP_Error) (required)
The WP_Error to copy from.
$to(WP_Error) (required)
The WP_Error to copy to.

Changelog

Since 5.6.0 Introduced.

Code of WP_Error::copy_errors() WP 5.7

<?php
protected static function copy_errors( WP_Error $from, WP_Error $to ) {
	foreach ( $from->get_error_codes() as $code ) {
		foreach ( $from->get_error_messages( $code ) as $error_message ) {
			$to->add( $code, $error_message );
		}

		foreach ( $from->get_all_error_data( $code ) as $data ) {
			$to->add_data( $data, $code );
		}
	}
}