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 |
|---|
stringintegerError code
stringError message
mixedOptional. Error data.
\WP_Erroradd(string|integer $code, string $message, mixed $data = '')
| since | 2.1.0 |
|---|---|
| access | public |
stringintegerError code.
stringError message.
mixedOptional. Error data.
add_data(mixed $data, string|integer $code = '')
The error code can only contain one error data.
| since | 2.1.0 |
|---|
mixedError data.
stringintegerError code.
get_error_code() : string | integer
| since | 2.1.0 |
|---|---|
| access | public |
stringintegerEmpty string, if no error codes.get_error_codes() : array
| since | 2.1.0 |
|---|---|
| access | public |
arrayList of error codes, if avaiable.get_error_data(string|integer $code = '') : mixed
| since | 2.1.0 |
|---|
stringintegerOptional. Error code.
mixedNull, if no errors.$error_data : array
array()| since | 2.1.0 |
|---|---|
| access | private |
$errors : array
array()| since | 2.1.0 |
|---|---|
| access | private |