Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Plugins by
Just realized by transferring some plugins to the latest q2a version 1.6.2 that the custom output is handled differently now.

Before we had to define:

$c = 2;
$qa_content['custom'.++$c]='<p>my output</p>";
$qa_content['custom'.++$c]='<p>my output II</p>";

which gave a clean output in 1.5.4:

<p>my output</p> <p>my output II</p>

Now in v1.6.2 I get this instead:

<div class="qa-part-custom3">
   <p>my output</p>

<div class="qa-part-custom4">
   <p>my output II</p>

Why was that changed? That could corrupt a lot of plugins I assume.
Q2A version: 1.6.2
*** How can we output now the content without these extra classes??

2 Answers

+1 vote

Yes you are right.. I had problem with lot of custom plugin I have done for clients.

Only simple different is you can do is just concatenate the previous $content variable using .=

So the code witll be in this way

$qa_content['custom']  = 'your first line'; //usually very first string or empty

$qa_content['custom'].='<p>my output</p>";

$qa_content['custom'].='<p>my output II</p>";

Thanks Jatin. I thought that would be the "solution". However, now the new classes interfere with some of my plugins that rely on heavy Javascript/Jquery and directly assigned CSS. When I select an element directly, the new classes interfere and the plugin gets corrupted. I have no idea why Gideon changed this. I don't need this extra class, just the content. It's like you say a sentence "I go home" and somebody throws in every time you say that "Goch, I go home, goch."...
* Have you already found a way to prevent the extra DIVs with class custom?
When I use AJAX features, throw a request to a page, I receive also these new DIVs inside. :(

On the other hand, I understand that Gideon wants to make it clear that this is custom information by adding the DIV(s). However, I guess this is not necessary. Especially not if I am on a page that has been created by a plugin.

Btw, this is why I am always very careful if it comes to updates. They can lead to new problems and a lot of extra work :(
The responsible part for those extra classes is: qa-theme-base.php, from line 744 to 748:

if ($partdiv)
    $this->output('<div class="qa-part-'.strtr($key, '_', '-').'">'); // to help target CSS to page parts

if (strpos($key, 'custom')===0)

The extra classes are unnecessary in my point of view. I have not seen any plugin that targets e.g. "qa-part-custom3".
Thanks Kai you found the reason.. I

In fact I have already requested here to remove wrapper for custom content. I found it is useless since developer most of the time adds own wrapper.
absolutely right, nice that we think the same here :)
0 votes

I am sad to say that but I did a core hack to solve this problem, it is a one liner (I know I could override function main_part() but I don't see the point in adding 50 lines to my theme file when I can remove 1 line in the core...

qa-theme-base.php remove line 733: (strpos($key, 'custom')===0) ||

Now my plugins work again!