Update random prefix logic to return alphabetic characters only

This commit is contained in:
Emili Castells Guasch 2025-06-09 17:33:52 +02:00
parent 20ef33f7ee
commit 95adde6740
No known key found for this signature in database

View file

@ -2106,9 +2106,15 @@ return array(
},
/**
* Returns random 6 characters length alphanumeric prefix, followed by a hyphen.
* Returns random 6 characters length alphabetic prefix, followed by a hyphen.
*/
'wcgateway.settings.invoice-prefix-random' => static function( ContainerInterface $container ): string {
return wp_generate_password( 6, false ) . '-';
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$prefix = '';
for ( $i = 0; $i < 6; $i++ ) {
$prefix .= $characters[ wp_rand( 0, strlen( $characters ) - 1 ) ];
}
return $prefix . '-';
},
);