X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f..e0feb3b2e5b436a06bbb04fbc838d1cd6ec95399:/wp-includes/class-wp-error.php diff --git a/wp-includes/class-wp-error.php b/wp-includes/class-wp-error.php index 971a4c7a..0969b12e 100644 --- a/wp-includes/class-wp-error.php +++ b/wp-includes/class-wp-error.php @@ -24,18 +24,16 @@ class WP_Error { * * @since 2.1.0 * @var array - * @access private */ - private $errors = array(); + public $errors = array(); /** * Stores the list of data for error codes. * * @since 2.1.0 * @var array - * @access private */ - private $error_data = array(); + public $error_data = array(); /** * Initialize the error. @@ -53,7 +51,6 @@ class WP_Error { * @param string|int $code Error code * @param string $message Error message * @param mixed $data Optional. Error data. - * @return WP_Error */ public function __construct( $code = '', $message = '', $data = '' ) { if ( empty($code) ) @@ -65,58 +62,6 @@ class WP_Error { $this->error_data[$code] = $data; } - /** - * Make private properties readable for backwards compatibility. - * - * @since 4.0.0 - * @access public - * - * @param string $name Property to get. - * @return mixed Property. - */ - public function __get( $name ) { - return $this->$name; - } - - /** - * Make private properties settable for backwards compatibility. - * - * @since 4.0.0 - * @access public - * - * @param string $name Property to set. - * @param mixed $value Property value. - * @return mixed Newly-set property. - */ - public function __set( $name, $value ) { - return $this->$name = $value; - } - - /** - * Make private properties checkable for backwards compatibility. - * - * @since 4.0.0 - * @access public - * - * @param string $name Property to check if set. - * @return bool Whether the property is set. - */ - public function __isset( $name ) { - return isset( $this->$name ); - } - - /** - * Make private properties un-settable for backwards compatibility. - * - * @since 4.0.0 - * @access public - * - * @param string $name Property to unset. - */ - public function __unset( $name ) { - unset( $this->$name ); - } - /** * Retrieve all error codes. * @@ -199,7 +144,7 @@ class WP_Error { * @since 2.1.0 * * @param string|int $code Optional. Error code. - * @return mixed Null, if no errors. + * @return mixed Error data, if it exists. */ public function get_error_data($code = '') { if ( empty($code) ) @@ -207,7 +152,6 @@ class WP_Error { if ( isset($this->error_data[$code]) ) return $this->error_data[$code]; - return null; } /** @@ -242,6 +186,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 ] ); + } } /** @@ -254,8 +213,6 @@ class WP_Error { * @param mixed $thing Check if unknown variable is a WP_Error object. * @return bool True, if WP_Error. False, if not WP_Error. */ -function is_wp_error($thing) { - if ( is_object($thing) && is_a($thing, 'WP_Error') ) - return true; - return false; +function is_wp_error( $thing ) { + return ( $thing instanceof WP_Error ); }