_wp_connectors_mask_api_key()
Masks an API key, showing only the last 4 characters.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
String. The masked key, e.g. "****fj39".
Usage
_wp_connectors_mask_api_key( $key ): string;
- $key(string) (required)
- The API key to mask.
Changelog
| Since 7.0.0 | Introduced. |
_wp_connectors_mask_api_key() wp connectors mask api key code WP 7.0
function _wp_connectors_mask_api_key( string $key ): string {
if ( strlen( $key ) <= 4 ) {
return $key;
}
return str_repeat( "\u{2022}", min( strlen( $key ) - 4, 16 ) ) . substr( $key, -4 );
}