mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
General: Introduce the wp_error_added and wp_error_checked actions.
These actions allow debugging tools to track `WP_Error` instances as they're created and subsequently passed between functions which check for error objects. Props Shelob9, Mte90, TimothyBlynJacobs, johnbillion Fixes #40568 git-svn-id: https://develop.svn.wordpress.org/trunk@49022 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -56,11 +56,7 @@ class WP_Error {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->errors[ $code ][] = $message;
|
||||
|
||||
if ( ! empty( $data ) ) {
|
||||
$this->error_data[ $code ] = $data;
|
||||
}
|
||||
$this->add( $code, $message, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +172,7 @@ class WP_Error {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an error or append additional message to an existing error.
|
||||
* Adds an error or appends an additional message to an existing error.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
@@ -186,9 +182,22 @@ class WP_Error {
|
||||
*/
|
||||
public function add( $code, $message, $data = '' ) {
|
||||
$this->errors[ $code ][] = $message;
|
||||
|
||||
if ( ! empty( $data ) ) {
|
||||
$this->error_data[ $code ] = $data;
|
||||
$this->add_data( $data, $code );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires when an error is added to a WP_Error object.
|
||||
*
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param string|int $code Error code.
|
||||
* @param string $message Error message.
|
||||
* @param mixed $data Error data. Might be empty.
|
||||
* @param WP_Error $wp_error The WP_Error object.
|
||||
*/
|
||||
do_action( 'wp_error_added', $code, $message, $data, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user