函数原型
rest_application_password_check_errors( WP_Error|null|true $result ): WP_Error|null|true
函数描述
Checks for errors when using application password-based authentication.
是否弃用
未弃用
函数参数
-
$result
WP_Error|null|true
Required - Error from another authentication handler, null if we should handle it, or another value if not.
函数返回值
WP_Error|null|true WP_Error if the application password is invalid, the $result, otherwise true.
函数位置
File: wp-includes/rest-api.php.
函数源码
function rest_application_password_check_errors( $result ) {
global $wp_rest_application_password_status;
if ( ! empty( $result ) ) {
return $result;
}
if ( is_wp_error( $wp_rest_application_password_status ) ) {
$data = $wp_rest_application_password_status->get_error_data();
if ( ! isset( $data['status'] ) ) {
$data['status'] = 401;
}
$wp_rest_application_password_status->add_data( $data );
return $wp_rest_application_password_status;
}
if ( $wp_rest_application_password_status instanceof WP_User ) {
return true;
}
return $result;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 5.6.0 | Introduced. |

