WordPress Error class.
Container for checking for WordPress errors and error messages. Return WP_Error and use is_wp_error() to check if this class is returned. Many core WordPress functions pass this class in the event of an error and if not handled properly will result in code errors.
package | WordPress |
---|---|
since | 2.1.0 |
WP_Error($code= ''
, $message= ''
, $data= ''
)
__construct(string|integer $code= ''
, string $message= ''
, mixed $data= ''
) : \WP_Error
If code parameter is empty then nothing will be done. It is possible to add multiple messages to the same code, but with other methods in the class.
All parameters are optional, but if the code parameter is set, then the data parameter is optional.
since | 2.1.0 |
---|
string
integer
Error code
string
Error message
mixed
Optional. Error data.
\WP_Error
add(string|integer $code, string $message, mixed $data = ''
)
since | 2.1.0 |
---|---|
access | public |
string
integer
Error code.
string
Error message.
mixed
Optional. Error data.
add_data(mixed $data, string|integer $code = ''
)
The error code can only contain one error data.
since | 2.1.0 |
---|
mixed
Error data.
string
integer
Error code.
get_error_code() : string | integer
since | 2.1.0 |
---|---|
access | public |
string
integer
Empty string, if no error codes.get_error_codes() : array
since | 2.1.0 |
---|---|
access | public |
array
List of error codes, if avaiable.get_error_data(string|integer $code = ''
) : mixed
since | 2.1.0 |
---|
string
integer
Optional. Error code.
mixed
Null, if no errors.$error_data : array
array()
since | 2.1.0 |
---|---|
access | private |
$errors : array
array()
since | 2.1.0 |
---|---|
access | private |