A WordPress-centric search engine for devs and theme authors



is_wp_error ›

Since2.1.0
Deprecatedn/a
is_wp_error ( $thing )
Parameters:
  • (mixed) $thing The variable to check.
    Required: Yes
Returns:
  • (bool) Whether the variable is an instance of WP_Error.
Defined at:
Codex:

Checks whether the given variable is a WordPress Error.

Returns whether $thing is an instance of the WP_Error class.


Source

function is_wp_error( $thing ) {
	$is_wp_error = ( $thing instanceof WP_Error );

	if ( $is_wp_error ) {
		/**
		 * Fires when `is_wp_error()` is called and it's an instance of `WP_Error`.
		 *
		 * @since 5.6.0
		 *
		 * @param WP_Error $thing The error object passed to `is_wp_error()`.
		 */
		do_action( 'wp_error_checked', $thing );
	}

	return $is_wp_error;
}