Make WordPress Core

Ticket #46894: 46894.diff

File 46894.diff, 2.5 KB (added by xkon, 6 years ago)
  • src/wp-admin/includes/file.php

    diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php
    index 2018f831b3..4baa331411 100644
    a b function wp_print_request_filesystem_credentials_modal() { 
    21332133 * @return string The HTML for this group and its items.
    21342134 */
    21352135function wp_privacy_generate_personal_data_export_group_html( $group_data ) {
    2136         $group_html  = '<h2>' . esc_html( $group_data['group_label'] ) . '</h2>';
     2136        $group_label = esc_html( $group_data['group_label'] );
     2137
     2138        $group_html  = '<h2 id="' . str_replace( ' ', '_', $group_label ) . '">' . $group_label . '</h2>';
    21372139        $group_html .= '<div>';
    21382140
    21392141        foreach ( (array) $group_data['items'] as $group_item_id => $group_item_data ) {
    function wp_privacy_generate_personal_data_export_group_html( $group_data ) { 
    21572159                $group_html .= '</table>';
    21582160        }
    21592161
     2162        $group_html .= '<div class="return_to_table_of_contents">';
     2163        $group_html .= '<a href="#table_of_contents">' . esc_html__( 'Return to table of contents' ) . '</a>';
     2164        $group_html .= '</div>';
     2165
    21602166        $group_html .= '</div>';
    21612167
    21622168        return $group_html;
    function wp_privacy_generate_personal_data_export_file( $request_id ) { 
    22362242        fwrite( $file, 'th { padding: 5px; text-align: left; width: 20%; }' );
    22372243        fwrite( $file, 'td { padding: 5px; }' );
    22382244        fwrite( $file, 'tr:nth-child(odd) { background-color: #fafafa; }' );
     2245        fwrite( $file, '#table_of_contents { padding: 10px 0 10px 0; }' );
     2246        fwrite( $file, '.return_to_table_of_contents { text-align:right; }' );
    22392247        fwrite( $file, '</style>' );
    22402248        fwrite( $file, '<title>' );
    22412249        fwrite( $file, esc_html( $title ) );
    function wp_privacy_generate_personal_data_export_file( $request_id ) { 
    22802288        // Merge in the special about group.
    22812289        $groups = array_merge( array( 'about' => $about_group ), $groups );
    22822290
     2291        // Create TOC
     2292        fwrite( $file, '<div id="table_of_contents">' );
     2293
     2294        $group_count = count( $groups );
     2295
     2296        foreach ( (array) $groups as $group_id => $group_data ) {
     2297                $group_label = $group_data['group_label'];
     2298
     2299                fwrite( $file, '<a href="#' . str_replace( ' ', '_', $group_label ) . '">' . $group_label . '</a>' );
     2300
     2301                if ( $group_count > 1 ) {
     2302                        fwrite( $file, ' | ' );
     2303                }
     2304
     2305                $group_count--;
     2306        }
     2307
     2308        fwrite( $file, '</div>' );
     2309
    22832310        // Now, iterate over every group in $groups and have the formatter render it in HTML.
    22842311        foreach ( (array) $groups as $group_id => $group_data ) {
    22852312                fwrite( $file, wp_privacy_generate_personal_data_export_group_html( $group_data ) );