Changeset 47278 for trunk/src/wp-admin/includes/privacy-tools.php
- Timestamp:
- 02/11/2020 09:26:25 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/privacy-tools.php
r47245 r47278 217 217 * 218 218 * @since 4.9.6 219 * @since 5.4.0 Added the `$group_id` and `$groups_count` parameters. 219 220 * 220 221 * @param array $group_data { … … 233 234 * } 234 235 * } 235 * @return string The HTML for this group and its items. 236 */ 237 function wp_privacy_generate_personal_data_export_group_html( $group_data ) { 238 $group_html = '<h2>'; 236 * @param string $group_id The group identifier. 237 * @param int $groups_count The number of all groups 238 * @return string $group_html The HTML for this group and its items. 239 */ 240 function wp_privacy_generate_personal_data_export_group_html( $group_data, $group_id = '', $groups_count = 1 ) { 241 $group_id_attr = sanitize_title_with_dashes( $group_data['group_label'] . '-' . $group_id ); 242 243 $group_html = '<h2 id="' . esc_attr( $group_id_attr ) . '">'; 239 244 $group_html .= esc_html( $group_data['group_label'] ); 240 245 … … 271 276 $group_html .= '</tbody>'; 272 277 $group_html .= '</table>'; 278 } 279 280 if ( 1 < $groups_count ) { 281 $group_html .= '<div class="return_to_top">'; 282 $group_html .= '<a href="#top">' . esc_html__( '↑ Return to top' ) . '</a>'; 283 $group_html .= '</div>'; 273 284 } 274 285 … … 374 385 $groups = array_merge( array( 'about' => $about_group ), $groups ); 375 386 387 $groups_count = count( $groups ); 388 376 389 // Convert the groups to JSON format. 377 390 $groups_json = wp_json_encode( $groups ); … … 411 424 fwrite( $file, 'td { padding: 5px; }' ); 412 425 fwrite( $file, 'tr:nth-child(odd) { background-color: #fafafa; }' ); 426 fwrite( $file, '.return_to_top { text-align:right; }' ); 413 427 fwrite( $file, '</style>' ); 414 428 fwrite( $file, '<title>' ); … … 417 431 fwrite( $file, "</head>\n" ); 418 432 fwrite( $file, "<body>\n" ); 419 fwrite( $file, '<h1>' . esc_html__( 'Personal Data Export' ) . '</h1>' ); 433 fwrite( $file, '<h1 id="top">' . esc_html__( 'Personal Data Export' ) . '</h1>' ); 434 435 // Create TOC. 436 if ( 1 < $groups_count ) { 437 fwrite( $file, '<div id="table_of_contents">' ); 438 fwrite( $file, '<h2>' . esc_html__( 'Table of Contents' ) . '</h2>' ); 439 fwrite( $file, '<ul>' ); 440 foreach ( (array) $groups as $group_id => $group_data ) { 441 $group_label = esc_html( $group_data['group_label'] ); 442 $group_id_attr = sanitize_title_with_dashes( $group_data['group_label'] . '-' . $group_id ); 443 $group_items_count = count( (array) $group_data['items'] ); 444 if ( $group_items_count > 1 ) { 445 $group_label .= sprintf( ' <span class="count">(%d)</span>', $group_items_count ); 446 } 447 fwrite( $file, '<li>' ); 448 fwrite( $file, '<a href="#' . esc_attr( $group_id_attr ) . '">' . $group_label . '</a>' ); 449 fwrite( $file, '</li>' ); 450 } 451 fwrite( $file, '</ul>' ); 452 fwrite( $file, '</div>' ); 453 } 420 454 421 455 // Now, iterate over every group in $groups and have the formatter render it in HTML. 422 456 foreach ( (array) $groups as $group_id => $group_data ) { 423 fwrite( $file, wp_privacy_generate_personal_data_export_group_html( $group_data ) );457 fwrite( $file, wp_privacy_generate_personal_data_export_group_html( $group_data, $group_id, $groups_count ) ); 424 458 } 425 459
Note: See TracChangeset
for help on using the changeset viewer.