| 3006 | // get the list of reserved names. |
| 3007 | $reserved_names = array_values( $user_prop_to_export ); |
| 3008 | |
| 3009 | /** |
| 3010 | * Filter to extend the Users personal data for the privacy exporter. |
| 3011 | * |
| 3012 | * @since 5.4.0 |
| 3013 | * |
| 3014 | * @param array $additional_user_data { |
| 3015 | * An array of name-value pairs of additional user data items. Default: the empty array. |
| 3016 | * |
| 3017 | * @type string $name The user-facing name of an item name-value pair, e.g. 'IP Address'. |
| 3018 | * @type string $value The user-facing value of an item data pair, e.g. '50.60.70.0'. |
| 3019 | * } |
| 3020 | * @param WP_User $user The user whose data is being exported. |
| 3021 | * @param string[] $reserved_names An array of reserved names. Any item in |
| 3022 | * `$additional_user_data` that uses one of these |
| 3023 | * for it's `name` will not be included in the export. |
| 3024 | */ |
| 3025 | $_extra_data = apply_filters( 'wp_privacy_additional_user_data', array(), $user, $reserved_names ); |
| 3026 | |
| 3027 | if ( is_array( $_extra_data ) && ! empty( $_extra_data ) ) { |
| 3028 | // remove items that use reserved names. |
| 3029 | $extra_data = array_filter( |
| 3030 | $_extra_data, |
| 3031 | function( $item ) use ( $reserved_names ) { |
| 3032 | return ! in_array( $item['name'], $reserved_names ); |
| 3033 | } |
| 3034 | ); |
| 3035 | |
| 3036 | if ( count( $extra_data ) !== count( $_extra_data ) ) { |
| 3037 | _doing_it_wrong( |
| 3038 | __FUNCTION__, |
| 3039 | sprintf( |
| 3040 | /* translators: %s: wp_privacy_additional_user_data */ |
| 3041 | __( 'Filter %s returned items with reserved names.' ), |
| 3042 | '<code>wp_privacy_additional_user_data</code>' |
| 3043 | ), |
| 3044 | '5.4.0' |
| 3045 | ); |
| 3046 | } |
| 3047 | |
| 3048 | if ( ! empty( $extra_data ) ) { |
| 3049 | $user_data_to_export = array_merge( $user_data_to_export, $extra_data ); |
| 3050 | } |
| 3051 | } |
| 3052 | |