WordPress.org

Make WordPress Core

Ticket #46894: 46894.3.diff

File 46894.3.diff, 2.7 KB (added by xkon, 6 months ago)
  • src/wp-admin/includes/privacy-tools.php

    diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php
    index efe46cce32..9eb095b844 100644
    a b function _wp_personal_data_cleanup_requests() { 
    234234 * @return string The HTML for this group and its items.
    235235 */
    236236function wp_privacy_generate_personal_data_export_group_html( $group_data ) {
    237         $group_html  = '<h2>';
     237        $group_html  = '<h2 id="' . sanitize_title( $group_data['group_label'] ) . '">';
    238238        $group_html .= esc_html( $group_data['group_label'] );
    239239
    240240        $items_count = count( (array) $group_data['items'] );
    function wp_privacy_generate_personal_data_export_group_html( $group_data ) { 
    271271                $group_html .= '</table>';
    272272        }
    273273
     274        $group_html .= '<div class="return_to_top">';
     275        $group_html .= '<a href="#top">' . esc_html__( '&uarr; Return to top' ) . '</a>';
     276        $group_html .= '</div>';
     277
    274278        $group_html .= '</div>';
    275279
    276280        return $group_html;
    function wp_privacy_generate_personal_data_export_file( $request_id ) { 
    350354        fwrite( $file, 'th { padding: 5px; text-align: left; width: 20%; }' );
    351355        fwrite( $file, 'td { padding: 5px; }' );
    352356        fwrite( $file, 'tr:nth-child(odd) { background-color: #fafafa; }' );
     357        fwrite( $file, '.return_to_top { text-align:right; }' );
    353358        fwrite( $file, '</style>' );
    354359        fwrite( $file, '<title>' );
    355360        fwrite( $file, esc_html( $title ) );
    function wp_privacy_generate_personal_data_export_file( $request_id ) { 
    360365        fwrite( $file, "<body>\n" );
    361366
    362367        // Heading.
    363         fwrite( $file, '<h1>' . esc_html__( 'Personal Data Export' ) . '</h1>' );
     368        fwrite( $file, '<h1 id="top">' . esc_html__( 'Personal Data Export' ) . '</h1>' );
    364369
    365370        // And now, all the Groups.
    366371        $groups = get_post_meta( $request_id, '_export_data_grouped', true );
    function wp_privacy_generate_personal_data_export_file( $request_id ) { 
    396401        // Merge in the special about group.
    397402        $groups = array_merge( array( 'about' => $about_group ), $groups );
    398403
     404        // Create TOC.
     405        if ( count( $groups ) > 1 ) {
     406                fwrite( $file, '<div id="table_of_contents">' );
     407
     408                fwrite( $file, '<h2>Table of Contents</h2>' );
     409
     410                fwrite( $file, '<ul>' );
     411
     412                foreach ( (array) $groups as $group_id => $group_data ) {
     413                        fwrite( $file, '<li>' );
     414                        fwrite( $file, '<a href="#' . sanitize_title( $group_data['group_label'] ) . '">' . $group_data['group_label'] . '</a>' );
     415                        fwrite( $file, '</li>' );
     416                }
     417
     418                fwrite( $file, '</ul>' );
     419                fwrite( $file, '</div>' );
     420        }
     421
    399422        // Now, iterate over every group in $groups and have the formatter render it in HTML.
    400423        foreach ( (array) $groups as $group_id => $group_data ) {
    401424                fwrite( $file, wp_privacy_generate_personal_data_export_group_html( $group_data ) );