making bbPress (and WordPress) work better!

Posts tagged “text control

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:

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.