easydigitaldownloads/Easy-Digital-Downloads — pull request #2542 by leewillis77 (2014-08-27 21:56:30+00:00)
Title: Attachments should not persist across calls to send()

Second attempt - I raised the PR against the right branch this time :)

In my previous commit I fixed up what was there to squash warnings. However, it strikes me that attachments are actually treated incorrectly in the previous code.

Specifically:
1. It's "difficult" to add attachments - you have to wrap add_filter()/remove_filter() around your calls to send() [From reading the code?]
2. It's possible for attachments to "leak" between emails if the same instance of the EDD_Emails class was used to send multiple emails.

The attachments are like "to" and "from" etc. they're specific to an individual invocation of send() and should be treated as such. The attached patch removes any storage of attachments outside of send() and changes the signature of send() to allow passing in of attachment info.

Note: I possibly have another change to make to the signature of send() to support setting of a "heading" to go into the email. I'm also unsure of the impact of these changes on any other related plugins (Email templates or similar)