Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce
Coupon_Code_Generator::parse_email_restrictions
Parse and validate email restrictions string.
Method of the class: Coupon_Code_Generator{}
No Hooks.
Returns
Array. Array of valid email addresses.
Usage
// private - for code of main (parent) class only $result = $this->parse_email_restrictions( $raw ): array;
- $raw(mixed) (required)
- Raw email restrictions value (comma-separated string).
Coupon_Code_Generator::parse_email_restrictions() Coupon Code Generator::parse email restrictions code WC 10.9.1
private function parse_email_restrictions( $raw ): array {
if ( ! is_string( $raw ) || '' === $raw ) {
return array();
}
$emails = array_map( 'trim', explode( ',', $raw ) );
return array_values(
array_filter(
$emails,
function ( string $email ): bool {
return (bool) is_email( $email );
}
)
);
}