Last Saturday at WordCamp Philly, I ran a session on “Building a Plugin in One Night”. Together, with about 50+ attendees, we brainstormed ideas for a new WordPress plugin that I could code that night.
The brainstorming went great, coming up with some good ideas… like plugins to:
- Help first responders after a disaster (Big Idea!)
- Add VIM (a Linux editor) shortcut commands to the Visual Editor
- Disable the Visual Editor on a per-post basis (The Winner)
- Allow users to create pages from the front end
- Add easy donations
- Log into WordPress via Google+ (Brian did it!)
- Add syntax highlighting to the Visual Editor (Chris did it!)
The concept that the audience voted for me to work on was a way to disable the Visual Editor tab on a per-post basis. The motivation for this is the fact that the autoformatting of the Visual tab will sometimes break a complicated (or not so complicated) HTML structure ruining your code. Folks wanted a way to say, “Hey, WordPress, back off on this page/post.”
And someone (you introduced yourself to me later, but I forget your name) came up with a kick ass name: Don’t Break the Code. It explains the purpose and also harkens back to my days at Haverford College, which has a strong social/academic honor code.
I had hoped for something a little more mainstream. Only a developer or power user will really appreciate a plugin to disable the Visual tab, but that’s okay. The effort would be appreciated.
Turns out there are already a few plugins that either disable the Visual tab or remove other filters to keep WordPress from breaking code. The started trickling in after the presentation wrapped:
… and probably a few more. So we weren’t blazing new ground.
Still, some good ideas came up during the session that could improve the experience of using a plugin like this. Like:
- Put the checkbox to disable the editor in the screen options area so it doesn’t clutter up the editor
- Only allow admins to disable the editor. Other roles will see what the admin chose.
- Allow admins to add a note RE why the Visual Editor is disable.
- Remove other filters (like wpautop) to lower interference even more.
I spent the spare time I had during that day and then after the after party from midnight to 5:30am the next morning looking through the code in the existing plugins and piecing together the best pieces of them. I liked how “Disable Visual Editor WYSIWYG” just grayed out and struckthrough the Visual tab instead of removing it directly. I liked how Raw HTML put things in the screen options space and also how they allowed for disabling the other filters.
Anyway, the plugin released that morning on GitHub and then later at the Dev Day to the WP repository. You can grab it here:
Don’t Break the Code WordPress Plugin
So far it allows admins to disable the Visual Tab just like we said. I improved on the DVE WYSIWYG plugin by disabling via Ajax for a better user experience (you don’t have to click update for it to take affect). And after trying to copy Raw HTML’s method of placing things in the screen options, decided to scratch that and just code it myself using some tutorials I found online.
It works nicely. I plan to add checkboxes for disabling other filters similar to Raw HTML and also want to include that “add a notice” functionality somehow. I was going to incorporate the syntax highlighting, but that works really well as a stand alone plugin. Chris’s code had some problems on my setup that I hope to look into and patch for him.
Let me know what you think of Don’t Break the Code. If you want to contribute, you can fork and patch via GitHub here.
Thanks!