| 846 | add_filter( 'add_menu_classes', '_wp_export_erase_request_bubble' ); |
| 847 | |
| 848 | /** |
| 849 | * Admin menu bubble for data export and erase requests. |
| 850 | * |
| 851 | * @since 4.9.7 |
| 852 | * |
| 853 | * @param array $menu Menu array. |
| 854 | */ |
| 855 | |
| 856 | function _wp_export_erase_request_bubble( $menu ) { |
| 857 | |
| 858 | $confirmed_export_request_counts = 0; |
| 859 | if ( current_user_can( 'export_others_personal_data' ) ) { |
| 860 | $export_request_counts = (array) wp_count_user_requests( 'export_personal_data' ); |
| 861 | if( isset( $export_request_counts['request-confirmed'] ) ) { |
| 862 | $confirmed_export_request_counts = (int) $export_request_counts['request-confirmed']; |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | $confirmed_erase_request_counts = 0; |
| 867 | if ( current_user_can( 'erase_others_personal_data' ) ) { |
| 868 | $erase_request_counts = (array) wp_count_user_requests( 'remove_personal_data' ); |
| 869 | if( isset( $erase_request_counts['request-confirmed'] ) ) { |
| 870 | $confirmed_erase_request_counts = (int) $erase_request_counts['request-confirmed']; |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | $request_count = $confirmed_export_request_counts + $confirmed_erase_request_counts; |
| 875 | |
| 876 | // Loop through menu items |
| 877 | foreach( $menu as $menu_key => $menu_data ){ |
| 878 | // If not the Tools menu, continue |
| 879 | if( 'tools.php' != $menu_data[2] ) |
| 880 | continue; |
| 881 | // On Tools menu add the bubble with the $request_count calculated above. |
| 882 | $menu[$menu_key][0] .= sprintf( |
| 883 | ' <span class="awaiting-confirmed-request-mod count-%d"><span class="confirmed-request-count">%d</span></span>', |
| 884 | $request_count, |
| 885 | number_format_i18n( $request_count ) |
| 886 | ); |
| 887 | } |
| 888 | return $menu; |
| 889 | } |
| 890 | |