为个人数据导出报告生成单个组。
原型
wp_privacy_generate_personal_data_export_group_html( array $group_data )
参数
$group_data
(array)
(Required)
要渲染的组数据。 ‘group_label’(字符串)该组的面向用户的标题,例如’评论’。 ‘items’(数组)一组组项。 ‘group_item_data’(array)项的名称 – 值对数组。 ‘name’(字符串)项目名称 – 值对的面向用户的名称,例如’IP地址’。 ‘value’(字符串)项目数据对的面向用户的值,例如’50 .60.70.0’ 。 }
返回值
(string)
此组及其项目的HTML。
源文件
路径:wp-admin/includes/file.php
<?php
...
function wp_privacy_generate_personal_data_export_group_html( $group_data ) {
$allowed_tags = array(
'a' => array(
'href' => array(),
'target' => array()
),
'br' => array()
);
$allowed_protocols = array( 'http', 'https' );
$group_html = '';
$group_html .= '<h2>' . esc_html( $group_data['group_label'] ) . '</h2>';
$group_html .= '<div>';
foreach ( (array) $group_data['items'] as $group_item_id => $group_item_data ) {
$group_html .= '<table>';
$group_html .= '<tbody>';
foreach ( (array) $group_item_data as $group_item_datum ) {
$value = $group_item_datum['value'];
// If it looks like a link, make it a link
if ( false === strpos( $value, ' ' ) && ( 0 === strpos( $value, 'http://' ) || 0 === strpos( $value, 'https://' ) ) ) {
$value = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
}
$group_html .= '<tr>';
$group_html .= '<th>' . esc_html( $group_item_datum['name'] ) . '</th>';
$group_html .= '<td>' . wp_kses( $value, $allowed_tags, $allowed_protocols ) . '</td>';
$group_html .= '</tr>';
}
$group_html .= '</tbody>';
$group_html .= '</table>';
}
$group_html .= '</div>';
return $group_html;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_privacy_generate_personal_data_export_group_html/