• 06 . 02 . 10
  • Using the Mystique WordPress theme with the Backtype Connect plugin causes posts to stop rendering halfway through. Luckily, the fix is relatively straightforward.

  • Tags

    , , , , ,

  • StumbleUpon

Fixing Mystique for Backtype Connect

I’ve been playing around with WordPress themes and plugins and one that caught my eye was Backtype Connect, which aggregates discussions from around the web and places them as comments onto the original post. Unfortunately it wasn’t playing nicely with the Mystique theme I’m currently using, with no comments showing and the sidebar not appearing on posts where there was a backtype comment.

It turned out to be a minor error in the Mystique theme, which deals with how CSS classes are assigned to the sections that display the comments. Mystique has the following lines of code at the bottom of its mystique_comment_class function:

$class = join(" ", $classes);
echo apply_filters("comment_class", $class);

Mystique is trying to do the right thing here, by allowing plugins to manipulate the classes with the ‘comment_class’ hook, just like WordPress’ own function. However, the code is turning the $classes array into a $class string and passing that to the plugins. Backtype Connect (and presumably other plugins) expect those classes to be passed as an array leading to the following error:

Fatal error: [] operator not supported for strings

However, because this error occurs within an HTML tag it isn’t rendered correctly, which means it is hard to spot. Nevertheless, it causes PHP to stop executing immediately, leading to half-rendered pages.

Luckily, the fix is simple. Simply join the array after the filter has been called and everything works well. Future revisions of the theme will probably fix this, but in the meantime, you can use the WordPress plugin editor to replace the two lines above in mystique/lib/core.php with the following:

$classes = apply_filters("comment_class", $classes);
echo implode(" ", $classes);

And they should live together in harmony.