Content editing

We are all probably used to the “helpfull” formatting Word adds to its text. Fortunately the CP editor gets rid of most of it.
Unfortunately we have a new contender. Grammerly
One of my clients actually adds content to his own website, I am not against this and even encourage their involvement. This particular client has started using grammerly and pasteing straight into the site content.
So almost every line of text has “” added.
I do not want to discourage the client, so any easy way to filter out this unwanted markup.

In theory, you could just add a filter to the_content, thats the filter that runs when post content (literally that field) is put out in the frontend.

Other options involve when the post or page is being saved, but thats usually not as ‘safe’ or may lead to different results.

cu, w0lf.

2 Likes

I’ve never looked deeply into this, but paste TinyMCE plugin can be configured to deal with this kind of situations.
Think the right hook is tiny_mce_before_init.
What I’m sure is that this approach will require a lot more work than using the_content filter.

This might be an unpopular take, but I think this is a training issue. TinyMCE has a ‘paste as text’ button that, if clicked before pasting, does not include formatting from the copied text.

If they’re willing to take a few minutes to learn why pasting formatted text is problematic, and how to prevent it, then they can learn how to paste text stripped of formatting and format it properly within the editor. If they’re not willing or able to learn that… :roll_eyes:

2 Likes