Skip to content

Word Fix Plugin

I am proud to announce the arrival of my second wordpress plugin! My first was a translate widget, which was very popular, but this one is of a different family. As users of Wordpress may know, a nice WYSIWYG (What You See Is What You Get) editor is now included for writing posts. A frustration I ran into when working on a project was that when pasting text from Microsoft Word, or an email, junky formatting from there often carried over, sometimes surprising readers with out-of-place fonts and colours. I personally write all my posts in the editor, but in this case, the users of Wordpress needed to be copying out of Word and emails. The solution? Write a plugin to clean up the mess, of course.

Word Fix will remove all the peculiar fonts, colours and other styles which may appear after copying text from other applications. It saves you the hassle of cleaning up the direct HTML code, which is especially handy if you or your users dont’ have the knowledge or time to dive into the code.

Installation: This is a bit tricky, because the plugin is actually for TinyMCE, the visual editor software, not Wordpress itself.

  1. Download the plugin for your version of Wordpress (2.0, or 2.1).
  2. Unzip it, and upload the “wordfix” folder into your “wp-includes/js/tinymce/plugins/” directory.
  3. Now, you need to modify a file. For Wordpress 2.0, switch your “wp-includes/js/tinymce/tiny_mce_gzip.php” file with this one. For Wordpress 2.1, switch your “/wp-includes/js/tinymce/tiny_mce_config.php” file with this one. All I’ve modified is adding the wordfix plugin to the list of loaded plugins, and the visible buttons on the editor.

Now when you go to write or edit a post, you should see the Word Fix button at the end of your toolbar: Word Fix. Simply click it, and the text in your editor pane will be cleaned up! It’ll take just a second, and you’ll see the text flash a bit when it’s complete. If for some reason it messed something up, just hit Control-Z to undo it. Save your post when the changes are finished, and your formatting should look the way it was meant to! I recommend you run this as soon as you copy in the text, and then proceed to make any other formatting changes after.

To uninstall the plugin, remove the two instances to ‘wordfix’ in either the tiny_mce_gzip.php (2.0) or tiny_mce_config.php (2.1) file. Then you can remove the wordfix folder in “wp-includes/js/tinymce/plugins/”.

If you want the details of what this plugin does exactly to your text, read on. Otherwise, go enjoy your nice clean formatting! First, all the html tags except for these are removed: (<a><img><p><u><b><i><strong><em><ul><li><ol><br><strike><code><abbr><!–more–>). Then, all class, id, and style attributes are removed from all tags. Then, all <b> and <i> tags are changed to <strong> and <em>, to match Wordpress standards. Combined, these steps eliminate all the formatting headaches I have encountered.

Icon based on the Silk Icons.

000-223 study guides are available in the market on discount rates. Candidates can prepare for 642-503 by taking the SNRS v2.0 diploma. 70-272 271 enables you how to help users and troubleshoot a Microsoft Windows XP Operating System. 642-164 judges a candidate’s understanding of the design, execution, and operation of CRS/UCCCX operation. With the assistance of these JN0-521 study guides, the JN0-521 test training can be completed quite effortlessly.

27 Comments

  1. Anon wrote:

    The plugin contains an absolute reference to /wp-includes/js/tinymce/… which is broken if wordpress is not installed in the root directory, for example /blog/wp-includes/…

    Sunday, January 28, 2007 at 17:21 | Permalink
  2. Trevor wrote:

    Thanks Anon,
    I’ll fix that tonight.

    Sunday, January 28, 2007 at 19:11 | Permalink
  3. Colin McStravick wrote:

    Trevor, nice work! Thanks for the plugin! Hey - is there a way that this can work automatically, without the Word Fix button? I have a lot of “newbie” authors, and I don’t want them to have to go thru the extra step of having to press the button. It would be sweet if the plugin worked automatically! Please let me know if there’s a way to do this. Thanks again very much!

    Tuesday, January 30, 2007 at 14:05 | Permalink
  4. AJ wrote:

    G’day Trevor,

    I am using Wordpress 2.1. After I loaded the plug-in, none of the buttons (bold italic etc) appeared in the visual editor. The page also generated an error which said “real TinyMCE is undefined”.
    Any hints as to what might be the problem?

    Thanks in advance,
    AJ

    Monday, February 5, 2007 at 20:29 | Permalink
  5. On the site rosebank.org I have installed this plugin… I click the button and nothing happens…

    Wednesday, February 7, 2007 at 15:42 | Permalink
  6. ashley a-p wrote:

    This didn’t work for me. When the button was clicked, a “not found” error (as well as an additional 404) came up in my editor in place of the ugly formatted text I was testing the plugin on. I’m guessing that the absolute path thing mentioned by anon is to blame (I just dl’d the plugin today, FYI).

    I’d love to use this, but The absolute path thing would have to be fixed, and I too would love to see this as an automatic thing :)

    Friday, February 9, 2007 at 15:42 | Permalink
  7. Trevor wrote:

    Ok, I’m assuming you guys both used the 2.0 version, since that’s the only place I found the absolute URL. It’s fixed now. Thanks for pointing out the problem!

    Friday, February 9, 2007 at 18:06 | Permalink
  8. Trevor, this is fantastic. It seems to work beautifully for me — I’m using Wordpress 2.1, newly updated. I have reporters entering text from shared Word docs, so your plugin was crucial.

    One thing: you might want to tell people that they must use the visual toolbar to see your button. I didn’t realize that even if the admin uses the visual toolbar, the new users (such as the Editor & the Authors) will start with the non-visual toolbar by default, and will not see your button. And will be confused by the HTML, too. That’s probably obvious to some, but may be worth pointing out.

    You may wish to add the button to the non-visual interface, too.

    Many thanks for a crucial and easy-to-implement tool!

    Saturday, February 10, 2007 at 14:07 | Permalink
  9. ashley a-p wrote:

    Thanks for reworking the plugin, but it’s still being a bit wonky for me. As a test, I posted the phrase “This post will be gone soon” in 20pt orange Times New Roman. When I hit the Wordfix button, it changed to this:

    %3Cp%20class%3D%22MsoNormal%22%20style%3D%22margin%3A%200in%200in%200pt%22%3E%3C
    span%20style%3D%22font-size%3A%2020pt%3B%20color%3A%20%23ff6600%22%3E%3Cfont%20face%
    3D%22Times%20New%20Roman%22%3EThis%20post%20will%20be%20gone%20soon%0A%3Cp%3E%C2
    %A0%3C%2Fp%3E%0A%3C%2Ffont%3E%3C%2Fspan%3E%3C%2Fp%3E

    I figured it might publish correctly, but no such luck. Looks exactly like that when published on the page.

    Saturday, February 10, 2007 at 18:04 | Permalink
  10. Aileen wrote:

    Hi Trevor,
    Thanks for what I think will be a very handy plugin.

    Unfortunately right now I can’t get it to work. Using WordPress 2.1, installed NOT in the root folder and Windows.

    I downloaded your 2.1 version, followed your installation instructions (I’ve just been checking that) and when I go to write/edit a post, what happens is that none of the buttons appears in the visual editor (as for AJ).

    I just downloaded today (12 Feb), so I figure I’ve got your latest version. Any thoughts?
    Thanks for your help,
    Aileen

    Sunday, February 11, 2007 at 22:17 | Permalink
  11. Michael Greisman wrote:

    Dang it, now it’s not working for me. I swear I tested this in IE 6 for windows…. I’m a little baffled why it’s not working now but (I believe) was earlier. HOwever, I have the similar situation: wordpress is not installed in the root dir. Any workarounds are welcome.

    Please fix when you get a chance, cuz this app really rocks for the purpose.

    Wednesday, February 14, 2007 at 15:18 | Permalink
  12. harvey wrote:

    So, I have 2.1 installed in the default location
    In Firefox, I see all the buttons including yours, but clicking on the Wordfix button doesn’t do anything
    In IE7, the Bold, Italic, etc, buttons are all hidden (I bet it’s just some css spacing issue?)
    Anyway, thanks for the plugin; I’ll check back occasionally to see if you have made tweaks
    Thanks!

    Saturday, February 17, 2007 at 16:26 | Permalink
  13. Geoff wrote:

    I’ve installed it and think I swapped in the file too - but I don’t see anything happening differently. I thought did it correctly - is it showing up for everyone else?

    Saturday, February 24, 2007 at 17:58 | Permalink
  14. Nick wrote:

    followed your instructions, no change, no button..
    linux, not root dir.

    looks like a handy plugin, just wish I could get it working.

    Monday, February 26, 2007 at 17:00 | Permalink
  15. Trevor wrote:

    Hi guys,
    Since this plugin deals with the somewhat mysterious (to me) workings of TinyMCE, I really don’t know what your problems are caused by, or how to fix them. Just make sure you copy the config file over properly (tiny_mce_config.php).

    Monday, February 26, 2007 at 17:13 | Permalink
  16. AJ wrote:

    Re-installed latest version and seems to be working now.
    Thanks Trev

    Tuesday, February 27, 2007 at 18:27 | Permalink
  17. Trevor wrote:

    Excellent!
    I’m glad to hear it’s working for you, AJ.

    Tuesday, February 27, 2007 at 18:31 | Permalink
  18. AJ wrote:

    BTW Trev,
    I have now upgraded to Wordpress 2.1.1 and the plugin still seems to be working (not that I have tested it extensively).
    I mention this because tiny_mce_config.php is one of the files that changed from 2.1 to 2.1.1. (You might want to have a closer look to see what changed specifically, and if there might be a hidden gotcha)

    Wednesday, February 28, 2007 at 20:22 | Permalink
  19. AJ wrote:

    Hi Trev,
    Wordpress 2.1.1 was security compromised so I have upgraded to 2.1.2 and the plugin stopped working again, ie all the visual edit icons disappeared.

    Going back to the 2.1.2 wordpress version of tiny_mce_config the icons came back.
    Comparing the two files there are only a few differences.
    Of course your file has ‘wordfix’, inserted in two sections, the Wordpress file also has three extra commands,
    cache_javascript_headers(); is inserted near the top of the file
    the line if ( $_SERVER['HTTPS'] ) { is now if ( $_SERVER['HTTPS'] == ‘on’ ) {
    and
    gecko_spellcheck : true, has been inserted into the intiArray section

    I tried taking the Wordpress file and simply inserting ‘wordfix’, at the appropriate locations but I couldn’t get it to work.

    Not being a PHP coder I have little idea what it all means, but hopefully you (or someone else) can stand on the shoulders of my work here and see a solution.

    Wednesday, March 7, 2007 at 19:02 | Permalink
  20. AJ wrote:

    Internet Explorer 7 is the work of the devil and should be renamed Internet Explorer 666. The probelms described above were happening in IE as I was trying to load the plugin at work. At home where I use Firefox the plugin works fine.
    I just have to make sure all my blog contributors are using Firefox. There are only a few so that is not a problem. Actually I shouldn’t be too harsh on Mr Gates’ product. Opera treats the plugin the same way.
    I guess I have learnt a lesson here. Work is for working and home is for Wordpress.

    Saturday, March 17, 2007 at 18:11 | Permalink
  21. Chris wrote:

    As an aside… Did you know that there are hidden toolbar buttons in the WP implementation of TinyMCE (2.1.x branch). You can enable them with a keystroke or a simple plugin. (More details)

    I bring it up as two of the hidden buttons relate to copy/paste — one specifically from Word. :-)

    Monday, March 19, 2007 at 18:29 | Permalink
  22. AJ wrote:

    Chris, Does this make Trev’s plugin redundent?

    Thursday, March 22, 2007 at 23:05 | Permalink
  23. Alexander wrote:

    Hi!

    Trev, could you please do me a favour and write an SQL SELECT (or UPDATE for that matter) to fix already submitted posts?

    The problem is, my friend of Messianic Commette has been keeping his blog for over a year and we just tolerated the broken design caused by Word formatting pasted in.

    Now as I’ve found your work I guess you know the specific rules for filtering the trash out from the strings stored in DB.

    Thank you!

    Saturday, August 4, 2007 at 16:16 | Permalink
  24. Trevor wrote:

    Hi Alexander,
    I’m sure it would be possible to do this, but the SQL part is beyond my expertise. If you want to see what changes are made to remove the formatting, check out the ajaxwordfix.php file in the plugin download. Sorry I can’t be of more help.

    Saturday, August 4, 2007 at 19:57 | Permalink
  25. The Don wrote:

    Hi Trev, on some of my posts I get this error:

    [code=HTTP_REQUEST_TOO_LONG] The HTTP request is too long. Contact your system administrator.

    Any reason why? I am using 2.2.

    Thursday, September 6, 2007 at 9:49 | Permalink
  26. will wrote:

    I’m attempting to use this plugin in a non-WordPress website. I am getting an error on the AJAX.request call. Are there some client-side or server-side dependencies I should be aware of? Perhaps something that’s turned on by default in Wordpress, but that other tinyMCE users may not have enabled?

    Thursday, October 11, 2007 at 13:35 | Permalink
  27. nonobots wrote:

    any chance to see that plugin upgraded to wordpress 2.3 ?

    I tried installing it and adding just the modification you state in tiny_mce_config.pgp (adding the plugin and adding the button) the button shows but nothing happens when I click on it. all the ugly MSo class stay there.

    Wednesday, March 26, 2008 at 19:01 | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*