[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

WordPress Error API.

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

Defines 1 class

WP_Error:: (14 methods):
  __construct()
  get_error_codes()
  get_error_code()
  get_error_messages()
  get_error_message()
  get_error_data()
  has_errors()
  add()
  add_data()
  get_all_error_data()
  remove()
  merge_from()
  export_to()
  copy_errors()


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
Initializes 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.

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

get_error_codes()   X-Ref
Retrieves all error codes.

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

get_error_code()   X-Ref
Retrieves the first error code available.

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

get_error_messages( $code = '' )   X-Ref
Retrieves all error messages, or the error messages for the given error code.

return: string[] Error strings on success, or empty array if there are none.
since: 2.1.0
param: string|int $code Optional. Retrieve messages matching code, if exists.

get_error_message( $code = '' )   X-Ref
Gets a 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.

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

get_error_data( $code = '' )   X-Ref
Retrieves the most recently added error data for an error code.

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

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

return: bool If the instance contains errors.
since: 5.1.0

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

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

add_data( $data, $code = '' )   X-Ref
Adds data to an error with the given code.

since: 2.1.0
since: 5.6.0 Errors can now contain more than one item of error data. {@see WP_Error::$additional_data}.
param: mixed      $data Error data.
param: string|int $code Error code.

get_all_error_data( $code = '' )   X-Ref
Retrieves all error data for an error code in the order in which the data was added.

return: mixed[] Array of error data, if it exists.
since: 5.6.0
param: string|int $code Error code.

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.

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

merge_from( WP_Error $error )   X-Ref
Merges the errors in the given error object into this one.

since: 5.6.0
param: WP_Error $error Error object to merge.

export_to( WP_Error $error )   X-Ref
Exports the errors in this object into the given one.

since: 5.6.0
param: WP_Error $error Error object to export into.

copy_errors( WP_Error $from, WP_Error $to )   X-Ref
Copies errors from one WP_Error instance to another.

since: 5.6.0
param: WP_Error $from The WP_Error to copy from.
param: WP_Error $to   The WP_Error to copy to.



Generated: Sat Dec 21 01:00:02 2024 Cross-referenced by PHPXref 0.7.1