boonebgorges / buddypress-group-email-subscription

Fine-grained email subscription for activity in BuddyPress groups
35 stars 31 forks source link

No (useful) content in mail, if there are shortcodes #139

Open Erenor opened 6 years ago

Erenor commented 6 years ago

When using this plugin (version 3.8.1) together with others like BP Activity Plus, the mails users receive contain the exact activity's content, for example:

[bpfb_images] 1_0-48931900-1520595052_big-kudu-1.jpg [/bpfb_images]

This, of course, gives no idea about the Activity contents. A solution would be to use the function do_shortcode() to "evaluate" content before using it in mails, to give users a preview of the Activity.

boonebgorges commented 6 years ago

Thanks for the report.

It feels to me like blanket evaluation of all shortcodes is probably not a great idea. Many shortcodes are used to embed iframes or other interactive content that won't work in various ways in emails.

Does it seem reasonable to have a filter that would allow site owners to toggle the processing of shortcodes? Or maybe we can have a whitelist of shortcodes that are processed by default, with a filter to allow more? (Not sure off the top of my head whether the latter is technically easy to do.) @r-a-y Do you have thoughts about an approach?

Erenor commented 6 years ago

The latter (whitelist of shortcodes) would involve a bit of work when managing the content string.

I do like the idea of a flag in BPGES' settings to allow site owners activate/deactivate the parsing of the content. Of course, this should be an "on/off" option, to avoid too many computation with the shortcodes whitelist (regex and so on). As you said, I got some issues with the "video" upload in BPAP plugin, when the mail application tries to render the iframe and the Javascript code, but I feel it is a "minor" issue when compared to the "blank" output it currently provides.

r-a-y commented 6 years ago

Does it seem reasonable to have a filter that would allow site owners to toggle the processing of shortcodes? Or maybe we can have a whitelist of shortcodes that are processed by default, with a filter to allow more? (Not sure off the top of my head whether the latter is technically easy to do.) @r-a-y Do you have thoughts about an approach?

We could enable do_shortcode() to run, and then we could apply our own version of KSES that will run afterwards so it would strip stuff like <iframe> tags.

I guess we'd need to decide what tags are supported. A good elements list to look at would be bbPress' KSES filter: https://bbpress.trac.wordpress.org/browser/tags/2.5.14/includes/common/formatting.php#L15

We'd also need to test how images would look in the default BP email template. I'm not sure how responsive the template is.

boonebgorges commented 6 years ago

We could enable do_shortcode() to run, and then we could apply our own version of KSES that will run afterwards so it would strip stuff like