Hi @mattyrob
At the end of the publish function, each of the groups of subscribers get mails sent to them:
// Registered Subscribers first
// first we send plaintext summary emails
$recipients = $this->get_registered( "cats=$post_cats_string&format=excerpt&author=$post->post_author" );
$recipients = apply_filters( 's2_send_plain_excerpt_subscribers', $recipients, $post->ID );
$this->mail( $recipients, $subject, $plain_excerpt_body );
// next we send plaintext full content emails
$recipients = $this->get_registered( "cats=$post_cats_string&format=post&author=$post->post_author" );
$recipients = apply_filters( 's2_send_plain_fullcontent_subscribers', $recipients, $post->ID );
$this->mail( $recipients, $subject, $plain_body );
// next we send html excerpt content emails
$recipients = $this->get_registered( "cats=$post_cats_string&format=html_excerpt&author=$post->post_author" );
$recipients = apply_filters( 's2_send_html_excerpt_subscribers', $recipients, $post->ID );
$this->mail( $recipients, $subject, $html_excerpt_body, 'html' );
// next we send html full content emails
$recipients = $this->get_registered( "cats=$post_cats_string&format=html&author=$post->post_author" );
$recipients = apply_filters( 's2_send_html_fullcontent_subscribers', $recipients, $post->ID );
$this->mail( $recipients, $subject, $html_body, 'html' );
// and finally we send to Public Subscribers
$recipients = apply_filters( 's2_send_public_subscribers', $public, $post->ID );
$this->mail( $recipients, $subject, $plain_excerpt_body, 'text' );
Since the html mails are sent to registered subscribers, before the plain text mails are sent to the public subscribers, the filter is added and not removed.
The problem occurs if someone registers for html mails, and then someone registers for the public mails. In that case, the html email will be sent first, and the plain text email afterwards, in the same context – so the filter is still present when the plain text email is sent.
WordPress 4.8.3, PHP 5.6.31