Make WordPress Core

Ticket #44000: 44000.4.diff

File 44000.4.diff, 3.9 KB (added by birgire, 7 years ago)
  • src/wp-admin/includes/user.php

    diff --git src/wp-admin/includes/user.php src/wp-admin/includes/user.php
    index 7694889..ecfe9ba 100644
    function wp_privacy_process_personal_data_erasure_page( $response, $eraser_index 
    991991 * @access private
    992992 */
    993993function _wp_privacy_hook_requests_page() {
    994         add_submenu_page( 'tools.php', __( 'Export Personal Data' ), __( 'Export Personal Data' ), 'export_others_personal_data', 'export_personal_data', '_wp_personal_data_export_page' );
    995         add_submenu_page( 'tools.php', __( 'Erase Personal Data' ), __( 'Erase Personal Data' ), 'erase_others_personal_data', 'remove_personal_data', '_wp_personal_data_removal_page' );
     994
     995        $export_count = 0;
     996        if ( current_user_can( 'export_others_personal_data' ) ) {
     997                $export_counts = (array) wp_count_user_requests( 'export_personal_data' );
     998                if ( isset( $export_counts['request-confirmed'] ) ) {
     999                        $export_count = (int) $export_counts['request-confirmed'];
     1000                }
     1001        }
     1002
     1003        $erase_count = 0;
     1004        if ( current_user_can( 'erase_others_personal_data' ) ) {
     1005                $erase_counts = (array) wp_count_user_requests( 'remove_personal_data' );
     1006                if ( isset( $erase_counts['request-confirmed'] ) ) {
     1007                        $erase_count = (int) $erase_counts['request-confirmed'];
     1008                }
     1009        }
     1010
     1011        $export_notice = sprintf(
     1012                '<span class="update-plugins count-%d"><span class="plugin-count">%d</span></span>',
     1013                $export_count,
     1014                number_format_i18n( $export_count )
     1015        );
     1016
     1017        $erase_notice = sprintf(
     1018                '<span class="update-plugins count-%d"><span class="plugin-count">%d</span></span>',
     1019                $erase_count,
     1020                number_format_i18n( $erase_count )
     1021        );
     1022
     1023        /* translators: %s Export bubble count notice */
     1024        add_submenu_page( 'tools.php', __( 'Export Personal Data' ), sprintf( __( 'Export Personal Data %s' ), $export_notice ), 'export_others_personal_data', 'export_personal_data', '_wp_personal_data_export_page' );
     1025
     1026        /* translators: %s Erase bubble count notice */
     1027        add_submenu_page( 'tools.php', __( 'Erase Personal Data' ), sprintf( __( 'Erase Personal Data %s' ), $erase_notice ), 'erase_others_personal_data', 'remove_personal_data', '_wp_personal_data_removal_page' );
    9961028}
    9971029
    9981030// TODO: move the following classes in new files.
  • src/wp-admin/menu.php

    diff --git src/wp-admin/menu.php src/wp-admin/menu.php
    index 0ad302e..4d0afb7 100644
    if ( current_user_can( 'list_users' ) ) { 
    252252        }
    253253}
    254254
    255 $menu[75]                     = array( __( 'Tools' ), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'dashicons-admin-tools' );
     255$confirmed_export_request_count = 0;
     256if ( current_user_can( 'export_others_personal_data' ) ) {
     257        $export_request_counts = (array) wp_count_user_requests( 'export_personal_data' );
     258        if ( isset( $export_request_counts['request-confirmed'] ) ) {
     259                $confirmed_export_request_count = (int) $export_request_counts['request-confirmed'];
     260        }
     261}
     262
     263$confirmed_erase_request_count = 0;
     264if ( current_user_can( 'erase_others_personal_data' ) ) {
     265        $erase_request_counts = (array) wp_count_user_requests( 'remove_personal_data' );
     266        if ( isset( $erase_request_counts['request-confirmed'] ) ) {
     267                $confirmed_erase_request_count = (int) $erase_request_counts['request-confirmed'];
     268        }
     269}
     270
     271$confirmed_request_count = $confirmed_export_request_count + $confirmed_erase_request_count;
     272
     273$request_notice = sprintf(
     274        '<span class="update-plugins count-%d"><span class="plugin-count">%d</span></span>',
     275        $confirmed_request_count,
     276        number_format_i18n( $confirmed_request_count )
     277);
     278
     279$menu[75]                     = array( sprintf( __( 'Tools %s' ), $request_notice ), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'dashicons-admin-tools' );
    256280        $submenu['tools.php'][5]  = array( __( 'Available Tools' ), 'edit_posts', 'tools.php' );
    257281        $submenu['tools.php'][10] = array( __( 'Import' ), 'import', 'import.php' );
    258282        $submenu['tools.php'][15] = array( __( 'Export' ), 'export', 'export.php' );