函数文档

wp_privacy_exports_dir()

💡 云策文档标注

概述

wp_privacy_exports_dir() 函数用于返回存储个人数据导出文件的目录路径。它基于上传目录构建路径,并可通过过滤器进行自定义。

关键要点

  • 函数返回一个字符串,表示个人数据导出文件的存储目录。
  • 目录路径通过组合 wp_upload_dir() 的 basedir 和 'wp-personal-data-exports/' 子目录生成。
  • 支持 apply_filters('wp_privacy_exports_dir', $exports_dir) 过滤器,允许开发者自定义目录路径。
  • 从 WordPress 4.9.6 版本引入,5.5.0 版本后导出文件使用相对路径,过滤器修改需确保服务器路径同步。

代码示例

function wp_privacy_exports_dir() {
    $upload_dir  = wp_upload_dir();
    $exports_dir = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/';

    /**
     * Filters 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
     *              via this filter should be reflected on the server.
     *
     * @param string $exports_dir Exports directory.
     */
    return apply_filters( 'wp_privacy_exports_dir', $exports_dir );
}

注意事项

  • 修改过滤器 wp_privacy_exports_dir 时,需确保服务器上的目录路径与实际存储位置一致,以避免文件访问问题。
  • 此函数与 wp_privacy_exports_url() 相关,分别处理目录路径和 URL。

📄 原文内容

Returns the directory used to store personal data export files.

Description

See also

  • wp_privacy_exports_url

Return

string Exports directory.

Source

function wp_privacy_exports_dir() {
	$upload_dir  = wp_upload_dir();
	$exports_dir = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/';

	/**
	 * Filters 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
	 *              via this filter should be reflected on the server.
	 *
	 * @param string $exports_dir Exports directory.
	 */
	return apply_filters( 'wp_privacy_exports_dir', $exports_dir );
}

Hooks

apply_filters( ‘wp_privacy_exports_dir’, string $exports_dir )

Filters the directory used to store personal data export files.

Changelog

Version Description
4.9.6 Introduced.