WP_Error::copy_errors() WordPress Method
The WP_Error::copy_errors() function is a method of the WP_Error class. This function is used to copy all error messages from one WP_Error object to another. This is useful when you need to combine multiple WP_Error objects into a single object.
WP_Error::copy_errors( WP_Error $from, WP_Error $to ) #
Copies errors from one WP_Error instance to another.
Contents
Parameters
Source
File: wp-includes/class-wp-error.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 ); } } }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.6.0 | Introduced. |