making bbPress (and WordPress) work better!

updated version of Text Control that works with WP 2.1-2.5

After struggling to get Text Control 2.0b1 to work with WordPress 2.1 even though other people are reporting it works fine, I found that someone had made entire code cleanups to Text control over here:
http://www.baptiste.us/2005/11/02/thoughts-on-xinha-text-control-and-wordpress/

or 2.0b2 Text Control

Somewhere along the line, their cleanup made it work with 2.0 and 2.1 properly, even with all my other plugins.

That version still does not activate on WordPress “pages” (vs posts) so I had to hack in a couple of easy hooks…

update: here’s a fully patched copy of 2.0b3-mod,
ready to install to plugins
(mirror just in case) (mirror 2)


(I’m posting these details below to show what changes are made)

in function tc_post_add_options() {
you have to add:

add_action('publish_page', 'tc_post_edit_post');
add_action('edit_page_form', 'tc_post_options');

What’s weird is it does not show the current formatting status auto-selected. I will have to hunt down that bug. But whatever you set it to, at least it obeys it.

I found the bug that was causing it not to show the current formatting settings for the post being edited. The way it’s grabbing the post ID # it no longer valid or not working (ie. $postdata->ID)
I changed it to this and it’s working fine:

function tc_post_options($content) {
$post_ID = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);

// Check if meta data already exists, otherwise use the defaults

$do_text = get_post_meta($post_ID, '_tc_post_format', true);
if (!$do_text) $do_text = get_option('tc_post_format');

$do_char = get_post_meta($post_ID, '_tc_post_encoding', true);
if (!$do_char) $do_char = get_option('tc_post_encoding');

One thing I REALLY don’t like about Text Control is it requires an extra database call for every post. I’d rather have some kind of internal WP code to disable formating, ie.
<!-- noformat -->
which would have zero database overhead and let you control the rest of the post natually.

Basically all I wanted this for was to be able to insert Javascript into a couple of my pages. What a workout, whew.

24 responses

  1. hugh69

    Hey, thanks! That was really starting to make me rip my hair out.
    I really want on option “JUST LEAVE MY TYPING ALONE!”.
    Almost there now…

    January 30, 2007 at 10:37 am

  2. hugh69

    Ahhh yes. That is exactly what I needed. Thanks again!

    January 30, 2007 at 10:53 am

  3. Mark B

    The Rapidshare link and the baptiste.us page is down.. ๐Ÿ˜ฆ Can you please post a new link?

    February 4, 2007 at 12:03 pm

  4. I posted it on mediafire now so hopefully it will stick around for a bit.
    http://www.mediafire.com/?4eiddn20ldw

    February 4, 2007 at 3:27 pm

  5. mokulen

    Wow, thank you for the update! It is *so* helpful!

    February 20, 2007 at 10:32 pm

  6. Pingback: aeternus.no-ip.org » WordPress Plugins are Go!

  7. andy

    You are the man. I can’t believe this is a plugin it should be immediatly integrated to WP. So Crazy.
    did I mention you are the man.

    August 1, 2007 at 9:18 pm

  8. Pingback: Oxyfish » Blog Archive » Blog Merge - Tom Shields' Blog

  9. sexyspring

    This plugin (and feature-set really) should be standard in WP. I spent an entire workday trying to figure out how to locally stop my newlines from being replaced with br tags. When I post HTML, I want to post HTML.

    Thanks for fixing this!

    February 2, 2008 at 4:51 pm

  10. This plugin is a life-saver! However, I find that it currently messes with a few other plugin that add dynamic things to the end of posts, most notably Gregarious (Digg buttons not displayed) and Podpress (flash player hidden). Can anyone confirm this or is it a problem with my site?

    February 5, 2008 at 5:04 pm

  11. I should mention that I’m using WordPress 2.3.2. ๐Ÿ™‚

    February 5, 2008 at 5:12 pm

  12. Chris I have this text-control working on a copy of the WP 2.4-2.5 trunk without issues.

    Can you explain what happens with the other plugins? Are the effects permanent or if you change the formatting type does the issue change?

    When I use flash players inside posts, I have to set text-control to Smarty-Pants or it won’t work. So see if changing the posts that misbehave to smarty-pants and see if it helps?

    February 6, 2008 at 4:42 am

  13. Hi CK – thanks for replying promptly.

    Basically, all of the wpautop options (except Textile 2) and smartypants, even when set to the defaults, do something to the plugins I’m using which tag things to the end of posts (Gregarious and Podpress). Textile 2 changes the formatting slightly but allows me to use the Javascript code I want to use on one of my pages (the reason for using this), but unfortunately although it leaves the Digg button intact (which uses the live Digg API) and keeps the Podpress flash player visible at the end of posts, it doesn’t allow me to visit the other static pages on my site, returning a rendered header but blank page content. Plus I understand Textile 2 shouldn’t be used if possible due to its bloatedness.

    As I understand it, Text Control should be transparent in use if the defaults were left—I then hoped to be able to change the text control options only for the Javascript static page (for a music download store), but even set to the defaults the blog posts are affected. I guess some theme customisation might’ve caused an incompatibility.

    I should probably instead try and package the page with the Javascript a little better, but I’m not much of a coder (more of a cut and paste coder!) so would be lost when it comes to the Javascript. The WP codex posts on the subject are all greek to me.

    February 6, 2008 at 11:31 am

  14. I’ve gotten round the formatting issue by creating a template containing the required code, then creating a blank page using that template. Seems to work so far, fingers crossed.

    February 6, 2008 at 8:36 pm

  15. Pingback: Markdown Magic | Weblog for 10k Luke

  16. thank you for sharing! very very cool. when it didn’t work for pages, i was like wtf!

    March 13, 2008 at 11:43 am

  17. Pingback: Turn Slowly for Maximum Vend » Blog Archive » How to Control WordPress HTML Formatting

  18. Pingback: Dynamic Galleries and Random Images for Wordpress Photoblogs

  19. Kris

    Hey Dude,
    It sounds like a really cool plugin. Only, the mediafire link doesn’t work. ๐Ÿ˜ฆ

    Can you please reupload it?

    September 2, 2008 at 2:48 pm

  20. Kris there’s a local mirrored copy link just below the mediafire one:
    https://ckon.files.wordpress.com/2008/02/text-control.txt
    Just rename the .txt to .php after you download.

    September 2, 2008 at 3:47 pm

  21. Carl B

    I can’t get this to work with a page using ExecPHP and WordPress 2.3.3. I can’t be bothered to upgrade to 2.6 at the moment since last time I tried, it broke a half-dozen things. I’m still getting random p tags where they don’t belong. ๐Ÿ˜ฆ

    November 10, 2008 at 11:57 pm

  22. Blake K

    Thank you so much for finally making this work with WP pages after all these years. You are a life saver.

    January 13, 2009 at 12:01 am

  23. This is a great plugin, and seems to work fine on WP 2.7. My only issue is that markdown doesn’t seem to work. When it’s on my server, the text just disappears, but when it’s on my localhost (PHP 5.2.6/Apache 2.2.11) I get:

    Warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier ‘|’ in /home/jason/Work/Web/wordpress/wp-content/plugins/text-control/text-control/markdown.php on line 766

    But notwithstanding (I prefer textile now anyways), this is great, thanks ๐Ÿ™‚

    March 13, 2009 at 4:46 am

  24. Seem to have solved the problem by getting the latest PHP Markdown from:

    http://michelf.com/projects/php-markdown/

    …and replacing the one in the text control package with it.

    March 13, 2009 at 7:01 am