rest_get_authenticated_app_password()
云策文档标注
概述
rest_get_authenticated_app_password() 函数用于获取当前请求认证所使用的 Application Password UUID。该函数返回一个字符串或 null 值,具体取决于是否使用了 Application Passwords。
关键要点
- 函数返回类型为 string|null,表示 Application Password UUID 或 null(如果未使用 Application Passwords)。
- 函数内部通过全局变量 $wp_rest_application_password_uuid 获取值。
- 此函数在 WordPress 5.7.0 版本中引入。
代码示例
Source function rest_get_authenticated_app_password() {
global $wp_rest_application_password_uuid;
return $wp_rest_application_password_uuid;
}注意事项
- 该函数主要用于 REST API 认证场景,例如在 WP_REST_Application_Passwords_Controller::get_current_item() 中调用。
- 开发者应确保在正确的上下文中使用,以避免安全风险。
原文内容