wp_privacy_anonymize_data

函数
wp_privacy_anonymize_data ( $type, $data = '' )
参数
  • (string) $type The type of data to be anonymized.
    Required:
  • (string) $data Optional The data to be anonymized.
    Required:
    Default: (empty)
返回值
  • (string) The anonymous data for the requested type.
定义位置
相关方法
wp_privacy_anonymize_ipwp_prepare_site_datawp_privacy_exports_dirwp_ajax_wp_privacy_erase_personal_datawp_normalize_site_data
引入
4.9.6
弃用
-

wp_privacy_anonymize_data: 这个函数用于匿名化存储在WordPress数据库中的个人数据。它用于保护用户的隐私,用随机生成的值来替换识别信息: 这个函数可以被开发者用来为他们的插件或主题编写自定义的匿名化功能。

按类型返回统一的"anonymous"数据。

function wp_privacy_anonymize_data( $type, $data = '' ) {

	switch ( $type ) {
		case 'email':
			$anonymous = 'deleted@site.invalid';
			break;
		case 'url':
			$anonymous = 'https://site.invalid';
			break;
		case 'ip':
			$anonymous = wp_privacy_anonymize_ip( $data );
			break;
		case 'date':
			$anonymous = '0000-00-00 00:00:00';
			break;
		case 'text':
			/* translators: Deleted text. */
			$anonymous = __( '[deleted]' );
			break;
		case 'longtext':
			/* translators: Deleted long text. */
			$anonymous = __( 'This content was deleted by the author.' );
			break;
		default:
			$anonymous = '';
			break;
	}

	/**
	 * Filters the anonymous data for each type.
	 *
	 * @since 4.9.6
	 *
	 * @param string $anonymous Anonymized data.
	 * @param string $type      Type of the data.
	 * @param string $data      Original data.
	 */
	return apply_filters( 'wp_privacy_anonymize_data', $anonymous, $type, $data );
}

常见问题

FAQs
查看更多 >