检查变量是否是WordPress错误。
原型
is_wp_error( mixed $thing )
描述
如果$ thing是WP_Error类的对象,则返回true。
参数
$thing
(mixed)
(Required)
检查未知变量是否为WP_Error对象。
返回值
(bool)
是的,如果
源文件
路径:wp-includes/load.php
<?php
...
function is_wp_error( $thing ) {
return ( $thing instanceof WP_Error );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/is_wp_error/