Automattic\WooCommerce\Internal\ProductDownloads

DownloadableFileAttachments::handle_attachment_link │ public │ WC 1.0

Use an ID-only link for downloadable product files.

The usual link includes the attachment's slug, which is based on the original file name. Canonical and other redirects that point to the attachment then land on a URL that reveals nothing and shows a 404.

Метод класса: DownloadableFileAttachments{}

Хуков нет.

Возвращает

string|mixed.

Использование

$DownloadableFileAttachments = new DownloadableFileAttachments();
$DownloadableFileAttachments->handle_attachment_link( $link, $attachment_id );
$link(строка|разное) (обязательный)
Attachment link.
$attachment_id(int|разное) (обязательный)
Attachment ID.

Код DownloadableFileAttachments::handle_attachment_link() WC 11.3.0

public function handle_attachment_link( $link, $attachment_id ) {
	$attachment_id = absint( $attachment_id );

	return $this->is_hidden_attachment( $attachment_id ) ? add_query_arg( 'attachment_id', $attachment_id, home_url( '/' ) ) : $link;
}