From 2b88252b3824ea564cc48fef17398f2e8602cef5 Mon Sep 17 00:00:00 2001 From: Konstantin Kovshenin Date: Wed, 8 Oct 2014 07:12:18 +0000 Subject: [PATCH] New `remove()` method and some unit tests for the `WP_Error` class. props stephenharris. fixes #28092. Built from https://develop.svn.wordpress.org/trunk@29854 git-svn-id: http://core.svn.wordpress.org/trunk@29617 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-error.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wp-includes/class-wp-error.php b/wp-includes/class-wp-error.php index 971a4c7a95..83488c3ef5 100644 --- a/wp-includes/class-wp-error.php +++ b/wp-includes/class-wp-error.php @@ -242,6 +242,21 @@ class WP_Error { $this->error_data[$code] = $data; } + + /** + * Removes the specified error. + * + * This function removes all error messages associated with the specified + * error code, along with any error data for that code. + * + * @since 4.1.0 + * + * @param string|int $code Error code. + */ + public function remove( $code ) { + unset( $this->errors[ $code ] ); + unset( $this->error_data[ $code ] ); + } } /**