WordPress.org

Make WordPress Core

Ticket #44000: 44000.patch

File 44000.patch, 2.1 KB (added by scott.deluzio, 6 weeks ago)

Adds notification bubble to Tools menu for GDPR export/erase confirmations

  • wp-admin/includes/user.php

     
    800800                'plural'   => 'privacy_requests',
    801801                'singular' => 'privacy_request',
    802802        ) );
     803
    803804        $requests_table->process_bulk_action();
    804805        $requests_table->prepare_items();
    805806        ?>
     
    845846}
    846847
    847848/**
     849 * Admin menu bubble for data export or removal requests.
     850 *
     851 * @since 4.9.6
     852 */
     853
     854add_filter( 'add_menu_classes', '_wp_export_removal_request_bubble' );
     855function _wp_export_removal_request_bubble( $menu ){
     856        // Start with a count of 0
     857        $request_count = 0;
     858
     859        // Get number of export requests that have been confirmed, and add to $request_count
     860        $export_requests = new WP_Privacy_Data_Export_Requests_Table( array(
     861                'plural'   => 'privacy_requests',
     862                'singular' => 'privacy_request',
     863        ) );
     864
     865        $export_requests->process_bulk_action();
     866        $export_requests->prepare_items();
     867
     868        foreach( $export_requests as $request ){
     869                $status = $request[0]->status;
     870                if( 'request-confirmed' == $status ){
     871                        $request_count++;
     872                }
     873        }
     874
     875        // Get number of removal requests that have been confirmed, and add to $request_count
     876        $removal_requests = new WP_Privacy_Data_Removal_Requests_Table( array(
     877                'plural'   => 'privacy_requests',
     878                'singular' => 'privacy_request',
     879        ) );
     880
     881        $removal_requests->process_bulk_action();
     882        $removal_requests->prepare_items();
     883
     884        foreach( $removal_requests as $request ){
     885                $status = $request[0]->status;
     886                if( 'request-confirmed' == $status ){
     887                        $request_count++;
     888                }
     889        }
     890
     891        // Loop through menu items
     892        foreach( $menu as $menu_key => $menu_data ){
     893                // If not the Tools menu, continue
     894                if( 'tools.php' != $menu_data[2] )
     895                        continue;
     896                // On Tools menu add the bubble with the $request_count calculated above.
     897                $menu[$menu_key][0] .= " <span class='update-plugins count-$request_count'><span class='plugin-count'>" . number_format_i18n( $request_count ) . '</span></span>';
     898        }
     899        return $menu;
     900}
     901
     902/**
    848903 * Personal data anonymization.
    849904 *
    850905 * @since 4.9.6