Hi @carryoncoding,
I have a fix in place but it’s not ready as part of a larger release at the moment.
For now, if you’re happy modifying the plugin, you should be able to change the line in /wp-plugins/bnfw/includes/admin/class-bnfw-notification.php that reads:
'message' => isset( $_POST['notification_message'] ) ? wp_kses_post( wp_unslash( $_POST['notification_message'] ) ) : '',
to:
'message' => isset( $_POST['notification_message'] ) ? $this->bnfw_kses_message_field( wp_unslash( $_POST['notification_message'] ) ) : '',
then add this to the bottom of that file:
/**
* Filters out the same tags as wp_kses_post, but allows some extra tags.
*
* @since 1.10
*
* @param string $message Content to filter through kses.
*
* @return string
*/
public function bnfw_kses_message_field( $message ) {
$allowed_tags = array_replace_recursive(
wp_kses_allowed_html( 'post' ),
array(
'html' => array(
'lang' => true,
'xmlns' => true,
),
'meta' => array(
'name' => true,
'charset' => true,
'content' => true,
),
'style' => true,
'head' => true,
'body' => array(
'style' => true,
),
)
);
/**
* Kses message allowed tags.
*
* @since 1.10
*
* @param array[]|string $allowed_tags An array of allowed HTML elements and attributes, or a context name such as 'post'.
*/
return wp_kses( $message, apply_filters( 'bnfw_kses_message_allowed_tags', $allowed_tags ) );
}
Let me know how you get on with this.
Thanks for sharing that code. I added as you described. Then pasted my html (shared 7 Sep 2022) into the “Message body” window.
When I clicked “Save”, the code was immediately corrupted as per the images I sent on 7 Sep. No change.
Perhaps something else is at play?
Kind regards,
Phil.
Hi @carryoncoding,
Are you able to clear your transients and your cache (if using one) and then re-test?
Thanks. Cleared transients, cleared browser cache. No other cache used on the site. Pasted in the html and the same result.
Hi @carryoncoding,
Ok, thanks.
Can you confirm that some of the tags mentioned in the code snippet I posted above are now working in your notification?
Interesting progress. The original issue remains. The html pasted into “Message body” window is corrupted as soon as you hit “Save”.
However, the email that results now looks different. Before I modified /wp-plugins/bnfw/includes/admin/class-bnfw-notification.php, the email reproduced a lot of the css at the top. Now, the only indication of a problem in the email is the number “96” appearing at the top, before the first bit of content.
Hi @carryoncoding,
That’s good that it’s working, even if not quite right.
If you do this does it work as expected? I suspect the 96 might be part of a tag that isn’t allowed.
Sorry for delay. I have now set this up and will test for a few days. I’ll report back at that point.
Cheers,
Phil.
That’s now working fine! I don’t follow how to add an image to this post, but the generated email is all looking good.
Thanks for your help.
Phil.
Hi @carryoncoding,
That’s great! So please you have it working now and thank you for your persistence.
The next version of BNFW (delayed at present) will have this code included.
If you like BNFW and the support, please feel free to leave an honest review.