[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-wp-error.php (summary)

WordPress Error API. Contains the WP_Error class and the is_wp_error() function.

File Size: 226 lines (5 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Error:: (10 methods):
  __construct()
  get_error_codes()
  get_error_code()
  get_error_messages()
  get_error_message()
  get_error_data()
  has_errors()
  add()
  add_data()
  remove()


Class: WP_Error  - X-Ref

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.

__construct( $code = '', $message = '', $data = '' )   X-Ref
Initialize the error.

If `$code` is empty, the other parameters will be ignored.
When `$code` is not empty, `$message` will be used even if
it is empty. The `$data` parameter will be used only if it
is not empty.

Though the class is constructed with a single error code and
message, multiple codes can be added using the `add()` method.

param: string|int $code Error code
param: string $message Error message
param: mixed $data Optional. Error data.
since: 2.1.0

get_error_codes()   X-Ref
Retrieve all error codes.

return: array List of error codes, if available.
since: 2.1.0

get_error_code()   X-Ref
Retrieve first error code available.

return: string|int Empty string, if no error codes.
since: 2.1.0

get_error_messages( $code = '' )   X-Ref
Retrieve all error messages or error messages matching code.

param: string|int $code Optional. Retrieve messages matching code, if exists.
return: array Error strings on success, or empty array on failure (if using code parameter).
since: 2.1.0

get_error_message( $code = '' )   X-Ref
Get single error message.

This will get the first message available for the code. If no code is
given then the first code available will be used.

param: string|int $code Optional. Error code to retrieve message.
return: string
since: 2.1.0

get_error_data( $code = '' )   X-Ref
Retrieve error data for error code.

param: string|int $code Optional. Error code.
return: mixed Error data, if it exists.
since: 2.1.0

has_errors()   X-Ref
Verify if the instance contains errors.

return: bool
since: 5.1.0

add( $code, $message, $data = '' )   X-Ref
Add an error or append additional message to an existing error.

param: string|int $code Error code.
param: string $message Error message.
param: mixed $data Optional. Error data.
since: 2.1.0

add_data( $data, $code = '' )   X-Ref
Add data for error code.

The error code can only contain one error data.

param: mixed $data Error data.
param: string|int $code Error code.
since: 2.1.0

remove( $code )   X-Ref
Removes the specified error.

This function removes all error messages associated with the specified
error code, along with any error data for that code.

param: string|int $code Error code.
since: 4.1.0



Generated: Mon Jul 22 01:00:03 2019 Cross-referenced by PHPXref 0.7.1