• 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.

3 responses to “Fixing Mystique for Backtype Connect”

  1. majelbstoat says:

    Stoat – Where?: Fixing Mystique for Backtype Connect http://bit.ly/9oe3Aj

    This comment was originally posted on Twitter

  2. HenrikOOlsen says:

    So, are you planning on fixing Gengo so it can run on recent WordPress installs anytime soon or will the solution for me be to take over the project and fix it myself?

    • Jamie Talbot says:

      Hi Henrik,

      I don't have the time to work on Gengo at the moment unfortunately. I would be more than happy for somebody passionate about it to take over. You should get in touch with Paolo Tresso, who was looking after Gengo the last I heard (the Gengo 2.3 project). I hope to be involved with the project again in the future, but can't guarantee any time at the moment, so if you need a fast, free, solution, doing it yourself is probably the only way at the moment.

Leave a Reply

Your email address will not be published. Required fields are marked *