Filter wp_mail based on content type
I can current filter the content type of the wp_mail function:
add_filter( 'wp_mail_content_type', function( $content_type ) {
return 'text/html';
});
And I can filter the message content
add_filter( 'wp_mail', function( $args ) {
$args['message'] = 'Filtered text here';
return $args;
});
But how can I only do the latter conditionally?
I only want to filter the message when the content type
== text/plain
.
I'm guessing there is a super-simple solution to this, but I haven't worked it out yet.