An evil little trick.

October 30, 2008

Yes, I said “evil”. Because it is.

I belong to a couple of awesome networking lists. On one of these lists, recently, someone was asking about a possible solution to what is truly a common problem for us designers/programmers who provide CMS solutions for our clients. The problem?

Microsoft Word.

All of you reading this…how many of you have create an awesome site design with pristine code and gorgeous formatting, and your client is all “hooray!”…and promptly starts writing their content up in Microsoft Word, and the C&P’s the stuff into the CMS you’ve just made for them? (Come on, I know you’re out there. Raise your hands.)

I have two clients, currently that do this. No matter what plugins I’ve installed, and no matter how many different ways I instruct them on how to do it correctly (even with using their beloved Word!) they don’t do it. They just keep C&P-ing from Word, and keep calling me when the site breaks because of it.

Now, to why I am evil.

When I first thought about doing this, it was over dinner with my husband. I was ranting about how – again – my clients were sending me frantic “emergency” emails because the site was broken, and what did I do? – only to find out – AGAIN – that they had used Microsoft Word to put in their content. Many times, they try to get really creative and use the “HTML” feature to created cool little things – which usually result in unclosed tags – which break the site. Let’s forget about the horrible invalid code it produces in general. They seem to live with the weird fonts and extra load times because of all the extra crap put it. It’s not until they decide to “be cool” that they break something and come crying to me.

Yes, there are a couple of great plugins out there that can help (like Tiny MCE Advanced, which is cool in its own right, and Plain Text Paste) – but they mean nothing if the client doesn’t use them.

I told my husband I was one step away from coding something for WordPress that would stop this.

He shook his head and said “no, it’s what they know. It’s really not your place to force them to use something else.” He had a point. But still.

When the question came up on the list today, I responded with that conversation. When they found out I already knew how to do this, I just haven’t yet, I had one person cheering me on, telling me she’d pay me to have something like this. So, really quickly, I just wrote it up for her.

So, I still haven’t decided whether or not I should implement these on the sites I have issues with. but I’ll put it out there for those of you who have no qualms about taking the candy form the baby. Truly, it is what’s best for them. Tough love…tough love.

Just copy the below and add it to your functions.php file. What it does is search for all instances of <p class=”MsoNormal” (note the lack of the closing “>” tag – that’s because, more often than not, there’s a bunch of crap following that tag), as well as the <font tag (lack of the closing “>” for the same reason). When it finds either of them, it replaces only those posts with a message: “Microsoft Word found!” If the crap isn’t there, the content is posted as it normally would be.

//strip Word!
function stripword($content) {
$find = array( '<p class="MsoNormal"', '<font' );
foreach ( $find as $f ) {
if ( ( $pos = stripos( $content, $f ) ) !== false ) {
$content = "Microsoft Word found!";
}
}
return($content);
}
add_filter('the_content', 'stripword');

Of course, you can add extra search strings to the array, and you can change the message that is seen. I bet, eventually, I could take this a step further an search for the stuff and just *strip* it – leaving only the content behind. But that’s an experiment for another day.

And, I’m sure you’re asking yourself “Yeah, but if that happens, the client will be calling you and saying things don’t work – it doesn’t change anything.” Well, the idea is more psychological, I guess, than anything. Right now, as it stands, the font weirdness seems to not bother most clients that insist on doing this. (They don’t even notice what it’s doing to the validity of their content, or anything else really.) They don’t even notice until the site actually breaks.

What my evil conspirators and I were planning – if we chose to do this – was to tell the client that the “new upgrade of WordPress is necessary, because it’s a major security fix.” and then proceed to tell tham that Matt, in all his wisdom and glory, got sick of telling people to stop using Microsoft Word and took matters into his own hands – and made it impossible to use it anymore. This would serve as a visual reminder that if they use it, the posts won’t post. So they need to clean up their act.

We figured after a few of these messages they’d get the idea and stop using Word LOL

So there you have it. Totally useless, and really only for psychological value. But hey – maybe it’ll work!

View Comments

I have thought of doing something like this. My thought was to just let them use Word, and change the behaviour of the editor to always look for Word content. Basically run the Paste from Word script all the time. But on the other hand the clients break it, they still pay to fix it. Oh well.

Yes, I agree. This isn’t something I’ve ever actually implemented (well, okay – ONCE I did. I couldn’t help it. After a while, you really get tired of the “emergency” emails that the site is broken because they’ve used Word again, after you’ve told them not to about 800 times LOL)

I would have liked to put this within the editor itself as well, but most clients who use Word to do their content also use the Visual Rich Editor – which utilizes TinyMCE. I’m not a Javascript guru, but the one time (a few years ago) when I did try to add a plugin to TinyMCE, it was a nightmare. I can’t imagine editing it so that it would recognize Word stuff. Well, I can, but I know *I* couldn’t do it!

This was a “quickie test” thing that I wrote in response to a query, and it actually worked pretty well. The lady I wrote it for actually used an image to notify the client that the post was broken – so it’s very versatile.

Anyway, if you ever do try to make it work with Tiny MCE, by all means, share! :)

Beautiful!

It’s MS Word that’s evil; this trick purges the world of evil, so has to be good.

Don’t give up the moral high ground so easily!

LOL – I shall now don my silver armor and ride my white horse against the tyranny of Microsoft! ;)

I thought I should mention an edit to his. i actually had someone use this and it didn’t work for them. Turns out the client was using something else (I can’t remember what,exactly, but it was another Microsoft Editor of some kind) and the $find array wasn’t catching the text, and the stuff was slipping by.

To fix it, we just edited the array slightly. The happy thing about Microsoft stuff is that they love that “MsoNormal” crap. So instead of:

$find = array( '<p class="MsoNormal"', '<font' );

we edited it to reflect the following:

$find = array( 'MsoNormal', '<font' );

And now anytime “MsoNormal” is used( it’s not case-sensitive), or the <font> tag, it’s found. A little less specific, but still very effective.

Sorry, comments are now closed on this post. You may thank the spammers for that one. But if you have any questions, please feel free to email me and ask - maybe it'll make for a good update in a future post. :)