Automattic\WooCommerce\Internal\Email\Unsubscribes
Endpoint::url_for
Build the URL the email's unsubscribe link should point to.
The raw email is hashed before it ever lands in the URL — see the class docblock for why. Callers pass the raw address (so the API stays ergonomic and signing stays in one place), but the rendered link only contains the hash.
Method of the class: Endpoint{}
No Hooks.
Returns
string.
Usage
$result = Endpoint::url_for( $order_id, $email, $kind ): string;
- $order_id(int) (required)
- Order id (informational; lookup is by email hash + kind).
- $email(string) (required)
- Billing email.
- $kind(string) (required)
- Email-kind identifier (the email class's
$this->id).
Endpoint::url_for() Endpoint::url for code WC 11.0.1
public static function url_for( int $order_id, string $email, string $kind ): string {
$hash = Storage::hash_email( $email );
if ( '' === $hash ) {
return '';
}
$sig = self::sign( $order_id, $hash, $kind );
return add_query_arg(
array(
self::QUERY_VAR => $order_id,
'kind' => $kind,
self::QUERY_VAR_HASH => $hash,
'sig' => $sig,
),
home_url( '/' )
);
}