wp_privacy_exports_url()
云策文档标注
概述
wp_privacy_exports_url() 函数用于返回存储个人数据导出文件的目录 URL。它基于 WordPress 上传目录构建路径,并可通过过滤器进行自定义。
关键要点
- 函数返回个人数据导出目录的 URL 字符串。
- 使用 wp_upload_dir() 获取上传目录信息,并通过 trailingslashit() 添加尾部斜杠。
- 提供 wp_privacy_exports_url 过滤器,允许开发者修改导出目录 URL。
- 自 WordPress 5.5.0 起,导出使用相对路径,因此通过过滤器更改 URL 需在服务器端同步调整。
代码示例
function wp_privacy_exports_url() {
$upload_dir = wp_upload_dir();
$exports_url = trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/';
/**
* Filters the URL of the directory used to store personal data export files.
*
* @since 4.9.6
* @since 5.5.0 Exports now use relative paths, so changes to the directory URL
* via this filter should be reflected on the server.
*
* @param string $exports_url Exports directory URL.
*/
return apply_filters( 'wp_privacy_exports_url', $exports_url );
}注意事项
- 此函数自 WordPress 4.9.6 版本引入。
- 相关函数包括 wp_privacy_exports_dir()(返回目录路径)、wp_upload_dir() 和 trailingslashit()。
- 常用于个人数据导出流程,如 wp_privacy_process_personal_data_export_page() 等函数。
原文内容
Returns the URL of the directory used to store personal data export files.
Description
See also
- wp_privacy_exports_dir
Source
function wp_privacy_exports_url() {
$upload_dir = wp_upload_dir();
$exports_url = trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/';
/**
* Filters the URL of the directory used to store personal data export files.
*
* @since 4.9.6
* @since 5.5.0 Exports now use relative paths, so changes to the directory URL
* via this filter should be reflected on the server.
*
* @param string $exports_url Exports directory URL.
*/
return apply_filters( 'wp_privacy_exports_url', $exports_url );
}
Hooks
- apply_filters( ‘wp_privacy_exports_url’, string $exports_url )
-
Filters the URL of the directory used to store personal data export files.
Changelog
| Version | Description |
|---|---|
| 4.9.6 | Introduced. |