函数原型
is_wp_error( mixed $thing ): bool
函数描述
Checks whether the given variable is a WordPress Error.
是否弃用
未弃用
函数参数
-
$thing
mixed
Required - The variable to check.
函数返回值
bool Whether the variable is an instance of WP_Error.
函数位置
File: wp-includes/load.php.
函数源码
function is_wp_error( $thing ) {
$is_wp_error = ( $thing instanceof WP_Error );
if ( $is_wp_error ) {
/**
* Fires when `is_wp_error()` is called and its parameter is an instance of `WP_Error`.
*
* @since 5.6.0
*
* @param WP_Error $thing The error object passed to `is_wp_error()`.
*/
do_action( 'is_wp_error_instance', $thing );
}
return $is_wp_error;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |

