wp_privacy_generate_personal_data_export_group_html( array $group_data, string $group_id = '', int $groups_count = 1 ): string
- Since
- 4.9.6, 5.4.0
- Source
wp-admin/includes/privacy-tools.php:258
Compatibility
- WordPress
- since 5.4.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$group_dataarray- The group data to render.
$group_labelstringThe user-facing heading for the group, e.g. 'Comments'.$itemsarray{ An array of group items.$group_item_dataarray{ An array of name-value pairs for the item.$namestringThe user-facing name of an item name-value pair, e.g. 'IP Address'.$valuestringThe user-facing value of an item data pair, e.g. '50.60.70.0'. } }
$group_idstringoptional- The group identifier.Default:
'' $groups_countintoptional- The number of all groupsDefault:
1
Return value
string- The HTML for this group and its items.
Performance profile
How much work a call to wp_privacy_generate_personal_data_export_group_html() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Light
- Scaling
- Scales with input
- Instructions
- 38–60
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 107.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()one call below wp_privacy_generate_personal_data_export_group_html()
Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_privacy_generate_personal_data_export_group_html() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($group_data) && !$groups_count | 38–44 | sanitize_title_with_dashes(), esc_attr(), esc_html() |
empty($group_data) && $groups_count | 46–52 | sanitize_title_with_dashes(), esc_attr(), esc_html(), esc_html__() |
!empty($group_data) && !$groups_count | 46–52 | sanitize_title_with_dashes(), esc_attr(), esc_html(), esc_html() |
!empty($group_data) && $groups_count | 54–60 | sanitize_title_with_dashes(), esc_attr(), esc_html(), esc_html(), esc_html__() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 107 | 38–60 | 10 | |
| 8.5 | 107 | 38–60 | 10 | |
| 8.4 | 107 | 38–60 | 10 | 9 fewer instructions than PHP 8.3 |
| 8.3 | 116 | 38–60 | 10 | |
| 8.2 | 116 | 38–60 | 10 | |
| 8.1 | 116 | 38–60 | 10 | |
| 7.4 | 116 | 38–60 | 10 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 8
- sanitize_title_with_dashes()Sanitizes a title, replacing whitespace and a few other characters with dashes.
- esc_attr()Escaping for HTML attributes.
- esc_html()Escaping for HTML blocks.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- str_starts_with()Polyfill for `str_starts_with()` function added in PHP 8.0.
- esc_url()Checks and cleans a URL.
- wp_kses()Filters text content and strips out disallowed HTML.
- esc_html__()Retrieves the translation of $text and escapes it for safe use in HTML output.
Used by · 1
- wp_privacy_generate_personal_data_export_file()Generate the personal data export file.
Source code
function wp_privacy_generate_personal_data_export_group_html( $group_data, $group_id = '', $groups_count = 1 ) { $group_id_attr = sanitize_title_with_dashes( $group_data['group_label'] . '-' . $group_id ); $group_html = '<h2 id="' . esc_attr( $group_id_attr ) . '">'; $group_html .= esc_html( $group_data['group_label'] ); $items_count = count( (array) $group_data['items'] ); if ( $items_count > 1 ) { $group_html .= sprintf( ' <span class="count">(%d)</span>', $items_count ); } $group_html .= '</h2>'; if ( ! empty( $group_data['group_description'] ) ) { $group_html .= '<p>' . esc_html( $group_data['group_description'] ) . '</p>'; } $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 ( ! str_contains( $value, ' ' ) && ( str_starts_with( $value, 'http://' ) || str_starts_with( $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, 'personal_data_export' ) . '</td>'; $group_html .= '</tr>'; } $group_html .= '</tbody>'; $group_html .= '</table>'; } if ( $groups_count > 1 ) { $group_html .= '<div class="return-to-top">'; $group_html .= '<a href="#top"><span aria-hidden="true">↑ </span> ' . esc_html__( 'Go to top' ) . '</a>'; $group_html .= '</div>'; } $group_html .= '</div>'; return $group_html;}Changelog
Introduced in 4.9.6. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$group_id and $groups_count parameters.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/privacy-tools.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.